QMCPACK
QueueOMPTarget.hpp
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) 2024 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 #ifndef QMCPLUSPLUS_QUEUE_OMPTARGET_H
13 #define QMCPLUSPLUS_QUEUE_OMPTARGET_H
14 
15 #include "Queue.hpp"
16 
17 namespace qmcplusplus
18 {
19 
20 namespace compute
21 {
22 
23 template<>
25 {
26 public:
27  // dualspace container
28  template<class DSC>
29  void enqueueH2D(DSC& dataset, typename DSC::size_type size = 0, typename DSC::size_type offset = 0)
30  {
31  if (dataset.data() == dataset.device_data())
32  return;
33 
34  auto host_ptr = dataset.data();
35  if (size == 0)
36  {
37  PRAGMA_OFFLOAD("omp target update to(host_ptr[offset:dataset.size()])")
38  }
39  else
40  {
41  PRAGMA_OFFLOAD("omp target update to(host_ptr[offset:size])")
42  }
43  }
44 
45  template<class DSC>
46  void enqueueD2H(DSC& dataset, typename DSC::size_type size = 0, typename DSC::size_type offset = 0)
47  {
48  if (dataset.data() == dataset.device_data())
49  return;
50 
51  auto host_ptr = dataset.data();
52  if (size == 0)
53  {
54  PRAGMA_OFFLOAD("omp target update from(host_ptr[offset:dataset.size()])")
55  }
56  else
57  {
58  PRAGMA_OFFLOAD("omp target update from(host_ptr[offset:size])")
59  }
60  }
61 
62  void sync() {}
63 };
64 
65 } // namespace compute
66 
67 } // namespace qmcplusplus
68 
69 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void enqueueH2D(DSC &dataset, typename DSC::size_type size=0, typename DSC::size_type offset=0)
void enqueueD2H(DSC &dataset, typename DSC::size_type size=0, typename DSC::size_type offset=0)