Logging lib for OpenMP
You can compile the lib by doing make
Then, you can use this lib from anywhere. The builds will look like:
gcc file.c -o file.o -L/path -lomp_logs
where path
is the path to the directory where you built the lib.
#include "path/to/the/file/omp_logs.h"
This list needs to be accessible by every call of the function log_task
.
You can put the list as a global variable to be sure.
task_list* list = NULL;
or with
task_list* list = task_list_init();
The function to log a task is:
void log_task(task_list** l, char* label, int info, int parent_id, void (*f)(void* args), void* args)
l
is the list of tasks that we created just beforelabel
is the label that you could give to the taskinfo
is a placeholder for some info that you could want to have (i.e. size of an array, index, ...)parent_id
is the id of the thread that is the parent of the thread running the task. You can get this id by doingomp_get_thread_num()
before creating the taskf
is the function that represents the task. It must be of typevoid (*f)(void* args)
args
is the argument(s) off
I invite you to look at the examples mergesort.c
and for_policies.c
When all the parallel stuff is done, you can get the logs in a svg
file:
tasks_to_svg(l, "filename.svg", x);
with x = 0
if you don't want a svg
file with script, x = 1
otherwise.
This will also free the list l
.
Even if this is a svg
file, you'll have to open it with your browser.
Here is an example (For the full experience: click on the image, and then, right click -> "View Image"):
Every line represents a thread across time.
Every rectangle is a task.
You can move your mouse on it to see some info:
- The
label
of the task - The number of ticks it took to execute the task
- The
info
of the task
Have a x86 architecture...
This work is highly inspired from wagnerf42's rayon-logs