QMCPACK
test_class_member.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2019 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 #include <memory>
16 #include <vector>
17 #include <iostream>
18 #include <omp.h>
20 
21 namespace qmcplusplus
22 {
23 template<typename T>
24 struct maptest
25 {
26  static const size_t size = 6;
27  T data[size];
28 
29  PRAGMA_OFFLOAD("omp declare target")
30  inline void set_value(int i, const T* restrict array, T* restrict data)
31  {
32  data[i] = array[i];
33  }
34  PRAGMA_OFFLOAD("omp end declare target")
35 
36  void run()
37  {
38  PRAGMA_OFFLOAD("omp target enter data map(alloc:data[0:6])")
39  T newdata[size] = {0, 1, 2, 3, 4, 5};
40  PRAGMA_OFFLOAD("omp target map(to:newdata[0:6]) map(from:data[0:6])")
41  {
42  PRAGMA_OFFLOAD("omp parallel for")
43  for (int i = 0; i < size; i++)
44  set_value(i, newdata, data);
45  }
46  PRAGMA_OFFLOAD("omp target exit data map(delete:data[0:6])")
47  std::cout << "data[5] = " << data[5] << std::endl;
48  }
49 };
50 
51 TEST_CASE("OMPclass member", "[OMP]")
52 {
53  maptest<double> tester;
54  tester.run();
55 }
56 
57 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
static const size_t size
void set_value(int i, const T *restrict array, T *restrict data)