]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/commitdiff
Removed custom allocator in favor of thrust.
authorShanigen <vkaraf@gmail.com>
Wed, 28 Mar 2018 13:03:05 +0000 (15:03 +0200)
committerShanigen <vkaraf@gmail.com>
Wed, 28 Mar 2018 13:03:05 +0000 (15:03 +0200)
src/managed_allocator.h [deleted file]

diff --git a/src/managed_allocator.h b/src/managed_allocator.h
deleted file mode 100644 (file)
index 0e6c5f1..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-// https://github.com/jaredhoberock/managed_allocator
-#ifndef MANAGED_ALLOCATOR_H
-#define MANAGED_ALLOCATOR_H
-
-#include <cuda_runtime.h>
-#include <thrust/system_error.h>
-#include <thrust/system/cuda/error.h>
-
-template<class T>
-class managed_allocator
-{
-public:
-    using value_type = T;
-    
-    managed_allocator() {}
-    
-    template<class U>
-    managed_allocator(const managed_allocator<U>&) {}
-    
-    value_type* allocate(size_t n)
-    {
-      value_type* result = nullptr;
-      
-      cudaError_t error = cudaMallocManaged(&result, n*sizeof(T), cudaMemAttachGlobal);
-      
-      if(error != cudaSuccess)
-      {
-       throw thrust::system_error(error, thrust::cuda_category(), "managed_allocator::allocate(): cudaMallocManaged");
-      }
-      
-      return result;
-    }
-    
-    void deallocate(value_type* ptr, size_t)
-    {
-      cudaError_t error = cudaFree(ptr);
-      
-      if(error != cudaSuccess)
-      {
-       throw thrust::system_error(error, thrust::cuda_category(), "managed_allocator::deallocate(): cudaFree");
-      }
-    }
-};   
-    template<class T1, class T2>
-    bool operator ==(const managed_allocator<T1>&, const managed_allocator<T2>&)
-    {
-      return true;
-    }
-    
-    template<class T1, class T2>
-    bool operator!=(const managed_allocator<T1>& lhs, const managed_allocator<T2>& rhs)
-    {
-      return !(lhs == rhs);
-    }
-
-#endif // MANAGED_ALLOCATOR_H