Skip to content

Commit

Permalink
change atomic to std::atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
vlkale committed Aug 7, 2023
1 parent 6e47ab9 commit 57f9a1f
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions common/kokkos-sampler/kp_sampler_skip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <atomic>
namespace KokkosTools {
namespace Sampler {
static atomic<uint64_t> uniqID = 0;
static std:atomic<uint64_t> uniqID = 0;
static uint64_t kernelSampleSkip = 101;
static int tool_verbosity = 0;
static int tool_globFence = 0;
Expand Down Expand Up @@ -210,38 +210,37 @@ void kokkosp_begin_parallel_for(const char* name, const uint32_t devID,
get_global_fence_choice(); // re-read environment variable to get most
// accurate value
if (0 < tool_globFence) {
invoke_ktools_fence(
0); // invoke tool-induced fence from device 0 for now
invoke_ktools_fence(0); // invoke tool-induced fence from device number 0 // TODO: use getDeviceID
}
*kID =
1; // set kernel ID to 1 so that it is matched with the end_parallel_*
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu calling child-begin function...\n",
(unsigned long long)(*kID));
}

if (NULL != beginForCallee) {
(*beginForCallee)(name, devID, kID);
uint64_t* nestedkID = 0;
(*beginForCallee)(name, devID, kID); // TODO: replace kID with nestedkID
// map.insert(kID, nestedkID);
}
}
}

void kokkosp_end_parallel_for(const uint64_t kID) {
if (kID > 0) { // check whether the corresponding begin parallel for was called // TODO: fix to hashmap
if (kID == uniqID) { // check whether the corresponding begin parallel for was called // TODO: fix to hashmap
get_global_fence_choice(); // re-read environment variable to get most
// accurate value
if (0 < tool_globFence) {
invoke_ktools_fence(
0); // invoke tool-induced fence from device 0 for now
invoke_ktools_fence(0); // invoke tool-induced fence from device number
}
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu calling child-end function...\n",
(unsigned long long)(kID));
}
if (NULL != endForCallee) {
(*endForCallee)(kID);
// (*endForCallee)(find(kID));
}
}
} // end uniqID sample match conditional
}

void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID,
Expand All @@ -255,10 +254,9 @@ void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID,
if (0 < tool_globFence) {
// using tool-induced fence from Kokkos_profiling rather than
// Kokkos_C_Profiling_interface. Note that this function
// only invokes a global (device 0 invoked) fence
// only invokes a fence on the device 0
invoke_ktools_fence(0);
}
*kID = 1; // set kernel ID to 1 so that it is matched with the end.
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu calling child-begin function...\n",
(unsigned long long)(*kID));
Expand All @@ -270,7 +268,7 @@ void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID,
}

void kokkosp_end_parallel_scan(const uint64_t kID) {
if (kID > 0) { // check that we match the begin scan kernel call
if (kID == uniqID) { // check that we match the begin scan kernel call
get_global_fence_choice(); // re-read environment variable to get most
// accurate value
if (0 < tool_globFence) {
Expand Down Expand Up @@ -303,7 +301,6 @@ void kokkosp_begin_parallel_reduce(const char* name, const uint32_t devID,
// only invokes a global (device 0 invoked) fence.
invoke_ktools_fence(0);
}
// *kID = 1; // set kernel ID to 1 so that it is matched with the end.
if (tool_verbosity > 0) {
printf("KokkosP: sample %llu calling child-begin function...\n",
(unsigned long long)(*kID));
Expand Down Expand Up @@ -355,7 +352,7 @@ void kokkosp_begin_fence(const char* name, const uint32_t devID,
}

void kokkosp_end_fence(const uint64_t kID) {
if (kID > 0) {
if (kID == uniqID) {
get_global_fence_choice(); // re-read environment variable to get most
// accurate value
if (0 < tool_globFence) {
Expand Down Expand Up @@ -396,7 +393,7 @@ void kokkosp_begin_deep_copy(const char* name, const uint32_t devID,
}

void kokkosp_end_deep_copy(const uint64_t kID) {
if (kID > 0) { // check that we match the begin deep copy kernel call
if (kID == uniqID) { // check that we match the begin deep copy kernel call
get_global_fence_choice(); // re-read environment variable to get most
// accurate value
if (0 < tool_globFence) {
Expand Down Expand Up @@ -436,5 +433,4 @@ EXPOSE_END_DEEP_COPY(impl::kokkosp_end_deep_copy)
EXPOSE_BEGIN_FENCE(impl::kokkosp_begin_fence)
EXPOSE_END_FENCE(impl::kokkosp_end_fence)


} // end extern "C"

0 comments on commit 57f9a1f

Please sign in to comment.