-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[OFFLOAD] Add plugin with support for Intel oneAPI Level Zero #158900
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
base: main
Are you sure you want to change the base?
Changes from all commits
0c42764
e8c471e
f8956cd
d3fc4d7
4b38386
6c1c820
fd91c47
84665dc
a2217db
08880a6
9a3088c
24d0645
0eb5712
f491f3d
9bbdae3
fe633f4
e36a8fc
53bce7e
69df388
91fa069
561e4ca
ad07ee8
5b90ccb
6b8280d
f983135
b6c393a
b226c70
af1945f
3dba3c3
ac62231
17c8e31
e550bf1
b859179
f1d1aad
c141f9d
dd774b6
7fa9dda
96411ce
a4cd814
6c5278f
44b2f48
b4e238f
166028d
6629159
c00c288
93d3948
4a2140e
94335ac
bd43212
2be5a5a
7f9c0c8
2d7cc66
987f44c
91e51ed
12ab478
3287b1a
69abec0
b7e95ab
91f1033
1221006
45d38a2
6ec68e7
ef8d794
19e888e
a591b0e
fc61165
40f2626
f04fef7
e95cab5
e0c46a6
0d3d6dc
2de9273
f4e89a9
5ebf0a4
8bff29d
d29eac0
4a6b196
caedd4d
01f9c44
e80dcf9
5451f22
120e3d4
40ad342
8bb25ad
08d5f32
ba08709
69c0db3
ba0ac45
32b9b59
b44f992
a14ee62
e1dfd79
21effca
581b952
045c94c
fd15e04
827b28c
26a1231
e2b8523
bd364c5
0f59337
579264a
26fbcc0
32819df
2d4f364
9c602be
bc0ccaf
fd38f8d
9c5942e
8160235
1cadfb8
6f850c2
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,66 @@ | ||
| # Create the library and add the default arguments. | ||
| add_target_library(omptarget.rtl.level_zero LEVEL_ZERO) | ||
|
|
||
| set(LEVEL_ZERO_SRC_FILES | ||
| src/L0Context.cpp | ||
| src/L0Device.cpp | ||
| src/L0Kernel.cpp | ||
| src/L0Memory.cpp | ||
| src/L0Program.cpp | ||
| src/L0Plugin.cpp | ||
| src/L0Program.cpp | ||
| src/L0Options.cpp | ||
| ) | ||
|
|
||
| target_sources(omptarget.rtl.level_zero PRIVATE | ||
| ${LEVEL_ZERO_SRC_FILES} | ||
| ) | ||
|
|
||
| target_include_directories(omptarget.rtl.level_zero PRIVATE | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
| ) | ||
|
|
||
| target_include_directories(omptarget.rtl.level_zero PRIVATE | ||
| ${LIBOMPTARGET_INCLUDE_DIR} | ||
| ${LIBOMPTARGET_DEP_LEVEL_ZERO_INCLUDE_DIR} | ||
| ${LIBOMPTARGET_LLVM_INCLUDE_DIRS} | ||
| ${LIBOMPTARGET_OMP_HEADER_DIR} | ||
| ) | ||
|
|
||
| cmake_path(GET LIBOMPTARGET_DEP_LEVEL_ZERO_LIBRARY FILENAME LEVEL_ZERO_LIBRARY_NAME) | ||
| if (EXISTS ${LIBOMPTARGET_DEP_LEVEL_ZERO_LIBRARY} AND NOT "level_zero" IN_LIST LIBOMPTARGET_DLOPEN_PLUGINS) | ||
| message(STATUS "Building Level Zero NG plugin linked against level_zero library") | ||
| if(UNIX) | ||
| target_link_libraries(omptarget.rtl.level_zero PRIVATE | ||
| ${LIBOMPTARGET_DEP_LEVEL_ZERO_LIBRARY}) | ||
| elseif(WIN32) | ||
| # Full path to the Level Zero library is recognized as a linker option, so we | ||
| # separate directory and file name | ||
| cmake_path(GET LIBOMPTARGET_DEP_LEVEL_ZERO_LIBRARY PARENT_PATH LEVEL_ZERO_LIBRARY_PATH) | ||
| target_link_libraries(omptarget.rtl.level_zero PRIVATE ${LEVEL_ZERO_LIBRARY_NAME} | ||
| ${LIBOMP_LIB_FILE}) | ||
| target_link_directories(omptarget.rtl.level_zero PRIVATE ${LEVEL_ZERO_LIBRARY_PATH}) | ||
| else() | ||
| message(FATAL_ERROR "Missing platform support") | ||
| endif() | ||
| else() | ||
| message(STATUS "Building Level Zero NG plugin for dlopened level_zero") | ||
| if(WIN32) | ||
| cmake_path(REPLACE_EXTENSION LEVEL_ZERO_LIBRARY_NAME dll) | ||
| endif() | ||
|
Comment on lines
+48
to
+50
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. Does the L0 library name change? Why can't we just do
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. The extension is different. Yes, we could do it in the source, but why would we want to do the required string manipulation at runtime when can be done statically here? |
||
| target_compile_definitions(omptarget.rtl.level_zero PRIVATE | ||
| LEVEL_ZERO_LIBRARY="${LEVEL_ZERO_LIBRARY_NAME}") | ||
| target_sources(omptarget.rtl.level_zero PRIVATE src/L0DynWrapper.cpp) | ||
| endif() | ||
|
|
||
| option(LIBOMPTARGET_FORCE_LEVELZERO_TESTS "Build Level Zero libomptarget tests" OFF) | ||
| if (LIBOMPTARGET_FOUND_INTELGPU_GPU OR LIBOMPTARGET_FORCE_LEVELZERO_TESTS) | ||
| # Report to the parent scope that we are building a plugin for intelgpu | ||
| set(LIBOMPTARGET_SYSTEM_TARGETS | ||
| "${LIBOMPTARGET_SYSTEM_TARGETS} spirv64-intel" PARENT_SCOPE) | ||
| list(APPEND LIBOMPTARGET_TESTED_PLUGINS "omptarget.rtl.level_zero") | ||
| set(LIBOMPTARGET_TESTED_PLUGINS "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE) | ||
| else() | ||
| message(STATUS "Not generating Level Zero tests, no supported devices detected." | ||
| " Use 'LIBOMPTARGET_FORCE_INTELGPU_TESTS' to override.") | ||
| endif() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| //===--- Level Zero Target RTL Implementation -----------------------------===// | ||
| // | ||
| // 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 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Async Queue wrapper for Level Zero | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_ASYNCQUEUE_H | ||
| #define OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_ASYNCQUEUE_H | ||
|
|
||
| #include <tuple> | ||
|
|
||
| #include "L0Memory.h" | ||
|
|
||
| namespace llvm { | ||
| namespace omp { | ||
| namespace target { | ||
| namespace plugin { | ||
|
|
||
| /// Abstract queue that supports asynchronous command submission | ||
| struct AsyncQueueTy { | ||
| /// List of events attached to submitted commands | ||
| llvm::SmallVector<ze_event_handle_t> WaitEvents; | ||
| /// Pending staging buffer to host copies | ||
| llvm::SmallVector<std::tuple<void *, void *, size_t>> H2MList; | ||
| /// Pending USM memory copy commands that must wait for kernel completion | ||
| llvm::SmallVector<std::tuple<const void *, void *, size_t>> USM2MList; | ||
| /// Kernel event not signaled | ||
| ze_event_handle_t KernelEvent = nullptr; | ||
| /// Is this queue being used currently | ||
| bool InUse = false; | ||
| /// Clear data | ||
| void reset() { | ||
| WaitEvents.clear(); | ||
| H2MList.clear(); | ||
| USM2MList.clear(); | ||
| KernelEvent = nullptr; | ||
| } | ||
| }; | ||
|
|
||
| typedef ObjPool<AsyncQueueTy> AsyncQueuePoolTy; | ||
|
|
||
| } // namespace plugin | ||
| } // namespace target | ||
| } // namespace omp | ||
| } // namespace llvm | ||
|
|
||
| #endif // OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_ASYNCQUEUE_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to do this check when we create the list rather than removing it later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the other plugins are treated in the same way right now (e.g., 3 lines above). They are in the "candidate" list and if some condition is not met they're removed.
I don't disagree with your statement about do it earlier but we should be consistent, so maybe something to do subsequently?