gen_babeltrace_cl_callbacks.rb 1023 Bytes
Newer Older
Brice Videau's avatar
Brice Videau committed
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
require 'yaml'
opencl_model = YAML::load_file("opencl_model.yaml")

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

opencl_model["events"].each { |name, fields|
  puts <<EOF
typedef void (#{name.gsub(":","_")}_cb)(
    #{(["const bt_event *bt_event"]+fields.each.collect { |n, f|
  s =  "#{f["type"].gsub("cl_errcode", "cl_int")}"
  s << " *" if f["pointer"]
  s << " *" if f["array"]
  s << " *" if f["string"]
  s << " #{n}"
  if f["array"]
    ["size_t _#{n}_length", s]
  else
    s
  end
}).flatten.join(",\n    ")});

EOF
}

puts <<EOF
#endif
EOF