From 4c878a0a4deb86911aed4ba369fec89f49d175bb Mon Sep 17 00:00:00 2001 From: Rahulkumar Gayatri Date: Thu, 2 Feb 2023 12:59:59 -0800 Subject: [PATCH 1/4] OpenMPTarget: Adding declare target for constexpr variables. Co-authored-by: Daniel Arndt --- core/src/Kokkos_View.hpp | 10 ++++++++++ core/src/impl/Kokkos_Atomic_Memory_Order.hpp | 11 +++++++++++ core/unit_test/TestNumericTraits.hpp | 6 ++++++ 3 files changed, 27 insertions(+) diff --git a/core/src/Kokkos_View.hpp b/core/src/Kokkos_View.hpp index fb03c10e48..7686fa89aa 100644 --- a/core/src/Kokkos_View.hpp +++ b/core/src/Kokkos_View.hpp @@ -494,8 +494,18 @@ constexpr bool is_assignable(const Kokkos::View& dst, namespace Kokkos { +// FIXME_OPENMPTARGET - The `declare target` is needed for the Intel GPUs with +// the OpenMPTarget backend +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL_PVC) +#pragma omp declare target +#endif + inline constexpr Kokkos::ALL_t ALL{}; +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL_PVC) +#pragma omp end declare target +#endif + inline constexpr Kokkos::Impl::WithoutInitializing_t WithoutInitializing{}; inline constexpr Kokkos::Impl::AllowPadding_t AllowPadding{}; diff --git a/core/src/impl/Kokkos_Atomic_Memory_Order.hpp b/core/src/impl/Kokkos_Atomic_Memory_Order.hpp index d8c6821267..0cb4f969fa 100644 --- a/core/src/impl/Kokkos_Atomic_Memory_Order.hpp +++ b/core/src/impl/Kokkos_Atomic_Memory_Order.hpp @@ -51,8 +51,19 @@ struct memory_order_relaxed_t { #endif static constexpr auto std_constant = std::memory_order_relaxed; }; + +// FIXME_OPENMPTARGET - The `declare target` is needed for the Intel GPUs with +// the OpenMPTarget backend +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL_PVC) +#pragma omp declare target +#endif + constexpr memory_order_relaxed_t memory_order_relaxed = {}; +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL_PVC) +#pragma omp end declare target +#endif + struct memory_order_acquire_t { using memory_order = memory_order_acquire_t; #if defined(KOKKOS_ENABLE_GNU_ATOMICS) || \ diff --git a/core/unit_test/TestNumericTraits.hpp b/core/unit_test/TestNumericTraits.hpp index 9146297cd8..03203f5d25 100644 --- a/core/unit_test/TestNumericTraits.hpp +++ b/core/unit_test/TestNumericTraits.hpp @@ -481,7 +481,13 @@ CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(double, round_error); CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(long double, round_error); CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(float, denorm_min); CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(double, denorm_min); + +// FIXME_OPENMPTARGET - The static_assert causes issues on Intel GPUs with the +// OpenMPTarget backend. +#if !defined(KOKKOS_ENABLE_OPENMPTARGET) && !defined(KOKKOS_ARCH_INTEL_PVC) CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(long double, denorm_min); +#endif + // clang-format off static_assert(Kokkos::Experimental::norm_min::value == std::numeric_limits< float>::min(), ""); static_assert(Kokkos::Experimental::norm_min::value == std::numeric_limits< double>::min(), ""); From 1d8dd90785795abc8982116c29f4d02897bfc783 Mon Sep 17 00:00:00 2001 From: Rahulkumar Gayatri Date: Thu, 2 Feb 2023 15:38:21 -0800 Subject: [PATCH 2/4] OpenMPTarget: Enable declare target for all Intel GPUs. --- core/src/Kokkos_View.hpp | 4 ++-- core/src/impl/Kokkos_Atomic_Memory_Order.hpp | 4 ++-- core/unit_test/TestNumericTraits.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/Kokkos_View.hpp b/core/src/Kokkos_View.hpp index 7686fa89aa..2af24918db 100644 --- a/core/src/Kokkos_View.hpp +++ b/core/src/Kokkos_View.hpp @@ -496,13 +496,13 @@ namespace Kokkos { // FIXME_OPENMPTARGET - The `declare target` is needed for the Intel GPUs with // the OpenMPTarget backend -#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL_PVC) +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL) #pragma omp declare target #endif inline constexpr Kokkos::ALL_t ALL{}; -#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL_PVC) +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL) #pragma omp end declare target #endif diff --git a/core/src/impl/Kokkos_Atomic_Memory_Order.hpp b/core/src/impl/Kokkos_Atomic_Memory_Order.hpp index 0cb4f969fa..cf05236204 100644 --- a/core/src/impl/Kokkos_Atomic_Memory_Order.hpp +++ b/core/src/impl/Kokkos_Atomic_Memory_Order.hpp @@ -54,13 +54,13 @@ struct memory_order_relaxed_t { // FIXME_OPENMPTARGET - The `declare target` is needed for the Intel GPUs with // the OpenMPTarget backend -#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL_PVC) +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL) #pragma omp declare target #endif constexpr memory_order_relaxed_t memory_order_relaxed = {}; -#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL_PVC) +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL) #pragma omp end declare target #endif diff --git a/core/unit_test/TestNumericTraits.hpp b/core/unit_test/TestNumericTraits.hpp index 03203f5d25..38c4f0e05d 100644 --- a/core/unit_test/TestNumericTraits.hpp +++ b/core/unit_test/TestNumericTraits.hpp @@ -484,7 +484,7 @@ CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(double, denorm_min); // FIXME_OPENMPTARGET - The static_assert causes issues on Intel GPUs with the // OpenMPTarget backend. -#if !defined(KOKKOS_ENABLE_OPENMPTARGET) && !defined(KOKKOS_ARCH_INTEL_PVC) +#if !defined(KOKKOS_ENABLE_OPENMPTARGET) && !defined(KOKKOS_ARCH_INTEL) CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(long double, denorm_min); #endif From 14f9425af6a1f6d0badce9dedebd88f9eba5dec4 Mon Sep 17 00:00:00 2001 From: Rahulkumar Gayatri Date: Thu, 2 Feb 2023 21:53:24 -0800 Subject: [PATCH 3/4] OpenMPTarget: Replace KOKKOS_ARCH_INTEL with KOKKOS_COMPILER_INTEL to protect declare target on Intel GPUs. --- core/src/Kokkos_View.hpp | 4 ++-- core/src/impl/Kokkos_Atomic_Memory_Order.hpp | 4 ++-- core/unit_test/TestNumericTraits.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/Kokkos_View.hpp b/core/src/Kokkos_View.hpp index 2af24918db..345708e784 100644 --- a/core/src/Kokkos_View.hpp +++ b/core/src/Kokkos_View.hpp @@ -496,13 +496,13 @@ namespace Kokkos { // FIXME_OPENMPTARGET - The `declare target` is needed for the Intel GPUs with // the OpenMPTarget backend -#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL) +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_COMPILER_INTEL) #pragma omp declare target #endif inline constexpr Kokkos::ALL_t ALL{}; -#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL) +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_COMPILER_INTEL) #pragma omp end declare target #endif diff --git a/core/src/impl/Kokkos_Atomic_Memory_Order.hpp b/core/src/impl/Kokkos_Atomic_Memory_Order.hpp index cf05236204..6d1bfb9c82 100644 --- a/core/src/impl/Kokkos_Atomic_Memory_Order.hpp +++ b/core/src/impl/Kokkos_Atomic_Memory_Order.hpp @@ -54,13 +54,13 @@ struct memory_order_relaxed_t { // FIXME_OPENMPTARGET - The `declare target` is needed for the Intel GPUs with // the OpenMPTarget backend -#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL) +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_COMPILER_INTEL) #pragma omp declare target #endif constexpr memory_order_relaxed_t memory_order_relaxed = {}; -#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_ARCH_INTEL) +#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_COMPILER_INTEL) #pragma omp end declare target #endif diff --git a/core/unit_test/TestNumericTraits.hpp b/core/unit_test/TestNumericTraits.hpp index 38c4f0e05d..0302ac1d9b 100644 --- a/core/unit_test/TestNumericTraits.hpp +++ b/core/unit_test/TestNumericTraits.hpp @@ -484,7 +484,7 @@ CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(double, denorm_min); // FIXME_OPENMPTARGET - The static_assert causes issues on Intel GPUs with the // OpenMPTarget backend. -#if !defined(KOKKOS_ENABLE_OPENMPTARGET) && !defined(KOKKOS_ARCH_INTEL) +#if !defined(KOKKOS_ENABLE_OPENMPTARGET) && !defined(KOKKOS_COMPILER_INTEL) CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(long double, denorm_min); #endif From 446532e3883918bb2941f1cc85fb65818b9919e9 Mon Sep 17 00:00:00 2001 From: Christian Trott Date: Fri, 3 Feb 2023 08:24:22 -0700 Subject: [PATCH 4/4] Update core/unit_test/TestNumericTraits.hpp Co-authored-by: Daniel Arndt --- core/unit_test/TestNumericTraits.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/unit_test/TestNumericTraits.hpp b/core/unit_test/TestNumericTraits.hpp index 0302ac1d9b..735022a107 100644 --- a/core/unit_test/TestNumericTraits.hpp +++ b/core/unit_test/TestNumericTraits.hpp @@ -484,7 +484,7 @@ CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(double, denorm_min); // FIXME_OPENMPTARGET - The static_assert causes issues on Intel GPUs with the // OpenMPTarget backend. -#if !defined(KOKKOS_ENABLE_OPENMPTARGET) && !defined(KOKKOS_COMPILER_INTEL) +#if !(defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_COMPILER_INTEL)) CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(long double, denorm_min); #endif