Skip to content

Commit

Permalink
Builtin atomic fixes for 32 bit windows (#1746)
Browse files Browse the repository at this point in the history
Co-authored-by: Rich Hornung <[email protected]>
  • Loading branch information
adayton1 and rhornung67 authored Oct 14, 2024
1 parent a7aa1b4 commit 0edd83c
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions include/RAJA/policy/atomic_builtin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <cstdint>

#if defined(RAJA_COMPILER_MSVC) || (defined(_WIN32) && defined(__INTEL_COMPILER))
#if defined(RAJA_COMPILER_MSVC) || ((defined(_WIN32) || defined(_WIN64)) && defined(__INTEL_COMPILER))
#include <intrin.h>
#endif

Expand All @@ -48,7 +48,7 @@ struct builtin_atomic {
namespace detail {


#if defined(RAJA_COMPILER_MSVC) || (defined(_WIN32) && defined(__INTEL_COMPILER))
#if defined(RAJA_COMPILER_MSVC) || ((defined(_WIN32) || defined(_WIN64)) && defined(__INTEL_COMPILER))


/*!
Expand Down Expand Up @@ -120,11 +120,14 @@ RAJA_INLINE long builtin_atomicOr(long *acc, long value)
return _InterlockedOr(acc, value);
}

#if defined(_WIN64)

RAJA_INLINE long long builtin_atomicOr(long long *acc, long long value)
{
return _InterlockedOr64(acc, value);
}

#endif

/*!
* Atomic load using atomic or
Expand Down Expand Up @@ -155,11 +158,15 @@ RAJA_INLINE long builtin_atomicExchange(long *acc, long value)
return _InterlockedExchange(acc, value);
}

#if defined(_WIN64)

RAJA_INLINE long long builtin_atomicExchange(long long *acc, long long value)
{
return _InterlockedExchange64(acc, value);
}

#endif


/*!
* Atomic store using atomic exchange
Expand Down Expand Up @@ -190,11 +197,15 @@ RAJA_INLINE long builtin_atomicCAS(long *acc, long compare, long value)
return _InterlockedCompareExchange(acc, value, compare);
}

#if defined(_WIN64)

RAJA_INLINE long long builtin_atomicCAS(long long *acc, long long compare, long long value)
{
return _InterlockedCompareExchange64(acc, value, compare);
}

#endif


/*!
* Atomic addition using intrinsics
Expand All @@ -214,11 +225,15 @@ RAJA_INLINE long builtin_atomicAdd(long *acc, long value)
return _InterlockedExchangeAdd(acc, value);
}

#if defined(_WIN64)

RAJA_INLINE long long builtin_atomicAdd(long long *acc, long long value)
{
return _InterlockedExchangeAdd64(acc, value);
}

#endif


/*!
* Atomic subtraction using intrinsics
Expand All @@ -238,11 +253,15 @@ RAJA_INLINE long builtin_atomicSub(long *acc, long value)
return _InterlockedExchangeAdd(acc, -value);
}

#if defined(_WIN64)

RAJA_INLINE long long builtin_atomicSub(long long *acc, long long value)
{
return _InterlockedExchangeAdd64(acc, -value);
}

#endif


/*!
* Atomic and using intrinsics
Expand All @@ -262,11 +281,15 @@ RAJA_INLINE long builtin_atomicAnd(long *acc, long value)
return _InterlockedAnd(acc, value);
}

#if defined(_WIN64)

RAJA_INLINE long long builtin_atomicAnd(long long *acc, long long value)
{
return _InterlockedAnd64(acc, value);
}

#endif


/*!
* Atomic xor using intrinsics
Expand All @@ -286,11 +309,15 @@ RAJA_INLINE long builtin_atomicXor(long *acc, long value)
return _InterlockedXor(acc, value);
}

#if defined(_WIN64)

RAJA_INLINE long long builtin_atomicXor(long long *acc, long long value)
{
return _InterlockedXor64(acc, value);
}

#endif


#else // RAJA_COMPILER_MSVC

Expand Down

0 comments on commit 0edd83c

Please sign in to comment.