File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 1212
1313#if BNB_HIP
1414#include < hip/hip_runtime.h>
15+ #include < atomic>
1516
1617// NOTE: This queries device 0 once and caches the result. On mixed RDNA+CDNA
1718// systems (warp size 32 vs 64) this will return the wrong value for whichever
1819// device doesn't match device 0.
1920static int bnb_host_warp_size () {
20- static int warp_size = 0 ;
21- if (warp_size == 0 )
22- (void )hipDeviceGetAttribute (&warp_size, hipDeviceAttributeWarpSize, 0 );
23- return warp_size;
21+ static std::atomic<int > warp_size{0 };
22+ int ws = warp_size.load (std::memory_order_relaxed);
23+ if (ws == 0 ) {
24+ (void )hipDeviceGetAttribute (&ws, hipDeviceAttributeWarpSize, 0 );
25+ warp_size.store (ws, std::memory_order_relaxed);
26+ }
27+ return ws;
2428}
2529#else
2630static constexpr int bnb_host_warp_size () { return 32 ; }
You can’t perform that action at this time.
0 commit comments