QMCPACK
SYCLDeviceManager.h
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) 2022 QMCPACK developers.
6 //
7 // File developed by: Thomas Applencourt, apl@anl.gov, Argonne National Laboratory
8 // Ye Luo, yeluo@anl.gov, Argonne National Laboratory
9 //
10 // File created by: Thomas Applencourt, apl@anl.gov, Argonne National Laboratory
11 //
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 #ifndef QMCPLUSPLUS_SYCLDEVICEMANAGER_H
16 #define QMCPLUSPLUS_SYCLDEVICEMANAGER_H
17 
18 #include <vector>
19 #include <memory>
20 #include <sycl/sycl.hpp>
21 #include "config.h"
22 #if defined(ENABLE_OFFLOAD)
23 #include <omp.h>
24 #endif
25 
26 namespace qmcplusplus
27 {
29 {
30 public:
31 #if defined(ENABLE_OFFLOAD)
32  syclDeviceInfo(const sycl::context& context, const sycl::device& device, const omp_interop_t& interop);
33 #else
34  syclDeviceInfo(const sycl::context& context, const sycl::device& device);
35 #endif
37  const sycl::context& get_context() const { return context_; }
38  const sycl::device& get_device() const { return device_; }
39 
40 private:
41  sycl::context context_;
42  sycl::device device_;
43 #if defined(ENABLE_OFFLOAD)
44  omp_interop_t interop_;
45 #endif
46 };
47 
48 /** SYCL device manager
49  */
51 {
53  std::vector<syclDeviceInfo> visible_devices;
54 
55  /// the global singleton which can be used to access the default queue of the default device.
56  static std::unique_ptr<sycl::queue> default_device_queue;
57 
58 public:
59  SYCLDeviceManager(int& default_device_num, int& num_devices, int local_rank, int local_size);
60 
61  /** access the the DeviceManager owned default queue.
62  * Restrict the use of it to performance non-critical operations.
63  * Note: CUDA has a default queue but all the SYCL queues are explicit.
64  */
66 };
67 } // namespace qmcplusplus
68 
69 #endif
static std::unique_ptr< sycl::queue > default_device_queue
the global singleton which can be used to access the default queue of the default device...
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
const sycl::context & get_context() const
const sycl::device & get_device() const
SYCLDeviceManager(int &default_device_num, int &num_devices, int local_rank, int local_size)
std::vector< syclDeviceInfo > visible_devices
syclDeviceInfo(const sycl::context &context, const sycl::device &device)
static sycl::queue & getDefaultDeviceDefaultQueue()
access the the DeviceManager owned default queue.