Skip to content

Commit

Permalink
Prob smplr (#16)
Browse files Browse the repository at this point in the history
* CMakeLists.txt: add_library to kp_add_library

Sampler's CMakeLists.txt: add_library to kp_add_library

* kp_core.hpp: remove pointer from ptpi

* kp_sampler_skip.cpp: pass by value kokkosp_p_t_p_i

kp_sampler_skip.cpp: last parameter should be passed by value rather than pointer in kokkosp_p_t_p_i

* kp_sampler_skip.cpp: remove dereference assignment for ptpi callback

* kp_core.hpp: apply clang-format

* Create test_sampler.cpp

* CMakeLists.txt: set up test for sampler

* test_sampler.cpp: put in code for sampler test

* test_sampler.cpp: typo in comment (2 invocation --> 2 invocations)

* CMakeLists.txt: support sampler test

* kp_sampler_skip.cpp: change printf to std::out for ctests

* kp_sampler_skip.cpp: include iostream for std::cout

* Update kp_sampler_skip.cpp: \n instead of std::endl

\n is faster for performance

* kp_sampler_skip.cpp: apply clang format

* kp_sampler_skip.cpp: fix for std::out of tool-invoked fence verbose debug print

* kp_sampler_skip.cpp: apply clang format

* Rename test_sampler.cpp to test_parfor.cpp

* Update CMakeLists.txt: reduce and scan sampling tests

* Create test_parreduce.cpp

* Create test_parscan.cpp

* Update test_parreduce.cpp: parallel_reduce function 

Test based on example shown at: https://kokkos.org/kokkos-core-wiki/API/core/parallel-dispatch/parallel_reduce.html

* test_parscan.cpp: put in test for sampling parallel_scan

Parallel scan sampling test based on example here: 

https://kokkos.org/kokkos-core-wiki/API/core/parallel-dispatch/parallel_scan.html

* Update test_parreduce.cpp: fix x[i] to x(i) 

View  index access of x does not use []

* Update test_parreduce.cpp: Kokkos:: for View

* test_parreduce.cpp: reduce lambda

* Update test_parscan.cpp: operator for cuda/hip build

* test_parscan.cpp: support scan test function

* test_parreduce.cpp: reduction operator second argument 

second argument

* test_parscan.cpp: fix scan test operator

* Update test_parscan.cpp: fix scan test to have to Views

* test_parscan.cpp: policy to size

* Update kp_kernel_logger.cpp: fix typo for scan callback

The typo was kokkospk_end_parallel_scan. This causes the third test for the sampler to fail.

* test_parscan.cpp: apply clang format

* test_parreduce.cpp: apply clang format

* CMakeLists.txt: add_library -> kp_add_library

* kp_sampler_skip.cpp: put in prob samplr

* CMakeLists.txt: sampling prob test

* Create test_parfor_prob.cpp

* Create test_parreduce_prob.cpp

* Create test_parscan_prob.cpp

* test_parfor_prob.cpp: edit matchers for prob sampling

* test_parreduce_prob.cpp: fix matchers

* Update test_parscan_prob.cpp: fix parscan test matchers

* Update test_parscan_prob.cpp: fix test comments

* test_parfor_prob.cpp: fix comments

* Update test_parreduce_prob.cpp: fix comments

* test_parfor.cpp: update matcher

* Update test_parscan.cpp: fix matchers

* test_parreduce.cpp: matchers fix

* Update kp_sampler_skip.cpp: add cout for end_parallel_xxx

* Update test_parfor.cpp: put in finished with end in matchers

* Update test_parscan.cpp: update matchers / comments removal

* test_parreduce.cpp: fix matchers

* Update kp_sampler_skip.cpp: fix elipses

* test_parscan.cpp: apply clang format

* CMakeLists.txt: skip rate is 0

* test_parscan.cpp: apply clang format

* test_parfor_prob.cpp: apply clang format

* Update README.md: add sampler entry

* test_parreduce_prob.cpp: apply clang format

* kp_sampler_skip.cpp: apply clang format

* README.md: sampler README for probability

* test_parreduce.cpp: fix int ref in operator

* test_parscan.cpp: int ref in operator

* test_parscan.cpp: long int in signature

* test_parreduce.cpp: long int in second argument to operator

* Update test_parreduce.cpp: change sum to int type

* Update test_parreduce.cpp: declare sum as long int

* Update kp_kernel_logger.cpp: kokkospk_end_parallel_scan --> kokkosp_end_parallel_scan

* Update README.md

Co-authored-by: Daniel Arndt <[email protected]>

* Update test_parfor.cpp

* test_parfor.cpp: put in fence test

* Update test_parfor.cpp: put in checks for number of calls and Null Ptr fence

* test_parfor.cpp: apply clang format

* fix test par for

* test_parfor.cpp: apply clang format

* kp_sampler_skip.cpp: fix sampler std::cout prints for test

* test_parfor.cpp: apply clang format

* test_parfor.cpp: fixing matcher string for number contains

* Update test_parfor.cpp: not substr

* test_parfor.cpp: apply clang format

* kp_sampler_skip.cpp: apply clang format

* test_parfor.cpp: apply clang format

* test_parfor.cpp: apply clang format

* Update test_parfor.cpp

* test_parfor.cpp: apply clang format

* test_parfor.cpp: Times function

* delete file accidentally put in tests directory

* Update test_parfor.cpp: remove AtMost

* Update test_parfor.cpp: remove using AtMost

* kp_sampler_skip.cpp: put back in

* Update test_parreduce.cpp

* test_parfor.cpp: remove count for number of times

* Update test_parscan.cpp

* Update test_parfor.cpp: removing Contains

* kp_sampler_skip.cpp: apply clang format

* test_parfor.cpp: apply clang format

* test_parreduce.cpp: apply clang format

* test_parscan.cpp: apply clang format

* Update test_parfor.cpp: putting in times

* test_parfor.cpp: apply clang format

* Update test_parreduce.cpp: put in times

* test_parscan.cpp: put in times test

* test_parscan.cpp: apply clang format

* test_parreduce.cpp: apply clang format

* test_parscan.cpp: apply clang format

* test_parscan.cpp: apply clang format

* test_parreduce.cpp: apply clang format

* test_parfor.cpp: apply clang format

* test_parfor.cpp: apply clang format

* test_parreduce.cpp: apply clang format

* test_parscan.cpp: apply clang format

* kp_sampler_skip.cpp: std::cout to std::cerr

Co-authored-by: Daniel Arndt <[email protected]>

* test_parscan.cpp: fix declaration for variable result

Co-authored-by: Damien L-G <[email protected]>

* test_parfor.cpp: revisions of tests PR review

* test_parreduce.cpp: fix with new tests

* test_parscan.cpp: fix sampler scan

* test_parreduce.cpp: fix with correct samples and comments

* CMakeLists.txt: fix sampler skip rate

* test_parfor.cpp: add string header

* test_parreduce.cpp: add string header

* test_parscan.cpp: add string header

* Update test_parfor.cpp: fix output

* test_parreduce.cpp: fix test

* test_parscan.cpp: fix occurrences variable

* test_parfor.cpp: apply clang format

* test_parreduce.cpp: apply clang format

* test_parscan.cpp: apply clang format

* test_parreduce.cpp: apply clang format

* test_parfor.cpp: fix sampler number from 11 to 12

* test_parreduce.cpp: sample number from 11 to 12

* test_parscan.cpp: change sample from 11 to 12

* kp_sampler_skip.cpp: revert cerr to cout

* CMakeLists.txt: make global fences 0

* CMakeLists.txt: remove setting of global fence environment variable

* Put in tests for sampler  (kokkos#248)

* CMakeLists.txt: tests for prob sampling

Without fence and with fence

* parreduce.hpp: file for parallel reduce

* Update parreduce.hpp: putting once pragma for header

* parfor.hpp: header file for parfor

* parfor.hpp: put in code for Kokkos parallel for test

* Create parscan.hpp: parscan code file

* parscan.hpp: put in code for scan

* test_parreduce.cpp: deleting parreduce header

* test_parscan.cpp: using header for parscan

* test_parfor.cpp: parfor header

* test_parfor_prob.cpp: header

* test_parreduce_prob.cpp: putting in parreduce hpp

* test_parscan_prob.cpp: fix includes

* test_parreduce_prob.cpp: HasSubStr to HasSubstr

* new MatchersProb based on random seed two from CI build test OpenMP

* matchersProb.hpp: update

* test_par*_prob.cpp: apply clang format

* test_parfor.cpp: apply clang format

* matchersProb.hpp: fix to matchers - apply clang format

* matchersProb.hpp: fix to matchers semicolon apply clang format

* matchersProb.hpp: fix to matchers semicolon apply clang format

---------

Co-authored-by: Christian Trott <[email protected]>
Co-authored-by: Damien L-G <[email protected]>
Co-authored-by: Daniel Arndt <[email protected]>
Co-authored-by: Damien L-G <[email protected]>
  • Loading branch information
5 people authored Apr 11, 2024
1 parent c16004a commit 3178c8b
Show file tree
Hide file tree
Showing 17 changed files with 652 additions and 40 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ void foo() {
The following provides an overview of the tools available in the set of Kokkos Tools. Click on each Kokkos Tools name to see more details about the tool via the Kokkos Tools Wiki.

### Utilities

+ [**KernelFilter:**](https://github.com/kokkos/kokkos-tools/wiki/KernelFilter)

A tool which is used in conjunction with analysis tools, to restrict them to a subset of the application.

+ [**KernelSampler:**](https://github.com/kokkos/kokkos-tools/wiki/KernelSampler)

A tool to be used in conjunction with analysis tools to restrict the tooling to samples of Kokkos kernel invocations.

### Memory Analysis
+ [**MemoryHighWater:**](https://github.com/kokkos/kokkos-tools/wiki/MemoryHighWater)

Expand Down
9 changes: 5 additions & 4 deletions common/kokkos-sampler/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
This is a sampler utility that is intended to complement other tools in the Kokkos Tools set. This utility allows for sampling of profiling or debugging data collected from a particular tool of the Kokkos Tools set at each Kokkos kernel invocation.


To use this utility, a Kokkos Tools user provides a sampling probability by setting the environment variable `KOKKOS_TOOLS_SAMPLER_PROB` to a positive real number between 0.0 and 100.0. The user can alternatively set a sampling skip rate, i.e., the number of Kokkos kernel invocations to skip before the next sample is taken. The user does so by setting the environment variable `KOKKOS_TOOLS_SAMPLER_SKIP` to a non-negative integer.

If both sampling probability and sampling skip rate are set by the user, this sampling utility only uses the sampling probability for sampling; the utility sets the sampling skip rate to 1, incorporating no pre-defined periodicity in sampling. If neither sampling probability nor the sampling skip rate are set by the user, then purely random sampling is againdone, with the sampler's probability being 10.0 percent. The sampler is periodic only if the sampling probability is not set by the user _and_ the sampling skip rate is set by the user.
For the randomized sampling, the user can ensure reproducibility by setting `KOKKOS_TOOLS_RANDOM_SEED` to any integer. If this environment variable is not set, the seed is based on
the C time function.
If both sampling probability and sampling skip rate are set by the user, this sampling utility only uses the sampling probability for sampling; the utility sets the sampling skip rate to 1, incorporating no pre-defined periodicity in sampling. If neither sampling probability nor the sampling skip rate are set by the user, then purely random sampling is done, with the sampler's probability being 10.0 percent. The sampler is periodic only if the sampling probability is not set by the user and the sampling skip rate is set by the user.

For the randomized sampling, the user can ensure reproducibility across multiple runs of a Kokkos application by setting `KOKKOS_TOOLS_RANDOM_SEED` to an integer value before all of the runs. If this environment variable is not set, the seed is based on the C time function.

For the state of the sampled profiling and logging data in memory to be captured at the time of the utility's callback invocation, it might be important to enforce fences. However, this also means that there are more synchronization points compared with running the program without the tool.This fencing behavior can be controlled by setting the environment variable `KOKKOS_TOOLS_GLOBALFENCES`. A non-zero value implies global fences on invocation of the tool. The default is not to introduce extra fences.
For the state of the sampled profiling and logging data in memory to be captured at the time of the utility's callback invocation, it might be important to enforce fences. However, this also means that there are more synchronization points compared with running the program without the tool. This fencing behavior can be controlled by setting the environment variable `KOKKOS_TOOLS_GLOBALFENCES`. A non-zero value implies global fences on invocation of the tool. The default is not to introduce extra fences.
15 changes: 14 additions & 1 deletion common/kokkos-sampler/kp_sampler_skip.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#include <cstdio>
#include <cstdint>
#include <cstdlib>
Expand Down Expand Up @@ -248,6 +249,7 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
<< tool_prob_num
<< " percent. The skip rate for sampler will not be used.\n";
}

kernelSampleSkip = 1;
}

Expand Down Expand Up @@ -294,6 +296,10 @@ void kokkosp_end_parallel_for(const uint64_t kID) {
invoke_ktools_fence(0);
}
(*endForCallee)(retrievedNestedkID);
if (tool_verbosity > 0) {
std::cout << "KokkosP: sample " << kID
<< " finished with child-end function.\n";
}
infokIDSample.erase(kID);
}
}
Expand Down Expand Up @@ -338,6 +344,10 @@ void kokkosp_end_parallel_scan(const uint64_t kID) {
invoke_ktools_fence(0);
}
(*endScanCallee)(retrievedNestedkID);
if (tool_verbosity > 0) {
std::cout << "KokkosP: sample " << kID
<< " finished with child-end function.\n";
}
infokIDSample.erase(kID);
}
}
Expand Down Expand Up @@ -381,8 +391,11 @@ void kokkosp_end_parallel_reduce(const uint64_t kID) {
if (tool_globFence) {
invoke_ktools_fence(0);
}

(*endReduceCallee)(retrievedNestedkID);
if (tool_verbosity > 0) {
std::cout << "KokkosP: sample " << kID
<< " finished with child-end function.\n";
}
infokIDSample.erase(kID);
}
}
Expand Down
Empty file added matchersProb.hpp
Empty file.
23 changes: 22 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
# KOKKOS_TOOLS_SAMPLER_VERBOSE : the test environment will receive the variable 'KOKKOS_TOOLS_SAMPLER_VERBOSE' that is set as the value of 1 for printing the sample has been taken
# KOKKOS_TOOLS_GLOBALFENCES : test environment receives the variable 'KOKKOS_TOOLS_GLOBALFENCES' that is set as the value of 1 to turn the tool's auto-fencing on.

