1 Commits
Author SHA1 Message Date
CHEN Xuan 03a23224a1 tests: enable ROCm packages test 2026-10-15 16:05:13 +08:00
20 changed files with 710 additions and 0 deletions
+77
View File
@@ -0,0 +1,77 @@
# library-prefix = rocmBase
#
# ROCm base suite-level shared library.
# Installs only the packages that are missing, records them in a flag file
# and uses reference counting so that the packages installed by this suite
# are removed once, after the last test case finishes.
# Packages that were already present before the suite are never removed.
#
# Usage in each test file:
# . "$(dirname "$0")/../lib.sh"
#
# Then call in rlPhaseStartSetup:
# rlRun "rocmBaseSetup \"\${PACKAGES[@]}\"" 0 "Install ROCm packages"
# The cleanup is auto-registered via rlCleanupAppend.
ROCM_BASE_FLAG="/tmp/.beakerlib_rocm_base_suite"
ROCM_BASE_LOCK="${ROCM_BASE_FLAG}.lock"
rocmBaseRoot() {
if [ "$(id -u)" -eq 0 ]; then
"$@"
else
sudo -n "$@"
fi
}
rocmBaseSetup() {
local pkg rc=0
local missing=()
# Register cleanup first so a partial install is also rolled back
rlCleanupAppend "rocmBaseCleanup"
(
flock 9
for pkg in "$@"; do
rpm -q "$pkg" >/dev/null 2>&1 || missing+=("$pkg")
done
if [ "${#missing[@]}" -gt 0 ]; then
rocmBaseRoot dnf install -y "${missing[@]}" || exit 1
for pkg in "${missing[@]}"; do
rpm -q "$pkg" >/dev/null 2>&1 && echo "pkg=$pkg" >> "$ROCM_BASE_FLAG"
done
fi
ref=$(sed -n 's/^ref=//p' "$ROCM_BASE_FLAG" 2>/dev/null)
ref=$(( ${ref:-0} + 1 ))
sed -i '/^ref=/d' "$ROCM_BASE_FLAG" 2>/dev/null
echo "ref=$ref" >> "$ROCM_BASE_FLAG"
) 9>"$ROCM_BASE_LOCK" || rc=$?
return $rc
}
rocmBaseCleanup() {
[ -f "$ROCM_BASE_FLAG" ] || return 0
(
flock 9
local ref pkgs=()
ref=$(sed -n 's/^ref=//p' "$ROCM_BASE_FLAG")
ref=$(( ${ref:-1} - 1 ))
if [ "$ref" -gt 0 ]; then
sed -i '/^ref=/d' "$ROCM_BASE_FLAG"
echo "ref=$ref" >> "$ROCM_BASE_FLAG"
exit 0
fi
mapfile -t pkgs < <(sed -n 's/^pkg=//p' "$ROCM_BASE_FLAG")
if [ "${#pkgs[@]}" -gt 0 ]; then
rocmBaseRoot dnf remove -y "${pkgs[@]}" || true
fi
rm -f "$ROCM_BASE_FLAG"
) 9>"$ROCM_BASE_LOCK" || true
}
+11
View File
@@ -0,0 +1,11 @@
summary: ROCm base functional tests without a GPU
tag:
- functional
- rocm-base
- gpu-less
duration: 10m
tier: 1
path: /tests/functional/pkgs/rocm-base
require:
- coreutils
- beakerlib
@@ -0,0 +1,18 @@
summary: ROCm base HIP offline compilation
test: ./test.sh
tag:
- functional
- rocm-base
- gpu-less
duration: 10m
tier: 1
path: /tests/functional/pkgs/rocm-base/test_rocm_base_hip_offline_compile
require:
- binutils
- gawk
- coreutils
- glibc
- grep
- perl-File-Which
- perl-URI
- beakerlib
@@ -0,0 +1,54 @@
#!/bin/bash
# Functional test: compile HIP code without a GPU.
. /usr/share/beakerlib/beakerlib.sh || exit 1
. "$(dirname "$0")/../lib.sh"
GPU_ARCHITECTURES=(gfx1100 gfx1201)
ROCM_BASE_TEST_PACKAGES=(
gcc-c++
hipcc
rocm-device-libs
rocm-comgr
rocm-comgr-devel
rocr-runtime
rocr-runtime-devel
rocm-hip
rocm-hip-devel
)
rlJournalStart
rlPhaseStartSetup "Environment setup"
rlRun "rocmBaseSetup \"\${ROCM_BASE_TEST_PACKAGES[@]}\"" 0 "Install ROCm packages"
TmpDir=$(mktemp -d)
rlRun "cp $(dirname "$0")/vector_add.cpp $TmpDir/" 0 "Copy vector_add.cpp"
rlRun "cd $TmpDir" 0 "Enter temporary directory"
rlRun "hipcc --version" 0 "Print hipcc version"
rlPhaseEnd
rlPhaseStartTest "Compile and inspect AMDGPU code objects"
for architecture in "${GPU_ARCHITECTURES[@]}"; do
executable="vector_add_$architecture"
rlRun "hipcc --offload-arch='$architecture' vector_add.cpp -o '$executable'" 0 \
"Compile vector add for $architecture"
rlRun "ldd '$executable' > 'ldd_$architecture.txt'" 0 \
"Resolve dependencies for $architecture"
rlAssertNotGrep "not found" "ldd_$architecture.txt"
rlRun "roc-obj-ls '$executable' > 'code_objects_$architecture.txt'" 0 \
"List code objects for $architecture"
rlAssertGrep "amdgcn-amd-amdhsa--$architecture" "code_objects_$architecture.txt"
done
rlPhaseEnd
rlPhaseStartCleanup "Clean up test environment"
rlRun "cd /" 0 "Leave temporary directory"
if [ -n "$TmpDir" ] && [ -d "$TmpDir" ]; then
rlRun "rm -rf $TmpDir" 0 "Remove temporary files"
fi
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
@@ -0,0 +1,69 @@
#include <hip/hip_runtime.h>
#include <cstdio>
#include <vector>
#define HIP_CHECK(expr) do { \
hipError_t error = (expr); \
if (error != hipSuccess) { \
std::fprintf(stderr, "%s\n", hipGetErrorString(error)); \
return 1; \
} \
} while (0)
__global__ void add(const int *a, const int *b, int *c, int n)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
c[i] = a[i] + b[i];
}
}
int main()
{
int count = 0;
HIP_CHECK(hipGetDeviceCount(&count));
if (count < 1) {
std::fprintf(stderr, "no GPU found\n");
return 2;
}
hipDeviceProp_t properties{};
HIP_CHECK(hipGetDeviceProperties(&properties, 0));
std::printf("device=%s arch=%s\n", properties.name, properties.gcnArchName);
constexpr int size = 4096;
std::vector<int> a(size), b(size), c(size);
for (int i = 0; i < size; ++i) {
a[i] = i;
b[i] = i * 2;
}
int *device_a = nullptr;
int *device_b = nullptr;
int *device_c = nullptr;
HIP_CHECK(hipMalloc(reinterpret_cast<void **>(&device_a), size * sizeof(int)));
HIP_CHECK(hipMalloc(reinterpret_cast<void **>(&device_b), size * sizeof(int)));
HIP_CHECK(hipMalloc(reinterpret_cast<void **>(&device_c), size * sizeof(int)));
HIP_CHECK(hipMemcpy(device_a, a.data(), size * sizeof(int), hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy(device_b, b.data(), size * sizeof(int), hipMemcpyHostToDevice));
hipLaunchKernelGGL(add, dim3((size + 255) / 256), dim3(256), 0, 0,
device_a, device_b, device_c, size);
HIP_CHECK(hipGetLastError());
HIP_CHECK(hipDeviceSynchronize());
HIP_CHECK(hipMemcpy(c.data(), device_c, size * sizeof(int), hipMemcpyDeviceToHost));
for (int i = 0; i < size; ++i) {
if (c[i] != i * 3) {
std::fprintf(stderr, "mismatch at %d: %d\n", i, c[i]);
return 3;
}
}
HIP_CHECK(hipFree(device_a));
HIP_CHECK(hipFree(device_b));
HIP_CHECK(hipFree(device_c));
std::puts("HIP vector add: PASS");
return 0;
}
@@ -0,0 +1,13 @@
summary: ROCm base HIPIFY command line tools
test: ./test.sh
tag:
- functional
- rocm-base
- gpu-less
duration: 2m
tier: 1
path: /tests/functional/pkgs/rocm-base/test_rocm_base_hipify
require:
- coreutils
- grep
- beakerlib
@@ -0,0 +1,38 @@
#!/bin/bash
# Functional test: translate CUDA APIs with HIPIFY.
. /usr/share/beakerlib/beakerlib.sh || exit 1
. "$(dirname "$0")/../lib.sh"
ROCM_BASE_TEST_PACKAGES=(
hipify
)
rlJournalStart
rlPhaseStartSetup "Environment setup"
rlRun "rocmBaseSetup \"\${ROCM_BASE_TEST_PACKAGES[@]}\"" 0 "Install ROCm packages"
TmpDir=$(mktemp -d)
rlRun "cd $TmpDir" 0 "Enter temporary directory"
rlRun "printf '%s\\n' 'void f(int *a, const cudaDeviceProp *b) { cudaChooseDevice(a,b); }' > hipify-input.cu" 0 \
"Create a minimal CUDA API input"
rlPhaseEnd
rlPhaseStartTest "Translate CUDA API names"
rlRun "hipify-perl hipify-input.cu -o hipify-output.cpp" 0 "Run hipify-perl"
rlAssertGrep "hipDeviceProp_t" "hipify-output.cpp"
rlAssertGrep "hipChooseDevice" "hipify-output.cpp"
rlRun "hipify-clang --version > hipify-clang-version.txt 2>&1" 0 \
"Run hipify-clang"
rlRun "test -s hipify-clang-version.txt" 0 "Check version output"
rlPhaseEnd
rlPhaseStartCleanup "Clean up test environment"
rlRun "cd /" 0 "Leave temporary directory"
if [ -n "$TmpDir" ] && [ -d "$TmpDir" ]; then
rlRun "rm -rf $TmpDir" 0 "Remove temporary files"
fi
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
@@ -0,0 +1,14 @@
summary: ROCm base Tensile command line tools
test: ./test.sh
tag:
- functional
- rocm-base
- gpu-less
duration: 2m
tier: 1
path: /tests/functional/pkgs/rocm-base/test_rocm_base_tensile
require:
- python3
- coreutils
- grep
- beakerlib
@@ -0,0 +1,35 @@
#!/bin/bash
# Functional test: validate GPU-independent Tensile tools.
. /usr/share/beakerlib/beakerlib.sh || exit 1
. "$(dirname "$0")/../lib.sh"
ROCM_BASE_TEST_PACKAGES=(
python-tensile
)
rlJournalStart
rlPhaseStartSetup "Environment setup"
rlRun "rocmBaseSetup \"\${ROCM_BASE_TEST_PACKAGES[@]}\"" 0 "Install ROCm packages"
TmpDir=$(mktemp -d)
rlRun "cd $TmpDir" 0 "Enter temporary directory"
rlPhaseEnd
rlPhaseStartTest "Validate Tensile command entry points"
rlRun "TensileGetPath > tensile-root.txt" 0 "Run TensileGetPath"
TensileRoot=$(cat tensile-root.txt)
rlRun "test -d '$TensileRoot'" 0 "Check Tensile root directory"
rlRun "Tensile --version > tensile-version.txt 2>&1" 0 "Print Tensile version"
rlAssertGrep "Tensile" "tensile-version.txt"
rlPhaseEnd
rlPhaseStartCleanup "Clean up test environment"
rlRun "cd /" 0 "Leave temporary directory"
if [ -n "$TmpDir" ] && [ -d "$TmpDir" ]; then
rlRun "rm -rf $TmpDir" 0 "Remove temporary files"
fi
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
+77
View File
@@ -0,0 +1,77 @@
# library-prefix = rocmGpu
#
# ROCm GPU suite-level shared library.
# Installs only the packages that are missing, records them in a flag file
# and uses reference counting so that the packages installed by this suite
# are removed once, after the last test case finishes.
# Packages that were already present before the suite are never removed.
#
# Usage in each test file:
# . "$(dirname "$0")/../lib.sh"
#
# Then call in rlPhaseStartSetup:
# rlRun "rocmGpuSetup \"\${PACKAGES[@]}\"" 0 "Install ROCm packages"
# The cleanup is auto-registered via rlCleanupAppend.
ROCM_GPU_FLAG="/tmp/.beakerlib_rocm_gpu_suite"
ROCM_GPU_LOCK="${ROCM_GPU_FLAG}.lock"
rocmGpuRoot() {
if [ "$(id -u)" -eq 0 ]; then
"$@"
else
sudo -n "$@"
fi
}
rocmGpuSetup() {
local pkg rc=0
local missing=()
# Register cleanup first so a partial install is also rolled back
rlCleanupAppend "rocmGpuCleanup"
(
flock 9
for pkg in "$@"; do
rpm -q "$pkg" >/dev/null 2>&1 || missing+=("$pkg")
done
if [ "${#missing[@]}" -gt 0 ]; then
rocmGpuRoot dnf install -y "${missing[@]}" || exit 1
for pkg in "${missing[@]}"; do
rpm -q "$pkg" >/dev/null 2>&1 && echo "pkg=$pkg" >> "$ROCM_GPU_FLAG"
done
fi
ref=$(sed -n 's/^ref=//p' "$ROCM_GPU_FLAG" 2>/dev/null)
ref=$(( ${ref:-0} + 1 ))
sed -i '/^ref=/d' "$ROCM_GPU_FLAG" 2>/dev/null
echo "ref=$ref" >> "$ROCM_GPU_FLAG"
) 9>"$ROCM_GPU_LOCK" || rc=$?
return $rc
}
rocmGpuCleanup() {
[ -f "$ROCM_GPU_FLAG" ] || return 0
(
flock 9
local ref pkgs=()
ref=$(sed -n 's/^ref=//p' "$ROCM_GPU_FLAG")
ref=$(( ${ref:-1} - 1 ))
if [ "$ref" -gt 0 ]; then
sed -i '/^ref=/d' "$ROCM_GPU_FLAG"
echo "ref=$ref" >> "$ROCM_GPU_FLAG"
exit 0
fi
mapfile -t pkgs < <(sed -n 's/^pkg=//p' "$ROCM_GPU_FLAG")
if [ "${#pkgs[@]}" -gt 0 ]; then
rocmGpuRoot dnf remove -y "${pkgs[@]}" || true
fi
rm -f "$ROCM_GPU_FLAG"
) 9>"$ROCM_GPU_LOCK" || true
}
+12
View File
@@ -0,0 +1,12 @@
summary: ROCm functional tests requiring a single AMD GPU
tag:
- functional
- rocm-gpu
- gpu
- single-gpu
duration: 20m
tier: 1
path: /tests/functional/pkgs/rocm-gpu
require:
- coreutils
- beakerlib
@@ -0,0 +1,14 @@
summary: Run ROCm Bandwidth Test on a single AMD GPU
test: ./test.sh
tag:
- functional
- rocm-gpu
- gpu
- single-gpu
duration: 10m
tier: 1
path: /tests/functional/pkgs/rocm-gpu/test_rocm_gpu_bandwidth
require:
- coreutils
- grep
- beakerlib
@@ -0,0 +1,37 @@
#!/bin/bash
# Test ROCm bandwidth on one AMD GPU.
. /usr/share/beakerlib/beakerlib.sh || exit 1
. "$(dirname "$0")/../lib.sh"
ROCM_GPU_TEST_PACKAGES=(
rocm-bandwidth-test
)
rlJournalStart
rlPhaseStartSetup "Environment setup"
rlRun "rocmGpuSetup \"\${ROCM_GPU_TEST_PACKAGES[@]}\"" 0 "Install ROCm packages"
TmpDir=$(mktemp -d)
rlRun "cd $TmpDir" 0
rlRun "test -r /dev/kfd && test -w /dev/kfd" 0 "Check KFD access"
rlPhaseEnd
rlPhaseStartTest "Run ROCm Bandwidth Test"
rlRun "rocm-bandwidth-test > bandwidth.txt 2>&1" 0 \
"Run bandwidth test"
rlRun "cat bandwidth.txt" 0 "Print bandwidth output"
rlAssertGrep 'GPU-[[:xdigit:]]\+' bandwidth.txt
rlAssertGrep "Device:" bandwidth.txt
rlAssertNotGrep "No subcommand provided" bandwidth.txt
rlAssertNotGrep "Error:" bandwidth.txt
rlPhaseEnd
rlPhaseStartCleanup "Clean up test environment"
rlRun "cd /" 0
if [ -n "$TmpDir" ] && [ -d "$TmpDir" ]; then
rlRun "rm -rf $TmpDir" 0 "Remove temporary files"
fi
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
@@ -0,0 +1,15 @@
summary: Compile and run a HIP program on a single AMD GPU
test: ./test.sh
tag:
- functional
- rocm-gpu
- gpu
- single-gpu
duration: 10m
tier: 1
path: /tests/functional/pkgs/rocm-gpu/test_rocm_gpu_hip_runtime
require:
- coreutils
- gawk
- grep
- beakerlib
@@ -0,0 +1,51 @@
#!/bin/bash
# Compile and run a HIP vector add on one AMD GPU.
. /usr/share/beakerlib/beakerlib.sh || exit 1
. "$(dirname "$0")/../lib.sh"
ROCM_GPU_TEST_PACKAGES=(
gcc-c++
hipcc
rocm-device-libs
rocr-runtime
rocm-hip
rocm-hip-devel
rocminfo
)
rlJournalStart
rlPhaseStartSetup "Environment setup"
rlRun "rocmGpuSetup \"\${ROCM_GPU_TEST_PACKAGES[@]}\"" 0 "Install ROCm packages"
TmpDir=$(mktemp -d)
rlRun "cp $(dirname "$0")/vector_add.cpp $TmpDir/" 0 \
"Copy HIP source"
rlRun "cd $TmpDir" 0
rlRun "rocminfo > rocminfo.txt 2>&1" 0 "Query GPU"
rlRun "grep -E '^[[:space:]]*Name:[[:space:]]+gfx[0-9]+' rocminfo.txt | awk '{print \$2}' | head -n 1 > gpu-architecture.txt" 0 \
"Find GPU architecture"
rlRun "test -s gpu-architecture.txt" 0 "Check for a GPU architecture"
GPU_ARCH=$(cat gpu-architecture.txt)
rlLogInfo "GPU architecture: $GPU_ARCH"
rlPhaseEnd
rlPhaseStartTest "Compile and run HIP vector addition"
rlRun "hipcc --version" 0 "Print hipcc version"
rlRun "hipcc --offload-arch='$GPU_ARCH' vector_add.cpp -o vector_add" 0 \
"Compile HIP vector add"
rlRun "./vector_add > run.txt 2>&1" 0 \
"Run HIP vector add"
rlRun "cat run.txt" 0 "Print HIP output"
rlAssertGrep "HIP vector add: PASS" run.txt
rlAssertGrep "arch=$GPU_ARCH" run.txt
rlPhaseEnd
rlPhaseStartCleanup "Clean up test environment"
rlRun "cd /" 0
if [ -n "$TmpDir" ] && [ -d "$TmpDir" ]; then
rlRun "rm -rf $TmpDir" 0 "Remove temporary files"
fi
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
@@ -0,0 +1,69 @@
#include <hip/hip_runtime.h>
#include <cstdio>
#include <vector>
#define HIP_CHECK(expr) do { \
hipError_t error = (expr); \
if (error != hipSuccess) { \
std::fprintf(stderr, "%s\n", hipGetErrorString(error)); \
return 1; \
} \
} while (0)
__global__ void add(const int *a, const int *b, int *c, int n)
{
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
c[i] = a[i] + b[i];
}
}
int main()
{
int count = 0;
HIP_CHECK(hipGetDeviceCount(&count));
if (count < 1) {
std::fprintf(stderr, "no GPU found\n");
return 2;
}
hipDeviceProp_t properties{};
HIP_CHECK(hipGetDeviceProperties(&properties, 0));
std::printf("device=%s arch=%s\n", properties.name, properties.gcnArchName);
constexpr int size = 4096;
std::vector<int> a(size), b(size), c(size);
for (int i = 0; i < size; ++i) {
a[i] = i;
b[i] = i * 2;
}
int *device_a = nullptr;
int *device_b = nullptr;
int *device_c = nullptr;
HIP_CHECK(hipMalloc(reinterpret_cast<void **>(&device_a), size * sizeof(int)));
HIP_CHECK(hipMalloc(reinterpret_cast<void **>(&device_b), size * sizeof(int)));
HIP_CHECK(hipMalloc(reinterpret_cast<void **>(&device_c), size * sizeof(int)));
HIP_CHECK(hipMemcpy(device_a, a.data(), size * sizeof(int), hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy(device_b, b.data(), size * sizeof(int), hipMemcpyHostToDevice));
hipLaunchKernelGGL(add, dim3((size + 255) / 256), dim3(256), 0, 0,
device_a, device_b, device_c, size);
HIP_CHECK(hipGetLastError());
HIP_CHECK(hipDeviceSynchronize());
HIP_CHECK(hipMemcpy(c.data(), device_c, size * sizeof(int), hipMemcpyDeviceToHost));
for (int i = 0; i < size; ++i) {
if (c[i] != i * 3) {
std::fprintf(stderr, "mismatch at %d: %d\n", i, c[i]);
return 3;
}
}
HIP_CHECK(hipFree(device_a));
HIP_CHECK(hipFree(device_b));
HIP_CHECK(hipFree(device_c));
std::puts("HIP vector add: PASS");
return 0;
}
@@ -0,0 +1,15 @@
summary: Discover a single AMD GPU with rocminfo
test: ./test.sh
tag:
- functional
- rocm-gpu
- gpu
- single-gpu
duration: 2m
tier: 1
path: /tests/functional/pkgs/rocm-gpu/test_rocm_gpu_info
require:
- coreutils
- gawk
- grep
- beakerlib
+41
View File
@@ -0,0 +1,41 @@
#!/bin/bash
# Discover one AMD GPU agent with rocminfo.
. /usr/share/beakerlib/beakerlib.sh || exit 1
. "$(dirname "$0")/../lib.sh"
ROCM_GPU_TEST_PACKAGES=(
rocminfo
)
rlJournalStart
rlPhaseStartSetup "Environment setup"
rlRun "rocmGpuSetup \"\${ROCM_GPU_TEST_PACKAGES[@]}\"" 0 "Install ROCm packages"
TmpDir=$(mktemp -d)
rlRun "cd $TmpDir" 0
rlRun "test -r /dev/kfd && test -w /dev/kfd" 0 "Check KFD access"
rlPhaseEnd
rlPhaseStartTest "Discover a single AMD GPU agent"
rlRun "rocminfo > rocminfo.txt 2>&1" 0 \
"Query HSA agents"
rlRun "cat rocminfo.txt" 0 "Print rocminfo output"
rlRun "grep -E '^[[:space:]]*Uuid:[[:space:]]+GPU-' rocminfo.txt > gpu-agents.txt" 0 \
"Find GPU agents"
rlRun "test \"\$(wc -l < gpu-agents.txt)\" -eq 1" 0 \
"Check for one GPU agent"
rlRun "grep -E '^[[:space:]]*Name:[[:space:]]+gfx[0-9]+' rocminfo.txt | awk '{print \$2}' | sort -u > gpu-architectures.txt" 0 \
"Find GPU architectures"
rlRun "cat gpu-architectures.txt" 0 "Print GPU architecture"
rlAssertGrep "Marketing Name:[[:space:]]*[^[:space:]]" rocminfo.txt
rlPhaseEnd
rlPhaseStartCleanup "Clean up test environment"
rlRun "cd /" 0
if [ -n "$TmpDir" ] && [ -d "$TmpDir" ]; then
rlRun "rm -rf $TmpDir" 0 "Remove temporary files"
fi
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
@@ -0,0 +1,14 @@
summary: Query a single AMD GPU with rocm-smi
test: ./test.sh
tag:
- functional
- rocm-gpu
- gpu
- single-gpu
duration: 2m
tier: 1
path: /tests/functional/pkgs/rocm-gpu/test_rocm_gpu_smi
require:
- coreutils
- grep
- beakerlib
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
# Query one AMD GPU with rocm-smi.
. /usr/share/beakerlib/beakerlib.sh || exit 1
. "$(dirname "$0")/../lib.sh"
ROCM_GPU_TEST_PACKAGES=(
rocm-smi
)
rlJournalStart
rlPhaseStartSetup "Environment setup"
rlRun "rocmGpuSetup \"\${ROCM_GPU_TEST_PACKAGES[@]}\"" 0 "Install ROCm packages"
TmpDir=$(mktemp -d)
rlRun "cd $TmpDir" 0
rlRun "test -r /dev/kfd && test -w /dev/kfd" 0 "Check KFD access"
rlPhaseEnd
rlPhaseStartTest "Query a single AMD GPU"
rlRun "rocm-smi --showproductname --showuniqueid --showbus > rocm-smi.txt 2>&1" 0 \
"Query GPU identity"
rlRun "cat rocm-smi.txt" 0 "Print rocm-smi output"
rlAssertGrep 'GPU\[[0-9]\+\]' rocm-smi.txt
rlAssertNotGrep "No AMD GPUs specified" rocm-smi.txt
rlAssertNotGrep "ERROR:" rocm-smi.txt
rlPhaseEnd
rlPhaseStartCleanup "Clean up test environment"
rlRun "cd /" 0
if [ -n "$TmpDir" ] && [ -d "$TmpDir" ]; then
rlRun "rm -rf $TmpDir" 0 "Remove temporary files"
fi
rlPhaseEnd
rlJournalPrintText
rlJournalEnd