Skip to content

Commit

Permalink
kp_sampler_skip.cpp: change printf to std::out for ctests
Browse files Browse the repository at this point in the history
  • Loading branch information
vlkale authored Apr 1, 2024
1 parent d13efe8 commit d1673d4
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions common/kokkos-sampler/kp_sampler_skip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,20 @@ void kokkosp_begin_parallel_for(const char* name, const uint32_t devID,
static uint64_t invocationNum = 0;
++invocationNum;
if ((invocationNum % kernelSampleSkip) == 0) {
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu calling child-begin function...\n",
(unsigned long long)(*kID));
}
if (tool_verbosity > 0) {
std::cout << "KokkosP: sample " << *kID
<< " calling child-begin function..." << std::endl;
}
if (tool_globFence) {
invoke_ktools_fence(0);
}
if (NULL != beginForCallee) {
uint64_t nestedkID = 0;
(*beginForCallee)(name, devID, &nestedkID);
if (tool_verbosity > 0) {
std::cout << "KokkosP: sample " << *kID
<< " called child-begin function." << std::endl;
}
infokIDSample.insert({*kID, nestedkID});
}
}
Expand All @@ -214,13 +218,18 @@ void kokkosp_end_parallel_for(const uint64_t kID) {
if (!(infokIDSample.find(kID) == infokIDSample.end())) {
uint64_t retrievedNestedkID = infokIDSample[kID];
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu calling child-end function...\n",
(unsigned long long)(kID));
std::cout << "KokkosP: sample " << kID
<< " calling child-end function..." << std::endl;
}

if (tool_globFence) {
invoke_ktools_fence(0);
}
(*endForCallee)(retrievedNestedkID);
if (tool_verbosity > 0) {
std::cout << "KokkosP: sample " << kID
<< " called child-end function." << std::endl;
}
infokIDSample.erase(kID);
}
}
Expand All @@ -233,15 +242,19 @@ void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID,
++invocationNum;
if ((invocationNum % kernelSampleSkip) == 0) {
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu calling child-begin function...\n",
(unsigned long long)(*kID));
std::cout << "KokkosP: sample " << *kID
<< " calling child-begin function..." << std::endl;
}
if (NULL != beginScanCallee) {
uint64_t nestedkID = 0;
if (tool_globFence) {
invoke_ktools_fence(0);
}
(*beginScanCallee)(name, devID, &nestedkID);
if (tool_verbosity > 0) {
std::cout << "KokkosP: sample " << *kID
<< " called child-begin function." << std::endl;
}
infokIDSample.insert({*kID, nestedkID});
}
}
Expand All @@ -252,13 +265,17 @@ void kokkosp_end_parallel_scan(const uint64_t kID) {
if (!(infokIDSample.find(kID) == infokIDSample.end())) {
uint64_t retrievedNestedkID = infokIDSample[kID];
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu calling child-end function...\n",
(unsigned long long)(kID));
std::cout << "KokkosP: sample " << kID
<< " calling child-end function..." << std::endl;
}
if (tool_globFence) {
invoke_ktools_fence(0);
}
(*endScanCallee)(retrievedNestedkID);
if (tool_verbosity > 0) {
std::cout << "KokkosP: sample " << kID
<< " called child-end function." << std::endl;
}
infokIDSample.erase(kID);
}
}
Expand All @@ -271,32 +288,40 @@ void kokkosp_begin_parallel_reduce(const char* name, const uint32_t devID,
++invocationNum;
if ((invocationNum % kernelSampleSkip) == 0) {
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu calling child-begin function...\n",
(unsigned long long)(*kID));
std::cout << "KokkosP: sample " << *kID
<< " calling child-begin function..." << std::endl;
}
if (NULL != beginReduceCallee) {
uint64_t nestedkID = 0;
if (tool_globFence) {
invoke_ktools_fence(0);
}
(*beginReduceCallee)(name, devID, &nestedkID);
if (tool_verbosity > 0) {
std::cout << "KokkosP: sample " << *kID
<< " called child-begin function." << std::endl;
}
infokIDSample.insert({*kID, nestedkID});
}
}
}

void kokkosp_end_parallel_reduce(const uint64_t kID) {
if (NULL != endScanCallee) {
if (NULL != endReduceCallee) {
if (!(infokIDSample.find(kID) == infokIDSample.end())) {
uint64_t retrievedNestedkID = infokIDSample[kID];
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu calling child-end function...\n",
(unsigned long long)(kID));
std::cout << "KokkosP: sample " << kID
<< " calling child-end function..." << std::endl;
}
if (tool_globFence) {
invoke_ktools_fence(0);
}
(*endScanCallee)(retrievedNestedkID);
(*endReduceCallee)(retrievedNestedkID);
if (tool_verbosity > 0) {
std::cout << "KokkosP: sample " << kID
<< " called child-end function." << std::endl;
}
infokIDSample.erase(kID);
}
}
Expand Down

0 comments on commit d1673d4

Please sign in to comment.