Skip to content

Instantly share code, notes, and snippets.

View DavidPoliakoff's full-sized avatar

David Poliakoff DavidPoliakoff

  • Google
  • Washington
View GitHub Profile
@DavidPoliakoff
DavidPoliakoff / gotcha_levels
Last active August 2, 2017 18:16 — forked from anonymous/gotcha_levels
Gotcha Switchboard
int init_my_tool(bool verbose){
if(verbose){
gotcha_wrap(a_few_functions);
}
else{
gotcha_wrap(all_the_functions);
}
}
@DavidPoliakoff
DavidPoliakoff / cali_gotcha.cpp
Last active August 4, 2017 15:39
Gotcha Example
ssize_t (*orig_read)(int fildes, void *buf, size_t nbyte);
ssize_t read_wrapper(int fildes, void* buf, size_t nbyte){
cali::Annotation("bytes_read").set(nbyte);
return orig_read(fildes, buf, nbyte);
}
struct gotcha_binding_t wrap_actions[] = {
{ "read", read_wrapper, &orig_read }
};
void init_bytecounter_tool(){
ssize_t (*orig_read)(int fildes, void *buf, size_t nbyte);
ssize_t read_wrapper(int fildes, void* buf, size_t nbyte){
TAU_REGISTER_CONTEXT_EVENT(event, "Bytes read");
TAU_CONTEXT_EVENT(event, nbyte);
return orig_read(fildes, buf, nbyte);
}
struct gotcha_binding_t wrap_actions[] = {
{ "read", read_wrapper, &orig_read }
};
bash-4.2$ ./autogen.sh
Running autoreconf -i ...
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `config'.
libtoolize: copying file `config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
@DavidPoliakoff
DavidPoliakoff / .cpp
Last active November 8, 2018 19:01
MPI Wrapping
int MPI_Send(const void *buf, int count,
MPI_Datatype datatype, int dest, int tag,
MPI_Comm comm){
// MPI Things
}
struct gotcha_binding_t mpi_wrappers[] = {
{ "MPI_Init", mpi_init_wrapper, &orig_mpi_init_handle },
// other wrappers as desired
};
static int mpi_init_wrapper(int* argc, char*** argv )
{
typeof(&puts) orig_init = gotcha_get_wrappee(orig_mpi_init_handle);
/** do tool_things */
return orig_init(str);
@DavidPoliakoff
DavidPoliakoff / cool_tool.cpp
Last active November 16, 2018 12:54
MPI Wrapping
int MPI_Send( /* Args */ ){
// typical MPI code
}
Kokkos::TeamPolicy<Kokkos::Cuda> execution_policy(total_amount_of_work,
outer_parallelism_batch_size,
inner_parallelism_batch_size);
Kokkos::parallel_for("implement_psychics", execution_policy,
KOKKOS_LAMBDA (team_member outer_handle) {
// some outer level work
double sum = psychics;
parallel_reduce (ThreadVectorRange (outer_handle, loop_count),
[=] (int& i, Scalar& lsum) {
@DavidPoliakoff
DavidPoliakoff / test.cpp
Created March 12, 2021 19:41
Kokkos Tool
extern "C" void kokkosp_begin_parallel_for(const char* name, const uint32_t devID, uint64_t* kID){
if(name matches a regex){
jonathans_api_wrapper_start();
*kID = 1;
}
}
extern "C" void kokkosp_end_parallel_for(uint64_t kID){
if(kID==1){
jonathans_api_wrapper_stop();
}