From 0406eca917270ebc4d05b20de4eecc45645d60f0 Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Mon, 15 Nov 2021 11:57:39 +0800 Subject: feat: Add skiplist cuda version Signed-off-by: KunoiSayami --- util/arena.cu | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'util/arena.cu') 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); -- cgit v1.3.1