QMCPACK
PlatformSelector.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) 2022 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 "PlatformSelector.hpp"
14 #include <config.h>
15 #include <stdexcept>
16 
17 namespace qmcplusplus
18 {
19 
20 template<>
21 const std::vector<std::string> PlatformSelector<SelectorKind::CPU_OMPTARGET>::candidate_values{"", "yes", "no",
22  "omptarget", "cpu"};
23 
24 template<>
26 {
27 #if defined(ENABLE_OFFLOAD)
28  if (value.empty() || value == "yes" || value == "omptarget")
29 #else
30  if (value == "omptarget")
31 #endif
33  else
34  return PlatformKind::CPU;
35 }
36 
37 template<>
39  "no", "cuda",
40  "omptarget", "cpu"};
41 
42 template<>
44 {
45 #if defined(ENABLE_CUDA)
46  if (value.empty() || value == "yes" || value == "cuda")
47  return PlatformKind::CUDA;
48  else if (value == "omptarget")
49 #else
50  if (value == "cuda")
51  throw std::runtime_error("Cannot access CUDA code path. Executables are built with ENABLE_CUDA=OFF.");
52 #if defined(ENABLE_OFFLOAD)
53  if (value.empty() || value == "yes" || value == "omptarget")
54 #else
55  if (value == "omptarget")
56 #endif
57 #endif
59  else
60  return PlatformKind::CPU;
61 }
62 
63 template<>
65  "no", "sycl",
66  "omptarget", "cpu"};
67 
68 template<>
70 {
71 #if defined(ENABLE_SYCL)
72  if (value.empty() || value == "yes" || value == "sycl")
73  return PlatformKind::SYCL;
74  else if (value == "omptarget")
75 #else
76  if (value == "sycl")
77  throw std::runtime_error("Cannot access SYCL code path. Executables are built with ENABLE_SYCL=OFF.");
78 #if defined(ENABLE_OFFLOAD)
79  if (value.empty() || value == "yes" || value == "omptarget")
80 #else
81  if (value == "omptarget")
82 #endif
83 #endif
85  else
86  return PlatformKind::CPU;
87 }
88 
89 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
static PlatformKind selectPlatform(std::string_view value)