Skip to content

Commit

Permalink
test_parscan.cpp: fix sampler scan
Browse files Browse the repository at this point in the history
  • Loading branch information
vlkale authored Apr 10, 2024
1 parent 22ba2e4 commit d8a492e
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions tests/sampler/test_parscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ using ::testing::Not;
struct Tester {
template <typename execution_space>
explicit Tester(const execution_space& space) {
//! Explicitly launch a kernel with a name, and run it 150 times with kernel
//! logger. Use a periodic sampling with skip rate 51. This should print
//! Explicitly launch a kernel with a name, and run it 15 times with kernel
//! logger. Use a periodic sampling with skip rate 5. This should print
//! out 2 invocations, and there is a single matcher with a regular
//! expression to check this.

long int N = 1024;
long int result;

for (int iter = 0; iter < 150; iter++) {
for (int iter = 0; iter < 15; iter++) {
result = 0;
Kokkos::parallel_scan("named kernel scan", N, *this, result);
}
Expand All @@ -30,21 +30,20 @@ struct Tester {
};

static const std::vector<std::string> matchers{
"KokkosP: sample 51 calling child-begin function...",
"KokkosP: sample 51 finished with child-begin function.",
"KokkosP: sample 51 calling child-end function...",
"KokkosP: sample 51 finished with child-end function.",
"KokkosP: sample 102 calling child-begin function...",
"KokkosP: sample 102 finished with child-begin function.",
"KokkosP: sample 102 calling child-end function...",
"KokkosP: sample 102 finished with child-end function."};
"KokkosP: sample 6 calling child-begin function...",
"KokkosP: sample 6 finished with child-begin function.",
"KokkosP: sample 6 calling child-end function...",
"KokkosP: sample 6 finished with child-end function.",
"KokkosP: sample 11 calling child-begin function...",
"KokkosP: sample 11 finished with child-begin function.",
"KokkosP: sample 11 calling child-end function...",
"KokkosP: sample 11 finished with child-end function."};

/**
* @test This test checks that the tool effectively samples.
*
*/

TEST(SamplerTest, ktoEnvVarDefault) {
//! Initialize @c Kokkos.
Kokkos::initialize();
Expand All @@ -71,8 +70,27 @@ TEST(SamplerTest, ktoEnvVarDefault) {
}

EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 1 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 75 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 149 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 2 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 3 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 4 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 5 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 7 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 8 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 9 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 10 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 12 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 13 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 14 calling")));
EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 15 calling")));

int occurrences = 0;
while (std::string::size_type pos = 0;
(pos = s.find("calling child-begin function", pos)) !=
std::string::npos) {
++occurrences;
pos += target.length();
}
EXPECT_EQ(occurrences, 2);

EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: FATAL: No child library of "
"sampler utility library to call")));
Expand Down

0 comments on commit d8a492e

Please sign in to comment.