File: trc_register_cb_libapi.cpp.mako

package info (click to toggle)
level-zero 1.28.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,308 kB
  • sloc: cpp: 149,246; ansic: 16,655; python: 12,807; makefile: 5
file content (59 lines) | stat: -rw-r--r-- 1,438 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<%
import re
from templates import helper as th
%><%
    n=namespace
    N=n.upper()

    x=tags['$x']
    X=x.upper()
%>/*
 *
 * Copyright (C) 2021-2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 * @file ${name}.cpp
 *
 */

#include "ze_lib.h"
#include "layers/zel_tracing_api.h"
#include "layers/zel_tracing_ddi.h"
#include "layers/zel_tracing_register_cb.h"
#include "${n}_api.h"

extern "C" { 

/// APIs to register callbacks for each ${n} API
%for s in specs:
%for obj in th.filter_items(s['objects'], 'type', 'function'):

${X}_APIEXPORT ${x}_result_t ${X}_APICALL
${th.make_tracing_func_name(n, tags, obj)}(
    zel_tracer_handle_t hTracer,
    zel_tracer_reg_t callback_type,
    ${th.make_pfncb_type(n, tags, obj)} ${th.make_pfncb_name(n, tags, obj)}
    ) {

    if(!ze_lib::context->tracing_lib)
        return ZE_RESULT_ERROR_UNINITIALIZED;
    typedef ze_result_t (ZE_APICALL *ze_pfnSetCallback_t)(
        zel_tracer_handle_t hTracer,
        zel_tracer_reg_t callback_type,
        ${th.make_pfncb_type(n, tags, obj)} ${th.make_pfncb_name(n, tags, obj)}
    );

    auto func = reinterpret_cast<ze_pfnSetCallback_t>(
        GET_FUNCTION_PTR(ze_lib::context->tracing_lib, "${th.make_tracing_func_name(n, tags, obj)}") );

    if(func)
        return func(hTracer, callback_type, ${th.make_pfncb_name(n, tags, obj)});

    return ZE_RESULT_ERROR_UNINITIALIZED;    
}

%endfor
%endfor #s in specs:

} //Extern C