17#include <TRUSTTab_parts.h>
22#include <DeviceMemory.h>
25bool self_tested_ =
false;
40 double mp = mp_norme_vect(a);
44 Cerr <<
"What! " << mp <<
" != " << sol << finl;
46 <<
"Weird bug seen during a sum reduction with Kokkos::parallel_reduce for TRUST production build on Cuda 11.6. Fixed with Cuda 12.1 (or before...)."
48 Cerr <<
"Update Cuda please !" << finl;
63 assert(a.get_data_location() == DataLocation::HostOnly);
65 assert(a.get_data_location() == DataLocation::HostDevice);
67 assert(a.get_data_location() == DataLocation::Host);
69 assert(a.get_data_location() == DataLocation::HostDevice);
75 assert(a.get_data_location() == DataLocation::HostOnly);
81 assert(a.get_data_location() == DataLocation::HostDevice);
90 assert(inco.get_data_location() == DataLocation::HostDevice);
91 assert(inco.ref_count() == 1);
98 assert(inco.ref_count() == 2);
101 CDoubleArrView a_v =
static_cast<const ArrOfDouble&
>(a).view_ro();
102 DoubleArrView b_v =
static_cast<ArrOfDouble&
>(b).view_wo();
103 Kokkos::parallel_for(N, KOKKOS_LAMBDA(
const int i)
109 const DoubleTab& const_b = b;
110 const DoubleTab& const_a = a;
111 assert(const_b[5] == const_a[5]);
112 assert(const_b[5] == 1);
116 assert(b.get_data_location() == DataLocation::HostDevice);
117 assert(inco.get_data_location() == DataLocation::HostDevice);
119 assert(inco.get_data_location() == DataLocation::HostDevice);
120 assert(inco.ref_count() == 1);
127 assert(inco.ref_count() == 2);
130 CDoubleArrView a_v =
static_cast<const ArrOfDouble&
>(a).view_ro();
131 DoubleArrView b_v =
static_cast<ArrOfDouble&
>(b).view_wo();
132 Kokkos::parallel_for(N, KOKKOS_LAMBDA(
const int i)
138 const DoubleTab& const_b = b;
139 const DoubleTab& const_a = a;
140 assert(const_b[5] == const_a[5]);
141 assert(const_b[5] == 1);
143 assert(b.get_data_location() == DataLocation::HostDevice);
145 assert(inco.ref_count() == 1);
149 assert(inco.get_data_location() == DataLocation::Device);
150 assert(inco.ref_count() == 1);
157 assert(inco.ref_count() == 2);
160 CDoubleArrView a_v =
static_cast<const ArrOfDouble&
>(a).view_ro();
161 DoubleArrView b_v =
static_cast<ArrOfDouble&
>(b).view_wo();
162 Kokkos::parallel_for(N, KOKKOS_LAMBDA(
const int i)
167 const DoubleTab& const_b = b;
168 const DoubleTab& const_a = a;
169 assert(const_b[5] == const_a[5]);
170 assert(const_b[5] == 2);
172 assert(b.get_data_location() == DataLocation::HostDevice);
173 assert(inco.get_data_location() == DataLocation::HostDevice);
175 assert(inco.get_data_location() == DataLocation::HostDevice);
179 assert(inco.get_data_location() == DataLocation::Device);
185 assert(inco.ref_count() == 2);
188 CDoubleArrView a_v =
static_cast<const ArrOfDouble&
>(a).view_ro();
189 DoubleArrView b_v =
static_cast<ArrOfDouble&
>(b).view_wo();
190 Kokkos::parallel_for(N, KOKKOS_LAMBDA(
const int i)
195 const DoubleTab& const_b = b;
196 const DoubleTab& const_a = a;
197 assert(const_b[5] == const_a[5]);
198 assert(const_b[5] == 3);
200 assert(b.get_data_location() == DataLocation::HostDevice);
201 assert(inco.get_data_location() == DataLocation::HostDevice);
203 assert(inco.get_data_location() == DataLocation::HostDevice);
207 ArrOfDouble a(10), b(10);
220 assert(b.get_data_location() == DataLocation::Device);
221 const ArrOfDouble& const_b = b;
225 assert(const_b[0] == 3);
236 assert(b.get_data_location() == DataLocation::Device);
238 const ArrOfDouble& const_b = b;
239 assert(const_b[0] == 1);
240 assert(const_b[b.size() - 1] == 1);
250 const ArrOfDouble& const_b = b;
252 assert(const_b[0] == 1);
253 assert(const_b[b.
size() - 1] == 1);
257 DoubleTab a(10), b(10);
258 const ArrOfDouble& const_a = a;
259 const ArrOfDouble& const_b = b;
265 assert(b.get_data_location() == DataLocation::HostDevice);
271 assert(b.get_data_location() == DataLocation::Device);
276 assert(b.get_data_location() == DataLocation::HostDevice);
277 assert(const_a[0] == 20);
278 assert(const_a[a.
size()-1] == 20);
279 assert(const_b[0] == -10);
280 assert(const_b[b.size()-1] == -10);
296 const ArrOfDouble& const_a = a;
297 assert(const_a[0] == 0);
305 assert(b.get_data_location()==DataLocation::Device);
307 assert(b.get_data_location()==DataLocation::Device);
309 const ArrOfDouble& const_b = b;
310 assert(const_b[0] == 1);
311 assert(const_b[b.size()-1] == 1);
325 assert(local_max_vect(a)==3);
326 assert(local_min_vect(a)==-10);
327 assert(local_max_abs_vect(a)==10);
328 assert(local_min_abs_vect(a)==1);
335 assert(local_imax_vect(a)==1);
336 assert(local_imin_vect(a)==2);
358 DoubleArrView a_v =
static_cast<ArrOfDouble&
>(a).view_wo();
359 Kokkos::parallel_for(2*N, KOKKOS_LAMBDA(
const int i)
384 assert(isAllocatedOnDevice(ptr_host));
386 assert(!isAllocatedOnDevice(ptr_host));
419 assert(b2.get_mem_storage() == STORAGE::TEMP_STORAGE);
420 assert(b2.get_data_location() == DataLocation::Device);
423 assert(b3.get_mem_storage() == STORAGE::TEMP_STORAGE);
424 assert(b3.get_data_location() == DataLocation::Device);
static int nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
DataLocation get_data_location()
void set_data_location(DataLocation flag)
bool isDataOnDevice() const
virtual void ref(const TRUSTTab &)
void ref_array(TRUSTArray< _TYPE_, _SIZE_ > &, _SIZE_ start=0, _SIZE_ sz=-1) override
virtual void ref_tab(TRUSTTab &, _SIZE_ start_line=0, _SIZE_ nb_lines=-1)
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
static void printMemoryMap()