Skip to content

Commit

Permalink
kp_sampler: fix name of seed environment varable and else condition f…
Browse files Browse the repository at this point in the history
…or seed for user input + README
  • Loading branch information
vlkale committed Oct 26, 2023
1 parent 27ea88d commit ad08a5e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions common/kokkos-sampler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ This is a sampler utility that is intended to complement other tools in the Kokk
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.

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.
4 changes: 1 addition & 3 deletions common/kokkos-sampler/kp_sampler_skip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
const uint32_t devInfoCount, void* deviceInfo) {
const char* tool_verbose_str = getenv("KOKKOS_TOOLS_SAMPLER_VERBOSE");
const char* tool_globFence_str = getenv("KOKKOS_TOOLS_GLOBALFENCES");
const char* tool_seed_str = getenv("KOKKOS_TOOLS_SEED");
const char* tool_seed_str = getenv("KOKKOS_TOOLS_RANDOM_SEED");

if (NULL != tool_verbose_str) {
tool_verbosity = atoi(tool_verbose_str);
Expand All @@ -102,8 +102,6 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
}
if (NULL != tool_seed_str) {
tool_seed = atoi(tool_seed_str);
} else {
tool_seed = 1;
}

char* profileLibrary = getenv("KOKKOS_TOOLS_LIBS");
Expand Down

0 comments on commit ad08a5e

Please sign in to comment.