CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
142 lines
3.8 KiB
C++
142 lines
3.8 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef ATOMIC_HELPERS_H
|
|
#define ATOMIC_HELPERS_H
|
|
|
|
#include "hip/hip_runtime_api.h"
|
|
#include <cassert>
|
|
|
|
#include "test_macros.h"
|
|
|
|
struct UserAtomicType {
|
|
int i;
|
|
|
|
__host__ __device__ explicit UserAtomicType(int d = 0) TEST_NOEXCEPT : i(d) {}
|
|
|
|
__host__ __device__ friend bool operator==(const UserAtomicType& x, const UserAtomicType& y) { return x.i == y.i; }
|
|
};
|
|
|
|
/*
|
|
|
|
Enable these once we have P0528
|
|
|
|
struct WeirdUserAtomicType
|
|
{
|
|
char i, j, k; // the 3 chars of doom
|
|
|
|
explicit WeirdUserAtomicType(int d = 0) TEST_NOEXCEPT : i(d) {}
|
|
|
|
friend bool operator==(const WeirdUserAtomicType& x, const WeirdUserAtomicType& y)
|
|
{ return x.i == y.i; }
|
|
};
|
|
|
|
struct PaddedUserAtomicType
|
|
{
|
|
char i; int j; // probably lock-free?
|
|
|
|
explicit PaddedUserAtomicType(int d = 0) TEST_NOEXCEPT : i(d) {}
|
|
|
|
friend bool operator==(const PaddedUserAtomicType& x, const PaddedUserAtomicType& y)
|
|
{ return x.i == y.i; }
|
|
};
|
|
|
|
*/
|
|
|
|
struct LargeUserAtomicType {
|
|
int a[128]; /* decidedly not lock-free */
|
|
|
|
__host__ __device__ LargeUserAtomicType(int d = 0) TEST_NOEXCEPT {
|
|
for (auto&& e : a)
|
|
e = d++;
|
|
}
|
|
|
|
__host__ __device__ friend bool operator==(LargeUserAtomicType const& x, LargeUserAtomicType const& y) TEST_NOEXCEPT {
|
|
for (int i = 0; i < 128; ++i)
|
|
if (x.a[i] != y.a[i])
|
|
return false;
|
|
return true;
|
|
}
|
|
};
|
|
|
|
template <template <class TestArg> class TestFunctor>
|
|
struct TestEachIntegralType {
|
|
__host__ __device__ void operator()() const {
|
|
TestFunctor<char>()();
|
|
TestFunctor<signed char>()();
|
|
TestFunctor<unsigned char>()();
|
|
TestFunctor<short>()();
|
|
TestFunctor<unsigned short>()();
|
|
TestFunctor<int>()();
|
|
TestFunctor<unsigned int>()();
|
|
TestFunctor<long>()();
|
|
TestFunctor<unsigned long>()();
|
|
TestFunctor<long long>()();
|
|
TestFunctor<unsigned long long>()();
|
|
TestFunctor<wchar_t>()();
|
|
#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
|
|
TestFunctor<char8_t>()();
|
|
#endif
|
|
TestFunctor<char16_t>()();
|
|
TestFunctor<char32_t>()();
|
|
TestFunctor<int8_t>()();
|
|
TestFunctor<uint8_t>()();
|
|
TestFunctor<int16_t>()();
|
|
TestFunctor<uint16_t>()();
|
|
TestFunctor<int32_t>()();
|
|
TestFunctor<uint32_t>()();
|
|
TestFunctor<int64_t>()();
|
|
TestFunctor<uint64_t>()();
|
|
}
|
|
};
|
|
|
|
template <template <class TestArg> class TestFunctor>
|
|
struct TestEachFloatingPointType {
|
|
__host__ __device__ void operator()() const {
|
|
TestFunctor<float>()();
|
|
TestFunctor<double>()();
|
|
TestFunctor<long double>()();
|
|
}
|
|
};
|
|
|
|
template <template <class TestArg> class TestFunctor>
|
|
struct TestEachPointerType {
|
|
__host__ __device__ void operator()() const {
|
|
TestFunctor<int*>()();
|
|
TestFunctor<const int*>()();
|
|
}
|
|
};
|
|
|
|
template <template <class TestArg> class TestFunctor>
|
|
struct TestEachAtomicType {
|
|
__host__ __device__ void operator()() const {
|
|
TestEachIntegralType<TestFunctor>()();
|
|
TestFunctor<UserAtomicType>()();
|
|
/*
|
|
Note: These aren't going to be lock-free,
|
|
so some libatomic.a is necessary. To handle
|
|
the case where the support functions are
|
|
missing, all tests that use this file should add:
|
|
XFAIL: !non-lockfree-atomics
|
|
*/
|
|
TestFunctor<LargeUserAtomicType>()();
|
|
/*
|
|
Enable these once we have P0528
|
|
|
|
TestFunctor<PaddedUserAtomicType>()();
|
|
TestFunctor<WeirdUserAtomicType>()();
|
|
*/
|
|
TestFunctor<int*>()();
|
|
TestFunctor<const int*>()();
|
|
TestFunctor<float>()();
|
|
TestFunctor<double>()();
|
|
}
|
|
};
|
|
|
|
#endif // ATOMIC_HELPERS_H
|