gen_babeltrace_cl_callbacks.rb 1.06 KB
Newer Older
Brice Videau's avatar
Brice Videau committed
1
require 'yaml'
2
opencl_babeltrace_model = YAML::load_file("opencl_babeltrace_model.yaml")
Brice Videau's avatar
Brice Videau committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

puts <<EOF
#ifndef _HEADER_CALLBACKS_H
#define _HEADER_CALLBACKS_H
#define CL_TARGET_OPENCL_VERSION 300
#define CL_USE_DEPRECATED_OPENCL_1_0_APIS
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
#define CL_USE_DEPRECATED_OPENCL_2_1_APIS
#define CL_USE_DEPRECATED_OPENCL_2_2_APIS
#include <CL/opencl.h>
#include <CL/cl_gl_ext.h>
#include <CL/cl_egl.h>
#include <CL/cl_ext_intel.h>
#include "tracer_opencl.h"

#include "babeltrace_cl.h"

EOF

24
25
26
27
28
29
30
31
opencl_babeltrace_model[:event_classes].each { |klass|
  name = klass[:name]
  fields = klass[:payload]
  decls = []
  fields.each { |f|
    decls.push ['size_t', "_#{f[:name]}_length"] if f[:class] == 'array_static'
    decls.push [f[:cast_type], f[:name]]
  }
Brice Videau's avatar
Brice Videau committed
32
33
  puts <<EOF
typedef void (#{name.gsub(":","_")}_cb)(
34
35
    #{(["const bt_event *bt_evt", "const bt_clock_snapshot *bt_clock"]+
      decls.collect { |t, n| "#{t} #{n}" }).join(",\n    ")});
Brice Videau's avatar
Brice Videau committed
36
37
38
39
40
41
42

EOF
}

puts <<EOF
#endif
EOF