Add event re-enqueue integration test#29
Add event re-enqueue integration test#29psychocoderHPC wants to merge 1 commit intopr-add-reusable-event-multi-handoff-testfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/integ/eventReEnqueue/eventReEnqueue.cpp`:
- Around line 33-37: The current early-return in the device availability check
(if(!devSelector.isAvailable()) { ... return; }) causes tests to be marked as
passed; replace the plain return with Catch2's skip macro (e.g., SKIP("No device
available for " + deviceSpec.getName()) or CATCH_SKIP(...) depending on project
configuration) so the branch in devSelector.isAvailable() records an explicit
skipped test using the message that includes deviceSpec.getName().
- Around line 40-41: The test currently creates producerQueue and consumerQueue
with device.makeQueue(queueKind::blocking), which serializes enqueues and hides
event re-enqueue bugs; update both calls to use queueKind::nonBlocking so
producerQueue and consumerQueue are non-blocking and the asynchronous race
around consumerQueue.waitFor(readyEvent) can surface stale-event failures
(change device.makeQueue(queueKind::blocking) to
device.makeQueue(queueKind::nonBlocking) for the producerQueue and consumerQueue
declarations).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 342e4cab-8771-426c-adf1-5df20f187a44
📒 Files selected for processing (1)
test/integ/eventReEnqueue/eventReEnqueue.cpp
| if(!devSelector.isAvailable()) | ||
| { | ||
| std::cout << "No device available for " << deviceSpec.getName() << std::endl; | ||
| return; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify the project Catch2 version/macros and existing skip style.
rg -n -C2 'catch2|Catch2' CMakeLists.txt **/CMakeLists.txt 2>/dev/null || true
rg -n -C2 '\bSKIP\(|\bCATCH_SKIP\('Repository: psychocoderHPC/alpaka3
Length of output: 1799
🌐 Web query:
Catch2 SKIP macro syntax version 3
💡 Result:
In Catch2 v3, the runtime-skip macro is:
- Syntax:
SKIP( [streamable expression] )(the message is optional, soSKIP()is valid) [1] - Example:
[1]
TEST_CASE("copy files between drives") { if (getNumberOfHardDrives() < 2) { SKIP("at least two hard drives required"); } // ... }
Notes:
SKIPwas introduced in Catch2 3.3.0. [1]- Like an explicit
FAIL,SKIPstops execution of the current test/section at that point. [1]
Sources: [1]
🌐 Web query:
Catch2 CATCH_SKIP vs SKIP macro
💡 Result:
In Catch2, SKIP(...) and CATCH_SKIP(...) are the same feature, just exposed under different naming depending on configuration:
SKIP(...)is the default user-facing macro (when you are not prefixing all macros). It records an explicit skip and then immediately aborts the current test case/section (similar control-flow toFAIL). [1][2]CATCH_SKIP(...)is the prefixed equivalent that is only provided when you compile withCATCH_CONFIG_PREFIX_ALL(to avoid macro name collisions by prefixing everything withCATCH_). Its implementation is the same (explicit skip + abort). [1]
Notes:
- Runtime skipping via
SKIP/CATCH_SKIPwas introduced in Catch2 v3.3.0. [2]
Sources:
[1] Catch2 header (catch_test_macros.hpp) showing CATCH_SKIP vs SKIP definitions (prefixed vs unprefixed). (raw.githubusercontent.com)
[2] Catch2 docs: “Explicitly skipping… at runtime” (SKIP macro, behavior, version introduced). (catch2-temp.readthedocs.io)
Citations:
- 1: https://raw.githubusercontent.com/catchorg/Catch2/devel/src/catch2/catch_test_macros.hpp
- 2: https://catch2-temp.readthedocs.io/en/latest/skipping-passing-failing.html
Mark unavailable-device cases as skipped instead of passed.
On Line 36, return; marks "no device" as a passing test. Use Catch2's SKIP() macro (available in v3.3.0+) to report this case explicitly.
Proposed change
if(!devSelector.isAvailable())
{
- std::cout << "No device available for " << deviceSpec.getName() << std::endl;
- return;
+ SKIP(std::string("No device available for ") + deviceSpec.getName());
}Note: Ensure the correct macro name (SKIP or CATCH_SKIP if prefixed) matches your project's Catch2 configuration. The SKIP() macro stops test execution and records an explicit skip in CI reports.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if(!devSelector.isAvailable()) | |
| { | |
| std::cout << "No device available for " << deviceSpec.getName() << std::endl; | |
| return; | |
| } | |
| if(!devSelector.isAvailable()) | |
| { | |
| SKIP(std::string("No device available for ") + deviceSpec.getName()); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@test/integ/eventReEnqueue/eventReEnqueue.cpp` around lines 33 - 37, The
current early-return in the device availability check
(if(!devSelector.isAvailable()) { ... return; }) causes tests to be marked as
passed; replace the plain return with Catch2's skip macro (e.g., SKIP("No device
available for " + deviceSpec.getName()) or CATCH_SKIP(...) depending on project
configuration) so the branch in devSelector.isAvailable() records an explicit
skipped test using the message that includes deviceSpec.getName().
| onHost::Queue producerQueue = device.makeQueue(queueKind::blocking); | ||
| onHost::Queue consumerQueue = device.makeQueue(queueKind::blocking); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify available queue kinds and existing async test patterns.
rg -n -C2 'enum class queueKind|queueKind::blocking|queueKind::nonBlocking'
rg -n -C3 'waitFor\(|enqueue\(readyEvent\)|makeQueue\(queueKind::'Repository: psychocoderHPC/alpaka3
Length of output: 1792
🏁 Script executed:
#!/bin/bash
# Search for queue kind enum and usage patterns
find . -type f -name "*.hpp" -o -name "*.h" -o -name "*.cpp" | head -20Repository: psychocoderHPC/alpaka3
Length of output: 914
🏁 Script executed:
#!/bin/bash
# Search for queueKind enum definition and usage
rg -n "enum.*queueKind|queueKind::" --type cpp --type hpp | head -50Repository: psychocoderHPC/alpaka3
Length of output: 93
🏁 Script executed:
#!/bin/bash
# Search for queueKind enum definition and usage
rg -n "enum.*queueKind|queueKind::" | head -60Repository: psychocoderHPC/alpaka3
Length of output: 6549
🏁 Script executed:
#!/bin/bash
# Read the eventReEnqueue test file to understand the test logic
cat test/integ/eventReEnqueue/eventReEnqueue.cppRepository: psychocoderHPC/alpaka3
Length of output: 2742
Use non-blocking queues to properly test event re-enqueue semantics.
Blocking queues serialize all enqueue operations, completing them before consumerQueue.waitFor(readyEvent) executes. This masks failures in event re-enqueue—if the event doesn't move to the later kernel completion point, the test still passes because all work is already done. Non-blocking queues create an actual asynchronous race where a stale event would cause the consumer to observe pre-kernel data.
Change lines 40–41 to use queueKind::nonBlocking:
Proposed change
- onHost::Queue producerQueue = device.makeQueue(queueKind::blocking);
- onHost::Queue consumerQueue = device.makeQueue(queueKind::blocking);
+ onHost::Queue producerQueue = device.makeQueue(queueKind::nonBlocking);
+ onHost::Queue consumerQueue = device.makeQueue(queueKind::nonBlocking);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onHost::Queue producerQueue = device.makeQueue(queueKind::blocking); | |
| onHost::Queue consumerQueue = device.makeQueue(queueKind::blocking); | |
| onHost::Queue producerQueue = device.makeQueue(queueKind::nonBlocking); | |
| onHost::Queue consumerQueue = device.makeQueue(queueKind::nonBlocking); |
🧰 Tools
🪛 Cppcheck (2.20.0)
[error] 40-40: Found an exit path from function with non-void return type that has missing return statement
(missingReturn)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@test/integ/eventReEnqueue/eventReEnqueue.cpp` around lines 40 - 41, The test
currently creates producerQueue and consumerQueue with
device.makeQueue(queueKind::blocking), which serializes enqueues and hides event
re-enqueue bugs; update both calls to use queueKind::nonBlocking so
producerQueue and consumerQueue are non-blocking and the asynchronous race
around consumerQueue.waitFor(readyEvent) can surface stale-event failures
(change device.makeQueue(queueKind::blocking) to
device.makeQueue(queueKind::nonBlocking) for the producerQueue and consumerQueue
declarations).
Split from local commit
3394db6640b67d9c31d285a8b4b9bd510cb1331d.Base branch:
pr-add-reusable-event-multi-handoff-test.Summary by CodeRabbit