-
Notifications
You must be signed in to change notification settings - Fork 794
[SYCL] Support dynamic linking on new offloading model #16055
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
martygrant
merged 9 commits into
intel:sycl
from
maarquitos14:maronas/device-image-deps-new-offload-driver
Nov 15, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7ee3043
Support dynamic linking on new offloading model
maarquitos14 171b169
Fix clang-format issue
maarquitos14 caaebb7
Merge remote-tracking branch 'origin/sycl' into maronas/device-image-…
maarquitos14 1a76fd8
Rename new test directory.
maarquitos14 d0d8337
Fix test failure.
maarquitos14 76d4f3d
Address code review feedback.
maarquitos14 9082959
Fix build failure.
maarquitos14 64308cb
Remove unnecessary line.
maarquitos14 03ca7ee
Update comments.
maarquitos14 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
13 changes: 13 additions & 0 deletions
13
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/Inputs/a.cpp
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,13 @@ | ||
| #define A_EXPORT | ||
| #include "a.hpp" | ||
| #include "b.hpp" | ||
| #include <iostream> | ||
|
|
||
| A_DECLSPEC SYCL_EXTERNAL int levelA(int val) { | ||
| #ifndef __SYCL_DEVICE_ONLY__ | ||
| std::cerr << "Host symbol used" << std::endl; | ||
| val ^= 0x1234; | ||
| #endif | ||
| val = levelB(val); | ||
| return val |= (0xA << 0); | ||
| } |
13 changes: 13 additions & 0 deletions
13
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/Inputs/a.hpp
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,13 @@ | ||
| #include <sycl/detail/core.hpp> | ||
|
|
||
| #if defined(MAKE_DLL) | ||
| #ifdef A_EXPORT | ||
| #define A_DECLSPEC __declspec(dllexport) | ||
| #else | ||
| #define A_DECLSPEC __declspec(dllimport) | ||
| #endif | ||
| #else | ||
| #define A_DECLSPEC | ||
| #endif | ||
|
|
||
| A_DECLSPEC SYCL_EXTERNAL int levelA(int val); |
13 changes: 13 additions & 0 deletions
13
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/Inputs/b.cpp
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,13 @@ | ||
| #define B_EXPORT | ||
| #include "b.hpp" | ||
| #include "c.hpp" | ||
| #include <iostream> | ||
|
|
||
| B_DECLSPEC SYCL_EXTERNAL int levelB(int val) { | ||
| #ifndef __SYCL_DEVICE_ONLY__ | ||
| std::cerr << "Host symbol used" << std::endl; | ||
| val ^= 0x2345; | ||
| #endif | ||
| val = levelC(val); | ||
| return val |= (0xB << 4); | ||
| } |
13 changes: 13 additions & 0 deletions
13
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/Inputs/b.hpp
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,13 @@ | ||
| #include <sycl/detail/core.hpp> | ||
|
|
||
| #if defined(MAKE_DLL) | ||
| #ifdef B_EXPORT | ||
| #define B_DECLSPEC __declspec(dllexport) | ||
| #else | ||
| #define B_DECLSPEC __declspec(dllimport) | ||
| #endif | ||
| #else | ||
| #define B_DECLSPEC | ||
| #endif | ||
|
|
||
| B_DECLSPEC SYCL_EXTERNAL int levelB(int val); |
13 changes: 13 additions & 0 deletions
13
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/Inputs/c.cpp
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,13 @@ | ||
| #define C_EXPORT | ||
| #include "c.hpp" | ||
| #include "d.hpp" | ||
| #include <iostream> | ||
|
|
||
| C_DECLSPEC SYCL_EXTERNAL int levelC(int val) { | ||
| #ifndef __SYCL_DEVICE_ONLY__ | ||
| std::cerr << "Host symbol used" << std::endl; | ||
| val ^= 0x3456; | ||
| #endif | ||
| val = levelD(val); | ||
| return val |= (0xC << 8); | ||
| } |
13 changes: 13 additions & 0 deletions
13
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/Inputs/c.hpp
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,13 @@ | ||
| #include <sycl/detail/core.hpp> | ||
|
|
||
| #if defined(MAKE_DLL) | ||
| #ifdef C_EXPORT | ||
| #define C_DECLSPEC __declspec(dllexport) | ||
| #else | ||
| #define C_DECLSPEC __declspec(dllimport) | ||
| #endif | ||
| #else | ||
| #define C_DECLSPEC | ||
| #endif | ||
|
|
||
| C_DECLSPEC SYCL_EXTERNAL int levelC(int val); |
11 changes: 11 additions & 0 deletions
11
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/Inputs/d.cpp
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 @@ | ||
| #define D_EXPORT | ||
| #include "d.hpp" | ||
| #include <iostream> | ||
|
|
||
| D_DECLSPEC SYCL_EXTERNAL int levelD(int val) { | ||
| #ifndef __SYCL_DEVICE_ONLY__ | ||
| std::cerr << "Host symbol used" << std::endl; | ||
| val ^= 0x4567; | ||
| #endif | ||
| return val |= (0xD << 12); | ||
| } |
13 changes: 13 additions & 0 deletions
13
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/Inputs/d.hpp
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,13 @@ | ||
| #include <sycl/detail/core.hpp> | ||
|
|
||
| #if defined(MAKE_DLL) | ||
| #ifdef D_EXPORT | ||
| #define D_DECLSPEC __declspec(dllexport) | ||
| #else | ||
| #define D_DECLSPEC __declspec(dllimport) | ||
| #endif | ||
| #else | ||
| #define D_DECLSPEC | ||
| #endif | ||
|
|
||
| D_DECLSPEC SYCL_EXTERNAL int levelD(int val); |
26 changes: 26 additions & 0 deletions
26
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/Inputs/wrapper.cpp
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,26 @@ | ||
| #include "a.hpp" | ||
| #include <iostream> | ||
| #include <sycl/detail/core.hpp> | ||
| #define EXPORT | ||
| #include "wrapper.hpp" | ||
|
|
||
| using namespace sycl; | ||
|
|
||
| class ExeKernel; | ||
|
|
||
| int wrapper() { | ||
| int val = 0; | ||
| { | ||
| buffer<int, 1> buf(&val, range<1>(1)); | ||
| queue q; | ||
| q.submit([&](handler &cgh) { | ||
| auto acc = buf.get_access(cgh); | ||
| cgh.single_task<ExeKernel>([=]() { acc[0] = levelA(acc[0]); }); | ||
| }); | ||
| } | ||
|
|
||
| std::cout << "val=" << std::hex << val << "\n"; | ||
| if (val != 0xDCBA) | ||
| return (1); | ||
| return (0); | ||
| } |
8 changes: 8 additions & 0 deletions
8
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/Inputs/wrapper.hpp
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,8 @@ | ||
| #if defined(_WIN32) | ||
| #ifdef EXPORT | ||
| __declspec(dllexport) | ||
| #else | ||
| __declspec(dllimport) | ||
| #endif | ||
| #endif | ||
| int wrapper(); |
45 changes: 45 additions & 0 deletions
45
sycl/test-e2e/DeviceImageDependencies/NewOffloadDriver/dynamic.cpp
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,45 @@ | ||
| // Test -fsycl-allow-device-image-dependencies with dynamic libraries. | ||
|
|
||
| // UNSUPPORTED: cuda || hip | ||
| // UNSUPPORTED-INTENDED: Not implemented yet for Nvidia/AMD backends. | ||
|
|
||
| // DEFINE: %{dynamic_lib_options} = -fsycl %fPIC %shared_lib -fsycl-allow-device-image-dependencies -I %S/Inputs %if windows %{-DMAKE_DLL %} | ||
| // DEFINE: %{dynamic_lib_suffix} = %if windows %{dll%} %else %{so%} | ||
|
|
||
| // RUN: %clangxx --offload-new-driver %{dynamic_lib_options} %S/Inputs/d.cpp -o %T/libdevice_d.%{dynamic_lib_suffix} | ||
| // RUN: %clangxx --offload-new-driver %{dynamic_lib_options} %S/Inputs/c.cpp %if windows %{%T/libdevice_d.lib%} -o %T/libdevice_c.%{dynamic_lib_suffix} | ||
| // RUN: %clangxx --offload-new-driver %{dynamic_lib_options} %S/Inputs/b.cpp %if windows %{%T/libdevice_c.lib%} -o %T/libdevice_b.%{dynamic_lib_suffix} | ||
| // RUN: %clangxx --offload-new-driver %{dynamic_lib_options} %S/Inputs/a.cpp %if windows %{%T/libdevice_b.lib%} -o %T/libdevice_a.%{dynamic_lib_suffix} | ||
|
|
||
| // RUN: %{build} --offload-new-driver -fsycl-allow-device-image-dependencies -I %S/Inputs -o %t.out \ | ||
| // RUN: %if windows \ | ||
| // RUN: %{%T/libdevice_a.lib%} \ | ||
| // RUN: %else \ | ||
| // RUN: %{-L%T -ldevice_a -ldevice_b -ldevice_c -ldevice_d -Wl,-rpath=%T%} | ||
|
|
||
| // RUN: %{run} %t.out | ||
|
|
||
| #include "a.hpp" | ||
| #include <iostream> | ||
| #include <sycl/detail/core.hpp> | ||
|
|
||
| using namespace sycl; | ||
|
|
||
| class ExeKernel; | ||
|
|
||
| int main() { | ||
| int val = 0; | ||
| { | ||
| buffer<int, 1> buf(&val, range<1>(1)); | ||
| queue q; | ||
| q.submit([&](handler &cgh) { | ||
| auto acc = buf.get_access(cgh); | ||
| cgh.single_task<ExeKernel>([=]() { acc[0] = levelA(acc[0]); }); | ||
| }); | ||
| } | ||
|
|
||
| std::cout << "val=" << std::hex << val << "\n"; | ||
| if (val != 0xDCBA) | ||
| return (1); | ||
| return (0); | ||
| } |
Oops, something went wrong.
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.
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.
can you double check and make sure this will actual fail if the arg appears for this case and the below one? if not we might want to use
implicit-check-notinstead of acheck-prefix