-
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][ESIMD] Report an error when slm_init is called more than once in the kernel #12804
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fb018e5
Initial Implementation
fineg74 10fceb8
rework the solution and add test
fineg74 95febd7
Remove unnecessary changes
fineg74 26c5eaf
Refactor the checks to cover more cases
fineg74 be39333
Remove unnecessary changes
fineg74 a0f13d1
Remove unneeded includes
fineg74 5edbbd5
Add comments
fineg74 1fa24a1
Add checks to prevent use of slm_init in functions called using invok…
fineg74 4685bab
Address PR comments
fineg74 3bbc5b2
Add checks to detect use of local_accessor and slm_init
fineg74 836c1ed
Fix test failure
fineg74 8853912
Address PR comments
fineg74 955f44a
Remove debug dump
fineg74 909bf52
Address PR comments, Improve handling of multiple kernels
fineg74 a909ff2
Remove incorrect test
fineg74 36e8273
Simplify the vlidation logic
fineg74 795a085
Update llvm/lib/SYCLLowerIR/ESIMD/LowerESIMD.cpp
fineg74 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
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
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,22 @@ | ||
// RUN: not %clangxx -fsycl %s 2>&1 | FileCheck %s | ||
|
||
// This test verifies more than 1 call to slm_init triggers an error. | ||
|
||
#include <iostream> | ||
#include <sycl/ext/intel/esimd.hpp> | ||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
using namespace sycl::ext::intel::esimd; | ||
|
||
int main() { | ||
queue Q; | ||
nd_range<1> NDR{range<1>{2}, range<1>{2}}; | ||
Q.parallel_for(NDR, [=](nd_item<1> NDI) SYCL_ESIMD_KERNEL { | ||
slm_init(1024); | ||
slm_init(1024); | ||
}).wait(); | ||
// CHECK: error: slm_init is called more than once from kernel 'typeinfo name for main::'lambda'(sycl::_V1::nd_item<1>)'. | ||
|
||
return 0; | ||
} |
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,34 @@ | ||
// This test verifies call to slm_init from a function called through | ||
// invoke_simd triggers an error. | ||
|
||
// RUN: not %clangxx -fsycl -fno-sycl-device-code-split-esimd -Xclang -fsycl-allow-func-ptr %s 2>&1 | FileCheck %s | ||
|
||
#include <sycl/ext/intel/esimd.hpp> | ||
#include <sycl/ext/oneapi/experimental/invoke_simd.hpp> | ||
#include <sycl/ext/oneapi/experimental/uniform.hpp> | ||
#include <sycl/sycl.hpp> | ||
|
||
#include <functional> | ||
#include <iostream> | ||
#include <type_traits> | ||
|
||
using namespace sycl::ext::oneapi::experimental; | ||
using namespace sycl; | ||
namespace esimd = sycl::ext::intel::esimd; | ||
|
||
SYCL_EXTERNAL | ||
[[intel::device_indirectly_callable]] void __regcall SIMD_CALLEE_VOID() | ||
SYCL_ESIMD_FUNCTION { | ||
esimd::slm_init<1024>(); | ||
} | ||
|
||
int main() { | ||
queue Q; | ||
nd_range<1> NDR{range<1>{2}, range<1>{2}}; | ||
Q.parallel_for(NDR, [=](nd_item<1> NDI) [[intel::reqd_sub_group_size(16)]] { | ||
sub_group sg = NDI.get_sub_group(); | ||
invoke_simd(sg, SIMD_CALLEE_VOID); | ||
}).wait(); | ||
return 0; | ||
} | ||
// CHECK: slm_init must be called directly from ESIMD kernel. |
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,29 @@ | ||
// RUN: %clangxx -fsycl %s | ||
|
||
// This test verifies usage of slm_init and local_accessor in different kernels | ||
// passes. | ||
|
||
#include <iostream> | ||
#include <sycl/ext/intel/esimd.hpp> | ||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
using namespace sycl::ext::intel::esimd; | ||
|
||
int main() { | ||
queue Q; | ||
nd_range<1> NDR{range<1>{2}, range<1>{2}}; | ||
Q.submit([&](handler &CGH) { | ||
auto InAcc = local_accessor<int, 1>(5, CGH); | ||
CGH.parallel_for(NDR, [=](nd_item<1> NDI) SYCL_ESIMD_KERNEL { | ||
scalar_load<int>(InAcc, 0); | ||
}); | ||
}).wait(); | ||
|
||
Q.submit([&](handler &CGH) { | ||
CGH.parallel_for(NDR, [=](nd_item<1> NDI) | ||
SYCL_ESIMD_KERNEL { slm_init(1024); }); | ||
}).wait(); | ||
|
||
return 0; | ||
} |
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,25 @@ | ||
// RUN: not %clangxx -fsycl %s 2>&1 | FileCheck %s | ||
|
||
// This test verifies usage of slm_init and local_accessor triggers an error. | ||
|
||
#include <iostream> | ||
#include <sycl/ext/intel/esimd.hpp> | ||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
using namespace sycl::ext::intel::esimd; | ||
|
||
int main() { | ||
queue Q; | ||
nd_range<1> NDR{range<1>{2}, range<1>{2}}; | ||
Q.submit([&](handler &CGH) { | ||
auto InAcc = local_accessor<int, 1>(5, CGH); | ||
CGH.parallel_for(NDR, [=](nd_item<1> NDI) SYCL_ESIMD_KERNEL { | ||
slm_init(1024); | ||
scalar_load<int>(InAcc, 0); | ||
}); | ||
}).wait(); | ||
// CHECK: error: slm_init can not be used with local accessors. | ||
|
||
return 0; | ||
} |
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,25 @@ | ||
// RUN: not %clangxx -fsycl %s 2>&1 | FileCheck %s | ||
|
||
// This test verifies usage of slm_init and local_accessor triggers an error. | ||
|
||
#include <iostream> | ||
#include <sycl/ext/intel/esimd.hpp> | ||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
using namespace sycl::ext::intel::esimd; | ||
|
||
int main() { | ||
queue Q; | ||
nd_range<1> NDR{range<1>{2}, range<1>{2}}; | ||
Q.submit([&](handler &CGH) { | ||
auto InAcc = local_accessor<int, 1>(5, CGH); | ||
CGH.parallel_for(NDR, [=](nd_item<1> NDI) SYCL_ESIMD_KERNEL { | ||
slm_init(1024); | ||
InAcc[0] = 5; | ||
}); | ||
}).wait(); | ||
// CHECK: error: slm_init can not be used with local accessors. | ||
|
||
return 0; | ||
} |
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,31 @@ | ||
// RUN: not %clangxx -fsycl %s 2>&1 | FileCheck %s | ||
|
||
// This test verifies call to slm_init from a function marked as | ||
// noinline triggers an error. | ||
|
||
#include <iostream> | ||
#include <sycl/ext/intel/esimd.hpp> | ||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
using namespace sycl::ext::intel::esimd; | ||
|
||
#ifdef _MSC_VER | ||
#define __SYCL_NOINLINE __declspec(noinline) | ||
#else | ||
#define __SYCL_NOINLINE __attribute__((noinline)) | ||
#endif | ||
|
||
__SYCL_NOINLINE void bar() { slm_init(1024); } | ||
__SYCL_NOINLINE void foo() { | ||
slm_init(1024); | ||
bar(); | ||
} | ||
|
||
int main() { | ||
queue Q; | ||
nd_range<1> NDR{range<1>{2}, range<1>{2}}; | ||
Q.parallel_for(NDR, [=](nd_item<1> NDI) SYCL_ESIMD_KERNEL { foo(); }).wait(); | ||
return 0; | ||
} | ||
// CHECK: error: slm_init is called more than once from kernel 'typeinfo name for main::'lambda'(sycl::_V1::nd_item<1>)'. |
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 we send an email to the CFE/SYCL language team as a non-blocking follow-up to see if they have any ideas on improving this check by doing it somewhere else (Sema?). Relying on the metadata should work but it seems a bit indirect and possibly flaky, but I don't know how to do any better today.
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.
Will do, although it looks like a standard way to mark passing accessors to the kernel from FE