DPC++ Runtime
Runtime libraries for oneAPI DPC++
force_device.cpp
Go to the documentation of this file.
1 //==---------- force_device.cpp - Forcing SYCL device ----------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include <CL/sycl/stl.hpp>
11 #include <detail/force_device.hpp>
12 
13 #include <algorithm>
14 #include <cstdlib>
15 
17 namespace sycl {
18 namespace detail {
19 
21  return l == info::device_type::all || l == r || r == info::device_type::all;
22 }
23 
25  if (const char *val = std::getenv("SYCL_DEVICE_TYPE")) {
26  std::string type(val);
27  std::transform(type.begin(), type.end(), type.begin(), ::tolower);
28 
29  if (type == "cpu") {
30  return info::device_type::cpu;
31  }
32  if (type == "gpu") {
33  return info::device_type::gpu;
34  }
35  if (type == "acc") {
36  return info::device_type::accelerator;
37  }
38  if (type == "host") {
39  return info::device_type::host;
40  }
41  throw cl::sycl::runtime_error("SYCL_DEVICE_TYPE is not recognized. Must "
42  "be GPU, CPU, ACC or HOST.",
44  }
46 }
47 
48 } // namespace detail
49 } // namespace sycl
50 } // __SYCL_INLINE_NAMESPACE(cl)
stl.hpp
cl::sycl::info::device_type
device_type
Definition: info_desc.hpp:180
sycl
Definition: invoke_simd.hpp:68
cl::sycl::detail::get_forced_type
info::device_type get_forced_type()
Definition: force_device.cpp:24
force_device.hpp
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::image_channel_order::r
@ r
PI_INVALID_VALUE
@ PI_INVALID_VALUE
Definition: pi.h:91
cl::sycl::all
detail::enable_if_t< detail::is_sigeninteger< T >::value, int > all(T x) __NOEXC
Definition: builtins.hpp:1297
info_desc.hpp
cl::sycl::detail::match_types
bool match_types(const info::device_type &l, const info::device_type &r)
Definition: force_device.cpp:20
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12