Skip to content

Commit

Permalink
Define KOKKOS_COMPILER_INTEL_LLVM
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed Apr 8, 2023
1 parent 140cbd7 commit d80f580
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
backend: 'OPENMP'
- distro: 'fedora:intel'
cxx: 'icpx'
cxx_extra_flags: '-fp-model=precise'
cxx_extra_flags: '-fp-model=precise -Wno-pass-failed'
cmake_build_type: 'Release'
backend: 'OPENMP'
- distro: 'fedora:intel'
cxx: 'icpx'
cxx_extra_flags: '-fp-model=precise'
cxx_extra_flags: '-fp-model=precise -Wno-pass-failed'
cmake_build_type: 'Debug'
backend: 'OPENMP'
- distro: 'ubuntu:latest'
Expand Down
3 changes: 2 additions & 1 deletion core/src/Kokkos_BitManipulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ rotr(T x, int s) noexcept {

namespace Kokkos::Impl {

#if defined(KOKKOS_COMPILER_CLANG) || defined(KOKKOS_COMPILER_GCC)
#if defined(KOKKOS_COMPILER_CLANG) || defined(KOKKOS_COMPILER_INTEL_LLVM) || \
defined(KOKKOS_COMPILER_GCC)
#define KOKKOS_IMPL_USE_GCC_BUILT_IN_FUNCTIONS
#endif

Expand Down
17 changes: 8 additions & 9 deletions core/src/Kokkos_Macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
* KOKKOS_COMPILER_NVCC
* KOKKOS_COMPILER_GNU
* KOKKOS_COMPILER_INTEL
* KOKKOS_COMPILER_INTEL_LLVM
* KOKKOS_COMPILER_CRAYC
* KOKKOS_COMPILER_APPLECC
* KOKKOS_COMPILER_CLANG
Expand Down Expand Up @@ -125,7 +126,7 @@
#define KOKKOS_COMPILER_INTEL __INTEL_COMPILER

#elif defined(__INTEL_LLVM_COMPILER)
#define KOKKOS_COMPILER_INTEL __INTEL_LLVM_COMPILER
#define KOKKOS_COMPILER_INTEL_LLVM __INTEL_LLVM_COMPILER

#elif defined(_CRAYC)
// CRAY compiler for host code
Expand Down Expand Up @@ -171,16 +172,13 @@
//----------------------------------------------------------------------------
// Intel compiler macros

#if defined(KOKKOS_COMPILER_INTEL)
// FIXME_ICPX
#if !defined(__INTEL_LLVM_COMPILER)
#if defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)
#if defined(KOKKOS_COMPILER_INTEL_LLVM) && \
KOKKOS_COMPILER_INTEL_LLVM >= 20230100
#define KOKKOS_ENABLE_PRAGMA_UNROLL 1
#define KOKKOS_ENABLE_PRAGMA_LOOPCOUNT 1
#define KOKKOS_ENABLE_PRAGMA_VECTOR 1
#endif

// FIXME_SYCL
#if !defined(KOKKOS_ENABLE_SYCL)
#define KOKKOS_ENABLE_PRAGMA_IVDEP 1
#endif

Expand Down Expand Up @@ -582,8 +580,9 @@ static constexpr bool kokkos_omp_on_host() { return false; }

#define KOKKOS_ATTRIBUTE_NODISCARD [[nodiscard]]

#if (defined(KOKKOS_COMPILER_GNU) || defined(KOKKOS_COMPILER_CLANG) || \
defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_NVHPC)) && \
#if (defined(KOKKOS_COMPILER_GNU) || defined(KOKKOS_COMPILER_CLANG) || \
defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM) || \
defined(KOKKOS_COMPILER_NVHPC)) && \
!defined(_WIN32) && !defined(__ANDROID__)
#if __has_include(<execinfo.h>)
#define KOKKOS_IMPL_ENABLE_STACKTRACE
Expand Down
4 changes: 2 additions & 2 deletions core/src/Kokkos_View.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,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_COMPILER_INTEL)
#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_COMPILER_INTEL_LLVM)
#pragma omp declare target
#endif

