Skip to content

Commit 04ff9bf

Browse files
author
Omar Ahmed
authored
Merge pull request #2076 from omarahmed1111/v0.10.4
Candidate for the v0.10.4 release tag
2 parents e53e464 + b21ba58 commit 04ff9bf

File tree

5 files changed

+48
-7
lines changed

5 files changed

+48
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

66
cmake_minimum_required(VERSION 3.20.0 FATAL_ERROR)
7-
project(unified-runtime VERSION 0.10.3)
7+
project(unified-runtime VERSION 0.10.4)
88

99
# Check if unified runtime is built as a standalone project.
1010
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR UR_STANDALONE_BUILD)

source/adapters/opencl/usm.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ urUSMHostAlloc(ur_context_handle_t hContext, const ur_usm_desc_t *pUSMDesc,
8787
void *Ptr = nullptr;
8888
uint32_t Alignment = pUSMDesc ? pUSMDesc->align : 0;
8989

90+
if (pUSMDesc && pUSMDesc->align != 0 &&
91+
((pUSMDesc->align & (pUSMDesc->align - 1)) != 0)) {
92+
return UR_RESULT_ERROR_INVALID_VALUE;
93+
}
94+
9095
std::vector<cl_mem_properties_intel> AllocProperties;
9196
if (pUSMDesc && pUSMDesc->pNext) {
9297
UR_RETURN_ON_FAILURE(usmDescToCLMemProperties(
@@ -130,6 +135,11 @@ urUSMDeviceAlloc(ur_context_handle_t hContext, ur_device_handle_t hDevice,
130135
void *Ptr = nullptr;
131136
uint32_t Alignment = pUSMDesc ? pUSMDesc->align : 0;
132137

138+
if (pUSMDesc && pUSMDesc->align != 0 &&
139+
((pUSMDesc->align & (pUSMDesc->align - 1)) != 0)) {
140+
return UR_RESULT_ERROR_INVALID_VALUE;
141+
}
142+
133143
std::vector<cl_mem_properties_intel> AllocProperties;
134144
if (pUSMDesc && pUSMDesc->pNext) {
135145
UR_RETURN_ON_FAILURE(usmDescToCLMemProperties(
@@ -173,6 +183,11 @@ urUSMSharedAlloc(ur_context_handle_t hContext, ur_device_handle_t hDevice,
173183
void *Ptr = nullptr;
174184
uint32_t Alignment = pUSMDesc ? pUSMDesc->align : 0;
175185

186+
if (pUSMDesc && pUSMDesc->align != 0 &&
187+
((pUSMDesc->align & (pUSMDesc->align - 1)) != 0)) {
188+
return UR_RESULT_ERROR_INVALID_VALUE;
189+
}
190+
176191
std::vector<cl_mem_properties_intel> AllocProperties;
177192
if (pUSMDesc && pUSMDesc->pNext) {
178193
UR_RETURN_ON_FAILURE(usmDescToCLMemProperties(

source/common/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ if (NOT DEFINED UMF_REPO)
2323
endif()
2424

2525
if (NOT DEFINED UMF_TAG)
26-
# v0.9.x 19.08.2024: Merge pull request #688 ...
27-
set(UMF_TAG 59c4150b7120a7af5b3c8eb2d9b8bbb5d2e96aa3)
26+
# v0.9.x 12.09.2024: 0.9.0 release
27+
set(UMF_TAG v0.9.0)
2828
endif()
2929

3030
message(STATUS "Will fetch Unified Memory Framework from ${UMF_REPO}")

source/loader/layers/tracing/ur_tracing_layer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ struct XptiContextManager {
3434
~XptiContextManager() { xptiFrameworkFinalize(); }
3535
};
3636

37-
static std::shared_ptr<XptiContextManager> xptiContextManagerGlobal = [] {
38-
return std::make_shared<XptiContextManager>();
39-
}();
37+
static std::shared_ptr<XptiContextManager> xptiContextManagerGet() {
38+
static auto contextManager = std::make_shared<XptiContextManager>();
39+
return contextManager;
40+
};
4041
static thread_local xpti_td *activeEvent;
4142

4243
///////////////////////////////////////////////////////////////////////////////
4344
context_t::context_t() : logger(logger::create_logger("tracing", true, true)) {
44-
this->xptiContextManager = xptiContextManagerGlobal;
45+
this->xptiContextManager = xptiContextManagerGet();
4546

4647
call_stream_id = xptiRegisterStream(CALL_STREAM_NAME);
4748
std::ostringstream streamv;

source/loader/ur_loader.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@ context_t *getContext() { return context_t::get_direct(); }
1515

1616
///////////////////////////////////////////////////////////////////////////////
1717
ur_result_t context_t::init() {
18+
#ifdef _WIN32
19+
// Suppress system errors.
20+
// Tells the system to not display the critical-error-handler message box.
21+
// Instead, the system sends the error to the calling process.
22+
// This is crucial for graceful handling of adapters that couldn't be
23+
// loaded, e.g. due to missing native run-times.
24+
// TODO: add reporting in case of an error.
25+
// NOTE: we restore the old mode to not affect user app behavior.
26+
// See https://github.com/intel/llvm/blob/sycl/sycl/ur_win_proxy_loader/ur_win_proxy_loader.cpp (preloadLibraries())
27+
UINT SavedMode = SetErrorMode(SEM_FAILCRITICALERRORS);
28+
#endif
29+
30+
#ifdef UR_STATIC_ADAPTER_LEVEL_ZERO
31+
// If the adapters were force loaded, it means the user wants to use
32+
// a specific adapter library. Don't load any static adapters.
33+
if (!adapter_registry.adaptersForceLoaded()) {
34+
auto &level_zero = platforms.emplace_back(nullptr);
35+
ur::level_zero::urAdapterGetDdiTables(&level_zero.dditable.ur);
36+
}
37+
#endif
38+
1839
for (const auto &adapterPaths : adapter_registry) {
1940
for (const auto &path : adapterPaths) {
2041
auto handle = LibLoader::loadAdapterLibrary(path.string().c_str());
@@ -24,6 +45,10 @@ ur_result_t context_t::init() {
2445
}
2546
}
2647
}
48+
#ifdef _WIN32
49+
// Restore system error handling.
50+
(void)SetErrorMode(SavedMode);
51+
#endif
2752

2853
forceIntercept = getenv_tobool("UR_ENABLE_LOADER_INTERCEPT");
2954

0 commit comments

Comments
 (0)