Update Kokkos library in LAMMPS to v4.0

This commit is contained in:
Stan Gerald Moore
2023-03-03 09:22:33 -07:00
parent df9bf18ed2
commit 14cb8576f4
1117 changed files with 33357 additions and 41720 deletions

View File

@ -1,46 +1,18 @@
/*
//@HEADER
// ************************************************************************
//
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Kokkos v. 4.0
// Copyright (2022) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
// See https://kokkos.org/LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Christian R. Trott (crtrott@sandia.gov)
//
// ************************************************************************
//@HEADER
*/
#ifndef KOKKOS_MACROS_HPP
#define KOKKOS_MACROS_HPP
@ -54,13 +26,33 @@
* KOKKOS_ENABLE_OPENMP Kokkos::OpenMP execution space
* KOKKOS_ENABLE_OPENMPTARGET Kokkos::Experimental::OpenMPTarget
* execution space
* KOKKOS_ENABLE_HIP Kokkos::Experimental::HIP execution space
* KOKKOS_ENABLE_HIP Kokkos::HIP execution space
* KOKKOS_ENABLE_SYCL Kokkos::Experimental::SYCL execution space
* KOKKOS_ENABLE_HWLOC HWLOC library is available.
* KOKKOS_ENABLE_DEBUG_BOUNDS_CHECK Insert array bounds checks, is expensive!
* KOKKOS_ENABLE_CUDA_UVM Use CUDA UVM for Cuda memory space.
*/
#define KOKKOS_VERSION_LESS(MAJOR, MINOR, PATCH) \
(KOKKOS_VERSION < ((MAJOR)*10000 + (MINOR)*100 + (PATCH)))
#define KOKKOS_VERSION_LESS_EQUAL(MAJOR, MINOR, PATCH) \
(KOKKOS_VERSION <= ((MAJOR)*10000 + (MINOR)*100 + (PATCH)))
#define KOKKOS_VERSION_GREATER(MAJOR, MINOR, PATCH) \
(KOKKOS_VERSION > ((MAJOR)*10000 + (MINOR)*100 + (PATCH)))
#define KOKKOS_VERSION_GREATER_EQUAL(MAJOR, MINOR, PATCH) \
(KOKKOS_VERSION >= ((MAJOR)*10000 + (MINOR)*100 + (PATCH)))
#define KOKKOS_VERSION_EQUAL(MAJOR, MINOR, PATCH) \
(KOKKOS_VERSION == ((MAJOR)*10000 + (MINOR)*100 + (PATCH)))
#if !KOKKOS_VERSION_EQUAL(KOKKOS_VERSION_MAJOR, KOKKOS_VERSION_MINOR, \
KOKKOS_VERSION_PATCH)
#error implementation bug
#endif
#ifndef KOKKOS_DONT_INCLUDE_CORE_CONFIG_H
#include <KokkosCore_config.h>
#endif
@ -73,11 +65,10 @@
* KOKKOS_COMPILER_NVCC
* KOKKOS_COMPILER_GNU
* KOKKOS_COMPILER_INTEL
* KOKKOS_COMPILER_IBM
* KOKKOS_COMPILER_CRAYC
* KOKKOS_COMPILER_APPLECC
* KOKKOS_COMPILER_CLANG
* KOKKOS_COMPILER_PGI
* KOKKOS_COMPILER_NVHPC
* KOKKOS_COMPILER_MSVC
*
* Macros for which compiler extension to use for atomics on intrinsic types
@ -117,15 +108,18 @@
// Code is parsed and separated into host and device code.
// Host code is compiled again with another compiler.
// Device code is compile to 'ptx'.
#define KOKKOS_COMPILER_NVCC __NVCC__
// NOTE: There is no __CUDACC_VER_PATCH__ officially, its __CUDACC_VER_BUILD__
// which does have more than one digit (potentially undefined number of them).
// This macro definition is in line with our other compiler defs
#define KOKKOS_COMPILER_NVCC \
__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__ * 10
#endif // #if defined( __NVCC__ )
#if !defined(KOKKOS_LAMBDA)
#define KOKKOS_LAMBDA [=]
#endif
#if (defined(KOKKOS_ENABLE_CXX17) || defined(KOKKOS_ENABLE_CXX20)) && \
!defined(KOKKOS_CLASS_LAMBDA)
#if !defined(KOKKOS_CLASS_LAMBDA)
#define KOKKOS_CLASS_LAMBDA [ =, *this ]
#endif
@ -150,21 +144,11 @@
#define KOKKOS_COMPILER_CRAYC _CRAYC
#endif
#if defined(__IBMCPP__)
// IBM C++
#define KOKKOS_COMPILER_IBM __IBMCPP__
#elif defined(__IBMC__)
#define KOKKOS_COMPILER_IBM __IBMC__
#elif defined(__ibmxl_vrm__) // xlclang++
#define KOKKOS_COMPILER_IBM __ibmxl_vrm__
#endif
#if defined(__APPLE_CC__)
#define KOKKOS_COMPILER_APPLECC __APPLE_CC__
#endif
#if defined(__clang__) && !defined(KOKKOS_COMPILER_INTEL) && \
!defined(KOKKOS_COMPILER_IBM)
#if defined(__clang__) && !defined(KOKKOS_COMPILER_INTEL)
#define KOKKOS_COMPILER_CLANG \
__clang_major__ * 100 + __clang_minor__ * 10 + __clang_patchlevel__
#endif
@ -178,15 +162,6 @@
#endif
#endif
#if defined(__PGIC__)
#define KOKKOS_COMPILER_PGI \
__PGIC__ * 100 + __PGIC_MINOR__ * 10 + __PGIC_PATCHLEVEL__
#if (1740 > KOKKOS_COMPILER_PGI)
#error "Compiling with PGI version earlier than 17.4 is not supported."
#endif
#endif
#if defined(__NVCOMPILER)
#define KOKKOS_COMPILER_NVHPC \
__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__ * 10 + \
@ -204,16 +179,6 @@
// of the supported OpenMP API version.
#endif // #if defined( _OPENMP )
#if defined(KOKKOS_ENABLE_CXX17)
#define KOKKOS_IMPL_FALLTHROUGH [[fallthrough]];
#elif defined(KOKKOS_COMPILER_GNU) && (KOKKOS_COMPILER_GNU >= 710)
#define KOKKOS_IMPL_FALLTHROUGH [[gnu::fallthrough]];
#elif defined(KOKKOS_COMPILER_CLANG)
#define KOKKOS_IMPL_FALLTHROUGH [[clang::fallthrough]];
#else
#define KOKKOS_IMPL_FALLTHROUGH
#endif
//----------------------------------------------------------------------------
// Intel compiler macros
@ -224,14 +189,6 @@
#define KOKKOS_ENABLE_PRAGMA_LOOPCOUNT 1
#define KOKKOS_ENABLE_PRAGMA_VECTOR 1
#endif
#if (1800 > KOKKOS_COMPILER_INTEL)
#define KOKKOS_ENABLE_PRAGMA_SIMD 1
#endif
// FIXME Workaround for ICE with intel 17,18,19,20,21 in Trilinos
#if (KOKKOS_COMPILER_INTEL <= 2100)
#define KOKKOS_IMPL_WORKAROUND_ICE_IN_TRILINOS_WITH_OLD_INTEL_COMPILERS
#endif
// FIXME_SYCL
#if !defined(KOKKOS_ENABLE_SYCL)
@ -256,8 +213,8 @@
#endif
#endif
#if (1700 > KOKKOS_COMPILER_INTEL)
#error "Compiling with Intel version earlier than 17.0 is not supported."
#if (1900 > KOKKOS_COMPILER_INTEL)
#error "Compiling with Intel version earlier than 19.0.5 is not supported."
#endif
#if !defined(KOKKOS_ENABLE_ASM) && !defined(_WIN32)
@ -276,13 +233,6 @@
#if defined(KOKKOS_ARCH_AVX512MIC)
#define KOKKOS_ENABLE_RFO_PREFETCH 1
#if (KOKKOS_COMPILER_INTEL < 1800) && !defined(KOKKOS_KNL_USE_ASM_WORKAROUND)
#define KOKKOS_KNL_USE_ASM_WORKAROUND 1
#endif
#endif
#if (1800 > KOKKOS_COMPILER_INTEL)
#define KOKKOS_IMPL_INTEL_WORKAROUND_NOEXCEPT_SPECIFICATION_VIRTUAL_FUNCTION
#endif
#if defined(__MIC__)
@ -296,21 +246,6 @@
#if defined(KOKKOS_COMPILER_CRAYC)
#endif
//----------------------------------------------------------------------------
// IBM Compiler macros
#if defined(KOKKOS_COMPILER_IBM)
#define KOKKOS_ENABLE_PRAGMA_UNROLL 1
//#define KOKKOS_ENABLE_PRAGMA_IVDEP 1
//#define KOKKOS_ENABLE_PRAGMA_LOOPCOUNT 1
//#define KOKKOS_ENABLE_PRAGMA_VECTOR 1
//#define KOKKOS_ENABLE_PRAGMA_SIMD 1
#if !defined(KOKKOS_ENABLE_ASM)
#define KOKKOS_ENABLE_ASM 1
#endif
#endif
//----------------------------------------------------------------------------
// CLANG compiler macros
@ -319,7 +254,6 @@
//#define KOKKOS_ENABLE_PRAGMA_IVDEP 1
//#define KOKKOS_ENABLE_PRAGMA_LOOPCOUNT 1
//#define KOKKOS_ENABLE_PRAGMA_VECTOR 1
//#define KOKKOS_ENABLE_PRAGMA_SIMD 1
#if !defined(KOKKOS_IMPL_HOST_FORCEINLINE_FUNCTION)
#define KOKKOS_IMPL_HOST_FORCEINLINE_FUNCTION \
@ -341,7 +275,6 @@
//#define KOKKOS_ENABLE_PRAGMA_IVDEP 1
//#define KOKKOS_ENABLE_PRAGMA_LOOPCOUNT 1
//#define KOKKOS_ENABLE_PRAGMA_VECTOR 1
//#define KOKKOS_ENABLE_PRAGMA_SIMD 1
#if defined(KOKKOS_ARCH_AVX512MIC)
#define KOKKOS_ENABLE_RFO_PREFETCH 1
@ -369,7 +302,6 @@
#define KOKKOS_ENABLE_PRAGMA_IVDEP 1
//#define KOKKOS_ENABLE_PRAGMA_LOOPCOUNT 1
#define KOKKOS_ENABLE_PRAGMA_VECTOR 1
//#define KOKKOS_ENABLE_PRAGMA_SIMD 1
#endif
//----------------------------------------------------------------------------
@ -408,11 +340,11 @@
#endif
#if !defined(KOKKOS_INLINE_FUNCTION_DELETED)
#define KOKKOS_INLINE_FUNCTION_DELETED inline
#define KOKKOS_INLINE_FUNCTION_DELETED
#endif
#if !defined(KOKKOS_DEFAULTED_FUNCTION)
#define KOKKOS_DEFAULTED_FUNCTION inline
#define KOKKOS_DEFAULTED_FUNCTION
#endif
#if !defined(KOKKOS_IMPL_HOST_FUNCTION)
@ -476,6 +408,7 @@
#if 1 < ((defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_CUDA) ? 1 : 0) + \
(defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_HIP) ? 1 : 0) + \
(defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_SYCL) ? 1 : 0) + \
(defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENACC) ? 1 : 0) + \
(defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMPTARGET) ? 1 : 0) + \
(defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMP) ? 1 : 0) + \
(defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_THREADS) ? 1 : 0) + \
@ -485,10 +418,12 @@
#endif
// If default is not specified then chose from enabled execution spaces.
// Priority: CUDA, HIP, SYCL, OPENMPTARGET, OPENMP, THREADS, HPX, SERIAL
// Priority: CUDA, HIP, SYCL, OPENACC, OPENMPTARGET, OPENMP, THREADS, HPX,
// SERIAL
#if defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_CUDA)
#elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_HIP)
#elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_SYCL)
#elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENACC)
#elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMPTARGET)
#elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMP)
#elif defined(KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_THREADS)
@ -500,6 +435,8 @@
#define KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_HIP
#elif defined(KOKKOS_ENABLE_SYCL)
#define KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_SYCL
#elif defined(KOKKOS_ENABLE_OPENACC)
#define KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENACC
#elif defined(KOKKOS_ENABLE_OPENMPTARGET)
#define KOKKOS_ENABLE_DEFAULT_DEVICE_TYPE_OPENMPTARGET
#elif defined(KOKKOS_ENABLE_OPENMP)
@ -514,6 +451,7 @@
//----------------------------------------------------------------------------
// Determine for what space the code is being compiled:
#if defined(KOKKOS_ENABLE_DEPRECATED_CODE_3)
#if defined(__CUDACC__) && defined(__CUDA_ARCH__) && defined(KOKKOS_ENABLE_CUDA)
#define KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_CUDA
@ -526,6 +464,7 @@
#define KOKKOS_ACTIVE_EXECUTION_MEMORY_SPACE_HOST
#endif
#endif
//----------------------------------------------------------------------------
// Remove surrounding parentheses if present
@ -574,6 +513,29 @@ static constexpr bool kokkos_omp_on_host() { return false; }
#endif
#endif
#ifdef KOKKOS_ENABLE_OPENACC
#ifdef KOKKOS_COMPILER_NVHPC
#define KOKKOS_IF_ON_DEVICE(CODE) \
if (__builtin_is_device_code()) { \
KOKKOS_IMPL_STRIP_PARENS(CODE) \
}
#define KOKKOS_IF_ON_HOST(CODE) \
if (!__builtin_is_device_code()) { \
KOKKOS_IMPL_STRIP_PARENS(CODE) \
}
#else
// FIXME_OPENACC acc_on_device is a non-constexpr function
#define KOKKOS_IF_ON_DEVICE(CODE) \
if constexpr (acc_on_device(acc_device_not_host)) { \
KOKKOS_IMPL_STRIP_PARENS(CODE) \
}
#define KOKKOS_IF_ON_HOST(CODE) \
if constexpr (acc_on_device(acc_device_host)) { \
KOKKOS_IMPL_STRIP_PARENS(CODE) \
}
#endif
#endif
#if !defined(KOKKOS_IF_ON_HOST) && !defined(KOKKOS_IF_ON_DEVICE)
#if (defined(KOKKOS_ENABLE_CUDA) && defined(__CUDA_ARCH__)) || \
(defined(KOKKOS_ENABLE_HIP) && defined(__HIP_DEVICE_COMPILE__)) || \
@ -603,15 +565,14 @@ static constexpr bool kokkos_omp_on_host() { return false; }
#define KOKKOS_ENABLE_TASKDAG
#endif
#if defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOS_ENABLE_DEPRECATED_CODE_4)
#define KOKKOS_ENABLE_CUDA_LDG_INTRINSIC
#endif
#define KOKKOS_INVALID_INDEX (~std::size_t(0))
#define KOKKOS_IMPL_CTOR_DEFAULT_ARG KOKKOS_INVALID_INDEX
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
#define KOKKOS_CONSTEXPR_14 constexpr
#define KOKKOS_DEPRECATED_TRAILING_ATTRIBUTE
#endif
// Guard intel compiler version 19 and older
// intel error #2651: attribute does not apply to any entity
// using <deprecated_type> KOKKOS_DEPRECATED = ...
@ -637,25 +598,16 @@ static constexpr bool kokkos_omp_on_host() { return false; }
#define KOKKOS_IMPL_WARNING(desc) KOKKOS_IMPL_DO_PRAGMA(message(#desc))
#endif
// DJS 05/28/2019: Bugfix: Issue 2155
// Use KOKKOS_ENABLE_CUDA_LDG_INTRINSIC to avoid memory leak in RandomAccess
// View
#if defined(KOKKOS_ENABLE_CUDA) && !defined(KOKKOS_ENABLE_CUDA_LDG_INTRINSIC)
#define KOKKOS_ENABLE_CUDA_LDG_INTRINSIC
#endif
#if defined(KOKKOS_ENABLE_CXX17) || defined(KOKKOS_ENABLE_CXX20)
#define KOKKOS_ATTRIBUTE_NODISCARD [[nodiscard]]
#else
#define KOKKOS_ATTRIBUTE_NODISCARD
#endif
#if (defined(KOKKOS_COMPILER_GNU) || defined(KOKKOS_COMPILER_CLANG) || \
defined(KOKKOS_COMPILER_INTEL) || defined(KOKKOS_COMPILER_PGI)) && \
!defined(_WIN32)
!defined(_WIN32) && !defined(__ANDROID__)
#if __has_include(<execinfo.h>)
#if (!defined(__linux__) || defined(__GLIBC_MINOR__))
#define KOKKOS_IMPL_ENABLE_STACKTRACE
#endif
#endif
#define KOKKOS_IMPL_ENABLE_CXXABI
#endif
@ -666,11 +618,6 @@ static constexpr bool kokkos_omp_on_host() { return false; }
#undef __CUDA_ARCH__
#endif
#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_3
#define KOKKOS_THREAD_LOCAL \
KOKKOS_DEPRECATED_WITH_COMMENT("Use thread_local instead!") thread_local
#endif
#if (defined(KOKKOS_IMPL_WINDOWS_CUDA) || defined(KOKKOS_COMPILER_MSVC)) && \
!defined(KOKKOS_COMPILER_CLANG)
// MSVC (as of 16.5.5 at least) does not do empty base class optimization by