Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
WarpSelectFloat.cu
1 /**
2 * Copyright (c) 2015-present, Facebook, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD+Patents license found in the
6 * LICENSE file in the root directory of this source tree.
7 */
8
9 #include "warpselect/WarpSelectImpl.cuh"
10
11 namespace faiss { namespace gpu {
12
13 // warp Q to thread Q:
14 // 1, 1
15 // 32, 2
16 // 64, 3
17 // 128, 3
18 // 256, 4
19 // 512, 8
20 // 1024, 8
21
22 WARP_SELECT_DECL(float, true, 1);
23 WARP_SELECT_DECL(float, true, 32);
24 WARP_SELECT_DECL(float, true, 64);
25 WARP_SELECT_DECL(float, true, 128);
26 WARP_SELECT_DECL(float, true, 256);
27 WARP_SELECT_DECL(float, true, 512);
28 WARP_SELECT_DECL(float, true, 1024);
29
30 WARP_SELECT_DECL(float, false, 1);
31 WARP_SELECT_DECL(float, false, 32);
32 WARP_SELECT_DECL(float, false, 64);
33 WARP_SELECT_DECL(float, false, 128);
34 WARP_SELECT_DECL(float, false, 256);
35 WARP_SELECT_DECL(float, false, 512);
36 WARP_SELECT_DECL(float, false, 1024);
37
38 void runWarpSelect(Tensor<float, 2, true>& in,
39 Tensor<float, 2, true>& outK,
40 Tensor<int, 2, true>& outV,
41 bool dir, int k, cudaStream_t stream) {
42 FAISS_ASSERT(k <= 1024);
43
44 if (dir) {
45 if (k == 1) {
46 WARP_SELECT_CALL(float, true, 1);
47 } else if (k <= 32) {
48 WARP_SELECT_CALL(float, true, 32);
49 } else if (k <= 64) {
50 WARP_SELECT_CALL(float, true, 64);
51 } else if (k <= 128) {
52 WARP_SELECT_CALL(float, true, 128);
53 } else if (k <= 256) {
54 WARP_SELECT_CALL(float, true, 256);
55 } else if (k <= 512) {
56 WARP_SELECT_CALL(float, true, 512);
57 } else if (k <= 1024) {
58 WARP_SELECT_CALL(float, true, 1024);
59 }
60 } else {
61 if (k == 1) {
62 WARP_SELECT_CALL(float, false, 1);
63 } else if (k <= 32) {
64 WARP_SELECT_CALL(float, false, 32);
65 } else if (k <= 64) {
66 WARP_SELECT_CALL(float, false, 64);
67 } else if (k <= 128) {
68 WARP_SELECT_CALL(float, false, 128);
69 } else if (k <= 256) {
70 WARP_SELECT_CALL(float, false, 256);
71 } else if (k <= 512) {
72 WARP_SELECT_CALL(float, false, 512);
73 } else if (k <= 1024) {
74 WARP_SELECT_CALL(float, false, 1024);
75 }
76 }
77 }
78
79 } } // namespace