# KOKKOS_TOOLS_SAMPLER_SKIP : test environment receives the variable 'KOKKOS_TOOLS_SAMPLER_SKIP' that is set as the value of the number of Kokkos kernel invocations to skip before a tooling activity is invoked.

function(kp_add_executable_and_test)
cmake_parse_arguments(kaeat_args "" "TARGET_NAME;SOURCE_FILE;KOKKOS_TOOLS_SAMPLER_VERBOSE;KOKKOS_TOOLS_GLOBALFENCES;KOKKOS_TOOLS_SAMPLER_SKIP" "KOKKOS_TOOLS_LIBS" ${ARGN})
cmake_parse_arguments(kaeat_args "" "TARGET_NAME;SOURCE_FILE;KOKKOS_TOOLS_SAMPLER_VERBOSE;KOKKOS_TOOLS_GLOBALFENCES;KOKKOS_TOOLS_SAMPLER_SKIP;KOKKOS_TOOLS_SAMPLER_PROB;KOKKOS_TOOLS_RANDOM_SEED" "KOKKOS_TOOLS_LIBS" ${ARGN})


if(NOT DEFINED kaeat_args_TARGET_NAME)
message(FATAL_ERROR "'TARGET_NAME' is a required argument.")
Expand Down Expand Up @@ -77,6 +80,24 @@ function(kp_add_executable_and_test)
PROPERTY
ENVIRONMENT "KOKKOS_TOOLS_SAMPLER_SKIP=${kaeat_args_KOKKOS_TOOLS_SAMPLER_SKIP}"
)
endif()

