QMCPACK
QueueSYCL.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_SYCL_H
13 #define QMCPLUSPLUS_QUEUE_SYCL_H
14 
15 #include "Queue.hpp"
16 #include "SYCLruntime.hpp"
17 
18 namespace qmcplusplus
19 {
20 
21 namespace compute
22 {
23 
24 template<>
26 {
27 public:
29 
30  // dualspace container
31  template<class DSC>
32  void enqueueH2D(DSC& dataset, typename DSC::size_type size = 0, typename DSC::size_type offset = 0)
33  {
34  if (dataset.data() == dataset.device_data())
35  return;
36 
37  if (size == 0)
38  queue_.memcpy(dataset.device_data() + offset, dataset.data() + offset,
39  dataset.size() * sizeof(typename DSC::value_type));
40  else
41  queue_.memcpy(dataset.device_data() + offset, dataset.data() + offset, size * sizeof(typename DSC::value_type));
42  }
43 
44  template<class DSC>
45  void enqueueD2H(DSC& dataset, typename DSC::size_type size = 0, typename DSC::size_type offset = 0)
46  {
47  if (dataset.data() == dataset.device_data())
48  return;
49 
50  if (size == 0)
51  queue_.memcpy(dataset.data() + offset, dataset.device_data() + offset,
52  dataset.size() * sizeof(typename DSC::value_type));
53  else
54  queue_.memcpy(dataset.data() + offset, dataset.device_data() + offset, size * sizeof(typename DSC::value_type));
55  }
56 
57  void sync() { queue_.wait(); }
58 
59  sycl::queue& getNative() { return queue_; }
60 
61 private:
63 };
64 
65 } // namespace compute
66 
67 } // namespace qmcplusplus
68 
69 #endif
sycl::queue createSYCLInOrderQueueOnDefaultDevice()
create an in-order queue using the default device
Definition: SYCLruntime.cpp:20
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
void enqueueH2D(DSC &dataset, typename DSC::size_type size=0, typename DSC::size_type offset=0)
Definition: QueueSYCL.hpp:32
void enqueueD2H(DSC &dataset, typename DSC::size_type size=0, typename DSC::size_type offset=0)
Definition: QueueSYCL.hpp:45
QMCTraits::FullPrecRealType value_type