Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

hdk_cas fixes for CUDA and Windows #375

Merged
merged 2 commits into from
Apr 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions omniscidb/QueryEngine/JoinHashTable/Runtime/HashJoinRuntime.cpp
Original file line number Diff line number Diff line change
@@ -215,19 +215,18 @@ void SUFFIX(init_hash_join_buff_tbb)(int32_t* groups_buffer,
#endif // #ifndef __CUDACC__

#ifdef __CUDACC__
#define hdk_cas(address, compare, val) atomicCAS(address, compare, val)
#define hdk_cas(address, compare, val) (atomicCAS(address, compare, val) == compare)
#elif defined(_MSC_VER)
#define hdk_cas(ptr, expected, desired) template <typename T>
template <typename T>
bool hdk_cas(T* ptr, T* expected, T desired) {
bool hdk_cas(T* ptr, T expected, T desired) {
if constexpr (sizeof(T) == 4) {
return InterlockedCompareExchange(reinterpret_cast<volatile long*>(ptr),
static_cast<long>(desired),
static_cast<long>(*expected)) ==
static_cast<long>(*expected);
static_cast<long>(expected)) ==
static_cast<long>(expected);
} else if constexpr (sizeof(T) == 8) {
return InterlockedCompareExchange64(
reinterpret_cast<volatile int64_t*>(ptr), desired, *expected) == *expected;
reinterpret_cast<volatile int64_t*>(ptr), desired, expected) == expected;
} else {
LOG(FATAL) << "Unsupported atomic operation";
}