Skip to content

Commit

Permalink
kp_sampler: set default seed to -1, tool fence verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivek Kale authored and Vivek Kale committed Oct 23, 2023
1 parent b629300 commit df84895
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions common/kokkos-sampler/kp_sampler_skip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static uint64_t kernelSampleSkip = std::numeric_limits<uint64_t>::max();
static double tool_prob_num = -1.0;
static int tool_verbosity = 0;
static int tool_globFence = 0;
static unsigned int tool_seed = 1;
static int tool_seed = -1;

// a hash table mapping kID to nestedkID
static std::unordered_map<uint64_t, uint64_t> infokIDSample;
Expand Down Expand Up @@ -51,11 +51,23 @@ uint32_t getDeviceID(uint32_t devid_in) {
}

void invoke_ktools_fence(uint32_t devID) {
if (tool_verbosity > 1) {
printf(
"KokkosP: Sampler utility finding"
" tool-induced fence function and invoking it.\n");
}

if (tpi_funcs.fence != nullptr) {
if (tool_verbosity > 1) {
printf(
"KokkosP: Sampler utility found fence function. Attempting to invoke"
" tool-induced fence on device %d.\n",
getDeviceID(devID));
}
tpi_funcs.fence(devID);
if (tool_verbosity > 1) {
printf(
"KokkosP: Sampler utility sucessfully invoked "
"KokkosP: Sampler utility sucessfully invoked"
" tool-induced fence on device %d\n",
getDeviceID(devID));
}
Expand Down Expand Up @@ -256,7 +268,7 @@ void kokkosp_init_library(const int loadSeq, const uint64_t interfaceVer,
srand(tool_seed);
if(tool_verbosity > 0) {
printf(
"KokkosP: seeding Random Number Generator using seed %u for "
"KokkosP: Seeding random number generator using seed %u for "
"probabilistic sampling.\n", tool_seed);
}
}
Expand Down Expand Up @@ -296,12 +308,16 @@ void kokkosp_begin_parallel_for(const char* name, const uint32_t devID,
printf("KokkosP: sample %llu calling child-begin function...\n",
(unsigned long long)(*kID));
}
if (tool_globFence) {
invoke_ktools_fence(0);
}
if (NULL != beginForCallee) {
if (tool_globFence) {
invoke_ktools_fence(0);
}
uint64_t nestedkID = 0;
(*beginForCallee)(name, devID, &nestedkID);
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu finished with child-begin function.\n",
(unsigned long long)(*kID));
}
infokIDSample.insert({*kID, nestedkID});
}
}
Expand Down Expand Up @@ -342,6 +358,10 @@ void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID,
invoke_ktools_fence(0);
}
(*beginScanCallee)(name, devID, &nestedkID);
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu finished with child-begin function.\n",
(unsigned long long)(*kID));
}
infokIDSample.insert({*kID, nestedkID});
}
}
Expand Down Expand Up @@ -382,6 +402,10 @@ void kokkosp_begin_parallel_reduce(const char* name, const uint32_t devID,
invoke_ktools_fence(0);
}
(*beginReduceCallee)(name, devID, &nestedkID);
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu finished with child-begin function.\n",
(unsigned long long)(*kID));
}
infokIDSample.insert({*kID, nestedkID});
}
}
Expand All @@ -399,6 +423,7 @@ void kokkosp_end_parallel_reduce(const uint64_t kID) {
if (tool_globFence) {
invoke_ktools_fence(0);
}

(*endScanCallee)(retrievedNestedkID);
infokIDSample.erase(kID);
}
Expand Down

0 comments on commit df84895

Please sign in to comment.