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

Factored babeltrace callback generation for ze and cuda.

parent 40f8ef6e
Pipeline #13161 failed with stage
......@@ -261,16 +261,15 @@ CUDA_LIB_GEN = \
EXTRA_DIST += $(CUDA_LIB_GEN)
babeltrace_cuda_callbacks.h: $(srcdir)/gen_babeltrace_cuda_callbacks.rb cuda_babeltrace_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $< > $@
babeltrace_cuda_callbacks.h: $(top_srcdir)/utils/gen_babeltrace_callbacks.rb cuda_babeltrace_model.yaml cuda.h.include
SRC_DIR=$(srcdir) $(RUBY) $< cuda > $@
BUILT_SOURCES += babeltrace_cuda_callbacks.h
babeltrace_cuda_dispatchers.c: $(top_srcdir)/utils/gen_babeltrace_dispatchers.rb cuda_babeltrace_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $< cuda > $@
EXTRA_DIST += \
gen_babeltrace_cuda_callbacks.rb
EXTRA_DIST += cuda.h.include
CLEANFILES += \
babeltrace_cuda_callbacks.h \
......
#define __CUDA_API_VERSION_INTERNAL 1
#include <cuda.h>
......@@ -23,4 +23,5 @@ EXTRA_DIST = \
bt_plugins/dust.rb \
bt_plugins/comparator.rb \
xprof_utils.h.erb \
gen_babeltrace_dispatchers.rb
gen_babeltrace_dispatchers.rb \
gen_babeltrace_callbacks.rb
require 'yaml'
cuda_babeltrace_model = YAML::load_file("cuda_babeltrace_model.yaml")
namespace = ARGV[0]
babeltrace_model = YAML::load_file("#{namespace}_babeltrace_model.yaml")
puts <<EOF
#ifndef _BABELTRACE_#{namespace.upcase}_CALLBACKS_H
#define _BABELTRACE_#{namespace.upcase}_CALLBACKS_H
EOF
header = File.join(ENV["SRC_DIR"], "#{namespace}.h.include")
puts File.read(header) if File.exist?(header)
puts <<EOF
#ifndef _BABELTRACE_CUDA_CALLBACKS_H
#define _BABELTRACE_CUDA_CALLBACKS_H
#define __CUDA_API_VERSION_INTERNAL 1
#include <cuda.h>
#include <babeltrace2/babeltrace.h>
EOF
cuda_babeltrace_model[:event_classes].each { |klass|
babeltrace_model[:event_classes].each { |klass|
name = klass[:name]
fields = klass[:payload]
decls = []
......
......@@ -267,14 +267,13 @@ ZE_LIB_GEN = \
EXTRA_DIST += $(ZE_LIB_GEN)
babeltrace_ze_callbacks.h: $(srcdir)/gen_babeltrace_ze_callbacks.rb ze_babeltrace_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $< > $@
babeltrace_ze_callbacks.h: $(top_srcdir)/utils/gen_babeltrace_callbacks.rb ze_babeltrace_model.yaml ze.h.include
SRC_DIR=$(srcdir) $(RUBY) $< ze > $@
babeltrace_ze_dispatchers.c: $(top_srcdir)/utils/gen_babeltrace_dispatchers.rb ze_babeltrace_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $< ze > $@
EXTRA_DIST += \
gen_babeltrace_ze_callbacks.rb
EXTRA_DIST += ze.h.include
CLEANFILES += \
babeltrace_ze_callbacks.h \
......
require 'yaml'
ze_babeltrace_model = YAML::load_file("ze_babeltrace_model.yaml")
puts <<EOF
#ifndef _BABELTRACE_ZE_CALLBACKS_H
#define _BABELTRACE_ZE_CALLBACKS_H
#include <ze_api.h>
#include <ze_ddi.h>
#include <zet_api.h>
#include <zet_ddi.h>
#include <zes_api.h>
#include <zes_ddi.h>
#include <layers/zel_tracing_api.h>
#include <layers/zel_tracing_ddi.h>
#include <babeltrace2/babeltrace.h>
EOF
ze_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]]
}
puts <<EOF
typedef void (#{name.gsub(":","_")}_cb)(
#{(["const bt_event *bt_evt", "const bt_clock_snapshot *bt_clock"]+
decls.collect { |t, n| "#{t} #{n}" }).join(",\n ")}
);
EOF
}
puts <<EOF
#endif
EOF
#include <ze_api.h>
#include <ze_ddi.h>
#include <zet_api.h>
#include <zet_ddi.h>
#include <zes_api.h>
#include <zes_ddi.h>
#include <layers/zel_tracing_api.h>
#include <layers/zel_tracing_ddi.h>
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