if (DEFINED kaeat_args_KOKKOS_TOOLS_SAMPLER_PROB)
set_property(
TEST ${kaeat_args_TARGET_NAME}
APPEND
PROPERTY
ENVIRONMENT "KOKKOS_TOOLS_SAMPLER_PROB=${kaeat_args_KOKKOS_TOOLS_SAMPLER_PROB}"
)
endif()

if (DEFINED kaeat_args_KOKKOS_TOOLS_RANDOM_SEED)
set_property(
TEST ${kaeat_args_TARGET_NAME}
APPEND
PROPERTY
ENVIRONMENT "KOKKOS_TOOLS_RANDOM_SEED=${kaeat_args_KOKKOS_TOOLS_RANDOM_SEED}"
)

endif()

Expand Down
81 changes: 80 additions & 1 deletion tests/sampler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,87 @@

## tests for skip rate 5, no fencing selected

kp_add_executable_and_test(
TARGET_NAME test_sampling_parfor
SOURCE_FILE test_parfor.cpp
KOKKOS_TOOLS_LIBS kp_kokkos_sampler kp_kernel_logger
KOKKOS_TOOLS_SAMPLER_VERBOSE 2
KOKKOS_TOOLS_SAMPLER_SKIP 50
KOKKOS_TOOLS_SAMPLER_SKIP 5
)

