| 102 | size_t counter = THREAD_COUNT; |
| 103 | |
| 104 | void doubleAllocationTest() { |
| 105 | setDevice(0); |
| 106 | |
| 107 | // Block until all threads are launched and the |
| 108 | // counter variable hits zero |
| 109 | std::unique_lock<std::mutex> lock(cvMutex); |
| 110 | // Check for current thread launch counter value |
| 111 | // if reached zero, notify others to continue |
| 112 | // otherwise block current thread |
| 113 | if (--counter == 0) |
| 114 | cv.notify_all(); |
| 115 | else |
| 116 | cv.wait(lock, [] { return counter == 0; }); |
| 117 | lock.unlock(); |
| 118 | |
| 119 | array a = randu(5, 5); |
| 120 | |
| 121 | // Wait for for other threads to hit randu call |
| 122 | // while this thread's variable a is still in scope. |
| 123 | std::this_thread::sleep_for(std::chrono::seconds(2)); |
| 124 | } |
| 125 | |
| 126 | int nextTargetDeviceId() { |
| 127 | static int nextId = 0; |