From d2a63a144453cce3de04c377b9ce2ae1a9c1967a Mon Sep 17 00:00:00 2001 From: Vivek Kale <11766050+vlkale@users.noreply.github.com> Date: Thu, 3 Aug 2023 11:13:50 -0700 Subject: [PATCH 1/2] Using kval hashmap (draft) for nestedID --- common/kokkos-sampler/kp_sampler_skip.cpp | 24 +++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/common/kokkos-sampler/kp_sampler_skip.cpp b/common/kokkos-sampler/kp_sampler_skip.cpp index 773753f8b..87bfb4cf8 100644 --- a/common/kokkos-sampler/kp_sampler_skip.cpp +++ b/common/kokkos-sampler/kp_sampler_skip.cpp @@ -5,10 +5,11 @@ #include #include "../../profiling/all/kp_core.hpp" #include "kp_config.hpp" +#include namespace KokkosTools { namespace Sampler { -static uint64_t uniqID = 0; +static atomic uniqID = 0; static uint64_t kernelSampleSkip = 101; static int tool_verbosity = 0; static int tool_globFence = 0; @@ -160,8 +161,10 @@ void kokkosp_begin_parallel_for(const char* name, const uint32_t devID, (unsigned long long)(*kID)); } - if (NULL != beginForCallee) { - (*beginForCallee)(name, devID, kID); + if (NULL != beginForCallee) { + uint64_t nestedID; + (*beginForCallee)(name, devID, nestedID); + // map.insert(kID, nestedID); } } } @@ -174,7 +177,10 @@ void kokkosp_end_parallel_for(const uint64_t kID) { } if (NULL != endForCallee) { - (*endForCallee)(kID); + (*endForCallee)(kID); + // (*endForCallee)(map.find(kID)); + + // map.clear(nestedID); } } } @@ -182,7 +188,6 @@ void kokkosp_end_parallel_for(const uint64_t kID) { void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID, uint64_t* kID) { *kID = uniqID++; - if (((*kID) % kernelSampleSkip) == 0) { if (tool_verbosity > 0) { printf("KokkosP: sample %llu calling child-begin function...\n", @@ -190,7 +195,9 @@ void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID, } if (NULL != beginScanCallee) { + uint64_t nestedID = 0; (*beginScanCallee)(name, devID, kID); + // map.insert(kID, nestedID); } } } @@ -204,6 +211,8 @@ void kokkosp_end_parallel_scan(const uint64_t kID) { if (NULL != endScanCallee) { (*endScanCallee)(kID); + // (*endForCallee)(map.find(kID)); + // map.clear(nestedID); } } } @@ -219,7 +228,8 @@ void kokkosp_begin_parallel_reduce(const char* name, const uint32_t devID, } if (NULL != beginReduceCallee) { - (*beginReduceCallee)(name, devID, kID); + (*beginReduceCallee)(name, devID, kID); + } } } @@ -233,6 +243,8 @@ void kokkosp_end_parallel_reduce(const uint64_t kID) { if (NULL != endReduceCallee) { (*endReduceCallee)(kID); + // (*endForCallee)(map.find(kID)); + // map.clear(nestedID); } } } From 3becbe2d34236444fa3e3b0e44a089380a99ab56 Mon Sep 17 00:00:00 2001 From: Vivek Kale <11766050+vlkale@users.noreply.github.com> Date: Sat, 5 Aug 2023 08:17:27 -0700 Subject: [PATCH 2/2] take out erroneous changes - uniqID --- common/kokkos-sampler/kp_sampler_skip.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/common/kokkos-sampler/kp_sampler_skip.cpp b/common/kokkos-sampler/kp_sampler_skip.cpp index 87bfb4cf8..c611db0c9 100644 --- a/common/kokkos-sampler/kp_sampler_skip.cpp +++ b/common/kokkos-sampler/kp_sampler_skip.cpp @@ -5,11 +5,10 @@ #include #include "../../profiling/all/kp_core.hpp" #include "kp_config.hpp" -#include namespace KokkosTools { namespace Sampler { -static atomic uniqID = 0; +static uint64_t uniqID = 0; static uint64_t kernelSampleSkip = 101; static int tool_verbosity = 0; static int tool_globFence = 0; @@ -153,7 +152,6 @@ void kokkosp_finalize_library() { void kokkosp_begin_parallel_for(const char* name, const uint32_t devID, uint64_t* kID) { - *kID = uniqID++; if (((*kID) % kernelSampleSkip) == 0) { if (tool_verbosity > 0) { @@ -178,16 +176,12 @@ void kokkosp_end_parallel_for(const uint64_t kID) { if (NULL != endForCallee) { (*endForCallee)(kID); - // (*endForCallee)(map.find(kID)); - - // map.clear(nestedID); } } } void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID, uint64_t* kID) { - *kID = uniqID++; if (((*kID) % kernelSampleSkip) == 0) { if (tool_verbosity > 0) { printf("KokkosP: sample %llu calling child-begin function...\n", @@ -197,7 +191,6 @@ void kokkosp_begin_parallel_scan(const char* name, const uint32_t devID, if (NULL != beginScanCallee) { uint64_t nestedID = 0; (*beginScanCallee)(name, devID, kID); - // map.insert(kID, nestedID); } } } @@ -211,8 +204,6 @@ void kokkosp_end_parallel_scan(const uint64_t kID) { if (NULL != endScanCallee) { (*endScanCallee)(kID); - // (*endForCallee)(map.find(kID)); - // map.clear(nestedID); } } } @@ -243,8 +234,6 @@ void kokkosp_end_parallel_reduce(const uint64_t kID) { if (NULL != endReduceCallee) { (*endReduceCallee)(kID); - // (*endForCallee)(map.find(kID)); - // map.clear(nestedID); } } }