Skip to content

Commit

Permalink
Avoid detecting unwanted fences in the parallel_scan_no_fence test
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed Feb 22, 2024
1 parent e2689ab commit e2c810e
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions core/unit_test/tools/TestEventCorrectness.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,19 @@ TEST(kokkosp, parallel_scan_no_fence) {
<< "skipping since the OpenMPTarget backend has unexpected fences";
#endif

// Execute the parallel_scan first without looking for fence events.
// Depending on the backend implementation and the order of tests,
// it might be that the first call to parallel_scan is reallocating scratch
// memory which implies a fence when deallocating. We are not interested in
// detecting this event.
TestScanFunctor tf;
Kokkos::parallel_scan("dogs", Kokkos::RangePolicy<>(0, 1), tf);

using namespace Kokkos::Test::Tools;
listen_tool_events(Config::DisableAll(), Config::EnableKernels(),
Config::EnableFences());
auto success = validate_absence(
[=]() {
TestScanFunctor tf;
Kokkos::parallel_scan("dogs", Kokkos::RangePolicy<>(0, 1), tf);
},
[=]() { Kokkos::parallel_scan("dogs", Kokkos::RangePolicy<>(0, 1), tf); },
[=](BeginFenceEvent begin_event) {
if (begin_event.name.find("Debug Only Check for Execution Error") !=
std::string::npos ||
Expand Down Expand Up @@ -450,13 +455,20 @@ TEST(kokkosp, parallel_scan_no_fence_view) {
<< "skipping since the OpenMPTarget backend has unexpected fences";
#endif

// Execute the parallel_scan first without looking for fence events.
// Depending on the backend implementation and the order of tests,
// it might be that the first call to parallel_scan is reallocating scratch
// memory which implies a fence when deallocating. We are not interested in
// detecting this event.
TestScanFunctor tf;
Kokkos::View<typename TestScanFunctor::value_type> v("scan_result");
Kokkos::parallel_scan("dogs", Kokkos::RangePolicy<>(0, 1), tf, v);

using namespace Kokkos::Test::Tools;
listen_tool_events(Config::DisableAll(), Config::EnableKernels(),
Config::EnableFences());
Kokkos::View<typename TestScanFunctor::value_type> v("scan_result");
auto success = validate_absence(
[=]() {
TestScanFunctor tf;
Kokkos::parallel_scan("dogs", Kokkos::RangePolicy<>(0, 1), tf, v);
},
[=](BeginFenceEvent begin_event) {
Expand Down

0 comments on commit e2c810e

Please sign in to comment.