Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

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