Skip to content

Commit 287b6fd

Browse files
committed
[UR] Consolidate platform and adapter backend enums into one.
1 parent 1873789 commit 287b6fd

File tree

9 files changed

+38
-64
lines changed

9 files changed

+38
-64
lines changed

sycl/cmake/modules/FetchUnifiedRuntime.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ if(SYCL_UR_USE_FETCH_CONTENT)
116116
CACHE PATH "Path to external '${name}' adapter source dir" FORCE)
117117
endfunction()
118118

119-
set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
119+
set(UNIFIED_RUNTIME_REPO "https://github.com/aarongreig/unified-runtime.git")
120120
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/UnifiedRuntimeTag.cmake)
121121

122122
set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES")
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
# commit 38ee6ce2a0400573c0c7c5da782bc32ff578fcc4
2-
# Merge: c7086f7f 91b6db04
3-
# Author: Callum Fare <[email protected]>
4-
# Date: Mon Nov 25 11:04:37 2024 +0000
5-
# Merge pull request #2303 from nrspruit/zeInitDrivers
6-
# [L0] Implement Support for zeInitDrivers
7-
set(UNIFIED_RUNTIME_TAG 38ee6ce2a0400573c0c7c5da782bc32ff578fcc4)
1+
set(UNIFIED_RUNTIME_TAG aaron/mergeAdapterPlatformBackend)

sycl/source/backend.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ static const AdapterPtr &getAdapter(backend Backend) {
4848
}
4949
}
5050

51-
backend convertUrBackend(ur_platform_backend_t UrBackend) {
51+
backend convertUrBackend(ur_backend_t UrBackend) {
5252
switch (UrBackend) {
53-
case UR_PLATFORM_BACKEND_UNKNOWN:
53+
case UR_BACKEND_UNKNOWN:
5454
return backend::all; // No specific backend
55-
case UR_PLATFORM_BACKEND_LEVEL_ZERO:
55+
case UR_BACKEND_LEVEL_ZERO:
5656
return backend::ext_oneapi_level_zero;
57-
case UR_PLATFORM_BACKEND_OPENCL:
57+
case UR_BACKEND_OPENCL:
5858
return backend::opencl;
59-
case UR_PLATFORM_BACKEND_CUDA:
59+
case UR_BACKEND_CUDA:
6060
return backend::ext_oneapi_cuda;
61-
case UR_PLATFORM_BACKEND_HIP:
61+
case UR_BACKEND_HIP:
6262
return backend::ext_oneapi_hip;
63-
case UR_PLATFORM_BACKEND_NATIVE_CPU:
63+
case UR_BACKEND_NATIVE_CPU:
6464
return backend::ext_oneapi_native_cpu;
6565
default:
6666
throw exception(make_error_code(errc::runtime),

sycl/source/detail/platform_impl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ platform_impl::filterDeviceFilter(std::vector<ur_device_handle_t> &UrDevices,
208208
std::vector<int> original_indices;
209209

210210
// Find out backend of the platform
211-
ur_platform_backend_t UrBackend = UR_PLATFORM_BACKEND_UNKNOWN;
211+
ur_backend_t UrBackend = UR_BACKEND_UNKNOWN;
212212
MAdapter->call<UrApiKind::urPlatformGetInfo>(
213-
MPlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t),
214-
&UrBackend, nullptr);
213+
MPlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_backend_t), &UrBackend,
214+
nullptr);
215215
backend Backend = convertUrBackend(UrBackend);
216216

217217
int InsertIDx = 0;

sycl/source/detail/platform_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class platform_impl {
4242
const std::shared_ptr<Adapter> &AAdapter)
4343
: MPlatform(APlatform), MAdapter(AAdapter) {
4444
// Find out backend of the platform
45-
ur_platform_backend_t UrBackend = UR_PLATFORM_BACKEND_UNKNOWN;
45+
ur_backend_t UrBackend = UR_BACKEND_UNKNOWN;
4646
AAdapter->call_nocheck<UrApiKind::urPlatformGetInfo>(
47-
APlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_platform_backend_t),
48-
&UrBackend, nullptr);
47+
APlatform, UR_PLATFORM_INFO_BACKEND, sizeof(ur_backend_t), &UrBackend,
48+
nullptr);
4949
MBackend = convertUrBackend(UrBackend);
5050
}
5151

