Skip to content

Commit 72e4e39

Browse files
committed
Revert device array caching and instead only do device 0
1 parent 0c94504 commit 72e4e39

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

csrc/ops.cu

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@
1313
#if BNB_HIP
1414
#include <hip/hip_runtime.h>
1515

16+
// NOTE: This queries device 0 once and caches the result. On mixed RDNA+CDNA
17+
// systems (warp size 32 vs 64) this will return the wrong value for whichever
18+
// device doesn't match device 0.
1619
static int bnb_host_warp_size() {
17-
constexpr int MAX_DEVICES = 32;
18-
static int cache[MAX_DEVICES] = {};
19-
int dev;
20-
(void)hipGetDevice(&dev);
21-
if (dev < 0 || dev >= MAX_DEVICES)
22-
return 64;
23-
if (cache[dev] == 0)
24-
(void)hipDeviceGetAttribute(&cache[dev], hipDeviceAttributeWarpSize, dev);
25-
return cache[dev];
20+
static int warp_size = 0;
21+
if (warp_size == 0)
22+
(void)hipDeviceGetAttribute(&warp_size, hipDeviceAttributeWarpSize, 0);
23+
return warp_size;
2624
}
2725
#else
2826
static constexpr int bnb_host_warp_size() { return 32; }

0 commit comments

Comments
 (0)