             // Notify stream0 that stream1 is complete and record the time of
             // the total transaction
             streams_1[j].enqueue.event(stop[j]);
-            streams_0[j].enqueue.wait(stop[j]);
-            streams_0[j].enqueue.event(stop[i]);
+            streams_0[i].enqueue.wait(stop[j]);
+            streams_0[i].enqueue.event(stop[i]);
 
             // Release the queued operations
             *flag = 1;


constexpr const unsigned long long default_timeout_clocks = 10000000ull;

__global__ void delay(volatile int *flag, unsigned long long timeout_clocks = default_timeout_clocks)
{
    // Wait until the application notifies us that it has completed queuing up the


    std::cout
        << "P2P=" << (test_p2p ? "Enabled": "Disabled") << " Latency "
        << (test_p2p ? (p2p_method == P2P_READ ? "(P2P Reads) " : "(P2P Writes) ") : "")
        << "Matrix (us)\n";

    std::cout << "   GPU ";

    for (auto device : cuda::devices()) {
        std::cout << std::setw(bandwidth::field_width) << device.id() << ' ';
    }

    std::cout << "\n";

    for (auto device : cuda::devices()) {
        std::cout << std::setw(bandwidth::field_width) << device.id() << ' ';

        for (auto peer : cuda::devices()) {
            std::cout << std::setprecision(bandwidth::precision) << std::setw(bandwidth::field_width) << gpuLatencyMatrix[device.id() * numGPUs + peer.id()] << ' ';
        }

        std::cout << "\n";
    }

    std::cout << "\n   CPU ";

    for (auto device : cuda::devices()) {
        std::cout << std::setw(bandwidth::field_width) << device.id() << ' ';
    }

    std::cout << "\n";

    for (auto device : cuda::devices()) {
        std::cout << std::setw(bandwidth::field_width) << device.id() << ' ';

        for (auto peer : cuda::devices()) {
            std::cout << std::setprecision(bandwidth::precision) << std::setw(bandwidth::field_width) << cpuLatencyMatrix[device.id() * numGPUs + peer.id()] << ' ';
        }

        std::cout << "\n";
