Skip to content

Commit 162c788

Browse files
committed
initial commit
1 parent 783574d commit 162c788

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "3rd/json11"]
2+
path = 3rd/json11
3+
url = https://github.com/dropbox/json11
4+
[submodule "3rd/spdlog"]
5+
path = 3rd/spdlog
6+
url = https://github.com/gabime/spdlog

3rd/json11

Submodule json11 added at 2df9473

3rd/spdlog

Submodule spdlog added at 592ea36

cpp/include/culda.cuh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2021 Jisang Yoon
2+
// All rights reserved.
3+
//
4+
// This source code is licensed under the Apache 2.0 license found in the
5+
// LICENSE file in the root directory of this source tree.
6+
#pragma once
7+
#include <thrust/copy.h>
8+
#include <thrust/fill.h>
9+
#include <thrust/random.h>
10+
#include <thrust/host_vector.h>
11+
#include <thrust/device_vector.h>
12+
#include <thrust/binary_search.h>
13+
#include <thrust/execution_policy.h>
14+
15+
#include <omp.h>
16+
#include <set>
17+
#include <random>
18+
#include <memory>
19+
#include <string>
20+
#include <fstream>
21+
#include <utility>
22+
#include <queue>
23+
#include <deque>
24+
#include <functional>
25+
#include <vector>
26+
#include <cmath>
27+
#include <chrono> // NOLINT
28+
29+
#include "json11.hpp"
30+
#include "log.hpp"
31+
#include "types.hpp"
32+
33+
namespace culda {
34+
35+
class CuLDA {
36+
public:
37+
CuLDA();
38+
~CuLDA();
39+
private:
40+
thrust::device_vector<cuda_scalar> device_data_;
41+
};
42+
43+
} // namespace culda

cpp/include/types.hpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) 2020 Jisang Yoon
2+
// All rights reserved.
3+
//
4+
// This source code is licensed under the Apache 2.0 license found in the
5+
// LICENSE file in the root directory of this source tree.
6+
#pragma once
7+
#include <cuda_fp16.h>
8+
9+
// experimental codes to use half precision
10+
// not properly working yet..
11+
// #define HALF_PRECISION 1
12+
13+
// #if __CUDA_ARCH__ < 530
14+
// #undef HALF_PRECISION
15+
// #endif
16+
17+
#ifdef HALF_PRECISION
18+
typedef half cuda_scalar;
19+
#define mul(x, y) ( __hmul(x, y) )
20+
#define add(x, y) ( __hadd(x, y) )
21+
#define sub(x, y) ( __hsub(x, y) )
22+
#define gt(x, y) ( __hgt(x, y) ) // x > y
23+
#define ge(x, y) ( __hge(x, y) ) // x >= y
24+
#define lt(x, y) ( __hlt(x, y) ) // x < y
25+
#define le(x, y) ( __hle(x, y) ) // x <= y
26+
#define out_scalar(x) ( __half2float(x) )
27+
#define conversion(x) ( __float2half(x) )
28+
#else
29+
typedef float cuda_scalar;
30+
#define mul(x, y) ( x * y )
31+
#define add(x, y) ( x + y )
32+
#define sub(x, y) ( x - y )
33+
#define gt(x, y) ( x > y )
34+
#define ge(x, y) ( x >= y )
35+
#define lt(x, y) ( x < y )
36+
#define le(x, y) ( x <= y )
37+
#define out_scalar(x) ( x )
38+
#define conversion(x) ( x )
39+
#endif
40+
41+
#define WARP_SIZE 32
42+
43+
struct Neighbor {
44+
cuda_scalar distance;
45+
int nodeid;
46+
bool checked;
47+
};
48+
49+
// to manage the compatibility with hnswlib
50+
typedef unsigned int tableint;
51+
typedef unsigned int sizeint;
52+
typedef float scalar;
53+
typedef size_t labeltype;
54+
55+
enum DIST_TYPE {
56+
DOT,
57+
L2,
58+
};

0 commit comments

Comments
 (0)