sycl/source/detail/ur.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,17 @@ static void initializeAdapters(std::vector<AdapterPtr> &Adapters,
199199
std::vector<ur_adapter_handle_t> adapters(adapterCount);
200200
CHECK_UR_SUCCESS(adapterGet(adapterCount, adapters.data(), nullptr));
201201

202-
auto UrToSyclBackend = [](ur_adapter_backend_t backend) -> sycl::backend {
202+
auto UrToSyclBackend = [](ur_backend_t backend) -> sycl::backend {
203203
switch (backend) {
204-
case UR_ADAPTER_BACKEND_LEVEL_ZERO:
204+
case UR_BACKEND_LEVEL_ZERO:
205205
return backend::ext_oneapi_level_zero;
206-
case UR_ADAPTER_BACKEND_OPENCL:
206+
case UR_BACKEND_OPENCL:
207207
return backend::opencl;
208-
case UR_ADAPTER_BACKEND_CUDA:
208+
case UR_BACKEND_CUDA:
209209
return backend::ext_oneapi_cuda;
210-
case UR_ADAPTER_BACKEND_HIP:
210+
case UR_BACKEND_HIP:
211211
return backend::ext_oneapi_hip;
212-
case UR_ADAPTER_BACKEND_NATIVE_CPU:
212+
case UR_BACKEND_NATIVE_CPU:
213213
return backend::ext_oneapi_native_cpu;
214214
default:
215215
// Throw an exception, this should be unreachable.
@@ -219,7 +219,7 @@ static void initializeAdapters(std::vector<AdapterPtr> &Adapters,
219219
};
220220

221221
for (const auto &UrAdapter : adapters) {
222-
ur_adapter_backend_t adapterBackend = UR_ADAPTER_BACKEND_UNKNOWN;
222+
ur_backend_t adapterBackend = UR_BACKEND_UNKNOWN;
223223
CHECK_UR_SUCCESS(adapterGetInfo(UrAdapter, UR_ADAPTER_INFO_BACKEND,
224224
sizeof(adapterBackend), &adapterBackend,
225225
nullptr));

sycl/source/detail/ur.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ template <backend BE> const AdapterPtr &getAdapter();
3838
} // namespace ur
3939

4040
// Convert from UR backend to SYCL backend enum
41-
backend convertUrBackend(ur_platform_backend_t UrBackend);
41+
backend convertUrBackend(ur_backend_t UrBackend);
4242

4343
} // namespace detail
4444
} // namespace _V1

sycl/unittests/Extensions/FPGADeviceSelectors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ template <const char PlatformName[]> struct RedefTemplatedWrapper {
3535
return UR_RESULT_SUCCESS;
3636
}
3737
case UR_PLATFORM_INFO_BACKEND: {
38-
constexpr auto MockPlatformBackend = UR_PLATFORM_BACKEND_UNKNOWN;
38+
constexpr auto MockPlatformBackend = UR_BACKEND_UNKNOWN;
3939
if (*params.ppPropValue) {
4040
std::memcpy(*params.ppPropValue, &MockPlatformBackend,
4141
sizeof(MockPlatformBackend));

sycl/unittests/helpers/UrMock.hpp

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ inline ur_result_t mock_urDeviceGet(void *pParams) {
8383
inline ur_result_t mock_urDeviceRetain(void *) { return UR_RESULT_SUCCESS; }
8484
inline ur_result_t mock_urDeviceRelease(void *) { return UR_RESULT_SUCCESS; }
8585

86-
template <ur_adapter_backend_t Backend>
86+
template <ur_backend_t Backend>
8787
inline ur_result_t mock_urAdapterGetInfo(void *pParams) {
8888
auto params = reinterpret_cast<ur_adapter_get_info_params_t *>(pParams);
8989

@@ -100,7 +100,7 @@ inline ur_result_t mock_urAdapterGetInfo(void *pParams) {
100100
return UR_RESULT_SUCCESS;
101101
}
102102

103-
template <ur_platform_backend_t Backend>
103+
template <ur_backend_t Backend>
104104
inline ur_result_t mock_urPlatformGetInfo(void *pParams) {
105105
auto params = reinterpret_cast<ur_platform_get_info_params_t *>(pParams);
106106
constexpr char MockPlatformName[] = "Mock platform";
@@ -518,16 +518,14 @@ template <sycl::backend Backend = backend::opencl> class UrMock {
518518
#define ADD_DEFAULT_OVERRIDE(func_name, func_override) \
519519
mock::getCallbacks().set_replace_callback(#func_name, \
520520
&MockAdapter::func_override);
521-
ADD_DEFAULT_OVERRIDE(
522-
urAdapterGetInfo,
523-
mock_urAdapterGetInfo<convertToUrAdapterBackend(Backend)>)
521+
ADD_DEFAULT_OVERRIDE(urAdapterGetInfo,
522+
mock_urAdapterGetInfo<convertToUrBackend(Backend)>)
524523
ADD_DEFAULT_OVERRIDE(urPlatformGet, mock_urPlatformGet)
525524
ADD_DEFAULT_OVERRIDE(urDeviceGet, mock_urDeviceGet)
526525
ADD_DEFAULT_OVERRIDE(urDeviceRetain, mock_urDeviceRetain)
527526
ADD_DEFAULT_OVERRIDE(urDeviceRelease, mock_urDeviceRelease)
528-
ADD_DEFAULT_OVERRIDE(
529-
urPlatformGetInfo,
530-
mock_urPlatformGetInfo<convertToUrPlatformBackend(Backend)>)
527+
ADD_DEFAULT_OVERRIDE(urPlatformGetInfo,
528+
mock_urPlatformGetInfo<convertToUrBackend(Backend)>)
531529
ADD_DEFAULT_OVERRIDE(urDeviceGetInfo, mock_urDeviceGetInfo)
532530
ADD_DEFAULT_OVERRIDE(urProgramGetInfo, mock_urProgramGetInfo)
533531
ADD_DEFAULT_OVERRIDE(urContextGetInfo, mock_urContextGetInfo)
@@ -580,39 +578,21 @@ template <sycl::backend Backend = backend::opencl> class UrMock {
580578
private:
581579
// These two helpers are needed to enable arbitrary backend selection
582580
// at compile time.
583-
static constexpr ur_platform_backend_t
584-
convertToUrPlatformBackend(const sycl::backend SyclBackend) {
581+
static constexpr ur_backend_t
582+
convertToUrBackend(const sycl::backend SyclBackend) {
585583
switch (SyclBackend) {
586584
case sycl::backend::opencl:
587-
return UR_PLATFORM_BACKEND_OPENCL;
585+
return UR_BACKEND_OPENCL;
588586
case sycl::backend::ext_oneapi_level_zero:
589-
return UR_PLATFORM_BACKEND_LEVEL_ZERO;
587+
return UR_BACKEND_LEVEL_ZERO;
590588
case sycl::backend::ext_oneapi_cuda:
591-
return UR_PLATFORM_BACKEND_CUDA;
589+
return UR_BACKEND_CUDA;
592590
case sycl::backend::ext_oneapi_hip:
593-
return UR_PLATFORM_BACKEND_HIP;
591+
return UR_BACKEND_HIP;
594592
case sycl::backend::ext_oneapi_native_cpu:
595-
return UR_PLATFORM_BACKEND_NATIVE_CPU;
593+
return UR_BACKEND_NATIVE_CPU;
596594
default:
597-
return UR_PLATFORM_BACKEND_UNKNOWN;
598-
}
599-
}
600-
601-
static constexpr ur_adapter_backend_t
602-
convertToUrAdapterBackend(sycl::backend SyclBackend) {
603-
switch (SyclBackend) {
604-
case sycl::backend::opencl:
605-
return UR_ADAPTER_BACKEND_OPENCL;
606-
case sycl::backend::ext_oneapi_level_zero:
607-
return UR_ADAPTER_BACKEND_LEVEL_ZERO;
608-
case sycl::backend::ext_oneapi_cuda:
609-
return UR_ADAPTER_BACKEND_CUDA;
610-
case sycl::backend::ext_oneapi_hip:
611-
return UR_ADAPTER_BACKEND_HIP;
612-
case sycl::backend::ext_oneapi_native_cpu:
613-
return UR_ADAPTER_BACKEND_NATIVE_CPU;
614-
default:
615-
return UR_ADAPTER_BACKEND_UNKNOWN;
595+
return UR_BACKEND_UNKNOWN;
616596
}
617597
}
618598
};

0 commit comments

Comments
 (0)