diff options
Diffstat (limited to 'util')
| -rw-r--r-- | util/arena.cuh | 2 | ||||
| -rw-r--r-- | util/random.cuh | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/util/arena.cuh b/util/arena.cuh index 950f286..f9ccb1e 100644 --- a/util/arena.cuh +++ b/util/arena.cuh @@ -17,7 +17,7 @@ namespace leveldb { class Arena { public: - __device__ Arena(); + explicit __device__ Arena(); Arena(const Arena&) = delete; Arena& operator=(const Arena&) = delete; diff --git a/util/random.cuh b/util/random.cuh index 95845f1..64eaadf 100644 --- a/util/random.cuh +++ b/util/random.cuh @@ -17,13 +17,13 @@ class Random { uint32_t seed_; public: - __device__ explicit Random(uint32_t s) : seed_(s & 0x7fffffffu) { + __host__ __device__ explicit Random(uint32_t s) : seed_(s & 0x7fffffffu) { // Avoid bad seeds. if (seed_ == 0 || seed_ == 2147483647L) { seed_ = 1; } } - __device__ uint32_t Next() { + __host__ __device__ uint32_t Next() { static const uint32_t M = 2147483647L; // 2^31-1 static const uint64_t A = 16807; // bits 14, 8, 7, 5, 2, 1, 0 // We are computing @@ -46,16 +46,16 @@ class Random { } // Returns a uniformly distributed value in the range [0..n-1] // REQUIRES: n > 0 - __device__ uint32_t Uniform(int n) { return Next() % n; } + __host__ __device__ uint32_t Uniform(int n) { return Next() % n; } // Randomly returns true ~"1/n" of the time, and false otherwise. // REQUIRES: n > 0 - __device__ bool OneIn(int n) { return (Next() % n) == 0; } + __host__ __device__ bool OneIn(int n) { return (Next() % n) == 0; } // Skewed: pick "base" uniformly from range [0,max_log] and then // return "base" random bits. The effect is to pick a number in the // range [0,2^max_log-1] with exponential bias towards smaller numbers. - __device__ uint32_t Skewed(int max_log) { return Uniform(1 << Uniform(max_log + 1)); } + __host__ __device__ uint32_t Skewed(int max_log) { return Uniform(1 << Uniform(max_log + 1)); } }; } // namespace leveldb |
