-
Notifications
You must be signed in to change notification settings - Fork 124
Move CUDA sources from intel/llvm to UR #896
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
Changes from all commits
d0ba73b
b504c5b
6b4298a
efac061
47b134a
b992d69
c71ee7c
7381044
d74234e
2fb0f02
0123900
bbb6788
8558159
c4a620e
470aaf1
80e7566
5967f17
4701e1e
2859bb5
26eba89
a0ac77c
e1ae1e2
6febad3
771cd2c
66f109a
4e362cb
4c12a32
7e0285e
be8a884
5817449
a2797ff
d18592c
00a84b3
d835cd1
2635ff3
5309374
a75b944
ea3c77e
da60f90
901787e
2bf7ed0
1cb9209
54cead7
2981a7d
99735cc
40e0901
3315f42
6cc3c4c
9c3acb1
8985991
e04e2f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| Language: Cpp | ||
| BasedOnStyle: LLVM | ||
| ... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,43 +3,43 @@ | |
| # See LICENSE.TXT | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| set(CUDA_DIR "${SYCL_ADAPTER_DIR}/sycl/plugins/unified_runtime/ur/adapters/cuda" CACHE PATH "CUDA adapter directory") | ||
| set(CUDA_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "CUDA adapter directory") | ||
|
|
||
| set(TARGET_NAME ur_adapter_cuda) | ||
|
|
||
| add_ur_adapter(${TARGET_NAME} | ||
| SHARED | ||
| ${CUDA_DIR}/ur_interface_loader.cpp | ||
| ${CUDA_DIR}/adapter.hpp | ||
| ${CUDA_DIR}/adapter.cpp | ||
| ${CUDA_DIR}/command_buffer.hpp | ||
| ${CUDA_DIR}/command_buffer.cpp | ||
| ${CUDA_DIR}/common.hpp | ||
| ${CUDA_DIR}/common.cpp | ||
| ${CUDA_DIR}/context.hpp | ||
| ${CUDA_DIR}/context.cpp | ||
| ${CUDA_DIR}/device.hpp | ||
| ${CUDA_DIR}/device.cpp | ||
| ${CUDA_DIR}/enqueue.cpp | ||
| ${CUDA_DIR}/event.hpp | ||
| ${CUDA_DIR}/event.cpp | ||
| ${CUDA_DIR}/kernel.hpp | ||
| ${CUDA_DIR}/kernel.cpp | ||
| ${CUDA_DIR}/memory.hpp | ||
| ${CUDA_DIR}/memory.cpp | ||
| ${CUDA_DIR}/platform.hpp | ||
| ${CUDA_DIR}/platform.cpp | ||
| ${CUDA_DIR}/program.hpp | ||
| ${CUDA_DIR}/program.cpp | ||
| ${CUDA_DIR}/queue.hpp | ||
| ${CUDA_DIR}/queue.cpp | ||
| ${CUDA_DIR}/sampler.hpp | ||
| ${CUDA_DIR}/sampler.cpp | ||
| ${CUDA_DIR}/tracing.cpp | ||
| ${CUDA_DIR}/usm.cpp | ||
| ${CUDA_DIR}/usm_p2p.cpp | ||
| ${CUDA_DIR}/../../ur.cpp | ||
| ${CUDA_DIR}/../../ur.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/ur_interface_loader.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/adapter.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/adapter.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/command_buffer.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/common.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/common.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/context.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/context.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/device.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/device.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/enqueue.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/event.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/event.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/kernel.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/memory.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/memory.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/platform.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/platform.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/program.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/program.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/queue.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/queue.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/sampler.hpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/sampler.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/tracing.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/usm.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/usm_p2p.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp | ||
| ) | ||
|
|
||
| set_target_properties(${TARGET_NAME} PROPERTIES | ||
|
|
@@ -67,6 +67,12 @@ else() | |
| ) | ||
| endif() | ||
|
|
||
| if(UMF_ENABLE_POOL_TRACKING) | ||
| target_compile_definitions("ur_adapter_cuda" PRIVATE UMF_ENABLE_POOL_TRACKING) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add this option in the readme?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as far as I know the UMF team are reworking stuff so that this option isn't needed, hopefully its days are numbered
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already an option in UR. It was just not being used in the adapter |
||
| else() | ||
| message(WARNING "CUDA adapter USM pools are disabled, set UMF_ENABLE_POOL_TRACKING to enable them") | ||
| endif() | ||
|
|
||
| target_link_libraries(${TARGET_NAME} PRIVATE | ||
| ${PROJECT_NAME}::headers | ||
| ${PROJECT_NAME}::common | ||
|
|
@@ -76,5 +82,5 @@ target_link_libraries(${TARGET_NAME} PRIVATE | |
| ) | ||
|
|
||
| target_include_directories(${TARGET_NAME} PRIVATE | ||
| ${CUDA_DIR}/../../../ | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/../../" | ||
| ) | ||
| 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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These licenses will need updating too, but a follow up PR is fine.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add this in a follow up PR |
||
| // 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(); | ||
| } | ||
|
|
||
| *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) { | ||
| std::ignore = pError; | ||
| *ppMessage = ErrorMessage; | ||
| return ErrorMessageCode; | ||
| } | ||
|
|
||
| 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; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| //===--------- adapter.hpp - 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; |
Uh oh!
There was an error while loading. Please reload this page.