MCPcopy Create free account
hub / github.com/DeepGraphLearning/graphvite / reallocate

Method reallocate

include/base/memory.h:108–134  ·  view source on GitHub ↗

Reallocate the memory space */

Source from the content-addressed store, hash-verified

106
107 /** Reallocate the memory space */
108 void reallocate(Index _capacity) {
109 if (capacity && !--(*refer_count)) {
110 delete refer_count;
111#ifdef PINNED_MEMORY
112 CUDA_CHECK(cudaFreeHost(host_ptr));
113#else
114 delete [] host_ptr;
115#endif
116 if (device_id != -1) {
117 CUDA_CHECK(cudaSetDevice(device_id));
118 CUDA_CHECK(cudaFree(device_ptr));
119 }
120 }
121 capacity = _capacity;
122 if (capacity) {
123 refer_count = new int(1);
124#ifdef PINNED_MEMORY
125 CUDA_CHECK(cudaMallocHost(&host_ptr, capacity * sizeof(Data)));
126#else
127 host_ptr = new Data[capacity];
128#endif
129 if (device_id != -1) {
130 CUDA_CHECK(cudaSetDevice(device_id));
131 CUDA_CHECK(cudaMalloc(&device_ptr, capacity * sizeof(Data)));
132 }
133 }
134 }
135
136 /** Resize the memory space. Reallocate only if the capacity is not enough. */
137 void resize(Index _count) {

Callers 4

clearMethod · 0.80
buildMethod · 0.80
clearMethod · 0.80
predictMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected