Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
gpu_base.hpp
Go to the documentation of this file.
1/*
2 * This file is part of Vlasiator.
3 * Copyright 2010-2025 Finnish Meteorological Institute and University of Helsinki
4 *
5 * For details of usage, see the COPYING file and read the "Rules of the Road"
6 * at http://www.physics.helsinki.fi/vlasiator/
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#ifndef GPU_BASE_H
24#define GPU_BASE_H
25
26#ifdef _OPENMP
27 #include <omp.h>
28#endif
29
30#include "arch_device_api.h"
31
32#include <stdio.h>
33#include <mutex>
34#include "include/splitvector/splitvec.h"
35#include "include/hashinator/hashinator.h"
36#include "../definitions.h"
37#include "../vlasovsolver/vec.h"
39#include <phiprof.hpp>
40
41#ifndef THREADS_PER_MP
42#define THREADS_PER_MP 2048
43#endif
44#ifndef REGISTERS_PER_MP
45#define REGISTERS_PER_MP 65536
46#endif
47
48// Device properties
49extern int gpuMultiProcessorCount;
50extern int blocksPerMP;
51extern int threadsPerMP;
52
53// Magic multipliers used to make educated guesses for initial allocations
54// and for managing dynamic increases in allocation sizes. Some of these are
55// scaled based on WID value for better guesses,
56static const uint VLASOV_BUFFER_MINBLOCKS = 32768/WID3;
57static const uint VLASOV_BUFFER_MINCOLUMNS = 2000/WID;
58static const uint INIT_VMESH_SIZE (32768/WID3);
59static const uint INIT_MAP_SIZE (16 - WID);
60static const double BLOCK_ALLOCATION_PADDING = 1.2;
61static const double BLOCK_ALLOCATION_FACTOR = 1.1;
62
63// Used in acceleration column construction. The flattened version of the
64// probe cube must store (5) counters / offsets, see vlasovsolver/gpu_acc_map.cpp for details.
65static const int GPU_PROBEFLAT_N = 5;
66
67// buffers need to be larger for translation to allow proper parallelism
68// GPUTODO: Get rid of this multiplier and consolidate buffer allocations.
69// WARNING: Simply removing this factor led to diffs in Flowthrough_trans_periodic, indicating that
70// there is somethign wrong with the evaluation of buffers! To be investigated.
72
73#define MAXCPUTHREADS 512 // hypothetical max size for some allocation arrays
74
75void gpu_init_device();
76void gpu_clear_device();
79uint gpu_getThread();
81int gpu_getDevice();
83int gpu_reportMemory(const size_t local_cap=0, const size_t ghost_cap=0, const size_t local_size=0, const size_t ghost_size=0);
84
85unsigned int nextPowerOfTwo(unsigned int n);
86
87void gpu_vlasov_allocate(uint maxBlockCount);
88void gpu_calculateProbeAllocation(uint maxBlockCount);
90void gpu_vlasov_allocate_perthread(uint cpuThreadID, uint maxBlockCount);
92
93void gpu_batch_allocate(uint nCells=0, uint maxNeighbours=0);
94
95void gpu_acc_allocate(uint maxBlockCount);
96void gpu_acc_allocate_perthread(uint cpuThreadID, uint firstAllocationCount, uint columnSetAllocationCount=0);
98
99void gpu_trans_allocate(cuint nAllCells=0,
100 cuint largestVmesh=0,
101 cuint unionSetSize=0);
103
106
107// Struct used by Vlasov Acceleration semi-Lagrangian solver
109 split::SplitVector<uint> setColumnOffsets; // index from columnBlockOffsets where new set of columns starts (length nColumnSets)
110 split::SplitVector<uint> setNumColumns; // how many columns in set of columns (length nColumnSets)
111
112 split::SplitVector<uint> columnBlockOffsets; // indexes where columns start (in blocks, length totalColumns)
113 split::SplitVector<uint> columnNumBlocks; // length of column (in blocks, length totalColumns)
114 split::SplitVector<int> minBlockK,maxBlockK;
115 split::SplitVector<int> kBegin;
116 split::SplitVector<int> i,j;
117 uint colSize = 0;
118 uint colSetSize = 0;
119 uint colCapacity = 0;
121
122 ColumnOffsets(uint nColumns=1, uint nColumnSets=1) {
123 gpuStream_t stream = gpu_getStream();
124 setColumnOffsets.resize(nColumnSets);
125 setNumColumns.resize(nColumnSets);
126 columnBlockOffsets.resize(nColumns);
127 columnNumBlocks.resize(nColumns);
128 minBlockK.resize(nColumns);
129 maxBlockK.resize(nColumns);
130 kBegin.resize(nColumns);
131 i.resize(nColumns);
132 j.resize(nColumns);
133 // These vectors themselves are not in unified memory, just their content data
134 setColumnOffsets.optimizeGPU(stream);
135 setNumColumns.optimizeGPU(stream);
136 columnBlockOffsets.optimizeGPU(stream);
137 columnNumBlocks.optimizeGPU(stream);
138 minBlockK.optimizeGPU(stream);
139 maxBlockK.optimizeGPU(stream);
140 kBegin.optimizeGPU(stream);
141 i.optimizeGPU(stream);
142 j.optimizeGPU(stream);
143 // Cached values
144 colSize = nColumns;
145 colSetSize = nColumnSets;
146 colCapacity = columnBlockOffsets.capacity(); // Uses this as an example
147 colSetCapacity = setNumColumns.capacity(); // Uses this as an example
148 }
150 setColumnOffsets.optimizeGPU(stream);
151 setNumColumns.optimizeGPU(stream);
152 columnBlockOffsets.optimizeGPU(stream);
153 columnNumBlocks.optimizeGPU(stream);
154 minBlockK.optimizeGPU(stream);
155 maxBlockK.optimizeGPU(stream);
156 kBegin.optimizeGPU(stream);
157 i.optimizeGPU(stream);
158 j.optimizeGPU(stream);
159 }
160 __host__ size_t sizeCols() const {
161 return colSize;
162 }
163 __host__ size_t capacityCols() const {
164 return colCapacity;
165 }
166 __host__ size_t capacityColSets() const {
167 return colSetCapacity;
168 }
169 __device__ size_t dev_sizeCols() const {
170 return columnBlockOffsets.size(); // Uses this as an example
171 }
172 __device__ size_t dev_sizeColSets() const {
173 return setNumColumns.size(); // Uses this as an example
174 }
175 __device__ size_t dev_capacityCols() const {
176 return columnBlockOffsets.capacity(); // Uses this as an example
177 }
178 __device__ size_t dev_capacityColSets() const {
179 return setNumColumns.capacity(); // Uses this as an example
180 }
181 size_t capacityInBytes() const {
182 return colCapacity * (2*sizeof(uint)+5*sizeof(int))
183 + colSetCapacity * (2*sizeof(uint))
184 + 4 * sizeof(split::SplitVector<uint>)
185 + 5 * sizeof(split::SplitVector<int>);
186 }
187 void setSizes(size_t nCols=0, size_t nColSets=0) {
188 // Ensure capacities are handled with cached values
189 setCapacities(nCols,nColSets);
190 // Only then resize
191 setColumnOffsets.resize(nColSets,true);
192 setNumColumns.resize(nColSets,true);
193 columnBlockOffsets.resize(nCols,true);
194 columnNumBlocks.resize(nCols,true);
195 minBlockK.resize(nCols,true);
196 maxBlockK.resize(nCols,true);
197 kBegin.resize(nCols,true);
198 i.resize(nCols,true);
199 j.resize(nCols,true);
200 colSize = nCols;
201 colSetSize = nColSets;
202 }
203 __device__ void device_setSizes(size_t nCols=0, size_t nColSets=0) {
204 // Cannot recapacitate
205 setColumnOffsets.device_resize(nColSets);
206 setNumColumns.device_resize(nColSets);
207 columnBlockOffsets.device_resize(nCols);
208 columnNumBlocks.device_resize(nCols);
209 minBlockK.device_resize(nCols);
210 maxBlockK.device_resize(nCols);
211 kBegin.device_resize(nCols);
212 i.device_resize(nCols);
213 j.device_resize(nCols);
214 colSize = nCols;
215 colSetSize = nColSets;
216 }
217 void setCapacities(size_t nCols=0, size_t nColSets=0) {
218 // check cached capacities to prevent page faults if not necessary
219 if (nCols > colCapacity) {
220 // Recapacitate column vectors
223 columnNumBlocks.reallocate(colCapacity);
224 minBlockK.reallocate(colCapacity);
225 maxBlockK.reallocate(colCapacity);
226 kBegin.reallocate(colCapacity);
227 i.reallocate(colCapacity);
228 j.reallocate(colCapacity);
229 }
230 if (nColSets > colSetCapacity) {
231 // Recapacitate columnSet vectors
234 setNumColumns.reallocate(colSetCapacity);
235 }
236 }
237};
238
239/*
240Usage options:
241(a):
2421. Create your pointer using one of the macros for creating pointers. Pass the "name" of your
243pointer to that macro. A corresponding variable in the memory manager will be automatically generated.
2442. Allocate memory to that pointer by passing the "name" to one of the allocation macros
2453. Get the pointer by passing the "name" to one of the get pointer methods macros
246(b):
2471. Define an index variable for your pointer and pass that to one of the methods for crate pointers
2482. Allocate memory to that pointer by passing the index to one of the allocation methods
2493. Get the pointer by passing the index to one of the get pointer methods
250*/
252 // Store pointers and their allocation sizes
253 std::vector<void*> gpuMemoryPointers;
254 std::vector<size_t> allocationSizes;
255 std::vector<uint> pointerDevice;
256 std::vector<void*> sessionPointers;
257 std::vector<size_t> sessionPointerOffset;
258 std::vector<uint> sessionPointerDevice;
259 std::vector<size_t> sessionAllocationSizes;
260 std::mutex memoryMutex;
261 bool sessionOn = false;
262 size_t dev_sessionSize = 0;
268 size_t maxPointerIndex = 0;
270
271 // Indices for session pointers
274
275 #define NO_POINTER_DEVICE 0
276 #define DEVICE_POINTER 1
277 #define HOST_POINTER 2
278
279 // Useful for passing typenames with commas to other macros
280 #define SINGLE_ARG(...) __VA_ARGS__
281
282 /*
283 Definitions for global pointer indices
284 Run the updateGpuMemoryPointerList.sh script to automatically update the list
285 All "names" for pointersinitialized with CREATE_UNIQUE_POINTER, CREATE_SUBPOINTERS, SESSION_HOST_ALLOCATE
286 , or SESSION_HOST_ALLOCATE are listed here.
287 */
288 #define DEFINITIONS_HERE
289 size_t dev_allMaps, dev_allPencilsContainers, dev_allPencilsMeshes, dev_blockDataOrdered, dev_bulkVX, dev_bulkVY, dev_bulkVZ, dev_bValues, dev_cellIdxArray, dev_cellIdxKeys, dev_cellIdxStartCutoff, dev_columnOffsetData, dev_Ddt, dev_densityPostAdjust, dev_densityPreAdjust, dev_dfdt_mu, dev_dxdydz, dev_fcount, dev_fmu, dev_intersections, dev_lists_delete, dev_lists_to_replace, dev_lists_with_replace_new, dev_lists_with_replace_old, dev_mass, dev_massLoss, dev_max_dt, dev_minValues, dev_moments1, dev_moments2, dev_nAfter, dev_nBefore, dev_nBlocksToChange, dev_nColumns, dev_nColumnSets, dev_nu0Values, dev_nWithContent, dev_overflownElements, dev_pencilBlockData, dev_pencilBlocksCount, dev_potentialDdtValues, dev_probeCubeData, dev_remappedCellIdxArray, dev_resizeSuccess, dev_smallCellIdxArray, dev_sparsity, dev_VBC, dev_VBCs, dev_vbwcl_neigh, dev_vbwcl_vec, dev_velocityIdxArray, dev_vmeshes, gpu_block_indices_to_id, gpu_block_indices_to_probe, gpu_cell_indices_to_id, gpuInitBlocks, gpuInitBuffer, host_allMaps, host_allPencilsContainers, host_allPencilsMeshes, host_blockDataOrdered, host_bulkVX, host_bulkVY, host_bulkVZ, host_bValues, host_cellIdxStartCutoff, host_Ddt, host_dxdydz, host_intersections, host_lists_delete, host_lists_to_replace, host_lists_with_replace_new, host_lists_with_replace_old, host_mass, host_massLoss, host_max_dt, host_minValues, host_moments1, host_moments2, host_nAfter, host_nBefore, host_nBlocksToChange, host_nColumns, host_nColumnSets, host_nu0Values, host_nWithContent, host_overflownElements, host_remappedCellIdxArray, host_resizeSuccess, host_returnLID, host_returnReal, host_returnRealf, host_smallCellIdxArray, host_sparsity, host_VBC, host_VBCs, host_vbwcl_neigh, host_vbwcl_vec, host_vmeshes, member, my_test_pointer, returnLID, returnReal, returnRealf;
290 #define DEFINITIONS_END
291 #undef DEFINITIONS_HERE
292 #undef DEFINITIONS_END
293
294 // Macro for using a global "name" for a pointer without manually adding the pointer to a list
295 // Other methods have similar macros for using pointers with "names"
296 #define CREATE_UNIQUE_POINTER(object, member) object.createPointer(object.member)
297 // Create a new pointer and replace the given index with the index corresponding to the pointer
298 bool createPointer(size_t& pointerIndex) {
299 if (pointerIndex != 0){
300 return false;
301 }
302
303 std::lock_guard<std::mutex> lock(memoryMutex);
304
305 // Leave first pointer empty
306 if (maxPointerIndex == 0) {
307 gpuMemoryPointers.push_back(nullptr);
308 allocationSizes.push_back((size_t)(0));
310 }
311
312 gpuMemoryPointers.push_back(nullptr);
313 allocationSizes.push_back((size_t)(0));
315
317 pointerIndex = maxPointerIndex;
318
319 return true;
320 }
321
322 #define CREATE_SUBPOINTERS(object, member, amount) object.createSubPointers(object.member, amount)
323 // Create a given number of subpointers
324 bool createSubPointers(size_t& firstPointerIndex, const size_t numberOfPointers) {
325 if (firstPointerIndex != 0 || numberOfPointers == 0){
326 return false;
327 }
328
329 std::lock_guard<std::mutex> lock(memoryMutex);
330
331 // Leave first pointer empty
332 if (maxPointerIndex == 0) {
333 gpuMemoryPointers.push_back(nullptr);
334 allocationSizes.push_back((size_t)(0));
336 }
337
338 firstPointerIndex = maxPointerIndex + 1;
339
340 for (size_t i = 0; i < numberOfPointers; i++) {
342 gpuMemoryPointers.push_back(nullptr);
343 allocationSizes.push_back((size_t)(0));
345 }
346
347 return true;
348 }
349
350 // Start a session, where we have one big session pointer which can be split into multiple smaller pointers
351 bool startSession(size_t dev_bytes, size_t host_bytes){
352 // Ensure that the session pointers are at least as big as the largest session so far
353 size_t host_requiredSessionSize = max(host_previousSessionSize, host_bytes);
354 size_t dev_requiredSessionSize = max(dev_previousSessionSize, dev_bytes);
355
358
359 if(sessionOn){
360 std::cerr << "Concurrent sessions not supported. Please end previous session before starting a new one.\n";
361 return false;
362 }
363 sessionOn = true;
364
365 // Reallocate session pointers if the required size increases
366 if(dev_requiredSessionSize > dev_sessionAllocationSize){
367 allocate(dev_sessionPointer, dev_requiredSessionSize);
368 dev_sessionAllocationSize = dev_requiredSessionSize;
369 }
370 dev_sessionSize = 0;
372
373 if(host_requiredSessionSize > host_sessionAllocationSize){
374 hostAllocate(host_sessionPointer, host_requiredSessionSize);
375 host_sessionAllocationSize = host_requiredSessionSize;
376 }
379
380 return true;
381 }
382
383 // Ending a session wipes the divisions of the session pointer
385 if(!sessionOn){
386 std::cerr << "No session is currently on. Please start a session before ending it.\n";
387 return false;
388 }
389 sessionOn = false;
391 dev_sessionSize = 0;
394
395 // Free the pointers that did not fit into the session pointer
397
399
400 return true;
401 }
402
403 #define ALLOCATE_GPU(object, member, bytes) object.allocate(object.member, bytes)
404 // Allocate memory to a pointer by index
405 bool allocate(const size_t& pointerIndex, size_t bytes) {
406 if (pointerIndex == 0) {
407 std::cerr << "Error: Pointer not found in 'gpuMemoryManager.allocate'.\n";
408 return false;
409 }
410
411 std::lock_guard<std::mutex> lock(memoryMutex);
412
413 if (allocationSizes[pointerIndex] >= bytes) {
414 //No need to reallocate
415 return false;
416 }
417
418 if (gpuMemoryPointers[pointerIndex] != nullptr) {
419 CHK_ERR( gpuFree(gpuMemoryPointers[pointerIndex]) );
420 }
421
422 CHK_ERR( gpuMalloc(&gpuMemoryPointers[pointerIndex], bytes) );
423 allocationSizes[pointerIndex] = bytes;
424 pointerDevice[pointerIndex] = DEVICE_POINTER;
425
426 return true;
427 }
428
429 #define ALLOCATE_WITH_BUFFER(object, member, bytes, buffer) object.allocateWithBuffer(object.member, bytes, buffer)
430 // Allocate memory to a pointer by index with an extra buffer added
431 bool allocateWithBuffer(const size_t& pointerIndex, size_t bytes, size_t buffer) {
432 if (pointerIndex == 0) {
433 std::cerr << "Error: Pointer not found in 'gpuMemoryManager.allocateWithBuffer'.\n";
434 return false;
435 }
436
437 std::lock_guard<std::mutex> lock(memoryMutex);
438
439 if (allocationSizes[pointerIndex] >= bytes) {
440 //No need to reallocate
441 return false;
442 }
443
444 if (gpuMemoryPointers[pointerIndex] != nullptr) {
445 CHK_ERR( gpuFree(gpuMemoryPointers[pointerIndex]) );
446 }
447
448 CHK_ERR( gpuMalloc(&gpuMemoryPointers[pointerIndex], bytes*buffer) );
449 allocationSizes[pointerIndex] = bytes*buffer;
450 pointerDevice[pointerIndex] = DEVICE_POINTER;
451
452 return true;
453 }
454
455 #define HOST_ALLOCATE_GPU(object, member, bytes) object.hostAllocate(object.member, bytes)
456 // Allocate pinned host memory to a pointer by index
457 bool hostAllocate(const size_t& pointerIndex, size_t bytes) {
458 if (pointerIndex == 0) {
459 std::cerr << "Error: Pointer not found in 'gpuMemoryManager.hostAllocate'.\n";
460 return false;
461 }
462
463 std::lock_guard<std::mutex> lock(memoryMutex);
464
465 if (allocationSizes[pointerIndex] >= bytes) {
466 //No need to reallocate
467 return false;
468 }
469
470 if (gpuMemoryPointers[pointerIndex] != nullptr) {
471 CHK_ERR( gpuFreeHost(gpuMemoryPointers[pointerIndex]) );
472 }
473
474 CHK_ERR( gpuMallocHost(&gpuMemoryPointers[pointerIndex], bytes) );
475 allocationSizes[pointerIndex] = bytes;
476 pointerDevice[pointerIndex] = HOST_POINTER;
477
478 return true;
479 }
480
481 #define HOST_ALLOCATE_WITH_BUFFER(object, member, bytes, buffer) object.hostAllocateWithBuffer(object.member, bytes, buffer)
482 // Allocate pinned host memory to a pointer by index with an extra buffer
483 bool hostAllocateWithBuffer(const size_t& pointerIndex, size_t bytes, size_t buffer) {
484 if (pointerIndex == 0) {
485 std::cerr << "Error: Pointer not found in 'gpuMemoryManager.hostAllocateWithBuffer'.\n";
486 return false;
487 }
488
489 std::lock_guard<std::mutex> lock(memoryMutex);
490
491 if (allocationSizes[pointerIndex] >= bytes) {
492 //No need to reallocate
493 return false;
494 }
495
496 if (gpuMemoryPointers[pointerIndex] != nullptr) {
497 CHK_ERR( gpuFreeHost(gpuMemoryPointers[pointerIndex]) );
498 }
499
500 CHK_ERR( gpuMallocHost(&gpuMemoryPointers[pointerIndex], bytes*buffer) );
501 allocationSizes[pointerIndex] = bytes*buffer;
502 pointerDevice[pointerIndex] = HOST_POINTER;
503
504 return true;
505 }
506
507 #define SUBPOINTER_ALLOCATE(object, member, index, bytes) object.subPointerAllocate(object.member, index, bytes)
508 // Allocate memory to a sub pointer by base index and index
509 bool subPointerAllocate(const size_t& firstPointerIndex, const uint index, size_t bytes) {
510
511 size_t pointerIndex = firstPointerIndex + index;
512
513 if (firstPointerIndex == 0 || pointerIndex > maxPointerIndex) {
514 std::cerr << "Error: Pointer not found in 'gpuMemoryManager.subPointerAllocate': firstPointerIndex = " << firstPointerIndex << ", pointerIndex = " << pointerIndex << ", maxPointerIndex = " << maxPointerIndex << "\n";
515 return false;
516 }
517
518 return allocate(pointerIndex, bytes);
519 }
520
521 // Allocate memory to a sub pointer by base index and index with an extra buffer
522 bool subPointerAllocateWithBuffer(const size_t& firstPointerIndex, const uint index, size_t bytes, size_t buffer) {
523
524 size_t pointerIndex = firstPointerIndex + index;
525
526 if (firstPointerIndex == 0 || pointerIndex > maxPointerIndex) {
527 std::cerr << "Error: Pointer not found in 'gpuMemoryManager.subPointerAllocateWithBuffer'.\n";
528 return false;
529 }
530
531 return allocateWithBuffer(pointerIndex, bytes, buffer);
532 }
533
534 #define SUBPOINTER_HOST_ALLOCATE(object, member, index, bytes) object.subPointerHostAllocate(object.member, index, bytes)
535 // Allocate host memory to a sub pointer by base index and index
536 bool subPointerHostAllocate(const size_t& firstPointerIndex, const uint index, size_t bytes) {
537
538 size_t pointerIndex = firstPointerIndex + index;
539
540 if (firstPointerIndex == 0 || pointerIndex > maxPointerIndex) {
541 std::cerr << "Error: Pointer not found in 'gpuMemoryManager.subPointerHostAllocate'.\n";
542 return false;
543 }
544
545 return hostAllocate(pointerIndex, bytes);
546 }
547
548 // Calculate the offset required to align a pointer
549 template<typename T>
550 size_t alignOffset(void* base, size_t offset) {
551 uintptr_t fullAddress = reinterpret_cast<uintptr_t>(base) + offset;
552 size_t alignment = std::max(alignof(T),size_t(256)); // Align to at least 256 bits
553 size_t alignedAddress = (fullAddress + alignment - 1) & ~(alignment - 1);
554 return alignedAddress - reinterpret_cast<uintptr_t>(base);
555 }
556
557 #define SESSION_ALLOCATE(object, type, member, bytes) object.sessionAllocate<type>(object.member, bytes)
558 // Create a new pointer by partitioning the session pointer
559 template<typename T>
560 bool sessionAllocate(size_t& pointerIndex, size_t bytes){
561 if(!sessionOn){
562 std::cerr << "No session is currently on. Please start a session before allocating to it.\n";
563 return false;
564 }
565
566 void *sessionPointer = getPointer<void>(dev_sessionPointer);
567 size_t offset = alignOffset<T>(sessionPointer, dev_sessionSize);
568
569 std::lock_guard<std::mutex> lock(memoryMutex);
570
571 // Leave first pointer empty
572 if (maxSessionPointerIndex == 0) {
573 sessionPointerOffset.push_back((size_t)(0));
574 sessionPointers.push_back(nullptr);
576 sessionAllocationSizes.push_back((size_t)(0));
577 }
578
580 pointerIndex = maxSessionPointerIndex;
581
582 int padding = offset - dev_sessionSize;
583 dev_sessionSize += bytes + padding;
584
585 sessionPointerOffset.push_back(offset);
586 sessionPointers.push_back(nullptr);
588 sessionAllocationSizes.push_back((size_t)(0));
589
590 // If the pointer does not fit into the session pointer, create a new pointer
593 sessionAllocationSizes[pointerIndex] = bytes;
594 CHK_ERR( gpuMalloc(&sessionPointers[pointerIndex], bytes) );
595 }
596
597 return true;
598 }
599
600 #define SESSION_HOST_ALLOCATE(object, type, member, bytes) object.sessionHostAllocate<type>(object.member, bytes)
601 // Create a new pointer by partitioning the host session pointer
602 template<typename T>
603 bool sessionHostAllocate(size_t& pointerIndex, size_t bytes){
604 if(!sessionOn){
605 std::cerr << "No session is currently on. Please start a session before allocating to it.\n";
606 return false;
607 }
608
609 void *sessionPointer = getPointer<void>(host_sessionPointer);
610 size_t offset = alignOffset<T>(sessionPointer, host_sessionSize);
611
612 std::lock_guard<std::mutex> lock(memoryMutex);
613
614 // Leave first pointer empty
615 if (maxSessionPointerIndex == 0) {
616 sessionPointerOffset.push_back((size_t)(0));
617 sessionPointers.push_back(nullptr);
619 sessionAllocationSizes.push_back((size_t)(0));
620 }
621
623 pointerIndex = maxSessionPointerIndex;
624
625 int padding = offset - host_sessionSize;
626 host_sessionSize += bytes + padding;
627
628 sessionPointerOffset.push_back(offset);
629 sessionPointers.push_back(nullptr);
631 sessionAllocationSizes.push_back((size_t)(0));
632
633 // If the pointer does not fit into the session pointer, create a new pointer
636 sessionAllocationSizes[pointerIndex] = bytes;
637 CHK_ERR( gpuMallocHost(&sessionPointers[pointerIndex], bytes) );
638 }
639
640 return true;
641 }
642
643 #define ALLOCATE_GPU_ASYNC(object, member, bytes, stream) object.allocateAsync(object.member, bytes, stream)
644 // Allocate memory to a pointer by index asynchronously
645 bool allocateAsync(const size_t& pointerIndex, size_t bytes, gpuStream_t stream) {
646 if (pointerIndex == 0) {
647 std::cerr << "Error: Pointer not found in 'gpuMemoryManager.allocateAsync'.\n";
648 return false;
649 }
650
651 std::lock_guard<std::mutex> lock(memoryMutex);
652
653 if (allocationSizes[pointerIndex] >= bytes) {
654 //No need to reallocate
655 return false;
656 }
657
658 if (gpuMemoryPointers[pointerIndex] != nullptr) {
659 CHK_ERR( gpuFreeAsync(gpuMemoryPointers[pointerIndex], stream) );
660 }
661
662 CHK_ERR( gpuMallocAsync(&gpuMemoryPointers[pointerIndex], bytes, stream) );
663 allocationSizes[pointerIndex] = bytes;
664 pointerDevice[pointerIndex] = DEVICE_POINTER;
665
666 return true;
667 }
668
669 #define SUBPOINTER_ALLOCATE_ASYNC(object, member, index, bytes, stream) object.subPointerAllocateAsync(object.member, index, bytes, stream)
670 // Allocate memory to a sub pointer by base index and index
671 bool subPointerAllocateAsync(const size_t& firstPointerIndex, const uint index, size_t bytes, gpuStream_t stream) {
672
673 size_t pointerIndex = firstPointerIndex + index;
674
675 if (firstPointerIndex == 0 || pointerIndex > maxPointerIndex) {
676 std::cerr << "Error: Pointer not found in 'gpuMemoryManager.subPointerAllocateAsync': firstPointerIndex = " << firstPointerIndex << ", pointerIndex = " << pointerIndex << ", maxPointerIndex = " << maxPointerIndex << "\n";
677 return false;
678 }
679
680 return allocateAsync(pointerIndex, bytes, stream);
681 }
682
683 // Free a pointer
684 bool freePointer(size_t& pointerIndex) {
685 if (pointerIndex == 0) {
686 std::cerr << "Error: Pointer not found in 'gpuMemoryManager.freePointer'.\n";
687 return false;
688 }
689
690 if (pointerIndex > maxPointerIndex) {
691 //Assumes it was freed already, could also be invalid pointer
692 return false;
693 }
694
695 std::lock_guard<std::mutex> lock(memoryMutex);
696
697 CHK_ERR( gpuFree(gpuMemoryPointers[pointerIndex]) );
698 allocationSizes[pointerIndex] = (size_t)(0);
699 pointerDevice[pointerIndex] = NO_POINTER_DEVICE;
700 gpuMemoryPointers[pointerIndex] = nullptr;
701
702 return true;
703 }
704
705 // Get allocated size for a pointer
706 size_t getSize(const size_t& pointerIndex) const {
707 if (pointerIndex != 0){
708 return allocationSizes[pointerIndex];
709 }
710 return 0;
711 }
712
713 // Get the total amount of GPU memory allocated with the memory manager
715 size_t total = 0;
716
717 for (size_t pointerIndex = 0; pointerIndex < gpuMemoryPointers.size(); pointerIndex++) {
718 if (gpuMemoryPointers[pointerIndex] != nullptr) {
719 if (pointerDevice[pointerIndex] == DEVICE_POINTER){
720 total += allocationSizes[pointerIndex];
721 }
722 }
723 }
724
725 for (size_t pointerIndex = 0; pointerIndex < sessionPointers.size(); pointerIndex++) {
726 if (sessionPointers[pointerIndex] != nullptr) {
727 if (sessionPointerDevice[pointerIndex] == DEVICE_POINTER){
728 total += sessionAllocationSizes[pointerIndex];
729 }
730 }
731 }
732
733 return total;
734 }
735
736 // get the total amount of host memory allocated with the memory manager
738 size_t total = 0;
739
740 for (size_t pointerIndex = 0; pointerIndex < gpuMemoryPointers.size(); pointerIndex++) {
741 if (gpuMemoryPointers[pointerIndex] != nullptr) {
742 if (pointerDevice[pointerIndex] == HOST_POINTER){
743 total += allocationSizes[pointerIndex];
744 }
745 }
746 }
747
748 for (size_t pointerIndex = 0; pointerIndex < sessionPointers.size(); pointerIndex++) {
749 if (sessionPointers[pointerIndex] != nullptr) {
750 if (sessionPointerDevice[pointerIndex] == HOST_POINTER){
751 total += sessionAllocationSizes[pointerIndex];
752 }
753 }
754 }
755
756 return total;
757 }
758
759 // Free all allocated pointers from session, besides the sessionpointer itself
761 for (size_t pointerIndex = 0; pointerIndex < sessionPointers.size(); pointerIndex++) {
762 if (sessionPointers[pointerIndex] != nullptr) {
763 if (sessionPointerDevice[pointerIndex] == DEVICE_POINTER){
764 CHK_ERR( gpuFree(sessionPointers[pointerIndex]) );
765 }else if (sessionPointerDevice[pointerIndex] == HOST_POINTER){
766 CHK_ERR( gpuFreeHost(sessionPointers[pointerIndex]) );
767 }
768 }
769 }
770
771 sessionPointers.clear();
772 sessionPointerOffset.clear();
773 sessionPointerDevice.clear();
775 }
776
777 // Free all allocated GPU memory
778 void freeAll() {
779 for (size_t pointerIndex = 0; pointerIndex < gpuMemoryPointers.size(); pointerIndex++) {
780 if (gpuMemoryPointers[pointerIndex] != nullptr) {
781 if (allocationSizes[pointerIndex] > 0){
782 if (pointerDevice[pointerIndex] == DEVICE_POINTER){
783 CHK_ERR( gpuFree(gpuMemoryPointers[pointerIndex]) );
784 }else if (pointerDevice[pointerIndex] == HOST_POINTER){
785 CHK_ERR( gpuFreeHost(gpuMemoryPointers[pointerIndex]) );
786 }
787 }
788 }
789 }
791
792 gpuMemoryPointers.clear();
793 allocationSizes.clear();
794 pointerDevice.clear();
795 sessionPointerOffset.clear();
796 sessionOn = false;
797 dev_sessionSize = 0;
803 maxPointerIndex = 0;
807 }
808
809 #define GET_POINTER(object, type, member) object.getPointer<type>(object.member)
810 // Get typed pointer
811 template <typename T>
812 T* getPointer(const size_t& pointerIndex) const {
813 if (pointerIndex == 0){
814 throw std::runtime_error("Unknown pointer name at gpuMemoryManager.getPointer!\n");
815 }
816 return static_cast<T*>(gpuMemoryPointers[pointerIndex]);
817 }
818
819 #define GET_SUBPOINTER(object, type, member, index) object.getSubPointer<type>(object.member, index)
820 // Get typed subpointer with an index
821 template <typename T>
822 T* getSubPointer(const size_t& firstPointerIndex, const uint index) const {
823
824 size_t pointerIndex = firstPointerIndex + index;
825
826 if (firstPointerIndex == 0 || pointerIndex > maxPointerIndex) {
827 throw std::runtime_error("Unknown pointer name at gpuMemoryManager.getSubPointer!\n");
828 }
829
830 return getPointer<T>(pointerIndex);
831 }
832
833 #define GET_SESSION_POINTER(object, type, member) object.getSessionPointer<type>(object.member)
834 // Get pointer in a session
835 template <typename T>
836 T* getSessionPointer(const size_t& pointerIndex) const {
837 if (pointerIndex == 0 || pointerIndex > maxSessionPointerIndex){
838 throw std::runtime_error("Unknown pointer name at gpuMemoryManager.getSessionPointer!\n");
839 }
840
841 // The pointer is usually contained in the session pointer and distinguished by an offset
842 char *sessionPointer = static_cast<char*>(gpuMemoryPointers[dev_sessionPointer]);
843 size_t offset = sessionPointerOffset[pointerIndex];
844
845 // If the pointer did not fit inside the session pointer, retrieve it from the separate map
846 if (offset > dev_sessionAllocationSize){
847 return static_cast<T*>(sessionPointers[pointerIndex]);
848 }
849
850 return reinterpret_cast<T*>(sessionPointer + offset);
851 }
852
853 #define GET_SESSION_HOST_POINTER(object, type, member) object.getSessionHostPointer<type>(object.member)
854 // Get host pointer in a session
855 template <typename T>
856 T* getSessionHostPointer(const size_t& pointerIndex) const {
857 if (pointerIndex == 0 || pointerIndex > maxSessionPointerIndex){
858 throw std::runtime_error("Unknown pointer name at gpuMemoryManager.getSessionHostPointer!\n");
859 }
860
861 // The pointer is usually contained in the session pointer and distinguished by an offset
862 char *sessionPointer = static_cast<char*>(gpuMemoryPointers[host_sessionPointer]);
863 size_t offset = sessionPointerOffset[pointerIndex];
864
865 // If the pointer did not fit inside the session pointer, retrieve it from the separate map
866 if (offset > host_sessionAllocationSize){
867 return static_cast<T*>(sessionPointers[pointerIndex]);
868 }
869
870 return reinterpret_cast<T*>(sessionPointer + offset);
871 }
872
873 // Update a new pointer to the memory manager
874 void updatePointer(const size_t& pointerIndex, void* newPtr) {
875 std::lock_guard<std::mutex> lock(memoryMutex);
876 gpuMemoryPointers[pointerIndex] = newPtr;
877 }
878
879 #define SET_SUBPOINTER(object, type, member, index, subPointerIndex) object.setSubPointer<type>(object.member, index, subPointerIndex)
880 // Set the value of the base pointer at a given index to be the corresponding sub pointer
881 template <typename T>
882 void setSubPointer(const size_t basePointerIndex, const size_t index, const size_t subPointerIndex){
883 if (basePointerIndex == 0 || subPointerIndex == 0) {
884 throw std::runtime_error("Error: Pointer not found in 'gpuMemoryManager.setSubPointer'.");
885 }
886
887 T** basePointer = static_cast<T**>(gpuMemoryPointers[basePointerIndex]);
888 T* subPointer = static_cast<T*>(gpuMemoryPointers[subPointerIndex]);
889 basePointer[index] = subPointer;
890 }
891};
892
894
898
899// Hash map and splitvectors buffers used in block adjustment are declared in block_adjust_gpu.hpp
900// Vector and set for use in translation are declared in vlasovsolver/gpu_trans_map_amr.hpp
901
902// Counters used in allocations
903extern std::vector<uint> gpu_vlasov_allocatedSize;
904extern uint gpu_acc_allocatedColumns;
905extern uint gpu_acc_foundColumnsCount;
906
907#endif
for i
Definition Dispersion.m:24
#define gpuStream_t
cudaStream_t gpuStreamList[]
Definition gpu_base.cpp:51
#define gpuMalloc
#define CHK_ERR(err)
#define gpuFree
#define gpuMallocHost
#define gpuMallocAsync
#define gpuFreeHost
#define gpuFreeAsync
#define WID
Definition common.h:514
const int WID3
Definition common.h:517
const uint32_t cuint
Definition definitions.h:50
int blocksPerMP
Definition gpu_base.cpp:43
GPUMemoryManager gpuMemoryManager
Definition gpu_base.cpp:64
std::vector< uint > gpu_vlasov_allocatedSize
Definition gpu_base.cpp:69
ColumnOffsets * host_columnOffsetData
Definition gpu_base.cpp:55
gpuStream_t gpuPriorityStreamList[MAXCPUTHREADS]
Definition gpu_base.cpp:52
size_t gpu_probeStride
Definition gpu_base.cpp:57
int threadsPerMP
Definition gpu_base.cpp:44
size_t gpu_probeFullSize
Definition gpu_base.cpp:57
size_t gpu_probeFlattenedSize
Definition gpu_base.cpp:57
uint gpu_largest_columnCount
Definition gpu_base.cpp:75
int gpuMultiProcessorCount
Definition gpu_base.cpp:42
#define DEVICE_POINTER
Definition gpu_base.hpp:276
unsigned int nextPowerOfTwo(unsigned int n)
Definition gpu_base.cpp:92
static const uint VLASOV_BUFFER_MINBLOCKS
Definition gpu_base.hpp:56
void gpu_batch_allocate(uint nCells=0, uint maxNeighbours=0)
Definition gpu_base.cpp:462
static const int GPU_PROBEFLAT_N
Definition gpu_base.hpp:65
void gpu_vlasov_deallocate()
Definition gpu_base.cpp:401
gpuStream_t gpu_getPriorityStream()
Definition gpu_base.cpp:248
uint gpu_getAllocationCount()
Definition gpu_base.cpp:259
uint gpu_acc_foundColumnsCount
static const uint INIT_MAP_SIZE(16 - WID)
void gpu_init_device()
Definition gpu_base.cpp:103
static const double BLOCK_ALLOCATION_PADDING
Definition gpu_base.hpp:60
uint gpu_vlasov_getSmallestAllocation()
Definition gpu_base.cpp:410
uint gpu_getMaxThreads()
Definition gpu_base.cpp:84
void gpu_vlasov_allocate(uint maxBlockCount)
Definition gpu_base.cpp:335
void gpu_acc_allocate(uint maxBlockCount)
Definition gpu_base.cpp:537
int gpu_getDevice()
Definition gpu_base.cpp:253
static const uint VLASOV_BUFFER_MINCOLUMNS
Definition gpu_base.hpp:57
void gpu_clear_device()
Definition gpu_base.cpp:229
#define HOST_POINTER
Definition gpu_base.hpp:277
static const uint INIT_VMESH_SIZE(32768/WID3)
void gpu_trans_allocate(cuint nAllCells=0, cuint largestVmesh=0, cuint unionSetSize=0)
Definition gpu_base.cpp:607
static const int TRANSLATION_BUFFER_ALLOCATION_FACTOR
Definition gpu_base.hpp:71
void gpu_acc_allocate_perthread(uint cpuThreadID, uint firstAllocationCount, uint columnSetAllocationCount=0)
Definition gpu_base.cpp:567
uint gpu_acc_allocatedColumns
static const double BLOCK_ALLOCATION_FACTOR
Definition gpu_base.hpp:61
uint gpu_getThread()
Definition gpu_base.cpp:77
int gpu_reportMemory(const size_t local_cap=0, const size_t ghost_cap=0, const size_t local_size=0, const size_t ghost_size=0)
Definition gpu_base.cpp:266
void gpu_trans_deallocate()
Definition gpu_base.cpp:663
void gpu_acc_deallocate()
Definition gpu_base.cpp:556
#define NO_POINTER_DEVICE
Definition gpu_base.hpp:275
gpuStream_t gpu_getStream()
Definition gpu_base.cpp:244
void gpu_calculateProbeAllocation(uint maxBlockCount)
Definition gpu_base.cpp:359
void gpu_vlasov_allocate_perthread(uint cpuThreadID, uint maxBlockCount)
Definition gpu_base.cpp:421
#define index(i, j, k)
uint32_t uint
split::SplitVector< int > j
Definition gpu_base.hpp:116
split::SplitVector< int > maxBlockK
Definition gpu_base.hpp:114
__device__ size_t dev_capacityColSets() const
Definition gpu_base.hpp:178
__host__ size_t capacityColSets() const
Definition gpu_base.hpp:166
__device__ void device_setSizes(size_t nCols=0, size_t nColSets=0)
Definition gpu_base.hpp:203
__device__ size_t dev_sizeColSets() const
Definition gpu_base.hpp:172
__host__ size_t capacityCols() const
Definition gpu_base.hpp:163
uint colSetCapacity
Definition gpu_base.hpp:120
void prefetchDevice(gpuStream_t stream)
Definition gpu_base.hpp:149
void setSizes(size_t nCols=0, size_t nColSets=0)
Definition gpu_base.hpp:187
split::SplitVector< uint > columnNumBlocks
Definition gpu_base.hpp:113
split::SplitVector< uint > setNumColumns
Definition gpu_base.hpp:110
size_t capacityInBytes() const
Definition gpu_base.hpp:181
ColumnOffsets(uint nColumns=1, uint nColumnSets=1)
Definition gpu_base.hpp:122
split::SplitVector< int > kBegin
Definition gpu_base.hpp:115
split::SplitVector< uint > setColumnOffsets
Definition gpu_base.hpp:109
void setCapacities(size_t nCols=0, size_t nColSets=0)
Definition gpu_base.hpp:217
__device__ size_t dev_capacityCols() const
Definition gpu_base.hpp:175
split::SplitVector< int > i
Definition gpu_base.hpp:116
__host__ size_t sizeCols() const
Definition gpu_base.hpp:160
split::SplitVector< uint > columnBlockOffsets
Definition gpu_base.hpp:112
split::SplitVector< int > minBlockK
Definition gpu_base.hpp:114
__device__ size_t dev_sizeCols() const
Definition gpu_base.hpp:169
size_t dev_allPencilsContainers
Definition gpu_base.hpp:289
size_t host_intersections
Definition gpu_base.hpp:289
bool subPointerAllocate(const size_t &firstPointerIndex, const uint index, size_t bytes)
Definition gpu_base.hpp:509
size_t totalGpuAllocation()
Definition gpu_base.hpp:714
size_t dev_cellIdxKeys
Definition gpu_base.hpp:289
bool allocate(const size_t &pointerIndex, size_t bytes)
Definition gpu_base.hpp:405
size_t dev_nBlocksToChange
Definition gpu_base.hpp:289
size_t maxPointerIndex
Definition gpu_base.hpp:268
size_t host_smallCellIdxArray
Definition gpu_base.hpp:289
size_t dev_blockDataOrdered
Definition gpu_base.hpp:289
bool sessionAllocate(size_t &pointerIndex, size_t bytes)
Definition gpu_base.hpp:560
bool createSubPointers(size_t &firstPointerIndex, const size_t numberOfPointers)
Definition gpu_base.hpp:324
size_t dev_lists_to_replace
Definition gpu_base.hpp:289
size_t dev_resizeSuccess
Definition gpu_base.hpp:289
std::vector< void * > gpuMemoryPointers
Definition gpu_base.hpp:253
size_t dev_allPencilsMeshes
Definition gpu_base.hpp:289
size_t host_minValues
Definition gpu_base.hpp:289
bool hostAllocateWithBuffer(const size_t &pointerIndex, size_t bytes, size_t buffer)
Definition gpu_base.hpp:483
size_t totalCpuAllocation()
Definition gpu_base.hpp:737
std::vector< size_t > sessionAllocationSizes
Definition gpu_base.hpp:259
size_t host_nColumnSets
Definition gpu_base.hpp:289
std::vector< size_t > allocationSizes
Definition gpu_base.hpp:254
size_t dev_probeCubeData
Definition gpu_base.hpp:289
size_t host_returnReal
Definition gpu_base.hpp:289
size_t host_sessionSize
Definition gpu_base.hpp:263
size_t dev_intersections
Definition gpu_base.hpp:289
void freeSessionPointers()
Definition gpu_base.hpp:760
T * getPointer(const size_t &pointerIndex) const
Definition gpu_base.hpp:812
bool subPointerAllocateWithBuffer(const size_t &firstPointerIndex, const uint index, size_t bytes, size_t buffer)
Definition gpu_base.hpp:522
T * getSessionHostPointer(const size_t &pointerIndex) const
Definition gpu_base.hpp:856
size_t dev_columnOffsetData
Definition gpu_base.hpp:289
size_t my_test_pointer
Definition gpu_base.hpp:289
size_t host_overflownElements
Definition gpu_base.hpp:289
bool allocateAsync(const size_t &pointerIndex, size_t bytes, gpuStream_t stream)
Definition gpu_base.hpp:645
size_t gpu_block_indices_to_probe
Definition gpu_base.hpp:289
std::mutex memoryMutex
Definition gpu_base.hpp:260
size_t dev_smallCellIdxArray
Definition gpu_base.hpp:289
size_t dev_overflownElements
Definition gpu_base.hpp:289
bool createPointer(size_t &pointerIndex)
Definition gpu_base.hpp:298
size_t alignOffset(void *base, size_t offset)
Definition gpu_base.hpp:550
size_t host_lists_with_replace_old
Definition gpu_base.hpp:289
size_t gpu_block_indices_to_id
Definition gpu_base.hpp:289
T * getSessionPointer(const size_t &pointerIndex) const
Definition gpu_base.hpp:836
size_t host_returnRealf
Definition gpu_base.hpp:289
size_t dev_pencilBlocksCount
Definition gpu_base.hpp:289
bool sessionHostAllocate(size_t &pointerIndex, size_t bytes)
Definition gpu_base.hpp:603
std::vector< size_t > sessionPointerOffset
Definition gpu_base.hpp:257
size_t getSize(const size_t &pointerIndex) const
Definition gpu_base.hpp:706
T * getSubPointer(const size_t &firstPointerIndex, const uint index) const
Definition gpu_base.hpp:822
bool subPointerHostAllocate(const size_t &firstPointerIndex, const uint index, size_t bytes)
Definition gpu_base.hpp:536
size_t host_vbwcl_neigh
Definition gpu_base.hpp:289
void setSubPointer(const size_t basePointerIndex, const size_t index, const size_t subPointerIndex)
Definition gpu_base.hpp:882
size_t host_nu0Values
Definition gpu_base.hpp:289
size_t dev_nWithContent
Definition gpu_base.hpp:289
size_t host_lists_delete
Definition gpu_base.hpp:289
size_t host_lists_with_replace_new
Definition gpu_base.hpp:289
size_t host_remappedCellIdxArray
Definition gpu_base.hpp:289
std::vector< uint > pointerDevice
Definition gpu_base.hpp:255
size_t dev_lists_with_replace_new
Definition gpu_base.hpp:289
size_t maxSessionPointerIndex
Definition gpu_base.hpp:269
size_t dev_remappedCellIdxArray
Definition gpu_base.hpp:289
size_t host_previousSessionSize
Definition gpu_base.hpp:267
size_t dev_vbwcl_neigh
Definition gpu_base.hpp:289
size_t dev_previousSessionSize
Definition gpu_base.hpp:266
size_t dev_densityPostAdjust
Definition gpu_base.hpp:289
size_t host_allPencilsMeshes
Definition gpu_base.hpp:289
size_t host_resizeSuccess
Definition gpu_base.hpp:289
size_t host_cellIdxStartCutoff
Definition gpu_base.hpp:289
size_t host_nBlocksToChange
Definition gpu_base.hpp:289
size_t host_returnLID
Definition gpu_base.hpp:289
bool subPointerAllocateAsync(const size_t &firstPointerIndex, const uint index, size_t bytes, gpuStream_t stream)
Definition gpu_base.hpp:671
bool freePointer(size_t &pointerIndex)
Definition gpu_base.hpp:684
size_t dev_sessionPointer
Definition gpu_base.hpp:272
bool allocateWithBuffer(const size_t &pointerIndex, size_t bytes, size_t buffer)
Definition gpu_base.hpp:431
size_t host_nWithContent
Definition gpu_base.hpp:289
size_t host_blockDataOrdered
Definition gpu_base.hpp:289
bool startSession(size_t dev_bytes, size_t host_bytes)
Definition gpu_base.hpp:351
size_t gpu_cell_indices_to_id
Definition gpu_base.hpp:289
bool hostAllocate(const size_t &pointerIndex, size_t bytes)
Definition gpu_base.hpp:457
size_t dev_sessionAllocationSize
Definition gpu_base.hpp:264
size_t dev_densityPreAdjust
Definition gpu_base.hpp:289
size_t dev_lists_with_replace_old
Definition gpu_base.hpp:289
size_t dev_velocityIdxArray
Definition gpu_base.hpp:289
size_t dev_lists_delete
Definition gpu_base.hpp:289
void updatePointer(const size_t &pointerIndex, void *newPtr)
Definition gpu_base.hpp:874
size_t host_sessionPointer
Definition gpu_base.hpp:273
size_t dev_cellIdxStartCutoff
Definition gpu_base.hpp:289
std::vector< void * > sessionPointers
Definition gpu_base.hpp:256
size_t dev_pencilBlockData
Definition gpu_base.hpp:289
size_t host_allPencilsContainers
Definition gpu_base.hpp:289
size_t dev_sessionSize
Definition gpu_base.hpp:262
size_t dev_nColumnSets
Definition gpu_base.hpp:289
size_t dev_cellIdxArray
Definition gpu_base.hpp:289
size_t host_lists_to_replace
Definition gpu_base.hpp:289
size_t dev_potentialDdtValues
Definition gpu_base.hpp:289
size_t host_vbwcl_vec
Definition gpu_base.hpp:289
size_t host_sessionAllocationSize
Definition gpu_base.hpp:265
std::vector< uint > sessionPointerDevice
Definition gpu_base.hpp:258
An interface to a type with floating point values.
static ARCH_HOSTDEV VecSimple< T > max(VecSimple< T > const &l, VecSimple< T > const &r)