diff options
| author | KunoiSayami <[email protected]> | 2021-11-22 19:05:34 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2021-11-22 19:05:34 +0800 |
| commit | 0e18a4800b0737dc8f1d3720bc79bf000529ddef (patch) | |
| tree | 228a9860c2347a9076a47edc00b6a61e9f4ec663 /util | |
| parent | d30033359c0b97b28b50f54eeea6e820156f7578 (diff) | |
feat(skiplist): Convert skiplist to cuda version
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'util')
| -rw-r--r-- | util/arena.cu | 2 | ||||
| -rw-r--r-- | util/arena.cuh | 6 | ||||
| -rw-r--r-- | util/random.cuh | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/util/arena.cu b/util/arena.cu index db5827d..a9556e5 100644 --- a/util/arena.cu +++ b/util/arena.cu @@ -8,7 +8,7 @@ namespace leveldb { static const int kBlockSize = 4096; -Arena::Arena() +__device__ Arena::Arena() : alloc_ptr_(nullptr), alloc_bytes_remaining_(0), memory_usage_(0), head_(nullptr), blocks_(nullptr) {} diff --git a/util/arena.cuh b/util/arena.cuh index afbc575..950f286 100644 --- a/util/arena.cuh +++ b/util/arena.cuh @@ -17,12 +17,12 @@ namespace leveldb { class Arena { public: - Arena(); + __device__ Arena(); Arena(const Arena&) = delete; Arena& operator=(const Arena&) = delete; - ~Arena(); + __device__ ~Arena(); // Return a pointer to a newly allocated memory block of "bytes" bytes. __device__ char* Allocate(size_t bytes); @@ -32,7 +32,7 @@ class Arena { // Returns an estimate of the total memory usage of data allocated // by the arena. - size_t MemoryUsage() const { + __device__ size_t MemoryUsage() const { return memory_usage_.load(cuda::memory_order_relaxed); } diff --git a/util/random.cuh b/util/random.cuh index 38eafe2..95845f1 100644 --- a/util/random.cuh +++ b/util/random.cuh @@ -17,7 +17,7 @@ class Random { uint32_t seed_; public: - explicit Random(uint32_t s) : seed_(s & 0x7fffffffu) { + __device__ explicit Random(uint32_t s) : seed_(s & 0x7fffffffu) { // Avoid bad seeds. if (seed_ == 0 || seed_ == 2147483647L) { seed_ = 1; |