kp_add_executable_and_test(
TARGET_NAME test_sampling_parscan
SOURCE_FILE test_parscan.cpp
KOKKOS_TOOLS_LIBS kp_kokkos_sampler kp_kernel_logger
KOKKOS_TOOLS_SAMPLER_VERBOSE 2
KOKKOS_TOOLS_SAMPLER_SKIP 5
)

kp_add_executable_and_test(
TARGET_NAME test_sampling_parreduce
SOURCE_FILE test_parreduce.cpp
KOKKOS_TOOLS_LIBS kp_kokkos_sampler kp_kernel_logger
KOKKOS_TOOLS_SAMPLER_VERBOSE 2
KOKKOS_TOOLS_SAMPLER_SKIP 5
)

## tests for probability of 51.6% (with skip rate 0), no fencing selected

kp_add_executable_and_test(
TARGET_NAME test_sampling_prob_parfor
SOURCE_FILE test_parfor_prob.cpp
KOKKOS_TOOLS_LIBS kp_kokkos_sampler kp_kernel_logger
KOKKOS_TOOLS_SAMPLER_VERBOSE 2
KOKKOS_TOOLS_RANDOM_SEED 2
KOKKOS_TOOLS_SAMPLER_PROB 51.6
)

kp_add_executable_and_test(
TARGET_NAME test_sampling_prob_parscan
SOURCE_FILE test_parscan_prob.cpp
KOKKOS_TOOLS_LIBS kp_kokkos_sampler kp_kernel_logger
KOKKOS_TOOLS_SAMPLER_VERBOSE 2
KOKKOS_TOOLS_RANDOM_SEED 2
KOKKOS_TOOLS_SAMPLER_PROB 51.6
)

