11 #include "../BlockSelectKernel.cuh"
12 #include "../Limits.cuh"
14 #define BLOCK_SELECT_DECL(TYPE, DIR, WARP_Q) \
15 extern void runBlockSelect_ ## TYPE ## _ ## DIR ## _ ## WARP_Q ## _( \
16 Tensor<TYPE, 2, true>& in, \
17 Tensor<TYPE, 2, true>& outK, \
18 Tensor<int, 2, true>& outV, \
23 #define BLOCK_SELECT_IMPL(TYPE, DIR, WARP_Q, THREAD_Q) \
24 void runBlockSelect_ ## TYPE ## _ ## DIR ## _ ## WARP_Q ## _( \
25 Tensor<TYPE, 2, true>& in, \
26 Tensor<TYPE, 2, true>& outK, \
27 Tensor<int, 2, true>& outV, \
30 cudaStream_t stream) { \
31 auto grid = dim3(in.getSize(0)); \
33 constexpr int kBlockSelectNumThreads = 128; \
34 auto block = dim3(kBlockSelectNumThreads); \
36 FAISS_ASSERT(k <= WARP_Q); \
37 FAISS_ASSERT(dir == DIR); \
39 auto kInit = dir ? Limits<TYPE>::getMin() : Limits<TYPE>::getMax(); \
42 blockSelect<TYPE, int, DIR, WARP_Q, THREAD_Q, kBlockSelectNumThreads> \
43 <<<grid, block, 0, stream>>>(in, outK, outV, kInit, vInit, k); \
46 #define BLOCK_SELECT_CALL(TYPE, DIR, WARP_Q) \
47 runBlockSelect_ ## TYPE ## _ ## DIR ## _ ## WARP_Q ## _( \
48 in, outK, outV, dir, k, stream)