Skip to content

Commit 942ff99

Browse files
zjgarveyclaude
andcommitted
test: kind-aware AQL doorbell (H2D/D2H roundtrip)
32 H2D/D2H roundtrips with data-integrity checks; each rings the AQL queue doorbell, so on a USER-kind-doorbell runtime (nightly MI300X) this repeatedly exercises the hsa_signal_store_screlease doorbell path. Verified on MI300X (98 assertions). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: zjgarvey <zjgarvey@gmail.com>
1 parent d84ace0 commit 942ff99

3 files changed

Lines changed: 65 additions & 1 deletion

File tree

tests/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ add_subdirectory(kernel_smoke)
2424
add_subdirectory(multithread)
2525

2626
# Graph API:
27-
add_subdirectory(graph)
27+
add_subdirectory(graph)
28+
29+
# Nightly ROCm bring-up regression tests:
30+
add_subdirectory(aql_doorbell)

tests/aql_doorbell/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2026 The IREE Authors
2+
#
3+
# Licensed under the Apache License v2.0 with LLVM Exceptions.
4+
# See https://llvm.org/LICENSE.txt for license information.
5+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
7+
add_hip_cts_test(aql_doorbell_test
8+
SOURCES aql_doorbell_test.cpp
9+
)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2026 The IREE Authors
2+
//
3+
// Licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
7+
// Nightly ROCm on MI300X returns a USER-kind queue doorbell signal (not
8+
// DOORBELL-kind), so the cached doorbell union slot is a signal value, not a
9+
// writable MMIO address. A raw atomic store to that slot faults — every H2D
10+
// copy / kernel dispatch would SEGV; the doorbell must be rung via
11+
// hsa_signal_store_screlease for USER/interrupt-kind doorbells.
12+
//
13+
// Each AQL submission rings the doorbell, so a stream of copies with integrity
14+
// checks exercises that path repeatedly on the affected hardware. GPU required;
15+
// the SEGV only reproduces on a USER-kind-doorbell runtime.
16+
17+
#include <algorithm>
18+
#include <cstdint>
19+
#include <vector>
20+
21+
#include <catch2/catch_test_macros.hpp>
22+
#include "hip_loader.hpp"
23+
#include "hip_test_fixture.hpp"
24+
25+
TEST_CASE_METHOD(HipTestFixture,
26+
"Repeated H2D/D2H roundtrips ring the doorbell correctly",
27+
"[memcpy][doorbell][nightly]") {
28+
const size_t kCount = 1u << 20; // 1M uint32 = 4 MiB
29+
const size_t kBytes = kCount * sizeof(uint32_t);
30+
std::vector<uint32_t> host_in(kCount);
31+
std::vector<uint32_t> host_out(kCount, 0u);
32+
for (size_t i = 0; i < kCount; ++i) {
33+
host_in[i] = static_cast<uint32_t>(i * 2654435761u);
34+
}
35+
36+
void* dev = nullptr;
37+
REQUIRE(hip().hipMalloc(&dev, kBytes) == hipSuccess);
38+
39+
// 32 doorbell rings (H2D + D2H each). On USER-kind-doorbell hardware a raw
40+
// doorbell store faults on the first ring; a correct runtime copies and the
41+
// data round-trips intact.
42+
for (int iter = 0; iter < 32; ++iter) {
43+
REQUIRE(hip().hipMemcpy(dev, host_in.data(), kBytes,
44+
hipMemcpyHostToDevice) == hipSuccess);
45+
std::fill(host_out.begin(), host_out.end(), 0u);
46+
REQUIRE(hip().hipMemcpy(host_out.data(), dev, kBytes,
47+
hipMemcpyDeviceToHost) == hipSuccess);
48+
REQUIRE(host_out == host_in);
49+
}
50+
51+
REQUIRE(hip().hipFree(dev) == hipSuccess);
52+
}

0 commit comments

Comments
 (0)