Users/taosang/SWDEV-510994 - Refractor atomics header and tests (#902)
* SWDEV-550626 - Refactor atomics header and tests
1. Introduce __HIP_ATOMIC_BACKWARD_COMPAT.
By default we define __HIP_ATOMIC_BACKWARD_COMPAT=1 to
let hip atomic functions maintain old assumptions. if
users want to adopt the new behavior, that is , by default
assume no-fine-grained no-remote-memory, then they can
define __HIP_ATOMIC_BACKWARD_COMPAT=0 and get the new
behaviour.
2. Use __HIP_ATOMIC_BACKWARD_COMPAT_MEMORY to replace
original __HIP_FINE_GRAINED_MEMORY in atomic header.
And apply __HIP_FINE_GRAINED_MEMORY onto all
atomicXXX_system() functions to prevent failure on memory
allocated by hipHostMalloc().
3. Replace HIP_TEST_FINE_GRAINED_MEMORY with
HIP_TEST_ATOMIC_BACKWARD_COMPAT_MEMORY in hip-tests.
4. Fix negative test errors.
Fix managed memory test error on memory order.
some other minor changes.
As a result all originally disabled tests are enabled.
5. Add more atomics tests in some cases.
6. Reduce test time in each case.
Reduce iteration number to 1 for tests that cost too much time.
8. Put common codes into hip_test_common.hh
Tá an tiomantas seo le fáil i:
tiomanta ag
GitHub
tuismitheoir
becb4646bd
tiomantas
4a31affb76
@@ -40,6 +40,16 @@ THE SOFTWARE.
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#if !defined(__HIP_ATOMIC_BACKWARD_COMPAT)
|
||||
#define __HIP_ATOMIC_BACKWARD_COMPAT 1
|
||||
#endif
|
||||
|
||||
#if defined(__has_extension) && __has_extension(clang_atomic_attributes) && __HIP_ATOMIC_BACKWARD_COMPAT
|
||||
#define HIP_TEST_ATOMIC_BACKWARD_COMPAT_MEMORY [[clang::atomic(fine_grained_memory, remote_memory)]]
|
||||
#else
|
||||
#define HIP_TEST_ATOMIC_BACKWARD_COMPAT_MEMORY
|
||||
#endif
|
||||
|
||||
#ifdef TEST_CLOCK_CYCLE
|
||||
#define clock_function() clock64()
|
||||
#else
|
||||
@@ -388,6 +398,30 @@ inline bool isP2PSupported(int& d1, int& d2) {
|
||||
return supported;
|
||||
}
|
||||
|
||||
inline bool checkConcurrentKernels(int num_devices) {
|
||||
for (auto i = 0; i < num_devices; ++i) {
|
||||
HIP_CHECK(hipSetDevice(i));
|
||||
int concurrent_kernels = 0;
|
||||
HIP_CHECK(hipDeviceGetAttribute(&concurrent_kernels, hipDeviceAttributeConcurrentKernels, i));
|
||||
if (!concurrent_kernels) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (num_devices > 1) {
|
||||
HIP_CHECK(hipSetDevice(0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool isXnackOn() {
|
||||
hipDeviceProp_t prop;
|
||||
int device = 0;
|
||||
HIP_CHECK(hipGetDevice(&device));
|
||||
HIP_CHECK(hipGetDeviceProperties(&prop, device));
|
||||
std::string gfxName(prop.gcnArchName);
|
||||
return gfxName.find("xnack+") != std::string::npos;
|
||||
}
|
||||
|
||||
inline bool areWarpMatchFunctionsSupported() {
|
||||
int matchFunctionsSupported = 1;
|
||||
#if HT_NVIDIA
|
||||
|
||||
Tagairt in Eagrán Nua
Cuir bac ar úsáideoir