 {
     int numElems = 10000000;
     int repeat = 5;
+	vector<cuda::stream_t> streams;
     vector<cuda::memory::device::unique_ptr<int[]>> buffers;
     vector<cuda::memory::device::unique_ptr<int[]>> buffersD2D; // buffer for D2D, that is, intra-GPU copy
     vector<cuda::event_t> start;
     vector<cuda::event_t> stop;
-    vector<cuda::stream_t> streams;
 
     auto flag = reinterpret_cast<volatile int *>(
         cuda::memory::host::allocate(sizeof(int), cuda::memory::portability_across_contexts::is_portable)

{
    int repeat = 100;
    int numElems = 4; // perform 1-int4 transfer.
    vector<cuda::memory::device::unique_ptr<int[]>> buffers;
    vector<cuda::memory::device::unique_ptr<int[]>> buffersD2D; // buffer for D2D, that is, intra-GPU copy
    vector<cuda::event_t> start;
    vector<cuda::event_t> stop;
    vector<cuda::stream_t> streams;

    auto flag = reinterpret_cast<volatile int *>(
        cuda::memory::host::allocate(sizeof(int), cuda::memory::portability_across_contexts::is_portable)

{
    int numElems = 10000000;
    int repeat = 5;

	// Note: The order of these declarations matters. The reason is, that memory
	// allocations do not hold a reference count to a primary context, while
	// streams do (and even that is a bit difficult to put faith in).
	// To avoid this, one would have to ensure the primary contexts are active
	// through the lifetimes of the pointers. That could mean, for example:
	//
	// 1. Holding a refunit-holding primary context wrappers array
	// 2. Placing the unique pointers within a curly-brackets scope, so they
	//    get release while the primary contexts array is still alive.
	//

	vector<cuda::stream_t> streams_0;
	vector<cuda::stream_t> streams_1;
    vector<cuda::memory::device::unique_ptr<int[]>> buffers;
    vector<cuda::memory::device::unique_ptr<int[]>> buffersD2D; // buffer for D2D, that is, intra-GPU copy
    vector<cuda::event_t> start;
    vector<cuda::event_t> stop;


    auto flag = reinterpret_cast<volatile int *>(
