MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / doubleAllocationTest

Function doubleAllocationTest

test/threading.cpp:104–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102size_t counter = THREAD_COUNT;
103
104void 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
126int nextTargetDeviceId() {
127 static int nextId = 0;

Callers

nothing calls this directly

Calls 4

randuFunction · 0.85
setDeviceFunction · 0.50
waitMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected