DPC++ Runtime
Runtime libraries for oneAPI DPC++
platform_util.hpp
Go to the documentation of this file.
1 //===--------- platform_util.hpp - platform utilities ----------*- C++ -*--===//
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 
9 #pragma once
10 
11 #include <cstdint>
12 
13 #include <stddef.h> // for ::size_t
14 
15 #include <sycl/detail/defines.hpp>
16 
17 #ifdef _MSC_VER
18 // This feature is not supported in MSVC.
19 #define __builtin_expect(a, b) (a)
20 #endif
21 
22 namespace sycl {
23 inline namespace _V1 {
24 namespace detail {
25 
26 struct PlatformUtil {
27  enum class TypeIndex : unsigned int {
28  Char = 0,
29  Short = 1,
30  Int = 2,
31  Long = 3,
32  Float = 4,
33  Double = 5,
34  Half = 6
35  };
36 
38  static uint32_t getNativeVectorWidth(TypeIndex Index);
39 
40  static uint32_t getMaxClockFrequency();
41 
42  static uint32_t getMemCacheLineSize();
43 
44  static uint64_t getMemCacheSize();
45 
46  static void prefetch(const char *Ptr, size_t NumBytes);
47 };
48 
49 } // namespace detail
50 } // namespace _V1
51 } // namespace sycl
detail
---— Error handling, matching OpenCL plugin semantics.
Definition: common.hpp:44
sycl
Definition: access.hpp:18
sycl::_V1::detail::PlatformUtil::TypeIndex
TypeIndex
Definition: platform_util.hpp:27
sycl::_V1::detail::PlatformUtil::prefetch
static void prefetch(const char *Ptr, size_t NumBytes)
Definition: platform_util.cpp:134
sycl::_V1::detail::PlatformUtil::TypeIndex::Half
@ Half
sycl::_V1::detail::PlatformUtil
Definition: platform_util.hpp:26
sycl::_V1::detail::PlatformUtil::TypeIndex::Int
@ Int
defines.hpp
sycl::_V1::detail::PlatformUtil::TypeIndex::Char
@ Char
sycl::_V1::detail::PlatformUtil::getMemCacheLineSize
static uint32_t getMemCacheLineSize()
Definition: platform_util.cpp:49
sycl::_V1::detail::PlatformUtil::TypeIndex::Long
@ Long
sycl::_V1::detail::PlatformUtil::getMaxClockFrequency
static uint32_t getMaxClockFrequency()
Definition: platform_util.cpp:42
sycl::_V1::detail::PlatformUtil::TypeIndex::Float
@ Float
sycl::_V1::detail::PlatformUtil::TypeIndex::Double
@ Double
sycl::_V1::detail::PlatformUtil::TypeIndex::Short
@ Short
sycl::_V1::detail::PlatformUtil::getMemCacheSize
static uint64_t getMemCacheSize()
Definition: platform_util.cpp:63
sycl::_V1::detail::PlatformUtil::getNativeVectorWidth
static uint32_t getNativeVectorWidth(TypeIndex Index)
Returns the maximum vector width counted in elements of the given type.
Definition: platform_util.cpp:77