-
Notifications
You must be signed in to change notification settings - Fork 70
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
Multi-threading support refactor #152
Conversation
Note: Using std::lock_guard() since std::scope_lock() requires the mutex to do std::try_lock() which our underlying implementation doesn't support. |
2fb1124
to
1a57d60
Compare
Preliminary hardware testing done. Now doing bulk change. |
Klockwork is failing for some reason...not sure why...
@zibaiwan @pcolberg Have any ideas on this issue? I did not modify the code highlighted by klockwork... |
This is a tricky one. Have you tried adding debug printfs to the existing lock functions, fpga-runtime-for-opencl/src/acl_thread.cpp Lines 23 to 37 in 412bdf9
as well as the new lock functions, fpga-runtime-for-opencl/src/acl_thread.cpp Lines 77 to 79 in 412bdf9
and running the test in question to see whether the locking behaviour differs from before the refactoring? export AOCL_BOARD_PACKAGE_ROOT=$(realpath test/board/a10_ref)
./acl_test -v -g acl_program -n create_from_builtin |
On a unrelated note to the previous issue: acl_condition_lock_guard will not be templated for now since I can't seem to get it work. Will add improvements later. |
Indeed found that the locking and locking are different...but maybe due to another thing (I didn't refactor acl_test yet). Will do more testings later... |
Klocwork seemed to have passed with the latest fix. |
8f79bab
to
745ca1f
Compare
Testing done. No runtime errors introduced with sycl-l3 test runs. |
@ericxu233 , thanks for doing the testing. If not already done, please run the ocl test as well. You can find the test set in the official FullCycle-oneAPI-ocl-weekly-lnx run. If it doesn't include the multithreading test that we discussed earlier, please run the multi-threading test separately as well. |
Please run clang-format by following the instruction in contributing. I know the name of the workflow "run clang-format" sounds like it may run the clang-format for you, but it actually only checks if your code is in clang-format and doesn't modify your pull request. (You probably already know this, just in case you don't.). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good to me as long as the conversations are resolved and the additional tests are completed.
3fad269
to
365438c
Compare
@pcolberg Could you please take a look and see if the changes are ok :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ericxu233, this is close to completion 🙂
1c07f9f
to
2da64d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ericxu233 . Looks good to me!
8fc1401
to
46e949b
Compare
fa0934f
to
fc87493
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Eric, this is ready for merging 🙂
I have slightly updated the comments in acl_thread.h
and removed left-over lock_count
in acl_event.cpp
and acl_mem.cpp
which were causing warnings.
I also moved acl_is_locked_callback()
, acl_wait_for_device_update()
, and acl_signal_device_update()
back to their old location. You had moved them to be consistent with the order in acl_thread.h
, but I think it's fine to have the order in acl_thread.cpp
be slightly out of sync, in favour of modifying as little code as possible. That will be appreciated by a future reader, e.g., looking at git blame
.
Please let me know if everything is in order before this is merged.
fc87493
to
64953b9
Compare
First stage of multi-threading support refactor by providing a mutex wrapper class around current routines and using std::scoped_lock to follow RAII.
64953b9
to
a429f7b
Compare
Third time is the charm 🙂 You can omit the mutex type when constructing the scoped lock: diff --git a/src/acl_command.cpp b/src/acl_command.cpp
index 6e71fc4..23a8c12 100644
--- a/src/acl_command.cpp
+++ b/src/acl_command.cpp
@@ -38,7 +38,7 @@
ACL_EXPORT
CL_API_ENTRY cl_int CL_API_CALL
clEnqueueBarrierIntelFPGA(cl_command_queue command_queue) {
- std::scoped_lock<acl_mutex_wrapper_t> lock{acl_mutex_wrapper};
+ std::scoped_lock lock{acl_mutex_wrapper};
if (!acl_command_queue_is_valid(command_queue)) {
return CL_INVALID_COMMAND_QUEUE; |
@pcolberg Looks good to me. I think everything is in order now. We are ready to merge. Thanks for the detailed code review and explanatoins! |
First stage of the multi-threading support refactor by providing a wrapper mutex class around the current routines and use std::loack_guard() to enable RAII practices.