forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Improve is_compatible (intel#9769)
Modify `is_compatible` to check if specific target is defined with `-fsycl-targets` and change the result. Previously there was a situation when kernel is compatible with the device by aspects, but actually it fails to run on this device as it was compiled for another target device. Related spec change: KhronosGroup/SYCL-Docs#381 Resolves intel#7561
- Loading branch information
1 parent
87a685d
commit 6a2245e
Showing
11 changed files
with
159 additions
and
6 deletions.
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
14 changes: 14 additions & 0 deletions
14
sycl/test-e2e/OptionalKernelFeatures/is_compatible/Inputs/is_compatible_with_env.cpp
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,14 @@ | ||
#include <sycl/sycl.hpp> | ||
|
||
int main() { | ||
sycl::device dev; | ||
if (sycl::is_compatible<class Kernel>(dev)) { | ||
sycl::queue q(dev); | ||
q.submit([&](sycl::handler &cgh) { | ||
cgh.parallel_for<class Kernel>(sycl::range<1>{1}, | ||
[=](sycl::id<1> Id) { int x = Id[0]; }); | ||
}).wait_and_throw(); | ||
return 0; | ||
} | ||
return 1; | ||
} |
7 changes: 7 additions & 0 deletions
7
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_amdgcn.cpp
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,7 @@ | ||
// REQUIRES: hip_amd, opencl, gpu, cpu | ||
|
||
// RUN: %clangxx -fsycl -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx906 -fsycl-targets=amdgcn-amd-amdhsa %S/Inputs/is_compatible_with_env.cpp -o %t.out | ||
|
||
// RUN: env ONEAPI_DEVICE_SELECTOR=hip:gpu %{run} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %{run} not %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run} not %t.out |
41 changes: 41 additions & 0 deletions
41
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_esimd_emulator.cpp
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,41 @@ | ||
// REQUIRES: esimd_emulator | ||
|
||
// RUN: %clangxx -fsycl %S/Inputs/is_compatible_with_env.cpp %t_negative_case.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=ext_intel_esimd_emulator:gpu %{run} not %t_negative_case.out | ||
|
||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
|
||
// Just an example from | ||
// https://github.com/intel/llvm/tree/sycl/sycl/doc/extensions/experimental/sycl_ext_intel_esimd | ||
|
||
#include <sycl/ext/intel/esimd.hpp> | ||
#include <sycl/sycl.hpp> | ||
|
||
int main() { | ||
sycl::device dev; | ||
if (sycl::is_compatible<class Test>(dev)) { | ||
float *A = malloc_shared<float>(Size, q); | ||
float *B = malloc_shared<float>(Size, q); | ||
float *C = malloc_shared<float>(Size, q); | ||
|
||
for (unsigned i = 0; i != Size; i++) { | ||
A[i] = B[i] = i; | ||
} | ||
|
||
q.submit([&](handler &cgh) { | ||
cgh.parallel_for<class Test>(Size / VL, | ||
[=](id<1> i) [[intel::sycl_explicit_simd]] { | ||
auto offset = i * VL; | ||
// pointer arithmetic, so offset is in | ||
// elements: | ||
simd<float, VL> va(A + offset); | ||
simd<float, VL> vb(B + offset); | ||
simd<float, VL> vc = va + vb; | ||
vc.copy_to(C + offset); | ||
}); | ||
}).wait_and_throw(); | ||
return 0; | ||
} | ||
return 1; | ||
} |
7 changes: 7 additions & 0 deletions
7
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_nvptx64.cpp
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,7 @@ | ||
// REQUIRES: cuda, opencl, gpu, cpu | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=nvptx64-nvidia-cuda %S/Inputs/is_compatible_with_env.cpp -o %t.out | ||
|
||
// RUN: env ONEAPI_DEVICE_SELECTOR=cuda:gpu %{run} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %{run} not %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run} not %t.out |
8 changes: 8 additions & 0 deletions
8
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_several_targets.cpp
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,8 @@ | ||
// REQUIRES: ocloc, level_zero, gpu, cpu | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64_fpga,spir64_gen -Xsycl-target-backend "-device *" %S/Inputs/is_compatible_with_env.cpp -o %t.out | ||
|
||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run} not %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:acc %{run} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %{run} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=level_zero:gpu %{run} %t.out |
7 changes: 7 additions & 0 deletions
7
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_spir64.cpp
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,7 @@ | ||
// REQUIRES: cuda, opencl, gpu, cpu | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64 %S/Inputs/is_compatible_with_env.cpp -o %t.out | ||
|
||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %{run} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=cuda:gpu %{run} not %t.out |
7 changes: 7 additions & 0 deletions
7
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_spir64_fpga.cpp
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,7 @@ | ||
// REQUIRES: opencl-aot, accelerator, gpu, cpu | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64_fpga %S/Inputs/is_compatible_with_env.cpp -o %t.out | ||
|
||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:fpga %{run} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=*:gpu %{run} not %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run} not %t.out |
7 changes: 7 additions & 0 deletions
7
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_spir64_gen.cpp
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,7 @@ | ||
// REQUIRES: ocloc, gpu, level_zero, cpu | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen -Xsycl-target-backend "-device *" %S/Inputs/is_compatible_with_env.cpp -o %t.out | ||
|
||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %{run} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=level_zero:gpu %{run} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run} not %t.out |
7 changes: 7 additions & 0 deletions
7
sycl/test-e2e/OptionalKernelFeatures/is_compatible/is_compatible_spir64_x86_64.cpp
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,7 @@ | ||
// REQUIRES: opencl-aot, cpu, gpu, level_zero | ||
|
||
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64 %S/Inputs/is_compatible_with_env.cpp -o %t.out | ||
|
||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:cpu %{run} %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %{run} not %t.out | ||
// RUN: env ONEAPI_DEVICE_SELECTOR=level_zero:gpu %{run} not %t.out |
File renamed without changes.