add can_map_host_memory.cpp and gcn_arch_name.cpp

This commit is contained in:
Carl Pearson
2025-01-08 08:22:09 -08:00
parent cf83db731c
commit 99f9b302e3
4 changed files with 52 additions and 0 deletions

View File

@@ -8,6 +8,8 @@ add_executable(hipmalloc_hipmemset hipmalloc_hipmemset.cpp)
add_executable(hipmallocmanaged_devaccess hipmallocmanaged_devaccess.cpp)
add_executable(hipmallocmanaged_hostaccess hipmallocmanaged_hostaccess.cpp)
add_executable(hipmallocmanaged_hipmemset hipmallocmanaged_hipmemset.cpp)
add_executable(can_map_host_memory can_map_host_memory.cpp)
add_executable(gcn_arch_name gcn_arch_name.cpp)
enable_testing()
add_test(NAME hipMalloc+HostAccess COMMAND hipmalloc_hostaccess)

24
can_map_host_memory.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include <iostream>
#include <hip/hip_runtime.h>
#define HIP(e) \
if (hipError_t err = (e); err != hipSuccess) { \
std::cerr << __FILE__ << ":" << __LINE__ << " " << err << "\n"; \
exit(1); \
}
int main(void) {
hipDeviceProp_t props;
HIP(hipGetDeviceProperties(&props, 0));
std::cout << "canMapHostMemory: " << props.canMapHostMemory << "\n";
if (props.canMapHostMemory) {
return 0;
} else {
return 1;
}
}

20
gcn_arch_name.cpp Normal file
View File

@@ -0,0 +1,20 @@
#include <iostream>
#include <hip/hip_runtime.h>
#define HIP(e) \
if (hipError_t err = (e); err != hipSuccess) { \
std::cerr << __FILE__ << ":" << __LINE__ << " " << err << "\n"; \
exit(1); \
}
int main(void) {
hipDeviceProp_t props;
HIP(hipGetDeviceProperties(&props, 0));
std::cout << "gcnArchName: " << props.gcnArchName << "\n";
return 0;
}

6
run.sh
View File

@@ -38,15 +38,21 @@ echo "= HSA_XNACK unset $arch ="
echo "================================"
unset HSA_XNACK
ctest --test-dir "build-$arch"
"build-$arch"/can_map_host_memory
"build-$arch"/gcn_arch_name
echo "================================"
echo "= HSA_XNACK=1 $arch ="
echo "================================"
export HSA_XNACK=1
ctest --test-dir "build-$arch"
"build-$arch"/can_map_host_memory
"build-$arch"/gcn_arch_name
echo "================================"
echo "= HSA_XNACK=0 $arch ="
echo "================================"
export HSA_XNACK=0
ctest --test-dir "build-$arch"
"build-$arch"/can_map_host_memory
"build-$arch"/gcn_arch_name
done;