inline constexpr Kokkos::ALL_t ALL{};

#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_COMPILER_INTEL)
#if defined(KOKKOS_ENABLE_OPENMPTARGET) && defined(KOKKOS_COMPILER_INTEL_LLVM)
#pragma omp end declare target
#endif

Expand Down
18 changes: 9 additions & 9 deletions core/src/impl/Kokkos_BitOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <cstdint>
#include <climits>

#ifdef KOKKOS_COMPILER_INTEL
#if defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)
#include <immintrin.h>
#endif

Expand All @@ -45,7 +45,7 @@ inline int int_log2_device(unsigned i) {
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP)
constexpr int shift = sizeof(unsigned) * CHAR_BIT - 1;
return shift - __clz(i);
#elif defined(KOKKOS_COMPILER_INTEL)
#elif defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)
return _bit_scan_reverse(i);
#else
return int_log2_fallback(i);
Expand All @@ -55,7 +55,7 @@ inline int int_log2_device(unsigned i) {
KOKKOS_IMPL_HOST_FUNCTION
inline int int_log2_host(unsigned i) {
// duplicating shift to avoid unused warning in else branch
#if defined(KOKKOS_COMPILER_INTEL)
#if defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)
constexpr int shift = sizeof(unsigned) * CHAR_BIT - 1;
(void)shift;
return _bit_scan_reverse(i);
Expand Down Expand Up @@ -104,7 +104,7 @@ inline int bit_first_zero_device(unsigned i) noexcept {
constexpr unsigned full = ~0u;
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP)
return full != i ? __ffs(~i) - 1 : -1;
#elif defined(KOKKOS_COMPILER_INTEL)
#elif defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)
return full != i ? _bit_scan_forward(~i) : -1;
#else
(void)full;
Expand All @@ -115,7 +115,7 @@ inline int bit_first_zero_device(unsigned i) noexcept {
KOKKOS_IMPL_HOST_FUNCTION
inline int bit_first_zero_host(unsigned i) noexcept {
constexpr unsigned full = ~0u;
#if defined(KOKKOS_COMPILER_INTEL)
#if defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)
return full != i ? _bit_scan_forward(~i) : -1;
#elif defined(KOKKOS_COMPILER_CRAYC)
return full != i ? _popcnt(i ^ (i + 1)) - 1 : -1;
Expand Down Expand Up @@ -153,15 +153,15 @@ int bit_scan_forward_fallback(unsigned i) {
KOKKOS_IMPL_DEVICE_FUNCTION inline int bit_scan_forward_device(unsigned i) {
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP)
return __ffs(i) - 1;
#elif defined(KOKKOS_COMPILER_INTEL)
#elif defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)
return _bit_scan_forward(i);
#else
return bit_scan_forward_fallback(i);
#endif
}

KOKKOS_IMPL_HOST_FUNCTION inline int bit_scan_forward_host(unsigned i) {
#if defined(KOKKOS_COMPILER_INTEL)
#if defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)
return _bit_scan_forward(i);
#elif defined(KOKKOS_COMPILER_CRAYC)
return i ? _popcnt(~i & (i - 1)) : -1;
Expand Down Expand Up @@ -200,15 +200,15 @@ int bit_count_fallback(unsigned i) {
KOKKOS_IMPL_DEVICE_FUNCTION inline int bit_count_device(unsigned i) {
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP)
return __popc(i);
#elif defined(KOKKOS_COMPILER_INTEL)
#elif defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)
return _popcnt32(i);
#else
return bit_count_fallback(i);
#endif
}

KOKKOS_IMPL_HOST_FUNCTION inline int bit_count_host(unsigned i) {
#if defined(KOKKOS_COMPILER_INTEL)
#if defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)
return _popcnt32(i);
#elif defined(KOKKOS_COMPILER_CRAYC)
return _popcnt(i);
Expand Down
6 changes: 6 additions & 0 deletions core/src/impl/Kokkos_Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ void pre_initialize_internal(const Kokkos::InitializationSettings& settings) {
std::to_string(KOKKOS_COMPILER_INTEL));
declare_configuration_metadata("tools_only", "compiler_family", "intel");
#endif
#ifdef KOKKOS_COMPILER_INTEL_LLVM
declare_configuration_metadata("compiler_version",
"KOKKOS_COMPILER_INTEL_LLVM",
std::to_string(KOKKOS_COMPILER_INTEL_LLVM));
declare_configuration_metadata("tools_only", "compiler_family", "intel_llvm");
#endif
#ifdef KOKKOS_COMPILER_NVCC
declare_configuration_metadata("compiler_version", "KOKKOS_COMPILER_NVCC",
std::to_string(KOKKOS_COMPILER_NVCC));
Expand Down
3 changes: 2 additions & 1 deletion core/src/impl/Kokkos_HostSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

/*--------------------------------------------------------------------------*/

#if defined(KOKKOS_COMPILER_INTEL) && !defined(KOKKOS_ENABLE_CUDA)
#if (defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_INTEL_LLVM)) && \
!defined(KOKKOS_ENABLE_CUDA)

// Intel specialized allocator does not interoperate with CUDA memory allocation

Expand Down
1 change: 1 addition & 0 deletions core/unit_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ SET(DEFAULT_DEVICE_SOURCES
TestParseCmdLineArgsAndEnvVars.cpp
TestSharedSpace.cpp
TestSharedHostPinnedSpace.cpp
TestCompilerMacros.cpp
default/TestDefaultDeviceType.cpp
default/TestDefaultDeviceType_a1.cpp
default/TestDefaultDeviceType_b1.cpp
Expand Down
13 changes: 7 additions & 6 deletions core/unit_test/TestCompilerMacros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
#include <gtest/gtest.h>
#include <Kokkos_Core.hpp>

#if 1 != ((defined(KOKKOS_COMPILER_INTEL) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_CRAYC) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_APPLECC) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_CLANG) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_GNU) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_NVHPC) ? 1 : 0) + \
#if 1 != ((defined(KOKKOS_COMPILER_INTEL) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_INTEL_LLVM) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_CRAYC) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_APPLECC) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_CLANG) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_GNU) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_NVHPC) ? 1 : 0) + \
(defined(KOKKOS_COMPILER_MSVC) ? 1 : 0))
#error "Only one host compiler macro can be defined"
#endif
Expand Down
2 changes: 0 additions & 2 deletions core/unit_test/TestInit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,3 @@ TEST(TEST_CATEGORY, dispatch) { test_dispatch<TEST_EXECSPACE>(); }
#endif

} // namespace Test

#include <TestCompilerMacros.hpp>
3 changes: 2 additions & 1 deletion core/unit_test/TestNumericTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ 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_LLVM))
CHECK_SAME_AS_NUMERIC_LIMITS_MEMBER_FUNCTION(long double, denorm_min);
#endif

Expand Down
2 changes: 1 addition & 1 deletion core/unit_test/TestViewMemoryAccessViolation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void test_view_memory_access_violations_from_device() {
}

// FIXME_SYCL
#if !(defined(KOKKOS_COMPILER_INTEL) && defined(KOKKOS_ENABLE_SYCL))
#if !(defined(KOKKOS_COMPILER_INTEL_LLVM) && defined(KOKKOS_ENABLE_SYCL))
TEST(TEST_CATEGORY_DEATH, view_memory_access_violations_from_host) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";

Expand Down
2 changes: 1 addition & 1 deletion core/unit_test/tools/TestLogicalSpaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ TEST(defaultdevicetype, access_allowed) {
test_allowed_access<fake_memory_space>();
}
// FIXME_SYCL
#if !(defined(KOKKOS_COMPILER_INTEL) && defined(KOKKOS_ENABLE_SYCL))
#if !(defined(KOKKOS_COMPILER_INTEL_LLVM) && defined(KOKKOS_ENABLE_SYCL))
TEST(defaultdevicetype_DeathTest, access_forbidden) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
ASSERT_DEATH(
Expand Down

0 comments on commit d80f580

Please sign in to comment.