Skip to content

Commit 997152c

Browse files
authored
Restore concurrent behavior to gpu_allocation_cache test (#8792)
1 parent cd3071e commit 997152c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

test/correctness/gpu_allocation_cache.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,18 @@ int main(int argc, char **argv) {
136136
Halide::Internal::JITSharedRuntime::reuse_device_allocations(false);
137137
};
138138

139-
// First run them serially (compilation of a Func isn't thread-safe).
140-
// test1(true);
141-
// test2(true);
142-
// test3(true);
143-
// return 0;
144-
145-
// Now run all at the same time to check for concurrency issues.
146-
147-
Halide::Tools::ThreadPool<void> pool(1);
139+
// We want to launch multiple instances of each test, but compilation of a
140+
// single Func is not thread-safe, so we'd better jit-compile them ahead of
141+
// time.
142+
f1[N - 1].compile_jit();
143+
f2[N - 1].compile_jit();
144+
f3[N - 1].compile_jit();
145+
146+
// Run all at the same time to check for concurrency issues. They'll
147+
// intentionally race on making allocations, and on setting the
148+
// allocation-cache-enabled flag. This shouldn't cause any incorrect output
149+
// or crashes.
150+
Halide::Tools::ThreadPool<void> pool;
148151
std::vector<std::future<void>> futures;
149152
futures.emplace_back(pool.async(test1, true));
150153
futures.emplace_back(pool.async(test1, true));

0 commit comments

Comments
 (0)