-
Notifications
You must be signed in to change notification settings - Fork 803
[SYCL][UR] Bump UR and implement adapter handles #10349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aelovikov-intel
merged 17 commits into
intel:sycl
from
callumfare:callum/ur_adapter_handles
Jul 28, 2023
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
bc77c1e
[SYCL][UR] Bump UR and implement adapter handles
callumfare f9ea562
Fix formatting
callumfare 76e469c
Merge branch 'sycl' into callum/ur_adapter_handles
callumfare 269b04a
Add HIP adapter changes for UR adapter handles
callumfare 5bdf4dc
Add adapter refcount info; address review feedback
callumfare 4d59d20
Clang format
callumfare d953f21
Fix unused param
callumfare 651ff6e
Merge branch 'sycl' into callum/ur_adapter_handles
callumfare 14deaf3
Use newer UR commit
callumfare c04b27c
Address review feedback
callumfare 98e6cf6
Fix incorrect piPlatformGet validation in Level Zero adapter
callumfare 5c58cf0
Merge branch 'sycl' into callum/ur_adapter_handles
callumfare da96cdd
Add urAdapter* entry points to native_cpu adapter
callumfare e396dd8
Merge branch 'sycl' into callum/ur_adapter_handles
callumfare 2c4eb77
Fix/tidy native_cpu urAdapter* entry points
callumfare 0c00ee8
Merge branch 'sycl' into callum/ur_adapter_handles
callumfare d31253f
Merge branch 'sycl' into callum/ur_adapter_handles
callumfare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| //===--------- adapter.cpp - CUDA Adapter ----------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===-----------------------------------------------------------------===// | ||
|
|
||
| #include <ur_api.h> | ||
|
|
||
| #include "common.hpp" | ||
|
|
||
| void enableCUDATracing(); | ||
| void disableCUDATracing(); | ||
|
|
||
| struct ur_adapter_handle_t_ { | ||
| std::atomic<uint32_t> RefCount = 0; | ||
| std::mutex Mutex; | ||
| }; | ||
|
|
||
| ur_adapter_handle_t_ adapter{}; | ||
|
|
||
| UR_APIEXPORT ur_result_t UR_APICALL urInit(ur_device_init_flags_t, | ||
| ur_loader_config_handle_t) { | ||
| return UR_RESULT_SUCCESS; | ||
| } | ||
|
|
||
| UR_APIEXPORT ur_result_t UR_APICALL urTearDown(void *) { | ||
| return UR_RESULT_SUCCESS; | ||
| } | ||
|
|
||
| UR_APIEXPORT ur_result_t UR_APICALL | ||
| urAdapterGet(uint32_t NumEntries, ur_adapter_handle_t *phAdapters, | ||
| uint32_t *pNumAdapters) { | ||
| if (NumEntries > 0 && phAdapters) { | ||
| std::lock_guard<std::mutex> Lock{adapter.Mutex}; | ||
| if (adapter.RefCount++ == 0) { | ||
| enableCUDATracing(); | ||
callumfare marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| *phAdapters = &adapter; | ||
| } | ||
|
|
||
| if (pNumAdapters) { | ||
| *pNumAdapters = 1; | ||
| } | ||
|
|
||
| return UR_RESULT_SUCCESS; | ||
| } | ||
|
|
||
| UR_APIEXPORT ur_result_t UR_APICALL urAdapterRetain(ur_adapter_handle_t) { | ||
| adapter.RefCount++; | ||
|
|
||
| return UR_RESULT_SUCCESS; | ||
| } | ||
|
|
||
| UR_APIEXPORT ur_result_t UR_APICALL urAdapterRelease(ur_adapter_handle_t) { | ||
| std::lock_guard<std::mutex> Lock{adapter.Mutex}; | ||
| if (--adapter.RefCount == 0) { | ||
| disableCUDATracing(); | ||
| } | ||
| return UR_RESULT_SUCCESS; | ||
| } | ||
|
|
||
| UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetLastError( | ||
| ur_adapter_handle_t, const char **ppMessage, int32_t *pError) { | ||
| *ppMessage = ErrorMessage; | ||
| *pError = ErrorMessageCode; | ||
| return UR_RESULT_SUCCESS; | ||
| } | ||
|
|
||
| UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t, | ||
| ur_adapter_info_t propName, | ||
| size_t propSize, | ||
| void *pPropValue, | ||
| size_t *pPropSizeRet) { | ||
| UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet); | ||
|
|
||
| switch (propName) { | ||
| case UR_ADAPTER_INFO_BACKEND: | ||
| return ReturnValue(UR_ADAPTER_BACKEND_CUDA); | ||
| case UR_ADAPTER_INFO_REFERENCE_COUNT: | ||
| return ReturnValue(adapter.RefCount.load()); | ||
| default: | ||
| return UR_RESULT_ERROR_INVALID_ENUMERATION; | ||
| } | ||
|
|
||
| return UR_RESULT_SUCCESS; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| //===--------- adapter.cpp - CUDA Adapter ----------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===-----------------------------------------------------------------===// | ||
|
|
||
| struct ur_adapter_handle_t_; | ||
|
|
||
| extern ur_adapter_handle_t_ adapter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.