OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
VCluster.cpp
1#define PRINT_STACKTRACE
2
3#include "config.h"
4#include "VCluster.hpp"
5#ifndef __CYGWIN__
6#include <execinfo.h>
7#endif
8
9#include "util/print_stack.hpp"
10#include "util/math_util_complex.hpp"
11
12Vcluster<> * global_v_cluster_private_heap = NULL;
13Vcluster<CudaMemory> * global_v_cluster_private_cuda = NULL;
14
15//
16std::vector<int> sieve_spf;
17
18// number of vcluster instances
19size_t n_vcluster = 0;
20bool ofp_initialized = false;
21
22size_t tot_sent = 0;
23size_t tot_recv = 0;
24
39size_t NBX_cnt = 0;
40
41std::string program_name;
42
43#ifdef CUDA_GPU
44
45#include "memory/CudaMemory.cuh"
46
47CudaMemory mem_tmp;
48
49CudaMemory rem_tmp;
50CudaMemory rem_tmp2[MAX_NUMER_OF_PROPERTIES];
51
52CudaMemory exp_tmp;
53CudaMemory exp_tmp2[MAX_NUMER_OF_PROPERTIES];
54
55#endif
56
57// Segmentation fault signal handler
58void bt_sighandler(int sig, siginfo_t * info, void * ctx_p)
59{
60 if (sig == SIGSEGV)
61 std::cout << "Got signal " << sig << " faulty address is %p, " << info->si_addr << " from " << info->si_pid << std::endl;
62 else
63 std:: cout << "Got signal " << sig << std::endl;
64
65 print_stack();
66
67 exit(1);
68}
69
70double time_spent = 0.0;
71
72
78void openfpm_init_vcl(int *argc, char ***argv)
79{
80
81#ifdef HAVE_PETSC
82
83 PetscInitialize(argc,argv,NULL,NULL);
84
85#endif
86
87 init_global_v_cluster_private(argc,argv);
88
89#ifdef SE_CLASS1
90 std::cout << "OpenFPM is compiled with debug mode LEVEL:1. Remember to remove SE_CLASS1 when you go in production" << std::endl;
91#endif
92
93#ifdef SE_CLASS2
94 std::cout << "OpenFPM is compiled with debug mode LEVEL:2. Remember to remove SE_CLASS2 when you go in production" << std::endl;
95#endif
96
97#ifdef SE_CLASS3
98 std::cout << "OpenFPM is compiled with debug mode LEVEL:3. Remember to remove SE_CLASS3 when you go in production" << std::endl;
99#endif
100
101 init_wrappers();
102
103 // install segmentation fault signal handler
104
105 struct sigaction sa;
106
107 sa.sa_sigaction = bt_sighandler;
108 sigemptyset(&sa.sa_mask);
109 sa.sa_flags = SA_RESTART;
110
111 sigaction(SIGSEGV, &sa, NULL);
112
113 if (argc != NULL && *argc != 0)
114 {program_name = std::string(*argv[0]);}
115
116 // Initialize math pre-computation tables
117 openfpm::math::init_getFactorization();
118
119 ofp_initialized = true;
120
121#ifdef CUDA_GPU
122
123 // Initialize temporal memory
124 mem_tmp.incRef();
125
126 exp_tmp.incRef();
127
128 for (int i = 0 ; i < MAX_NUMER_OF_PROPERTIES ; i++)
129 {
130 exp_tmp2[i].incRef();
131 }
132
133
134#endif
135}
136
137size_t openfpm_vcluster_compilation_mask()
138{
139 size_t compiler_mask = CUDA_ON_BACKEND;
140
141 return compiler_mask;
142}
143
149void openfpm_finalize()
150{
151#ifdef HAVE_PETSC
152
153 PetscFinalize();
154
155#endif
156
157 delete_global_v_cluster_private();
158 ofp_initialized = false;
159
160#ifdef CUDA_GPU
161
162 // Release memory
163 mem_tmp.destroy();
164 mem_tmp.decRef();
165
166 exp_tmp.destroy();
167 exp_tmp.decRef();
168
169 for (int i = 0 ; i < MAX_NUMER_OF_PROPERTIES ; i++)
170 {
171 exp_tmp2[i].destroy();
172 exp_tmp2[i].decRef();
173 }
174
175#endif
176}
virtual void incRef()
Increment the reference counter.
virtual void decRef()
Decrement the reference counter.
virtual void destroy()
destroy memory
Definition CudaMemory.cu:80
Implementation of VCluster class.
Definition VCluster.hpp:59