DPC++ Runtime
Runtime libraries for oneAPI DPC++
os_util.hpp
Go to the documentation of this file.
1
//===-- os_util.hpp - OS 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
// Abstracts the operating system services.
10
11
#pragma once
12
13
#include <
sycl/detail/export.hpp
>
// for __SYCL_EXPORT
14
15
#include <cstdlib>
// for size_t
16
#include <string>
// for string
17
#include <sys/stat.h>
// for stat
18
19
#ifdef _WIN32
20
#define __SYCL_RT_OS_WINDOWS
21
// Windows platform
22
#ifdef _WIN64
23
// 64-bit Windows platform
24
#else
25
// 32-bit Windows platform
26
#endif // _WIN64
27
#elif __linux__
28
// Linux platform
29
#define __SYCL_RT_OS_LINUX
30
#define __SYCL_RT_OS_POSIX_SUPPORT
31
#elif defined(__APPLE__) && defined(__MACH__)
32
// Apple OSX
33
#define __SYCL_RT_OS_DARWIN
34
#define __SYCL_RT_OS_POSIX_SUPPORT
35
#else
36
#error "Unsupported compiler or OS"
37
#endif // _WIN32
38
39
namespace
sycl
{
40
inline
namespace
_V1 {
41
namespace
detail
{
42
44
class
__SYCL_EXPORT
OSUtil
{
45
public
:
47
static
std::string getCurrentDSODir();
48
50
static
std::string
getDirName
(
const
char
*Path);
51
52
#ifdef __SYCL_RT_OS_WINDOWS
53
static
constexpr
const
char
*DirSep =
"\\"
;
54
#else
55
static
constexpr
const
char
*DirSep =
"/"
;
56
#endif
57
59
static
size_t
getOSMemSize();
60
63
static
void
*
alignedAlloc
(
size_t
Alignment
,
size_t
NumBytes);
64
66
static
void
alignedFree(
void
*Ptr);
67
69
static
int
makeDir(
const
char
*Dir);
70
72
static
bool
isPathPresent
(
const
std::string &Path) {
73
#ifdef __SYCL_RT_OS_WINDOWS
74
struct
_stat Stat;
75
return
!_stat(Path.c_str(), &Stat);
76
#else
77
struct
stat Stat;
78
return
!stat(Path.c_str(), &Stat);
79
#endif
80
}
81
};
82
83
}
// namespace detail
84
}
// namespace _V1
85
}
// namespace sycl
detail
---— Error handling, matching OpenCL plugin semantics.
Definition:
common.hpp:44
sycl
Definition:
access.hpp:18
export.hpp
sycl::_V1::detail::OSUtil::isPathPresent
static bool isPathPresent(const std::string &Path)
Checks if specified path is present.
Definition:
os_util.hpp:72
sycl::_V1::detail::OSUtil
Groups the OS-dependent services.
Definition:
os_util.hpp:44
sycl::_V1::ext::oneapi::experimental::detail::Alignment
@ Alignment
Definition:
property.hpp:193
sycl::_V1::detail::usm::alignedAlloc
void * alignedAlloc(size_t Alignment, size_t Bytes, const context &Ctxt, const device &Dev, sycl::usm::alloc Kind, const code_location &CL)
sycl::_V1::detail::getDirName
std::string getDirName(const char *Path)
include
sycl
detail
os_util.hpp
Generated by
1.8.17