-
Notifications
You must be signed in to change notification settings - Fork 738
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
[SYCL] Add support for JIT-ing in AMD and NVIDIA backends #14280
Merged
Merged
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
4158578
[SYCL] Introduce SYCL_JIT_KERNELS env var
jchlanda 9bf827f
[SYCL] Extend kernel fusion with JIT-ing
jchlanda 0bc1146
[SYCL] Define JIT pipeline and introduce materializer pass
jchlanda 1aaf3e5
[SYCL] Add functionality to create/cache/retrieve materialized kernels
jchlanda 8221f0f
[SYCL] Introduce SYCL_JIT_TARGET_{CPU,FEATURES} env variables
jchlanda 434bc9f
[SYCL] Document SYCL_JIT_{KERNELS,TARGET_CPU,TARGET_FEATURES} env vars
jchlanda c3c9abc
PR feedback
jchlanda df9133f
PR feedback 2
jchlanda b725f00
Merge remote-tracking branch 'upstream/sycl' into jakub/jit_spec_const
jchlanda c23a986
Merge fixes
jchlanda bb1e3f9
Merge remote-tracking branch 'upstream/sycl' into jakub/jit_spec_const
jchlanda 93b07a7
Merge fixes
jchlanda cf4ec36
Debug printout fix
jchlanda f86d998
PR feedback 3
jchlanda e6169ce
Correct assert
jchlanda 5385ad5
strstr returns a pointer on success
jchlanda 0a3ecf1
Use default pipeline
jchlanda 1bc67ce
Merge remote-tracking branch 'upstream/sycl' into jakub/jit_spec_const
jchlanda 8bef1d4
Docs tidy-up
jchlanda 681da06
Merge remote-tracking branch 'upstream/sycl' into jakub/jit_spec_const
jchlanda 391ce43
Merge remote-tracking branch 'upstream/sycl' into jakub/jit_spec_const
jchlanda 1fb459a
Merge remote-tracking branch 'upstream/sycl' into jakub/jit_spec_const
jchlanda 5f3d2c9
Merge remote-tracking branch 'upstream/sycl' into jakub/jit_spec_const
jchlanda 94b5ad5
Constexpr debug output in program manager
jchlanda a876daa
Merge remote-tracking branch 'upstream/sycl' into jakub/jit_spec_const
jchlanda 21c814f
build fix
jchlanda 87f1a87
orfer of includes
jchlanda 509e3e6
JIT e2e test
jchlanda d8c6499
clang format the test
jchlanda 66bd110
include fix in the test
jchlanda a403149
Merge remote-tracking branch 'upstream/sycl' into jakub/jit_spec_const
jchlanda 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 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,110 @@ | ||
// REQUIRES: cuda || hip | ||
|
||
// RUN: %{build} -fsycl-embed-ir -o %t.out | ||
// RUN: env SYCL_JIT_AMDGCN_PTX_KERNELS=1 env SYCL_JIT_COMPILER_DEBUG="sycl-spec-const-materializer" %{run} %t.out &> %t.txt ; FileCheck %s --input-file %t.txt | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
constexpr size_t Size = 16; | ||
constexpr int SeedKernel = 3; | ||
constexpr int SeedKernelBundle = 5; | ||
|
||
constexpr int ValInt = 11; | ||
constexpr std::array<int, 2> ValArr{13, 17}; | ||
const static sycl::specialization_id<int> SpecConstInt; | ||
const static sycl::specialization_id<std::array<int, 2>> SpecConstArr; | ||
|
||
int validate(int Seed, std::vector<int> &Input, std::vector<int> &Output) { | ||
for (int i = 0; i < Size; ++i) { | ||
int Expected = ValInt + ValArr[0] + ValArr[1] + Input[i] + Seed; | ||
if (Expected != Output[i]) { | ||
return -1; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
// CHECK: Working on function: | ||
// CHECK: ================== | ||
// CHECK: _ZTSZ15runKernelBundleN4sycl3_V15queueERSt6vectorIiSaIiEES5_E10WoofBundle | ||
int runKernelBundle(sycl::queue Queue, std::vector<int> &Input, | ||
std::vector<int> &Output) { | ||
for (int i = 0; i < Size; ++i) { | ||
Output[i] = 42; | ||
Input[i] = i * i; | ||
} | ||
|
||
sycl::device Device; | ||
sycl::context Context = Queue.get_context(); | ||
|
||
auto InputBundle = | ||
sycl::get_kernel_bundle<class WoofBundle, sycl::bundle_state::input>( | ||
Context, {Device}); | ||
InputBundle.set_specialization_constant<SpecConstInt>(ValInt); | ||
InputBundle.set_specialization_constant<SpecConstArr>(ValArr); | ||
|
||
auto ExecBundle = sycl::build(InputBundle); | ||
|
||
{ | ||
sycl::buffer<int> OutBuff(Output.data(), Output.size()); | ||
sycl::buffer<int> InBuff(Input.data(), Input.size()); | ||
Queue.submit([&](sycl::handler &cgh) { | ||
sycl::accessor OutAcc(OutBuff, cgh, sycl::write_only); | ||
sycl::accessor InAcc(InBuff, cgh, sycl::read_only); | ||
cgh.use_kernel_bundle(ExecBundle); | ||
cgh.template parallel_for<class WoofBundle>( | ||
sycl::range<1>{Size}, [=](sycl::id<1> i, sycl::kernel_handler kh) { | ||
const auto KernelSpecConst = | ||
kh.get_specialization_constant<SpecConstInt>(); | ||
const auto KernelSpecConstArr = | ||
kh.get_specialization_constant<SpecConstArr>(); | ||
OutAcc[i] = KernelSpecConst + KernelSpecConstArr[0] + | ||
KernelSpecConstArr[1] + InAcc[i] + SeedKernelBundle; | ||
}); | ||
}); | ||
Queue.wait_and_throw(); | ||
} | ||
|
||
return validate(SeedKernelBundle, Input, Output); | ||
} | ||
|
||
// CHECK: Working on function: | ||
// CHECK: ================== | ||
// CHECK: _ZTSZZ9runKernelN4sycl3_V15queueERSt6vectorIiSaIiEES5_ENKUlRT_E_clINS0_7handlerEEEDaS7_E10WoofKernel | ||
int runKernel(sycl::queue Queue, std::vector<int> &Input, | ||
std::vector<int> &Output) { | ||
for (int i = 0; i < Size; ++i) { | ||
Output[i] = 42; | ||
Input[i] = i * i; | ||
} | ||
{ | ||
sycl::buffer<int> OutBuff(Output.data(), Output.size()); | ||
sycl::buffer<int> InBuff(Input.data(), Input.size()); | ||
Queue.submit([&](auto &CGH) { | ||
sycl::accessor OutAcc(OutBuff, CGH, sycl::write_only); | ||
sycl::accessor InAcc(InBuff, CGH, sycl::read_only); | ||
CGH.template set_specialization_constant<SpecConstInt>(ValInt); | ||
CGH.template set_specialization_constant<SpecConstArr>(ValArr); | ||
CGH.template parallel_for<class WoofKernel>( | ||
sycl::range<1>{Size}, [=](sycl::id<1> i, sycl::kernel_handler KH) { | ||
const auto KernelSpecConst = | ||
KH.get_specialization_constant<SpecConstInt>(); | ||
const auto KernelSpecConstArr = | ||
KH.get_specialization_constant<SpecConstArr>(); | ||
OutAcc[i] = KernelSpecConst + KernelSpecConstArr[0] + | ||
KernelSpecConstArr[1] + InAcc[i] + SeedKernel; | ||
}); | ||
}); | ||
Queue.wait_and_throw(); | ||
} | ||
|
||
return validate(SeedKernel, Input, Output); | ||
} | ||
|
||
int main() { | ||
std::vector<int> Input(Size); | ||
std::vector<int> Output(Size); | ||
sycl::queue Queue; | ||
return runKernel(Queue, Input, Output) | | ||
runKernelBundle(Queue, Input, Output); | ||
} |
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.
sycl/sycl.hpp
is not permitted in E2E tests. You wantsycl/detail/core.hpp
and then probably some other headers.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.
Done.