Commit aa69d6f2 authored by Brice Videau's avatar Brice Videau
Browse files

Refactoring.

parent 459bb2bf
......@@ -183,7 +183,9 @@ static inline void _register_ze_event(
ADD_ZE_EVENT(_ze_event);
}
ze_event_handle_t _get_profiling_event(ze_command_list_handle_t command_list) {
ze_event_handle_t _get_profiling_event(
ze_command_list_handle_t command_list,
ze_event_pool_handle_t *pool_ret) {
struct _ze_obj_h *o_h = NULL;
FIND_ZE_OBJ(&command_list, o_h);
......@@ -206,7 +208,7 @@ ze_event_handle_t _get_profiling_event(ze_command_list_handle_t command_list) {
ZE_EVENT_POOL_DESTROY_PTR(event_pool);
return NULL;
}
_register_ze_event(event, command_list, event_pool);
*pool_ret = event_pool;
return event;
}
......@@ -293,7 +295,7 @@ void _lib_cleanup() {
static void _load_tracer(void) {
void * handle = dlopen("libze_loader.so", RTLD_LAZY | RTLD_LOCAL);
if( !handle ) {
printf("Failure: could not load ze library!\n");
fprintf(stderr, "Failure: could not load ze library!\n");
exit(1);
}
......
......@@ -648,14 +648,14 @@ register_prologue "zeEventHostReset", <<EOF
}
EOF
# WARNING: there seems to be no way to profile if
# zeCommandListAppendEventReset is used or at least
# not very cleanly is used....
profiling_prologue = lambda { |event_name|
<<EOF
if (_do_profile) {
if(!#{event_name}) {
#{event_name} = _get_profiling_event(hCommandList);
} else {
_register_ze_event(#{event_name}, hCommandList, NULL);
}
ze_event_pool_handle_t _pool = NULL;
if (_do_profile && !#{event_name}) {
#{event_name} = _get_profiling_event(hCommandList, &_pool);
}
EOF
}
......@@ -663,8 +663,13 @@ EOF
profiling_epilogue = lambda { |event_name|
<<EOF
if (_do_profile && #{event_name}) {
if (_retval == ZE_RESULT_SUCCESS)
if (_retval == ZE_RESULT_SUCCESS) {
_register_ze_event(#{event_name}, hCommandList, _pool);
tracepoint(lttng_ust_ze_profiling, event_profiling, #{event_name});
} else if (_pool) {
ZE_EVENT_DESTROY_PTR(#{event_name});
ZE_EVENT_POOL_DESTROY_PTR(_pool);
}
}
EOF
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment