HIP
HIP copied to clipboard
Problems with hip implementing atomic on AMD GPU
Hello,everyone. I have some questions about atomic while using HIP.When I want to use atomic.load() in a device function based on the hip:rocm-4.0.0 version, error like : ../bucket.cuh:48:44: error: no matching member function for call to 'load' lane_pair_ = ptr_[tile_.thread_rank()].load(order);
/usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/atomic:246:7: note: candidate function not viable: call to host function from device function load(memory_order __m = memory_order_seq_cst) const noexcept ^ /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/atomic:255:7: note: candidate function not viable: call to host function from device function load(memory_order __m = memory_order_seq_cst) const volatile noexcept
So I have the below questions:
- Have you ever encountered such a problem and how to solve it?
- Can I override device struct atomic{...} in HIP like cuda/atomic?
std::atomic does not work in GPU device code. You should use the atomicAdd, atomicAnd, atomicCAS, etc. device intrinsics instead. See https://docs.amd.com/bundle/HIP_Supported_CUDA_API_Reference_Guide/page/CUDA_Device_API_supported_by_HIP.html
Hi @frobnitzem , Thanks for your reply, I got it..