milupHPC documentation
  • src
  • subdomain_key_tree
subdomain_handler.cpp
Go to the documentation of this file.
1#include "../../include/subdomain_key_tree/subdomain_handler.h"
2
3SubDomainKeyTreeHandler::SubDomainKeyTreeHandler() {
4
5 boost::mpi::communicator comm;
6
7 h_rank = comm.rank();
8 h_numProcesses = comm.size();
9 h_range = new keyType[h_numProcesses + 1];
10 h_procParticleCounter = new integer[h_numProcesses];
11
12 h_subDomainKeyTree = new SubDomainKeyTree();
13 h_subDomainKeyTree->set(h_rank, h_numProcesses, h_range, h_procParticleCounter);
14
15 cuda::malloc(d_rank, 1);
16 cuda::malloc(d_numProcesses, 1);
17 cuda::malloc(d_range, h_numProcesses + 1);
18 //cuda::malloc(d_hilberRange, h_numProcesses + 1);
19 cuda::malloc(d_procParticleCounter, h_numProcesses);
20
21 cuda::malloc(d_subDomainKeyTree, 1);
22 SubDomainKeyTreeNS::Kernel::Launch::set(d_subDomainKeyTree, h_rank, h_numProcesses, d_range, d_procParticleCounter);
23}
24
25SubDomainKeyTreeHandler::~SubDomainKeyTreeHandler() {
26
27 delete [] h_range;
28 delete [] h_procParticleCounter;
29 delete h_subDomainKeyTree;
30
31 cuda::free(d_range);
32 cuda::free(d_procParticleCounter);
33 cuda::free(d_subDomainKeyTree);
34}
35
36void SubDomainKeyTreeHandler::reset() {
37 cuda::set(d_procParticleCounter, 0, h_numProcesses);
38 for (int i=0; i<h_numProcesses; i++) {
39 h_procParticleCounter[i] = 0;
40 }
41}
42
43void SubDomainKeyTreeHandler::copy(To::Target target, bool range, bool counter) {
44 if (range) {
45 cuda::copy(h_range, d_range, (h_numProcesses + 1), target);
46 }
47 if (counter) {
48 cuda::copy(h_procParticleCounter, d_procParticleCounter, h_numProcesses, target);
49 }
50}
51
52DomainListHandler::DomainListHandler(integer domainListSize) : domainListSize(domainListSize) {
53
54 cuda::malloc(d_domainListIndices, domainListSize);
55 cuda::malloc(d_domainListLevels, domainListSize);
56 cuda::malloc(d_domainListIndex, 1);
57 cuda::malloc(d_domainListCounter, 1);
58 cuda::malloc(d_domainListKeys, domainListSize);
59 cuda::malloc(d_sortedDomainListKeys, domainListSize);
60 cuda::malloc(d_relevantDomainListIndices, domainListSize);
61 cuda::malloc(d_relevantDomainListLevels, domainListSize);
62 cuda::malloc(d_relevantDomainListProcess, domainListSize);
63 cuda::malloc(d_relevantDomainListOriginalIndex, domainListSize);
64
65 cuda::malloc(d_borders, 2 * DIM * domainListSize);
66
67 cuda::malloc(d_domainList, 1);
68 DomainListNS::Kernel::Launch::set(d_domainList, d_domainListIndices, d_domainListLevels,
69 d_domainListIndex, d_domainListCounter, d_domainListKeys,
70 d_sortedDomainListKeys, d_relevantDomainListIndices,
71 d_relevantDomainListLevels, d_relevantDomainListProcess);
72 DomainListNS::Kernel::Launch::setBorders(d_domainList, d_borders, d_relevantDomainListOriginalIndex);
73}
74
75DomainListHandler::~DomainListHandler() {
76
77 cuda::free(d_domainListIndices);
78 cuda::free(d_domainListLevels);
79 cuda::free(d_domainListIndex);
80 cuda::free(d_domainListCounter);
81 cuda::free(d_domainListKeys);
82 cuda::free(d_sortedDomainListKeys);
83 cuda::free(d_relevantDomainListIndices);
84 cuda::free(d_relevantDomainListLevels);
85 cuda::free(d_relevantDomainListProcess);
86 cuda::free(d_relevantDomainListOriginalIndex);
87 cuda::free(d_borders);
88 cuda::free(d_domainList);
89
90}
91
92void DomainListHandler::reset() {
93
94 keyType maxKey = (keyType)KEY_MAX;
95 cuda::set(d_domainListIndices, -1, domainListSize);
96 cuda::set(d_domainListLevels, -1, domainListSize);
97 cuda::set(d_domainListIndex, 0, 1);
98 cuda::set(d_domainListCounter, 0, 1);
99 cuda::set(d_domainListKeys, maxKey, domainListSize);
100 cuda::set(d_sortedDomainListKeys, maxKey, domainListSize);
101 cuda::set(d_relevantDomainListIndices, -1, domainListSize);
102}
103
DomainListHandler::DomainListHandler
DomainListHandler(integer domainListSize)
Constructor.
Definition: subdomain_handler.cpp:52
DomainListHandler::d_borders
real * d_borders
Definition: subdomain_handler.h:104
DomainListHandler::d_relevantDomainListLevels
integer * d_relevantDomainListLevels
Definition: subdomain_handler.h:101
DomainListHandler::d_sortedDomainListKeys
keyType * d_sortedDomainListKeys
device sorted domain list keys
Definition: subdomain_handler.h:98
DomainListHandler::d_domainListIndices
integer * d_domainListIndices
device domain list indices
Definition: subdomain_handler.h:88
DomainListHandler::d_domainListLevels
integer * d_domainListLevels
device domain list levels
Definition: subdomain_handler.h:90
DomainListHandler::domainListSize
integer domainListSize
length/size of domain list
Definition: subdomain_handler.h:85
DomainListHandler::d_domainListKeys
keyType * d_domainListKeys
device domain list key
Definition: subdomain_handler.h:96
DomainListHandler::d_relevantDomainListIndices
integer * d_relevantDomainListIndices
device relevant domain list indices
Definition: subdomain_handler.h:100
DomainListHandler::d_relevantDomainListProcess
integer * d_relevantDomainListProcess
Definition: subdomain_handler.h:102
DomainListHandler::~DomainListHandler
~DomainListHandler()
Destructor.
Definition: subdomain_handler.cpp:75
DomainListHandler::reset
void reset()
Resetting entries.
Definition: subdomain_handler.cpp:92
DomainListHandler::d_domainList
DomainList * d_domainList
device instance of DomainList class
Definition: subdomain_handler.h:107
DomainListHandler::d_domainListIndex
integer * d_domainListIndex
device domain list index
Definition: subdomain_handler.h:92
DomainListHandler::d_domainListCounter
integer * d_domainListCounter
device domain list counter
Definition: subdomain_handler.h:94
DomainListHandler::d_relevantDomainListOriginalIndex
integer * d_relevantDomainListOriginalIndex
Definition: subdomain_handler.h:103
SubDomainKeyTreeHandler::h_range
keyType * h_range
host range(s)
Definition: subdomain_handler.h:31
SubDomainKeyTreeHandler::SubDomainKeyTreeHandler
SubDomainKeyTreeHandler()
Constructor.
Definition: subdomain_handler.cpp:3
SubDomainKeyTreeHandler::h_rank
integer h_rank
host MPI rank
Definition: subdomain_handler.h:27
SubDomainKeyTreeHandler::d_numProcesses
integer * d_numProcesses
device MPI number of processes
Definition: subdomain_handler.h:38
SubDomainKeyTreeHandler::d_subDomainKeyTree
SubDomainKeyTree * d_subDomainKeyTree
device instance of class SubDomainKeyTree
Definition: subdomain_handler.h:48
SubDomainKeyTreeHandler::~SubDomainKeyTreeHandler
~SubDomainKeyTreeHandler()
Destructor.
Definition: subdomain_handler.cpp:25
SubDomainKeyTreeHandler::h_subDomainKeyTree
SubDomainKeyTree * h_subDomainKeyTree
host instance of class SubDomainKeyTree
Definition: subdomain_handler.h:46
SubDomainKeyTreeHandler::d_range
keyType * d_range
device range(s)
Definition: subdomain_handler.h:40
SubDomainKeyTreeHandler::reset
void reset()
Resetting member variables.
Definition: subdomain_handler.cpp:36
SubDomainKeyTreeHandler::h_procParticleCounter
integer * h_procParticleCounter
host counter for particles in dependence of MPI process belonging
Definition: subdomain_handler.h:33
SubDomainKeyTreeHandler::d_rank
integer * d_rank
device MPI rank
Definition: subdomain_handler.h:36
SubDomainKeyTreeHandler::h_numProcesses
integer h_numProcesses
host MPI number of processes
Definition: subdomain_handler.h:29
SubDomainKeyTreeHandler::d_procParticleCounter
integer * d_procParticleCounter
host counter for particles in dependence of MPI process belonging
Definition: subdomain_handler.h:43
SubDomainKeyTreeHandler::copy
void copy(To::Target target=To::device, bool range=true, bool counter=true)
Copy (parts of the) SubDomainKeyTree instance(s) between host and device.
Definition: subdomain_handler.cpp:43
SubDomainKeyTree
SubDomainKeyTree class handling rank, number of processes and ranges.
Definition: subdomain.cuh:62
SubDomainKeyTree::set
CUDA_CALLABLE_MEMBER void set(integer rank, integer numProcesses, keyType *range, integer *procParticleCounter)
Setter.
Definition: subdomain.cu:36
DomainListNS::Kernel::Launch::set
void set(DomainList *domainList, integer *domainListIndices, integer *domainListLevels, integer *domainListIndex, integer *domainListCounter, keyType *domainListKeys, keyType *sortedDomainListKeys, integer *relevantDomainListIndices, integer *relevantDomainListLevels, integer *relevantDomainListProcess)
Wrapper for DomainListNS::Kernel::set().
Definition: subdomain.cu:2115
DomainListNS::Kernel::Launch::setBorders
void setBorders(DomainList *domainList, real *borders, integer *relevantDomainListOriginalIndex)
Definition: subdomain.cu:2125
SubDomainKeyTreeNS::Kernel::Launch::set
void set(SubDomainKeyTree *subDomainKeyTree, integer rank, integer numProcesses, keyType *range, integer *procParticleCounter)
Wrapper for SubDomainKeyTreeNS::Kernel::set().
Definition: subdomain.cu:1538
cuda::copy
void copy(T *h_var, T *d_var, std::size_t count=1, To::Target copyTo=To::device)
Copy between host and device and vice-versa.
Definition: cuda_runtime.h:30
cuda::set
void set(T *d_var, T val, std::size_t count=1)
Set device memory to a specific value.
Definition: cuda_runtime.h:56
cuda::free
void free(T *d_var)
Free device memory.
Definition: cuda_runtime.h:81
cuda::malloc
void malloc(T *&d_var, std::size_t count)
Allocate device memory.
Definition: cuda_runtime.h:70
keyType
unsigned long keyType
Definition: parameter.h:18
integer
int integer
Definition: parameter.h:17
KEY_MAX
#define KEY_MAX
Definition: parameter.h:102
DIM
#define DIM
Dimension of the problem.
Definition: parameter.h:38
To::Target
Target
Definition: parameter.h:164

milupHPC - src/subdomain_key_tree/subdomain_handler.cpp Source File
Generated on Wed Aug 31 2022 12:16:53 by Doxygen 1.9.3