kp_add_executable_and_test(
TARGET_NAME test_sampling_prob_parreduce
SOURCE_FILE test_parreduce_prob.cpp
KOKKOS_TOOLS_LIBS kp_kokkos_sampler kp_kernel_logger
KOKKOS_TOOLS_SAMPLER_VERBOSE 2
KOKKOS_TOOLS_RANDOM_SEED 2
KOKKOS_TOOLS_SAMPLER_PROB 51.6
)

## tests for probability of 51.6% (with skip rate 0), with fences

kp_add_executable_and_test(
TARGET_NAME test_sampling_prob_parfor_fence
SOURCE_FILE test_parfor_prob.cpp
KOKKOS_TOOLS_LIBS kp_kokkos_sampler kp_kernel_logger
KOKKOS_TOOLS_SAMPLER_VERBOSE 2
KOKKOS_TOOLS_RANDOM_SEED 2
KOKKOS_TOOLS_SAMPLER_PROB 51.6
KOKKOS_TOOLS_GLOBALFENCES 1
)

kp_add_executable_and_test(
TARGET_NAME test_sampling_prob_parscan_fence
SOURCE_FILE test_parscan_prob.cpp
KOKKOS_TOOLS_LIBS kp_kokkos_sampler kp_kernel_logger
KOKKOS_TOOLS_SAMPLER_VERBOSE 2
KOKKOS_TOOLS_RANDOM_SEED 2
KOKKOS_TOOLS_SAMPLER_PROB 51.6
KOKKOS_TOOLS_GLOBALFENCES 1
)

