Skip to content

Commit

Permalink
Merge pull request #1404 from LLNL/bugfix/crobeck/amdclang_missing_sy…
Browse files Browse the repository at this point in the history
…mbols

Fix amdclang missing symbols
  • Loading branch information
rhornung67 authored Dec 14, 2022
2 parents b8aa3a6 + 5d458ce commit 3af6528
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
26 changes: 20 additions & 6 deletions include/RAJA/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define RAJA_config_HPP

#include <utility>
#include <cstddef>
#include <type_traits>

#if defined(_MSVC_LANG)
Expand Down Expand Up @@ -239,6 +240,15 @@ static_assert(RAJA_HAS_SOME_CXX14,
#define RAJA_PRAGMA(x) _Pragma(RAJA_STRINGIFY(x))
#endif


/* NOTE: Below we define RAJA_MAX_ALIGN for each compiler, currently it is set as 16 bytes
for all cases, except MSVC. Previously this was set by alignof(std::max_align_t) which, in Clang,
is based on the sizeof(long double). This causes an in inconsistency as CUDA/HIP long doubles
are demoted to doubles causing alignof(std::max_align_t) to return 8 bytes on the device and
16 bytes on the host. We therefore set a standard size and ensure validity through a
static_assert.
*/

namespace RAJA {

#if defined(RAJA_ENABLE_OPENMP) && !defined(__HIP_DEVICE_COMPILE__)
Expand Down Expand Up @@ -374,7 +384,7 @@ const int DATA_ALIGN = @RAJA_DATA_ALIGN@;
//
// Configuration options for Intel compilers
//

#define RAJA_MAX_ALIGN 16
#if defined (RAJA_ENABLE_FORCEINLINE_RECURSIVE)
#define RAJA_FORCEINLINE_RECURSIVE RAJA_PRAGMA(forceinline recursive)
#else
Expand All @@ -387,6 +397,7 @@ const int DATA_ALIGN = @RAJA_DATA_ALIGN@;
#define RAJA_INLINE inline __attribute__((always_inline))
#endif


#define RAJA_UNROLL RAJA_PRAGMA(unroll)
#define RAJA_UNROLL_COUNT(N) RAJA_PRAGMA(unroll(N))

Expand All @@ -412,9 +423,9 @@ const int DATA_ALIGN = @RAJA_DATA_ALIGN@;
//
// Configuration options for GNU compilers
//
#define RAJA_MAX_ALIGN 16
#define RAJA_FORCEINLINE_RECURSIVE
#define RAJA_INLINE inline __attribute__((always_inline))

#if !defined(__NVCC__)
#define RAJA_UNROLL RAJA_PRAGMA(GCC unroll 10000)
#define RAJA_UNROLL_COUNT(N) RAJA_PRAGMA(GCC unroll N)
Expand Down Expand Up @@ -446,11 +457,11 @@ const int DATA_ALIGN = @RAJA_DATA_ALIGN@;
//
// Configuration options for xlc compiler (i.e., bgq/sequoia).
//
#define RAJA_MAX_ALIGN 16
#define RAJA_FORCEINLINE_RECURSIVE
#define RAJA_INLINE inline __attribute__((always_inline))
#define RAJA_UNROLL
#define RAJA_UNROLL_COUNT(N)

// FIXME: alignx is breaking CUDA+xlc
#if defined(RAJA_ENABLE_CUDA)
#define RAJA_ALIGN_DATA(d) d
Expand All @@ -476,12 +487,11 @@ const int DATA_ALIGN = @RAJA_DATA_ALIGN@;
//
// Configuration options for clang compilers
//
#define RAJA_MAX_ALIGN 16
#define RAJA_FORCEINLINE_RECURSIVE
#define RAJA_INLINE inline __attribute__((always_inline))
#define RAJA_UNROLL RAJA_PRAGMA(clang loop unroll(enable))
#define RAJA_UNROLL_COUNT(N) RAJA_PRAGMA(clang loop unroll_count(N))


// note that neither nvcc nor Apple Clang compiler currently doesn't support
// the __builtin_assume_aligned attribute
#if defined(RAJA_ENABLE_CUDA) || defined(__APPLE__)
Expand Down Expand Up @@ -514,7 +524,7 @@ const int DATA_ALIGN = @RAJA_DATA_ALIGN@;

// This is the same as undefined compiler, but squelches the warning message
#elif defined(RAJA_COMPILER_MSVC)

#define RAJA_MAX_ALIGN alignof(std::max_align_t)
#define RAJA_FORCEINLINE_RECURSIVE
#define RAJA_INLINE inline
#define RAJA_ALIGN_DATA(d) d
Expand All @@ -526,6 +536,7 @@ const int DATA_ALIGN = @RAJA_DATA_ALIGN@;
#else

#pragma message("RAJA_COMPILER unknown, using default empty macros.")
#define RAJA_MAX_ALIGN 16
#define RAJA_FORCEINLINE_RECURSIVE
#define RAJA_INLINE inline
#define RAJA_ALIGN_DATA(d) d
Expand All @@ -536,6 +547,9 @@ const int DATA_ALIGN = @RAJA_DATA_ALIGN@;

#endif

static_assert(RAJA_MAX_ALIGN >= alignof(std::max_align_t) && (RAJA_MAX_ALIGN/alignof(std::max_align_t))*alignof(std::max_align_t) == RAJA_MAX_ALIGN,
"Inconsistent RAJA_MAX_ALIGN size");

#cmakedefine RAJA_HAVE_POSIX_MEMALIGN
#cmakedefine RAJA_HAVE_ALIGNED_ALLOC
#cmakedefine RAJA_HAVE_MM_MALLOC
Expand Down
5 changes: 2 additions & 3 deletions include/RAJA/pattern/WorkGroup/WorkStruct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct WorkStruct;
* sizeof(GenericWorkStruct) <= sizeof(WorkStruct<size>)
*/
template < typename Dispatcher_T >
using GenericWorkStruct = WorkStruct<alignof(std::max_align_t), Dispatcher_T>;
using GenericWorkStruct = WorkStruct<RAJA_MAX_ALIGN, Dispatcher_T>;

template < size_t size, Platform platform, typename dispatch_policy, typename DispatcherID, typename ... CallArgs >
struct WorkStruct<size, Dispatcher<platform, dispatch_policy, DispatcherID, CallArgs...>>
Expand All @@ -71,7 +71,6 @@ struct WorkStruct<size, Dispatcher<platform, dispatch_policy, DispatcherID, Call
"WorkStruct and GenericWorkStruct must have obj at the same offset");
static_assert(sizeof(value_type) <= sizeof(true_value_type),
"WorkStruct must not be smaller than GenericWorkStruct");

true_value_type* value_ptr = static_cast<true_value_type*>(ptr);

value_ptr->dispatcher = dispatcher;
Expand Down Expand Up @@ -112,7 +111,7 @@ struct WorkStruct<size, Dispatcher<platform, dispatch_policy, DispatcherID, Call

const dispatcher_type* dispatcher;
typename dispatcher_type::invoker_type invoke;
typename std::aligned_storage<size, alignof(std::max_align_t)>::type obj;
typename std::aligned_storage<size, RAJA_MAX_ALIGN>::type obj;
};

} // namespace detail
Expand Down

0 comments on commit 3af6528

Please sign in to comment.