Skip to content

Commit 582246b

Browse files
kevinjoseph1995meta-codesync[bot]
authored andcommitted
Remove use of __AMDGCN_WAVEFRONT_SIZE macro with it being deprecated in ROCm 7 (#4619)
Summary: Usage of `__AMDGCN_WAVEFRONT_SIZE` is a compilation error when using amdclang++ shipped with ROCm 7.x.x. For versions >= 7 we delegate to rocprim to get the right constexpr value that can be used in device code. We continue using __AMDGCN_WAVEFRONT_SIZE for older ROCm versions to maintain compatibility. Note that the usage of kWarpSize in host code is still non-sensical however the current usage of this variable seems to always be in device functions. See https://rocm.docs.amd.com/en/latest/about/release-notes.html#amdgpu-wavefront-size-compiler-macro-deprecation for deprecation notice. Pull Request resolved: #4619 Reviewed By: mnorris11 Differential Revision: D95327171 Pulled By: subhadeepkaran fbshipit-source-id: f1a7b7d67a7c5a6c2a8068f4608d23873d21ff40
1 parent 2dff119 commit 582246b

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

faiss/gpu/impl/PQCodeDistances-inl.cuh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
namespace faiss {
2121
namespace gpu {
2222

23-
#if defined(USE_AMD_ROCM) && __AMDGCN_WAVEFRONT_SIZE == 64u
24-
#define LAUNCH_BOUND 320
25-
#else
26-
#define LAUNCH_BOUND 288
27-
#endif
23+
__device__ constexpr inline int getLaunchBound() {
24+
return kWarpSize == 32 ? 288 : 320;
25+
}
2826

2927
// Kernel responsible for calculating distance from residual vector to
3028
// each product quantizer code centroid
@@ -33,7 +31,7 @@ template <
3331
typename CentroidT,
3432
int DimsPerSubQuantizer,
3533
bool L2Distance>
36-
__global__ void __launch_bounds__(LAUNCH_BOUND, 3) pqCodeDistances(
34+
__global__ void __launch_bounds__(getLaunchBound(), 3) pqCodeDistances(
3735
Tensor<float, 2, true> queries,
3836
int queriesPerBlock,
3937
Tensor<CentroidT, 2, true> coarseCentroids,

faiss/gpu/utils/DeviceDefs.cuh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,28 @@
88
#pragma once
99

1010
#include <cuda.h>
11+
#ifdef USE_AMD_ROCM
12+
#include <rocm-core/rocm_version.h> // ROCm version macros
13+
#if ROCM_VERSION_MAJOR >= 7
14+
#include <rocprim/intrinsics/arch.hpp> // rocprim::arch::wavefront
15+
#endif
16+
#endif
1117

1218
namespace faiss {
1319
namespace gpu {
1420

1521
#ifdef USE_AMD_ROCM
1622

23+
#if ROCM_VERSION_MAJOR < 7
1724
#if __AMDGCN_WAVEFRONT_SIZE == 32u
1825
constexpr int kWarpSize = 32;
1926
#else
2027
constexpr int kWarpSize = 64;
2128
#endif
29+
#else
30+
// ROCm 7.0 and above
31+
constexpr __device__ int kWarpSize = rocprim::arch::wavefront::max_size();
32+
#endif
2233

2334
// This is a memory barrier for intra-warp writes to shared memory.
2435
__forceinline__ __device__ void warpFence() {

0 commit comments

Comments
 (0)