Skip to content

Commit a05c96d

Browse files
authored
Merge pull request #1201 from pbalcer/getenv-ur-hpp
[common] remove the use of std::getenv from common code
2 parents 8c2d93d + f16d31d commit a05c96d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

source/common/ur_util.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <vector>
2323

2424
#ifdef _WIN32
25+
#define NOMINMAX
26+
2527
#include <windows.h>
2628
inline int ur_getpid(void) { return static_cast<int>(GetCurrentProcessId()); }
2729
#else
@@ -59,7 +61,6 @@ inline int ur_getpid(void) { return static_cast<int>(getpid()); }
5961
#endif
6062
///////////////////////////////////////////////////////////////////////////////
6163
#if defined(_WIN32)
62-
#include <Windows.h>
6364
#define MAKE_LIBRARY_NAME(NAME, VERSION) NAME ".dll"
6465
#else
6566
#define HMODULE void *

source/ur/ur.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include <ur_api.h>
2525

26+
#include "ur_util.hpp"
27+
2628
template <class To, class From> To ur_cast(From Value) {
2729
// TODO: see if more sanity checks are possible.
2830
assert(sizeof(From) == sizeof(To));
@@ -61,9 +63,10 @@ const ur_command_t UR_EXT_COMMAND_TYPE_USER =
6163
// overhead from mutex locking. Default value is 0 which means that single
6264
// thread mode is disabled.
6365
static const bool SingleThreadMode = [] {
64-
const char *UrRet = std::getenv("UR_L0_SINGLE_THREAD_MODE");
65-
const char *PiRet = std::getenv("SYCL_PI_LEVEL_ZERO_SINGLE_THREAD_MODE");
66-
const bool RetVal = UrRet ? std::stoi(UrRet) : (PiRet ? std::stoi(PiRet) : 0);
66+
auto UrRet = ur_getenv("UR_L0_SINGLE_THREAD_MODE");
67+
auto PiRet = ur_getenv("SYCL_PI_LEVEL_ZERO_SINGLE_THREAD_MODE");
68+
const bool RetVal =
69+
UrRet ? std::stoi(*UrRet) : (PiRet ? std::stoi(*PiRet) : 0);
6770
return RetVal;
6871
}();
6972

0 commit comments

Comments
 (0)