Skip to content

Commit 7f2f12e

Browse files
callumfaremartygrant
authored andcommitted
[SYCL][UR] Bump UR and implement adapter handles (#10349)
Bump the Unified Runtime commit, and make adapter changes needed for the newly added adapter handles (see #715 for details) This fixes #10066 by providing an implementation of `piPluginGetLastError` in pi2ur.
1 parent 58b72b8 commit 7f2f12e

File tree

3 files changed

+68
-17
lines changed

3 files changed

+68
-17
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//===---------------- runtime.cpp - Native CPU Adapter --------------------===//
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+
#include "common.hpp"
10+
#include "ur_api.h"
11+
12+
struct ur_adapter_handle_t_ {
13+
std::atomic<uint32_t> RefCount = 0;
14+
} Adapter;
15+
16+
UR_APIEXPORT ur_result_t UR_APICALL urInit(ur_device_init_flags_t,
17+
ur_loader_config_handle_t) {
18+
return UR_RESULT_SUCCESS;
19+
}
20+
21+
UR_APIEXPORT ur_result_t UR_APICALL urTearDown(void *) {
22+
return UR_RESULT_SUCCESS;
23+
}
24+
25+
UR_APIEXPORT ur_result_t UR_APICALL urAdapterGet(
26+
uint32_t, ur_adapter_handle_t *phAdapters, uint32_t *pNumAdapters) {
27+
if (phAdapters) {
28+
Adapter.RefCount++;
29+
*phAdapters = &Adapter;
30+
}
31+
if (pNumAdapters) {
32+
*pNumAdapters = 1;
33+
}
34+
return UR_RESULT_SUCCESS;
35+
}
36+
37+
UR_APIEXPORT ur_result_t UR_APICALL urAdapterRelease(ur_adapter_handle_t) {
38+
Adapter.RefCount--;
39+
return UR_RESULT_SUCCESS;
40+
}
41+
42+
UR_APIEXPORT ur_result_t UR_APICALL urAdapterRetain(ur_adapter_handle_t) {
43+
Adapter.RefCount++;
44+
return UR_RESULT_SUCCESS;
45+
}
46+
47+
UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t,
48+
ur_adapter_info_t propName,
49+
size_t propSize,
50+
void *pPropValue,
51+
size_t *pPropSizeRet) {
52+
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
53+
54+
switch (propName) {
55+
case UR_ADAPTER_INFO_BACKEND:
56+
return ReturnValue(UR_ADAPTER_BACKEND_NATIVE_CPU);
57+
case UR_ADAPTER_INFO_REFERENCE_COUNT:
58+
return ReturnValue(Adapter.RefCount.load());
59+
default:
60+
return UR_RESULT_ERROR_INVALID_ENUMERATION;
61+
}
62+
63+
return UR_RESULT_SUCCESS;
64+
}

sycl/plugins/unified_runtime/ur/adapters/native_cpu/runtime.cpp

Lines changed: 0 additions & 17 deletions
This file was deleted.

sycl/plugins/unified_runtime/ur/adapters/native_cpu/ur_interface_loader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable(
200200
}
201201
pDdiTable->pfnInit = urInit;
202202
pDdiTable->pfnTearDown = urTearDown;
203+
pDdiTable->pfnAdapterGet = urAdapterGet;
204+
pDdiTable->pfnAdapterGetInfo = urAdapterGetInfo;
205+
pDdiTable->pfnAdapterRelease = urAdapterRelease;
206+
pDdiTable->pfnAdapterRetain = urAdapterRetain;
203207
return UR_RESULT_SUCCESS;
204208
}
205209

0 commit comments

Comments
 (0)