Skip to content

Commit

Permalink
test_parfor.cpp: revisions of tests PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
vlkale committed Apr 10, 2024
1 parent fd36878 commit d146c28
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions tests/sampler/test_parfor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ 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.

for (int iter = 0; iter < 150; iter++) {
for (int iter = 0; iter < 15; iter++) {
Kokkos::parallel_for("named kernel",
Kokkos::RangePolicy<execution_space>(space, 0, 1),
*this);
Expand All @@ -29,14 +29,14 @@ 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.
Expand Down Expand Up @@ -69,8 +69,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 d146c28

Please sign in to comment.