-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
169 additions
and
1 deletion.
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
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
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
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
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,117 @@ | ||
#include <omp-tools.h> | ||
#include <omp.h> | ||
|
||
#include <assert.h> | ||
#include <inttypes.h> | ||
#include <stdio.h> | ||
#include <sys/resource.h> | ||
|
||
#include <lo2s/ringbuf.hpp> | ||
|
||
#define PARALLEL_BEGIN 1 | ||
#define PARALLEL_END 2 | ||
std::unique_ptr<lo2s::RingbufWriter> rb_writer = nullptr; | ||
clockid_t clockid = CLOCK_MONOTONIC_RAW; | ||
std::map<uint64_t, std::string> cctx_map = { { PARALLEL_BEGIN, "parallel_begin" }, | ||
{ PARALLEL_END, "parallel_end" } }; | ||
|
||
uint64_t timestampfunc() | ||
{ | ||
struct timespec ts; | ||
clock_gettime(clockid, &ts); | ||
std::cerr << clockid << std::endl; | ||
uint64_t res = ts.tv_sec * 1000000000 + ts.tv_nsec; | ||
std::cerr << res << std::endl; | ||
return res; | ||
} | ||
|
||
static void on_ompt_callback_implicit_task(ompt_scope_endpoint_t endpoint, | ||
ompt_data_t* parallel_data, ompt_data_t* task_data, | ||
unsigned int actual_parallelism, unsigned int index, | ||
int flags) | ||
{ | ||
} | ||
|
||
static void on_ompt_callback_parallel_begin(ompt_data_t* encountering_task_data, | ||
const ompt_frame_t* encountering_task_frame, | ||
ompt_data_t* parallel_data, | ||
uint32_t requested_parallelism, int flags, | ||
const void* codeptr_ra) | ||
{ | ||
printf("PARALLEL_BEGIN!"); | ||
} | ||
|
||
static void on_ompt_callback_task_create( | ||
ompt_data_t* encountering_task_data, /* id of parent task */ | ||
const ompt_frame_t* encountering_task_frame, /* frame data for parent task */ | ||
ompt_data_t* new_task_data, /* id of created task */ | ||
int flags, int has_dependences, const void* codeptr_ra) /* pointer to outlined function */ | ||
{ | ||
} | ||
|
||
static void on_ompt_callback_task_schedule(ompt_data_t* prior_task_data, | ||
ompt_task_status_t prior_task_status, | ||
ompt_data_t* next_task_data) | ||
{ | ||
} | ||
|
||
static void on_ompt_callback_thread_begin(ompt_thread_t thread_type, ompt_data_t* thread_data) | ||
{ | ||
} | ||
|
||
static void on_ompt_callback_parallel_end(ompt_data_t* parallel_data, | ||
ompt_data_t* encountering_task_data, int flags, | ||
const void* codeptr_ra) | ||
{ | ||
printf("PARALLEL_END!"); | ||
} | ||
|
||
static void on_ompt_callback_thread_end(ompt_data_t* thread_data) | ||
{ | ||
} | ||
|
||
#define register_callback_t(name, type) \ | ||
do \ | ||
{ \ | ||
type f_##name = &on_##name; \ | ||
if (ompt_set_callback(name, (ompt_callback_t)f_##name) == ompt_set_never) \ | ||
printf("0: Could not register callback '" #name "'\n"); \ | ||
} while (0) | ||
|
||
#define register_callback(name) register_callback_t(name, name##_t) | ||
|
||
int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num, ompt_data_t* tool_data) | ||
{ | ||
std::cout << "Initializing injection!" << std::endl; | ||
pid_t pid = getpid(); | ||
rb_writer = | ||
std::make_unique<lo2s::RingbufWriter>(16, lo2s::ExecutionScope(lo2s::Process(pid)), "cuda"); | ||
|
||
while (!rb_writer->ready()) | ||
{ | ||
}; | ||
clockid = rb_writer->header()->clockid; | ||
ompt_set_callback_t ompt_set_callback = (ompt_set_callback_t)lookup("ompt_set_callback"); | ||
|
||
register_callback(ompt_callback_implicit_task); | ||
register_callback(ompt_callback_parallel_begin); | ||
register_callback(ompt_callback_parallel_end); | ||
register_callback(ompt_callback_task_create); | ||
register_callback(ompt_callback_task_schedule); | ||
register_callback(ompt_callback_thread_begin); | ||
register_callback(ompt_callback_thread_end); | ||
|
||
return 1; // success | ||
} | ||
|
||
void ompt_finalize(ompt_data_t* tool_data) | ||
{ | ||
} | ||
|
||
ompt_start_tool_result_t* ompt_start_tool(unsigned int omp_version, const char* runtime_version) | ||
{ | ||
static ompt_start_tool_result_t ompt_start_tool_result = { &ompt_initialize, | ||
&ompt_finalize, | ||
{ .value = 0 } }; | ||
return &ompt_start_tool_result; | ||
} |