kp_add_executable_and_test(
TARGET_NAME test_sampling_prob_parreduce_fence
SOURCE_FILE test_parreduce_prob.cpp
KOKKOS_TOOLS_LIBS kp_kokkos_sampler kp_kernel_logger
KOKKOS_TOOLS_SAMPLER_VERBOSE 2
KOKKOS_TOOLS_RANDOM_SEED 2
KOKKOS_TOOLS_SAMPLER_PROB 51.6
KOKKOS_TOOLS_GLOBALFENCES 1
)
42 changes: 42 additions & 0 deletions tests/sampler/matchersProb.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once

static const std::vector<std::string> matchers{
"KokkosP: sample 3 calling child-begin function...",
"KokkosP: sample 3 finished with child-begin function.",
"KokkosP: sample 3 calling child-end function...",
"KokkosP: sample 3 finished with child-end function.",

"KokkosP: sample 4 calling child-begin function...",
"KokkosP: sample 4 finished with child-begin function.",
"KokkosP: sample 4 calling child-end function...",
"KokkosP: sample 4 finished with child-end function.",

"KokkosP: sample 5 calling child-begin function...",
"KokkosP: sample 5 finished with child-begin function.",
"KokkosP: sample 5 calling child-end function...",
"KokkosP: sample 5 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 8 calling child-begin function...",
"KokkosP: sample 8 finished with child-begin function.",
"KokkosP: sample 8 calling child-end function...",
"KokkosP: sample 8 finished with child-end function.",

"KokkosP: sample 12 calling child-begin function...",
"KokkosP: sample 12 finished with child-begin function.",
"KokkosP: sample 12 calling child-end function...",
"KokkosP: sample 12 finished with child-end function.",

"KokkosP: sample 13 calling child-begin function...",
"KokkosP: sample 13 finished with child-begin function.",
"KokkosP: sample 13 calling child-end function...",
"KokkosP: sample 13 finished with child-end function.",

"KokkosP: sample 14 calling child-begin function...",
"KokkosP: sample 14 finished with child-begin function.",
"KokkosP: sample 14 calling child-end function...",
"KokkosP: sample 14 finished with child-end function."};
11 changes: 11 additions & 0 deletions tests/sampler/matchersSkip.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

static const std::vector<std::string> matchers{
"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 12 calling child-begin function...",
"KokkosP: sample 12 finished with child-begin function.",
"KokkosP: sample 12 calling child-end function...",
"KokkosP: sample 12 finished with child-end function."};
19 changes: 19 additions & 0 deletions tests/sampler/parfor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

struct Tester {
template <typename execution_space>
explicit Tester(const execution_space& space) {
//! 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 < 15; iter++) {
Kokkos::parallel_for("named kernel",
Kokkos::RangePolicy<execution_space>(space, 0, 1),
*this);
}
}

KOKKOS_FUNCTION void operator()(const int) const {}
};
21 changes: 21 additions & 0 deletions tests/sampler/parreduce.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

struct Tester {
template <typename execution_space>
explicit Tester(const execution_space& space) {
//! 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 sum;
for (int iter = 0; iter < 15; iter++) {
sum = 0;
Kokkos::parallel_reduce("named kernel reduce",
Kokkos::RangePolicy<execution_space>(space, 0, 1),
*this, sum);
}
}

KOKKOS_FUNCTION void operator()(const int, long int&) const {}
};
21 changes: 21 additions & 0 deletions tests/sampler/parscan.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

struct Tester {
template <typename execution_space>
explicit Tester(const execution_space& space) {
//! 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 < 15; iter++) {
result = 0;
Kokkos::parallel_scan("named kernel scan", N, *this, result);
}
}

KOKKOS_FUNCTION void operator()(const int, long int&, bool) const {}
};
Loading

0 comments on commit 3178c8b

Please sign in to comment.