-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sampling overlay prototype #117
Closed
DavidPoliakoff
wants to merge
2
commits into
kokkos:develop
from
DavidPoliakoff:testing/fenceless_sampler
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CXX=g++ | ||
CXXFLAGS=-O3 -std=c++11 -g -I../../include | ||
SHARED_CXXFLAGS=-shared -fPIC | ||
|
||
all: kp_passthrough.so | ||
|
||
MAKEFILE_PATH := $(subst Makefile,,$(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
kp_passthrough.so: ${MAKEFILE_PATH}passthrough.cpp | ||
$(CXX) $(SHARED_CXXFLAGS) $(CXXFLAGS) -o $@ ${MAKEFILE_PATH}passthrough.cpp | ||
|
||
clean: | ||
rm *.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
#include <cinttypes> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <cstring> | ||
#include <cxxabi.h> | ||
#include <dlfcn.h> | ||
#include <impl/Kokkos_Profiling_Interface.hpp> | ||
#include <iostream> | ||
#include <regex> | ||
#include <string> | ||
#include <tool_chain.hpp> | ||
#include <unordered_set> | ||
#include <vector> | ||
static Kokkos::Tools::callback_chainer next; | ||
extern "C" void kokkosp_begin_parallel_scan(const char *name, | ||
const uint32_t devID, | ||
uint64_t *kID) { | ||
next.kokkosp_begin_parallel_scan(name, devID, kID); | ||
} | ||
extern "C" void kokkosp_begin_parallel_for(const char *name, | ||
const uint32_t devID, | ||
uint64_t *kID) { | ||
next.kokkosp_begin_parallel_for(name, devID, kID); | ||
} | ||
extern "C" void kokkosp_begin_parallel_reduce(const char *name, | ||
const uint32_t devID, | ||
uint64_t *kID) { | ||
|
||
next.kokkosp_begin_parallel_reduce(name, devID, kID); | ||
} | ||
extern "C" void kokkosp_end_parallel_scan(uint64_t kID) { | ||
next.kokkosp_end_parallel_scan(kID); | ||
} | ||
extern "C" void kokkosp_end_parallel_for(uint64_t kID) { | ||
next.kokkosp_end_parallel_for(kID); | ||
} | ||
extern "C" void kokkosp_end_parallel_reduce(uint64_t kID) { | ||
next.kokkosp_end_parallel_reduce(kID); | ||
} | ||
extern "C" void | ||
kokkosp_init_library(int loadseq, uint64_t version, uint32_t ndevinfos, | ||
Kokkos_Profiling_KokkosPDeviceInfo *devInfos) { | ||
next.setup(loadseq); | ||
next.kokkosp_init_library(loadseq, version, ndevinfos, devInfos); | ||
} | ||
extern "C" void kokkosp_finalize_library() { next.kokkosp_finalize_library(); } | ||
extern "C" void kokkosp_push_profile_region(const char *name) { | ||
next.kokkosp_push_profile_region(name); | ||
} | ||
extern "C" void kokkosp_pop_profile_region() { | ||
next.kokkosp_pop_profile_region(); | ||
} | ||
extern "C" void kokkosp_allocate_data(Kokkos::Profiling::SpaceHandle handle, | ||
const char *name, void *ptr, | ||
uint64_t size) { | ||
next.kokkosp_allocate_data(handle, name, ptr, size); | ||
} | ||
extern "C" void kokkosp_deallocate_data(Kokkos::Profiling::SpaceHandle handle, | ||
const char *name, void *ptr, | ||
uint64_t size) { | ||
next.kokkosp_deallocate_data(handle, name, ptr, size); | ||
} | ||
extern "C" void kokkosp_begin_deep_copy(Kokkos::Tools::SpaceHandle dst_handle, | ||
const char *dst_name, | ||
const void *dst_ptr, | ||
Kokkos::Tools::SpaceHandle src_handle, | ||
const char *src_name, | ||
const void *src_ptr, uint64_t size) { | ||
next.kokkosp_begin_deep_copy(dst_handle, dst_name, dst_ptr, src_handle, | ||
src_name, src_ptr, size); | ||
} | ||
extern "C" void kokkosp_end_deep_copy() { next.kokkosp_end_deep_copy(); } | ||
extern "C" void kokkosp_begin_fence(const char *name, const uint32_t devID, | ||
uint64_t *kID) { | ||
next.kokkosp_begin_fence(name, devID, kID); | ||
} | ||
extern "C" void kokkosp_end_fence(uint64_t kID) { next.kokkosp_end_fence(kID); } | ||
extern "C" void kokkosp_dual_view_sync(const char *label, const void *const ptr, | ||
bool to_device) { | ||
next.kokkosp_dual_view_sync(label, ptr, to_device); | ||
} | ||
extern "C" void kokkosp_dual_view_modify(const char *label, | ||
const void *const ptr, | ||
bool to_device) { | ||
next.kokkosp_dual_view_modify(label, ptr, to_device); | ||
} | ||
extern "C" void kokkosp_declare_metadata(const char *key, const char *value) { | ||
next.kokkosp_declare_metadata(key, value); | ||
} | ||
extern "C" void kokkosp_create_profile_section(const char *name, | ||
uint32_t *sec_id) { | ||
next.kokkosp_create_profile_section(name, sec_id); | ||
} | ||
extern "C" void kokkosp_start_profile_section(uint32_t sec_id) { | ||
next.kokkosp_start_profile_section(sec_id); | ||
} | ||
extern "C" void kokkosp_stop_profile_section(uint32_t sec_id) { | ||
next.kokkosp_stop_profile_section(sec_id); | ||
} | ||
extern "C" void kokkosp_destroy_profile_section(uint32_t sec_id) { | ||
next.kokkosp_destroy_profile_section(sec_id); | ||
} | ||
extern "C" void kokkosp_profile_event(const char *name) { | ||
next.kokkosp_profile_event(name); | ||
} | ||
extern "C" void | ||
kokkosp_declare_output_type(const char *name, size_t id, | ||
Kokkos::Tools::Experimental::VariableInfo *info) { | ||
next.kokkosp_declare_output_type(name, id, info); | ||
} | ||
extern "C" void | ||
kokkosp_declare_input_type(const char *name, size_t id, | ||
Kokkos::Tools::Experimental::VariableInfo *info) { | ||
next.kokkosp_declare_input_type(name, id, info); | ||
} | ||
extern "C" void kokkosp_request_values( | ||
size_t context_id, size_t num_context_values, | ||
Kokkos::Tools::Experimental::VariableValue *context_values, | ||
size_t num_output_values, | ||
Kokkos::Tools::Experimental::VariableValue *output_values) { | ||
next.kokkosp_request_values(context_id, num_context_values, context_values, | ||
num_output_values, output_values); | ||
} | ||
extern "C" void kokkosp_end_context(size_t context_id) { | ||
next.kokkosp_end_context(context_id); | ||
} | ||
extern "C" void kokkosp_begin_context(size_t context_id) { | ||
next.kokkosp_begin_context(context_id); | ||
} | ||
extern "C" void kokkosp_declare_optimization_goal( | ||
size_t context_id, Kokkos::Tools::Experimental::OptimizationGoal goal) { | ||
next.kokkosp_declare_optimization_goal(context_id, goal); | ||
} | ||
extern "C" void kokkosp_print_help(char *arg0) { | ||
next.kokkosp_print_help(arg0); | ||
} | ||
extern "C" void kokkosp_parse_args(int argc, char **argv) { | ||
|
||
next.kokkosp_parse_args(argc, argv); | ||
} | ||
extern "C" void | ||
kokkosp_transmit_actions(Kokkos::Tools::Experimental::ToolActions actions) { | ||
next.kokkosp_transmit_actions(actions); | ||
} | ||
extern "C" void kokkosp_request_responses( | ||
Kokkos::Tools::Experimental::ToolResponses *responses) { | ||
next.kokkosp_request_responses(responses); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CXX=g++ | ||
CXXFLAGS=-O3 -std=c++11 -g -I../../include | ||
SHARED_CXXFLAGS=-shared -fPIC | ||
|
||
all: kp_sampler.so | ||
|
||
MAKEFILE_PATH := $(subst Makefile,,$(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
kp_sampler.so: ${MAKEFILE_PATH}sampler.cpp | ||
$(CXX) $(SHARED_CXXFLAGS) $(CXXFLAGS) -o $@ ${MAKEFILE_PATH}sampler.cpp | ||
|
||
clean: | ||
rm *.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
#include <cinttypes> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <cstring> | ||
#include <cxxabi.h> | ||
#include <dlfcn.h> | ||
#include <impl/Kokkos_Profiling_Interface.hpp> | ||
#include <iostream> | ||
#include <regex> | ||
#include <string> | ||
#include <tool_chain.hpp> | ||
#include <unordered_set> | ||
#include <vector> | ||
static Kokkos::Tools::callback_chainer next; | ||
using action_type = Kokkos::Tools::Experimental::ToolActions; | ||
action_type actions; | ||
static uint64_t sample_rate = 101; | ||
|
||
extern "C" void kokkosp_begin_parallel_scan(const char *name, | ||
const uint32_t devID, | ||
uint64_t *kID) { | ||
*kID = 0; | ||
static uint64_t encounter; | ||
++encounter; | ||
if ((encounter % sample_rate) == 0) { | ||
actions.fence(0); | ||
*kID = 1; | ||
next.kokkosp_begin_parallel_scan(name, devID, kID); | ||
} | ||
} | ||
extern "C" void kokkosp_begin_parallel_for(const char *name, | ||
const uint32_t devID, | ||
uint64_t *kID) { | ||
*kID = 0; | ||
static uint64_t encounter; | ||
++encounter; | ||
if ((encounter % sample_rate) == 0) { | ||
actions.fence(0); | ||
*kID = 1; | ||
next.kokkosp_begin_parallel_for(name, devID, kID); | ||
} | ||
} | ||
extern "C" void kokkosp_begin_parallel_reduce(const char *name, | ||
const uint32_t devID, | ||
uint64_t *kID) { | ||
*kID = 0; | ||
static uint64_t encounter; | ||
++encounter; | ||
if ((encounter % sample_rate) == 0) { | ||
actions.fence(0); | ||
*kID = 1; | ||
next.kokkosp_begin_parallel_reduce(name, devID, kID); | ||
} | ||
} | ||
extern "C" void kokkosp_end_parallel_scan(uint64_t kID) { | ||
if (kID > 0) { | ||
actions.fence(0); | ||
next.kokkosp_end_parallel_scan(kID); | ||
} | ||
} | ||
extern "C" void kokkosp_end_parallel_for(uint64_t kID) { | ||
if (kID > 0) { | ||
actions.fence(0); | ||
next.kokkosp_end_parallel_for(kID); | ||
} | ||
} | ||
extern "C" void kokkosp_end_parallel_reduce(uint64_t kID) { | ||
if (kID > 0) { | ||
actions.fence(0); | ||
next.kokkosp_end_parallel_reduce(kID); | ||
} | ||
} | ||
#include <iostream> | ||
extern "C" void | ||
kokkosp_init_library(int loadseq, uint64_t version, uint32_t ndevinfos, | ||
Kokkos_Profiling_KokkosPDeviceInfo *devInfos) { | ||
next.setup(loadseq); | ||
next.kokkosp_init_library(loadseq, version, ndevinfos, devInfos); | ||
} | ||
extern "C" void kokkosp_finalize_library() { next.kokkosp_finalize_library(); } | ||
extern "C" void kokkosp_push_profile_region(const char *name) { | ||
actions.fence(0); | ||
next.kokkosp_push_profile_region(name); | ||
} | ||
extern "C" void kokkosp_pop_profile_region() { | ||
actions.fence(0); | ||
next.kokkosp_pop_profile_region(); | ||
} | ||
extern "C" void kokkosp_allocate_data(Kokkos::Profiling::SpaceHandle handle, | ||
const char *name, void *ptr, | ||
uint64_t size) { | ||
next.kokkosp_allocate_data(handle, name, ptr, size); | ||
} | ||
extern "C" void kokkosp_deallocate_data(Kokkos::Profiling::SpaceHandle handle, | ||
const char *name, void *ptr, | ||
uint64_t size) { | ||
next.kokkosp_deallocate_data(handle, name, ptr, size); | ||
} | ||
extern "C" void kokkosp_begin_deep_copy(Kokkos::Tools::SpaceHandle dst_handle, | ||
const char *dst_name, | ||
const void *dst_ptr, | ||
Kokkos::Tools::SpaceHandle src_handle, | ||
const char *src_name, | ||
const void *src_ptr, uint64_t size) { | ||
next.kokkosp_begin_deep_copy(dst_handle, dst_name, dst_ptr, src_handle, | ||
src_name, src_ptr, size); | ||
} | ||
extern "C" void kokkosp_end_deep_copy() { next.kokkosp_end_deep_copy(); } | ||
extern "C" void kokkosp_begin_fence(const char *name, const uint32_t devID, | ||
uint64_t *kID) { | ||
next.kokkosp_begin_fence(name, devID, kID); | ||
} | ||
extern "C" void kokkosp_end_fence(uint64_t kID) { next.kokkosp_end_fence(kID); } | ||
extern "C" void kokkosp_dual_view_sync(const char *label, const void *const ptr, | ||
bool to_device) { | ||
next.kokkosp_dual_view_sync(label, ptr, to_device); | ||
} | ||
extern "C" void kokkosp_dual_view_modify(const char *label, | ||
const void *const ptr, | ||
bool to_device) { | ||
next.kokkosp_dual_view_modify(label, ptr, to_device); | ||
} | ||
extern "C" void kokkosp_declare_metadata(const char *key, const char *value) { | ||
next.kokkosp_declare_metadata(key, value); | ||
} | ||
extern "C" void kokkosp_create_profile_section(const char *name, | ||
uint32_t *sec_id) { | ||
next.kokkosp_create_profile_section(name, sec_id); | ||
} | ||
extern "C" void kokkosp_start_profile_section(uint32_t sec_id) { | ||
next.kokkosp_start_profile_section(sec_id); | ||
} | ||
extern "C" void kokkosp_stop_profile_section(uint32_t sec_id) { | ||
next.kokkosp_stop_profile_section(sec_id); | ||
} | ||
extern "C" void kokkosp_destroy_profile_section(uint32_t sec_id) { | ||
next.kokkosp_destroy_profile_section(sec_id); | ||
} | ||
extern "C" void kokkosp_profile_event(const char *name) { | ||
next.kokkosp_profile_event(name); | ||
} | ||
extern "C" void | ||
kokkosp_declare_output_type(const char *name, size_t id, | ||
Kokkos::Tools::Experimental::VariableInfo *info) { | ||
next.kokkosp_declare_output_type(name, id, info); | ||
} | ||
extern "C" void | ||
kokkosp_declare_input_type(const char *name, size_t id, | ||
Kokkos::Tools::Experimental::VariableInfo *info) { | ||
next.kokkosp_declare_input_type(name, id, info); | ||
} | ||
extern "C" void kokkosp_request_values( | ||
size_t context_id, size_t num_context_values, | ||
Kokkos::Tools::Experimental::VariableValue *context_values, | ||
size_t num_output_values, | ||
Kokkos::Tools::Experimental::VariableValue *output_values) { | ||
next.kokkosp_request_values(context_id, num_context_values, context_values, | ||
num_output_values, output_values); | ||
} | ||
extern "C" void kokkosp_end_context(size_t context_id) { | ||
next.kokkosp_end_context(context_id); | ||
} | ||
extern "C" void kokkosp_begin_context(size_t context_id) { | ||
next.kokkosp_begin_context(context_id); | ||
} | ||
extern "C" void kokkosp_declare_optimization_goal( | ||
size_t context_id, Kokkos::Tools::Experimental::OptimizationGoal goal) { | ||
next.kokkosp_declare_optimization_goal(context_id, goal); | ||
} | ||
extern "C" void kokkosp_print_help(char *arg0) { | ||
next.kokkosp_print_help(arg0); | ||
} | ||
extern "C" void kokkosp_parse_args(int argc, char **argv) { | ||
|
||
next.kokkosp_parse_args(argc, argv); | ||
} | ||
extern "C" void | ||
kokkosp_transmit_actions(Kokkos::Tools::Experimental::ToolActions nactions) { | ||
actions = nactions; | ||
next.kokkosp_transmit_actions(nactions); | ||
} | ||
extern "C" void kokkosp_request_responses( | ||
Kokkos::Tools::Experimental::ToolResponses *responses) { | ||
responses->requires_global_fencing = false; | ||
next.kokkosp_request_responses(responses); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making a comment for myself (David, you don't need to respond to this of course) that I think this parameter to fence function should not have to be zero.