From 40ee3b93e4c989bb121a7d6944b72cb327a86759 Mon Sep 17 00:00:00 2001 From: "Kornev, Nikita" Date: Wed, 2 Oct 2024 07:48:25 -0700 Subject: [PATCH 1/3] [SYCL] Add new aspect ext_oneapi_virtual_functions Spec: https://github.com/intel/llvm/pull/10540 --- llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td | 4 +++- sycl/include/sycl/device_aspect_macros.hpp | 10 ++++++++++ sycl/include/sycl/info/aspects.def | 1 + sycl/source/detail/device_impl.cpp | 6 ++++++ sycl/source/feature_test.hpp.in | 1 + sycl/test-e2e/Basic/aspects.cpp | 3 +++ .../VirtualFunctions/2/1/1/missing-overrides.cpp | 3 +-- .../VirtualFunctions/2/1/1/more-complex-hierarchy.cpp | 3 +-- .../VirtualFunctions/2/1/1/simple-hierarchy.cpp | 3 +-- .../2/2/single-construct-single-use.cpp | 3 +-- 10 files changed, 28 insertions(+), 9 deletions(-) diff --git a/llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td b/llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td index cda1c77bd4b6c..b3bd7021f5a43 100644 --- a/llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td +++ b/llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td @@ -85,6 +85,7 @@ def AspectExt_oneapi_virtual_mem : Aspect<"ext_oneapi_virtual_mem">; def AspectExt_oneapi_cuda_cluster_group : Aspect<"ext_oneapi_cuda_cluster_group">; def AspectExt_intel_fpga_task_sequence : Aspect<"ext_intel_fpga_task_sequence">; def AspectExt_oneapi_atomic16 : Aspect<"ext_oneapi_atomic16">; +def AspectExt_oneapi_virtual_functions : Aspect<"ext_oneapi_virtual_functions">; // Deprecated aspects def AspectInt64_base_atomics : Aspect<"int64_base_atomics">; def AspectInt64_extended_atomics : Aspect<"int64_extended_atomics">; @@ -148,7 +149,8 @@ def : TargetInfo<"__TestAspectList", AspectExt_oneapi_graph, AspectExt_oneapi_limited_graph, AspectExt_oneapi_private_alloca, AspectExt_oneapi_queue_profiling_tag, AspectExt_oneapi_virtual_mem, AspectExt_oneapi_cuda_cluster_group, AspectExt_intel_fpga_task_sequence, - AspectExt_oneapi_atomic16], + AspectExt_oneapi_atomic16, + AspectExt_oneapi_virtual_functions], []>; // This definition serves the only purpose of testing whether the deprecated aspect list defined in here and in SYCL RT // match. diff --git a/sycl/include/sycl/device_aspect_macros.hpp b/sycl/include/sycl/device_aspect_macros.hpp index 08e8f8460f884..dc0500552fd44 100644 --- a/sycl/include/sycl/device_aspect_macros.hpp +++ b/sycl/include/sycl/device_aspect_macros.hpp @@ -395,6 +395,11 @@ #define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_atomic16__ 0 #endif +#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_virtual_functions__ +//__SYCL_ASPECT(ext_oneapi_virtual_functions, 81) +#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_virtual_functions__ 0 +#endif + #ifndef __SYCL_ANY_DEVICE_HAS_host__ // __SYCL_ASPECT(host, 0) #define __SYCL_ANY_DEVICE_HAS_host__ 0 @@ -779,3 +784,8 @@ //__SYCL_ASPECT(ext_oneapi_oneapi_atomic16, 80) #define __SYCL_ANY_DEVICE_HAS_ext_oneapi_atomic16__ 0 #endif + +#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_virtual_functions__ +//__SYCL_ASPECT(ext_oneapi_virtual_functions, 81) +#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_virtual_functions__ 0 +#endif diff --git a/sycl/include/sycl/info/aspects.def b/sycl/include/sycl/info/aspects.def index 8126e05bf3bec..8a931dde35a71 100644 --- a/sycl/include/sycl/info/aspects.def +++ b/sycl/include/sycl/info/aspects.def @@ -71,3 +71,4 @@ __SYCL_ASPECT(ext_oneapi_unique_addressing_per_dim, 77) __SYCL_ASPECT(ext_oneapi_bindless_images_sample_1d_usm, 78) __SYCL_ASPECT(ext_oneapi_bindless_images_sample_2d_usm, 79) __SYCL_ASPECT(ext_oneapi_atomic16, 80) +__SYCL_ASPECT(ext_oneapi_virtual_functions, 81) diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 92b5e01fe00a6..6cd2c4b151260 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -768,6 +768,12 @@ bool device_impl::has(aspect Aspect) const { // Likely L0 doesn't check it properly. Need to double-check. return has_extension("cl_ext_float_atomics"); } + case aspect::ext_oneapi_virtual_functions: { + backend BE = getBackend(); + bool isCompatibleBE = BE == sycl::backend::ext_oneapi_level_zero || + BE == sycl::backend::opencl; + return (is_cpu() || is_gpu()) && isCompatibleBE; + } } return false; // This device aspect has not been implemented yet. diff --git a/sycl/source/feature_test.hpp.in b/sycl/source/feature_test.hpp.in index a61e504eb5e4c..8453becadfeba 100644 --- a/sycl/source/feature_test.hpp.in +++ b/sycl/source/feature_test.hpp.in @@ -110,6 +110,7 @@ inline namespace _V1 { #define SYCL_EXT_ONEAPI_ENQUEUE_NATIVE_COMMAND 1 // In progress yet #define SYCL_EXT_ONEAPI_ATOMIC16 0 +#define SYCL_EXT_ONEAPI_VIRTUAL_FUNCTIONS 0 #ifndef __has_include #define __has_include(x) 0 diff --git a/sycl/test-e2e/Basic/aspects.cpp b/sycl/test-e2e/Basic/aspects.cpp index 19ecd16e01053..114f069eee40b 100644 --- a/sycl/test-e2e/Basic/aspects.cpp +++ b/sycl/test-e2e/Basic/aspects.cpp @@ -90,6 +90,9 @@ int main() { if (plt.has(aspect::ext_oneapi_atomic16)) { std::cout << " ext_oneapi_atomic16" << std::endl; } + if (plt.has(aspect::ext_oneapi_virtual_functions)) { + std::cout << " ext_oneapi_virtual_functions" << std::endl; + } } std::cout << "Passed." << std::endl; return 0; diff --git a/sycl/test-e2e/VirtualFunctions/2/1/1/missing-overrides.cpp b/sycl/test-e2e/VirtualFunctions/2/1/1/missing-overrides.cpp index eaaf237040b99..8a9a0baa34f47 100644 --- a/sycl/test-e2e/VirtualFunctions/2/1/1/missing-overrides.cpp +++ b/sycl/test-e2e/VirtualFunctions/2/1/1/missing-overrides.cpp @@ -1,5 +1,4 @@ -// UNSUPPORTED: cuda, hip, acc -// FIXME: replace unsupported with an aspect check once we have it +// REQUIRES: aspect-ext_oneapi_virtual_functions // // RUN: %{build} -o %t.out %helper-includes // RUN: %{run} %t.out diff --git a/sycl/test-e2e/VirtualFunctions/2/1/1/more-complex-hierarchy.cpp b/sycl/test-e2e/VirtualFunctions/2/1/1/more-complex-hierarchy.cpp index cdce73763ff35..05b2e60f5e411 100644 --- a/sycl/test-e2e/VirtualFunctions/2/1/1/more-complex-hierarchy.cpp +++ b/sycl/test-e2e/VirtualFunctions/2/1/1/more-complex-hierarchy.cpp @@ -1,5 +1,4 @@ -// UNSUPPORTED: cuda, hip, acc -// FIXME: replace unsupported with an aspect check once we have it +// REQUIRES: aspect-ext_oneapi_virtual_functions // // RUN: %{build} -o %t.out %helper-includes // RUN: %{run} %t.out diff --git a/sycl/test-e2e/VirtualFunctions/2/1/1/simple-hierarchy.cpp b/sycl/test-e2e/VirtualFunctions/2/1/1/simple-hierarchy.cpp index 90299bc8e09f7..4b6943c5e7d7a 100644 --- a/sycl/test-e2e/VirtualFunctions/2/1/1/simple-hierarchy.cpp +++ b/sycl/test-e2e/VirtualFunctions/2/1/1/simple-hierarchy.cpp @@ -1,5 +1,4 @@ -// UNSUPPORTED: cuda, hip, acc -// FIXME: replace unsupported with an aspect check once we have it +// REQUIRES: aspect-ext_oneapi_virtual_functions // // RUN: %{build} -o %t.out %helper-includes // RUN: %{run} %t.out diff --git a/sycl/test-e2e/VirtualFunctions/2/2/single-construct-single-use.cpp b/sycl/test-e2e/VirtualFunctions/2/2/single-construct-single-use.cpp index 5f8c7c9323465..b37b64409b9ef 100644 --- a/sycl/test-e2e/VirtualFunctions/2/2/single-construct-single-use.cpp +++ b/sycl/test-e2e/VirtualFunctions/2/2/single-construct-single-use.cpp @@ -1,5 +1,4 @@ -// UNSUPPORTED: cuda, hip, acc -// FIXME: replace unsupported with an aspect check once we have it +// REQUIRES: aspect-ext_oneapi_virtual_functions // // RUN: %{build} -o %t.out %helper-includes // RUN: %{run} %t.out From b4571193abb9152bd94f4bcab86585c95dc78c64 Mon Sep 17 00:00:00 2001 From: KornevNikita Date: Mon, 7 Oct 2024 07:31:49 -0700 Subject: [PATCH 2/3] apply suggestions --- sycl/source/feature_test.hpp.in | 1 - sycl/test-e2e/VirtualFunctions/2/1/1/missing-overrides.cpp | 2 -- sycl/test-e2e/VirtualFunctions/2/1/1/more-complex-hierarchy.cpp | 2 -- sycl/test-e2e/VirtualFunctions/2/1/1/simple-hierarchy.cpp | 2 -- .../VirtualFunctions/2/2/single-construct-single-use.cpp | 2 -- sycl/test-e2e/VirtualFunctions/lit.local.cfg | 1 + 6 files changed, 1 insertion(+), 9 deletions(-) diff --git a/sycl/source/feature_test.hpp.in b/sycl/source/feature_test.hpp.in index 8453becadfeba..a61e504eb5e4c 100644 --- a/sycl/source/feature_test.hpp.in +++ b/sycl/source/feature_test.hpp.in @@ -110,7 +110,6 @@ inline namespace _V1 { #define SYCL_EXT_ONEAPI_ENQUEUE_NATIVE_COMMAND 1 // In progress yet #define SYCL_EXT_ONEAPI_ATOMIC16 0 -#define SYCL_EXT_ONEAPI_VIRTUAL_FUNCTIONS 0 #ifndef __has_include #define __has_include(x) 0 diff --git a/sycl/test-e2e/VirtualFunctions/2/1/1/missing-overrides.cpp b/sycl/test-e2e/VirtualFunctions/2/1/1/missing-overrides.cpp index 8a9a0baa34f47..f198bc94f855f 100644 --- a/sycl/test-e2e/VirtualFunctions/2/1/1/missing-overrides.cpp +++ b/sycl/test-e2e/VirtualFunctions/2/1/1/missing-overrides.cpp @@ -1,5 +1,3 @@ -// REQUIRES: aspect-ext_oneapi_virtual_functions -// // RUN: %{build} -o %t.out %helper-includes // RUN: %{run} %t.out diff --git a/sycl/test-e2e/VirtualFunctions/2/1/1/more-complex-hierarchy.cpp b/sycl/test-e2e/VirtualFunctions/2/1/1/more-complex-hierarchy.cpp index 05b2e60f5e411..bb334972c3f77 100644 --- a/sycl/test-e2e/VirtualFunctions/2/1/1/more-complex-hierarchy.cpp +++ b/sycl/test-e2e/VirtualFunctions/2/1/1/more-complex-hierarchy.cpp @@ -1,5 +1,3 @@ -// REQUIRES: aspect-ext_oneapi_virtual_functions -// // RUN: %{build} -o %t.out %helper-includes // RUN: %{run} %t.out diff --git a/sycl/test-e2e/VirtualFunctions/2/1/1/simple-hierarchy.cpp b/sycl/test-e2e/VirtualFunctions/2/1/1/simple-hierarchy.cpp index 4b6943c5e7d7a..2bfb3dd0f010d 100644 --- a/sycl/test-e2e/VirtualFunctions/2/1/1/simple-hierarchy.cpp +++ b/sycl/test-e2e/VirtualFunctions/2/1/1/simple-hierarchy.cpp @@ -1,5 +1,3 @@ -// REQUIRES: aspect-ext_oneapi_virtual_functions -// // RUN: %{build} -o %t.out %helper-includes // RUN: %{run} %t.out diff --git a/sycl/test-e2e/VirtualFunctions/2/2/single-construct-single-use.cpp b/sycl/test-e2e/VirtualFunctions/2/2/single-construct-single-use.cpp index b37b64409b9ef..ccf0c77036085 100644 --- a/sycl/test-e2e/VirtualFunctions/2/2/single-construct-single-use.cpp +++ b/sycl/test-e2e/VirtualFunctions/2/2/single-construct-single-use.cpp @@ -1,5 +1,3 @@ -// REQUIRES: aspect-ext_oneapi_virtual_functions -// // RUN: %{build} -o %t.out %helper-includes // RUN: %{run} %t.out diff --git a/sycl/test-e2e/VirtualFunctions/lit.local.cfg b/sycl/test-e2e/VirtualFunctions/lit.local.cfg index f74079fb0725a..3626f5dc6d960 100644 --- a/sycl/test-e2e/VirtualFunctions/lit.local.cfg +++ b/sycl/test-e2e/VirtualFunctions/lit.local.cfg @@ -4,3 +4,4 @@ import os # paths like "../../../helper.hpp" in them, so let's just register a # substitution to add directory with helper headers into include search path config.substitutions.append(("%helper-includes", "-I {}".format(os.path.dirname(os.path.abspath(__file__))))) +config.required_features += ['aspect-ext_oneapi_virtual_functions'] From f03ddbe7c8ddbc2167ea90e9761207239efccc30 Mon Sep 17 00:00:00 2001 From: KornevNikita Date: Tue, 8 Oct 2024 08:58:07 -0700 Subject: [PATCH 3/3] apply suggestions --- sycl/source/detail/device_impl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 6cd2c4b151260..e0508b57e912b 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -769,6 +769,7 @@ bool device_impl::has(aspect Aspect) const { return has_extension("cl_ext_float_atomics"); } case aspect::ext_oneapi_virtual_functions: { + // TODO: move to UR like e.g. aspect::ext_oneapi_virtual_mem backend BE = getBackend(); bool isCompatibleBE = BE == sycl::backend::ext_oneapi_level_zero || BE == sycl::backend::opencl;