diff options
| author | KunoiSayami <[email protected]> | 2021-11-15 11:57:39 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2021-11-15 11:57:39 +0800 |
| commit | 0406eca917270ebc4d05b20de4eecc45645d60f0 (patch) | |
| tree | e3dcf31673b0ae38669317cfce82b5bd6ff3ed2d /util/arena.cu | |
| parent | ff62cbaad13d4bd309de5d3dda8c7051325d5663 (diff) | |
feat: Add skiplist cuda version
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'util/arena.cu')
| -rw-r--r-- | util/arena.cu | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/util/arena.cu b/util/arena.cu index 09ec6e6..5075318 100644 --- a/util/arena.cu +++ b/util/arena.cu @@ -13,11 +13,12 @@ Arena::Arena() Arena::~Arena() { for (size_t i = 0; i < blocks_.size(); i++) { - cudaFree(blocks_[i]); + //cudaFree(blocks_[i]); + delete [] blocks_[i]; } } -char* Arena::AllocateFallback(size_t bytes) { +__device__ char* Arena::AllocateFallback(size_t bytes) { if (bytes > kBlockSize / 4) { // Object is more than a quarter of our block size. Allocate it separately // to avoid wasting too much space in leftover bytes. @@ -35,7 +36,7 @@ char* Arena::AllocateFallback(size_t bytes) { return result; } -char* Arena::AllocateAligned(size_t bytes) { +__device__ char* Arena::AllocateAligned(size_t bytes) { const int align = (sizeof(void*) > 8) ? sizeof(void*) : 8; static_assert((align & (align - 1)) == 0, "Pointer size should be a power of 2"); @@ -56,8 +57,8 @@ char* Arena::AllocateAligned(size_t bytes) { } char* Arena::AllocateNewBlock(size_t block_bytes) { - char* result = nullptr; - cudaMallocManaged((void **)&result, sizeof(char) * block_bytes); + char* result = new char[block_bytes]; + //cudaMallocManaged((void **)&result, sizeof(char) * block_bytes); blocks_.push_back(result); memory_usage_.fetch_add(block_bytes + sizeof(char*), std::memory_order_relaxed); |
