-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clfftBakePlan is not thread-safe #250
Comments
if I create different |
If I remember correctly, the problem manifests if you have identically configured handles. Unless you have specific performance problems/requirements I would use a global mutex around "clfftBakePlan" to be safe. The chance of a race condition is slim, but non-zero. |
|
A different handle does not matter, it is still not thread-safe. The question is how you create the handle. |
I review some code, like repo.cpp. It has a lock, which can guarantee safety? Line 206 in c59712e
If I create opencl context in every thread, and the map key is different, which create by opencl context. Line 208 in c59712e
I dont review all code, and am not clear about relationship between function. I will write some demo to test it. I am new to write opencl code. There are not many libraries, and many libraries have not been updated. Is opencl good choice to write GPU code? |
The scenario:
5 Threads concurrently calling clfftBakePlan with identically configured fft handles.
Immediate symptoms:
The
assert(NULL == p)
in repo.cpp, line 218 triggers.clFFT/src/library/repo.cpp
Line 218 in c59712e
Then occasionally a crash with a nullptr later on.
The cause:
The function
FFTAction::compileKernels
will compile kernels, but only if they are not cached already. The problem is that the query of the cache is not protected with a mutex.clFFT/src/library/enqueue.cpp
Line 713 in c59712e
compileKernels
for the first timefftRepo
at the same timeCLFFT_INVALID_PROGRAM
return code.fftRepo.setclProgram
with the same parameters.The first call will set the program, the next calls will trigger the
assert
.The fix:
Any query to the cache followed by a set to a cache must be an atomic operation. Here a scopedLock would do the trick.
I could prepare a PR, but can only take the time to do so if the PR has a chance of being merged into the code. Is this repository still being maintained? Also, I'd like the fix to be integrated with vcpkg.
The text was updated successfully, but these errors were encountered: