Skip to content

[SYCL] Fix DeviceCodeSplit checks to eliminate KernelInfo usage #9316

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ void runKernelsFromFile2() {
{
sycl::buffer<int, 1> Buf(&Data, sycl::range<1>(1));
auto KernelID1 = sycl::get_kernel_id<File2Kern1>();
auto KernelID2 = sycl::get_kernel_id<File1Kern1>();
auto KernelID3 = sycl::get_kernel_id<File1Kern2>();
auto KB = sycl::get_kernel_bundle<sycl::bundle_state::executable>(
Q.get_context(), {KernelID1});
auto Krn = KB.get_kernel(KernelID1);

assert(!KB.has_kernel(KernelID2));
assert(!KB.has_kernel(KernelID3));
std::vector<sycl::kernel_id> KernelIDStorage = KB.get_kernel_ids();
assert(KernelIDStorage.size() == 1);
assert(KernelIDStorage[0] == KernelID1);

Q.submit([&](sycl::handler &Cgh) {
auto Acc = Buf.get_access<sycl::access::mode::read_write>(Cgh);
Expand Down
45 changes: 22 additions & 23 deletions sycl/test-e2e/DeviceCodeSplit/split-per-source-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,40 @@
int main() {
sycl::queue Q;
int Data = 0;
{
sycl::buffer<int, 1> Buf(&Data, sycl::range<1>(1));
auto KernelID = sycl::get_kernel_id<File1Kern1>();
auto KB = sycl::get_kernel_bundle<sycl::bundle_state::executable>(
Q.get_context(), {KernelID});
auto Krn = KB.get_kernel(KernelID);

assert(KB.has_kernel(KernelID));
// TODO uncomment once the KernelInfo in multiple translation units
// bug is fixed.
// assert(!Prg.has_kernel<File2Kern1>());
auto KernelID = sycl::get_kernel_id<File1Kern1>();
auto KB = sycl::get_kernel_bundle<sycl::bundle_state::executable>(
Q.get_context(), {KernelID});
assert(KB.has_kernel(KernelID));
auto Krn1 = KB.get_kernel(KernelID);

auto KernelID2 = sycl::get_kernel_id<File1Kern2>();
assert(KB.has_kernel(KernelID2));
auto Krn2 = KB.get_kernel(KernelID2);

std::vector<sycl::kernel_id> KernelIDStorage = KB.get_kernel_ids();
assert(KernelIDStorage.size() == 2);
assert(std::any_of(
KernelIDStorage.begin(), KernelIDStorage.end(),
[&KernelID](const sycl::kernel_id &id) { return id == KernelID; }));
assert(std::any_of(
KernelIDStorage.begin(), KernelIDStorage.end(),
[&KernelID2](const sycl::kernel_id &id) { return id == KernelID2; }));

{
sycl::buffer<int, 1> Buf(&Data, sycl::range<1>(1));
Q.submit([&](sycl::handler &Cgh) {
auto Acc = Buf.get_access<sycl::access::mode::read_write>(Cgh);
Cgh.single_task<File1Kern1>(/*Krn,*/ [=]() { Acc[0] = 1; });
Cgh.single_task<File1Kern1>(Krn1, [=]() { Acc[0] = 1; });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the most important part of the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, main change is get_kernel_ids usage

});
}
assert(Data == 1);

{
sycl::buffer<int, 1> Buf(&Data, sycl::range<1>(1));
auto KernelID1 = sycl::get_kernel_id<File1Kern1>();
auto KernelID2 = sycl::get_kernel_id<File1Kern2>();
auto KB = sycl::get_kernel_bundle<sycl::bundle_state::executable>(
Q.get_context(), {KernelID1});
auto Krn = KB.get_kernel(KernelID2);

assert(KB.has_kernel(KernelID1));
// TODO uncomment once the KernelInfo in multiple translation units
// bug is fixed.
// assert(!Prg.has_kernel<File2Kern1>());

Q.submit([&](sycl::handler &Cgh) {
auto Acc = Buf.get_access<sycl::access::mode::read_write>(Cgh);
Cgh.single_task<File1Kern2>(/*Krn,*/ [=]() { Acc[0] = 2; });
Cgh.single_task<File1Kern2>(Krn2, [=]() { Acc[0] = 2; });
});
}
assert(Data == 2);
Expand Down