Skip to content
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

Implementations for atomic load, store and exchange operations #1297

Merged
merged 4 commits into from
Jan 31, 2024

Conversation

adarshyoga
Copy link
Contributor

@adarshyoga adarshyoga commented Jan 26, 2024

  • Have you provided a meaningful PR description?

This PR adds overloads and intrinsics for load, store and exchange atomic operations. It also contains unit tests that verify the functionality and the failure cases for these operations.

  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • If this PR is a work in progress, are you filing the PR as a draft?

@adarshyoga adarshyoga requested a review from diptorupd January 26, 2024 08:05
@adarshyoga adarshyoga self-assigned this Jan 26, 2024
@adarshyoga adarshyoga force-pushed the experimental/ld_str_excg_ols branch from 8ead4e8 to 5a3a087 Compare January 26, 2024 08:06
@diptorupd
Copy link
Contributor

@adarshyoga the crash is reproducible if you use ONEAPI_DEVICE_SELECTOR=opencl:cpu

I ran it with gdb and here is the backtrace:

0x00007ffff5f325f5 in std::_Function_handler<void (sycl::_V1::handler&), DPCTLQueue_SubmitRange::{lambda(sycl::_V1::handler&)#1}>::_M_invoke(std::_Any_data const&, sycl::_V1::handler&) ()
   from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/libDPCTLSyclInterface.so.0
(gdb) bt
#0  0x00007ffff5f325f5 in std::_Function_handler<void (sycl::_V1::handler&), DPCTLQueue_SubmitRange::{lambda(sycl::_V1::handler&)#1}>::_M_invoke(std::_Any_data const&, sycl::_V1::handler&) ()
   from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/libDPCTLSyclInterface.so.0
#1  0x00007ffff5b0ce36 in sycl::_V1::detail::queue_impl::submit_impl(std::function<void (sycl::_V1::handler&)> const&, std::shared_ptr<sycl::_V1::detail::queue_impl> const&, std::shared_ptr<sycl::_V1::detail::queue_impl> const&, std::shared_ptr<sycl::_V1::detail::queue_impl> const&, sycl::_V1::detail::code_location const&, std::function<void (bool, bool, sycl::_V1::event&)> const*)
    () from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/../../../libsycl.so.6
#2  0x00007ffff5b0c406 in sycl::_V1::detail::queue_impl::submit(std::function<void (sycl::_V1::handler&)> const&, std::shared_ptr<sycl::_V1::detail::queue_impl> const&, sycl::_V1::detail::code_location const&, std::function<void (bool, bool, sycl::_V1::event&)> const*) () from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/../../../libsycl.so.6
#3  0x00007ffff5b0c3c5 in sycl::_V1::queue::submit_impl(std::function<void (sycl::_V1::handler&)>, sycl::_V1::detail::code_location const&) ()
   from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/../../../libsycl.so.6
#4  0x00007ffff5f2e6bc in DPCTLQueue_SubmitRange () from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/libDPCTLSyclInterface.so.0
#5  0x00007fffa75861fd in numba_dpex::experimental::launcher::call_kernel[abi:v16][abi:c8tJTC_2fWQAlzW1yBDkop6GEOEUMEOYSPGuIQMViAQ3iQ8IbKQIMbwoOGNoQDDWwQR1NHAS3lQ9XgSucwm4pgLNTQs00pSK3QBAA_3d](type_28KernelDispatcher_28_3cfunction_20test_load_store_fn::_3clocals_3e::_kernel_20at_200x7fff4613ba60_3e_29_29, Range_3c1_3e, UniTuple<DpnpNdArray<double, 1, C, opencl_cpu>, 2>) ()
#6  0x00007fffa75866ca in cpython::numba_dpex::experimental::launcher::call_kernel[abi:v16][abi:c8tJTC_2fWQAlzW1yBDkop6GEOEUMEOYSPGuIQMViAQ3iQ8IbKQIMbwoOGNoQDDWwQR1NHAS3lQ9XgSucwm4pgLNTQs00pSK3QBAA_3d](type_28KernelDispatcher_28_3cfunction_20test_load_store_fn::_3clocals_3e::_kernel_20at_200x7fff4613ba60_3e_29_29, Range_3c1_3e, UniTuple<DpnpNdArray<double, 1, C, opencl_cpu>, 2>) ()
#7  0x00007ffff357da25 in compile_and_invoke(Dispatcher*, _object*, _object*, _object*) ()

@adarshyoga
Copy link
Contributor Author

@adarshyoga the crash is reproducible if you use ONEAPI_DEVICE_SELECTOR=opencl:cpu

I ran it with gdb and here is the backtrace:

0x00007ffff5f325f5 in std::_Function_handler<void (sycl::_V1::handler&), DPCTLQueue_SubmitRange::{lambda(sycl::_V1::handler&)#1}>::_M_invoke(std::_Any_data const&, sycl::_V1::handler&) ()
   from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/libDPCTLSyclInterface.so.0
(gdb) bt
#0  0x00007ffff5f325f5 in std::_Function_handler<void (sycl::_V1::handler&), DPCTLQueue_SubmitRange::{lambda(sycl::_V1::handler&)#1}>::_M_invoke(std::_Any_data const&, sycl::_V1::handler&) ()
   from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/libDPCTLSyclInterface.so.0
#1  0x00007ffff5b0ce36 in sycl::_V1::detail::queue_impl::submit_impl(std::function<void (sycl::_V1::handler&)> const&, std::shared_ptr<sycl::_V1::detail::queue_impl> const&, std::shared_ptr<sycl::_V1::detail::queue_impl> const&, std::shared_ptr<sycl::_V1::detail::queue_impl> const&, sycl::_V1::detail::code_location const&, std::function<void (bool, bool, sycl::_V1::event&)> const*)
    () from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/../../../libsycl.so.6
#2  0x00007ffff5b0c406 in sycl::_V1::detail::queue_impl::submit(std::function<void (sycl::_V1::handler&)> const&, std::shared_ptr<sycl::_V1::detail::queue_impl> const&, sycl::_V1::detail::code_location const&, std::function<void (bool, bool, sycl::_V1::event&)> const*) () from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/../../../libsycl.so.6
#3  0x00007ffff5b0c3c5 in sycl::_V1::queue::submit_impl(std::function<void (sycl::_V1::handler&)>, sycl::_V1::detail::code_location const&) ()
   from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/../../../libsycl.so.6
#4  0x00007ffff5f2e6bc in DPCTLQueue_SubmitRange () from /home/diptorupd/miniconda3/envs/dpex-devel/lib/python3.11/site-packages/dpctl/libDPCTLSyclInterface.so.0
#5  0x00007fffa75861fd in numba_dpex::experimental::launcher::call_kernel[abi:v16][abi:c8tJTC_2fWQAlzW1yBDkop6GEOEUMEOYSPGuIQMViAQ3iQ8IbKQIMbwoOGNoQDDWwQR1NHAS3lQ9XgSucwm4pgLNTQs00pSK3QBAA_3d](type_28KernelDispatcher_28_3cfunction_20test_load_store_fn::_3clocals_3e::_kernel_20at_200x7fff4613ba60_3e_29_29, Range_3c1_3e, UniTuple<DpnpNdArray<double, 1, C, opencl_cpu>, 2>) ()
#6  0x00007fffa75866ca in cpython::numba_dpex::experimental::launcher::call_kernel[abi:v16][abi:c8tJTC_2fWQAlzW1yBDkop6GEOEUMEOYSPGuIQMViAQ3iQ8IbKQIMbwoOGNoQDDWwQR1NHAS3lQ9XgSucwm4pgLNTQs00pSK3QBAA_3d](type_28KernelDispatcher_28_3cfunction_20test_load_store_fn::_3clocals_3e::_kernel_20at_200x7fff4613ba60_3e_29_29, Range_3c1_3e, UniTuple<DpnpNdArray<double, 1, C, opencl_cpu>, 2>) ()
#7  0x00007ffff357da25 in compile_and_invoke(Dispatcher*, _object*, _object*, _object*) ()

Thats great! Thanks for fixing this and adding the license.
So, was the crash occurring when using non-float32 dtypes of the input arrays with opencl:cpu?

Also, is there anything more needed for this PR? Do the two commits need to be squashed?

@diptorupd diptorupd force-pushed the experimental/ld_str_excg_ols branch from f23f358 to a1148f1 Compare January 29, 2024 20:39
    - Removes the helper function for intrinsic codegen for atomic store
      and atomic exchange.
    - Adds a new module that has helper functions for inserting the
      LLVM IR module-level declaration for individual SPV functions.
@adarshyoga adarshyoga force-pushed the experimental/ld_str_excg_ols branch from ae7d68e to 988ee51 Compare January 30, 2024 22:54
@diptorupd diptorupd force-pushed the experimental/ld_str_excg_ols branch from 988ee51 to fb916a2 Compare January 31, 2024 15:33
@diptorupd diptorupd merged commit f59d9e8 into main Jan 31, 2024
47 of 52 checks passed
@diptorupd diptorupd deleted the experimental/ld_str_excg_ols branch January 31, 2024 18:46
github-actions bot added a commit that referenced this pull request Jan 31, 2024
Implementations for atomic load, store and exchange operations f59d9e8
github-actions bot added a commit to chudur-budur/numba-dpex that referenced this pull request Feb 1, 2024
…str_excg_ols

Implementations for atomic load, store and exchange operations f59d9e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants