aboutsummaryrefslogtreecommitdiff
path: root/util/arena.cu
diff options
context:
space:
mode:
Diffstat (limited to 'util/arena.cu')
-rw-r--r--util/arena.cu11
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);