MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / release

Function release

extensions/include/cuMat/src/DevicePointer.h:9–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include "Context.h"
8
9CUMAT_NAMESPACE_BEGIN
10
11template <typename T>
12class DevicePointer
13{
14private:
15 T* pointer_;
16 int* counter_;
17 CUMAT_NAMESPACE Context* context_;
18 friend class DevicePointer<typename std::remove_const<T>::type>;
19
20 __host__ __device__
21 void release()
22 {
23#ifndef __CUDA_ARCH__
24 //no decrement of the counter in CUDA-code, counter is in host-memory
25 assert(CUMAT_IMPLIES(counter_, (*counter_) > 0) && "Attempt to calling release() twice");
26 if ((counter_) && (--(*counter_) == 0))
27 {
28 delete counter_;
29
30 //DEBUG
31 if (&Context::current() != context_)
32 {
33 CUMAT_LOG_WARNING(
34 "Freeing memory with a different context than the current context.\n"
35 "This will likely crash with an invalid-resource-handle error due to different Cub-Allocators");
36 }
37
38 context_->freeDevice(pointer_);
39 }
40#endif
41 }
42
43public:
44 DevicePointer(size_t size, CUMAT_NAMESPACE Context& ctx)

Callers 4

DevicePointer.hFile · 0.85
~DevicePointerFunction · 0.85
EventClass · 0.85
~EventMethod · 0.85

Calls 1

freeDeviceMethod · 0.80

Tested by

no test coverage detected