Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
DonAurelio committed Nov 2, 2023
1 parent e7fbad9 commit 4e3e42d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
15 changes: 6 additions & 9 deletions hip/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,18 @@ BTX_HIP_GENERATED = \

EXTRA_DIST = \
$(top_srcdir)/utils/babeltrace_to_metababel_model.rb \
$(top_srcdir)/xprof/interval_model.yaml \
$(top_srcdir)/utils/btx_interval_model.yaml \
btx_hipmatching_model.yaml

CLEANFILES = \
btx_model.yaml
btx_hip_model.yaml \
btx_interval_model.yaml

btx_model.yaml: $(top_srcdir)/utils/babeltrace_to_metababel_model.rb hip_babeltrace_model.yaml
btx_hip_model.yaml: $(top_srcdir)/utils/babeltrace_to_metababel_model.rb hip_babeltrace_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $^ > $@

btx_interval_model.yaml: $(top_srcdir)/utils/babeltrace_to_metababel_model.rb $(top_srcdir)/xprof/interval_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $^ > $@

$(BTX_HIP_GENERATED) &: btx_interval_model.yaml btx_hipmatching_model.yaml btx_model.yaml
$(METABABEL) -u btx_model.yaml -d btx_interval_model.yaml -t FILTER -o btx_filter_hip -p hipinterval -c interval --matching $(srcdir)/btx_hipmatching_model.yaml -i hip.h.include
$(BTX_HIP_GENERATED) &: $(top_srcdir)/utils/btx_interval_model.yaml btx_hipmatching_model.yaml btx_hip_model.yaml
$(METABABEL) -u btx_hip_model.yaml -d $(top_srcdir)/utils/btx_interval_model.yaml -t FILTER -o btx_filter_hip -p hipinterval -c interval --matching $(srcdir)/btx_hipmatching_model.yaml -i hip.h.include

$(MODIFIED_HIP_HDR) &: $(HIP_HDR) $(srcdir)/headers.patch
$(RM) -r modified_include/
Expand Down Expand Up @@ -226,7 +224,6 @@ HIP_MODEL = \
$(srcdir)/../utils/LTTng.rb \
hip.h.include

# TODO: Take this file and use the script to generate the new model version.
hip_babeltrace_model.yaml: $(srcdir)/gen_babeltrace_hip_model.rb $(HIP_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@

Expand Down
15 changes: 11 additions & 4 deletions hip/btx_hipinterval_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@


struct data_s {
std::unordered_map<hpt_function_name_t, int64_t> dispatch;
std::unordered_map<hpt_t, int64_t> entry_ts;
};

typedef struct data_s data_t;

void set_entry_ts(data_t *data, hpt_t hpt, int64_t ts) {
data->entry_ts[hpt] = ts;
}

int64_t get_entry_ts(data_t *data, hpt_t hpt) {
return data->entry_ts.at(hpt);
}

std::string strip_event_class_name(const char *str) {
std::string temp(str);
std::smatch match;
Expand All @@ -34,7 +42,7 @@ static void send_host_message(void *btx_handle, void *usr_data, int64_t ts,
uint64_t vtid, bool err) {

std::string event_class_name_striped = strip_event_class_name(event_class_name);
const int64_t _start = (static_cast<data_t *>(usr_data))->dispatch.at({hostname, vpid, vtid, event_class_name_striped});
const int64_t _start = get_entry_ts(static_cast<data_t *>(usr_data), {hostname, vpid, vtid});

btx_push_message_lttng_host(btx_handle, hostname, vpid, vtid, _start, BACKEND_HIP,
event_class_name_striped.c_str(), (ts - _start), err);
Expand All @@ -49,8 +57,7 @@ void btx_finalize_component(void *usr_data) {
static void entries_callback(void *btx_handle, void *usr_data, int64_t ts,
const char *event_class_name, const char *hostname, int64_t vpid,
uint64_t vtid) {

((data_t *)usr_data)->dispatch[{hostname, vpid, vtid, strip_event_class_name(event_class_name)}] = ts;
set_entry_ts(((data_t *)usr_data), {hostname, vpid, vtid}, ts);
}

static void exits_callback_hipError_absent(void *btx_handle, void *usr_data, int64_t ts,
Expand Down
2 changes: 1 addition & 1 deletion hip/btx_hipmatching_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
:members:
- :name: ^hipResult$
:field_class:
:type: ^integer_signed$
:type: integer_signed
:cast_type: ^hipError_t$

- :set_id: exits_hipError_absent
Expand Down
17 changes: 7 additions & 10 deletions utils/babeltrace_to_metababel_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@

HIP_STRUCT_TYPES = [
'struct hipChannelFormatDesc',
'struct hipExtent',
'hipIpcMemHandle_t',
'hipIpcEventHandle_t',
'hipPitchedPtr',
'hipExtent',
'hipPitchedPtr',
'hipExtent',
'struct hipExtent',
'dim3',
'hipPitchedPtr',
'hipExtent',
'hipPitchedPtr',
'hipExtent',
'dim3',
]

Expand Down Expand Up @@ -52,7 +45,9 @@ def translate_key_value(k,v)
def get_element_field_class(element_field, parent_field)
class_properties = element_field.delete(:class_properties)
field_properties = (element_field.to_a + class_properties.to_a).filter_map {|k,v| translate_key_value(k,v) unless INGONRE_PROPERTIES.include?(k) }.to_h

if parent_field[:class] == 'array_dynamic'
# get array elements' cast_type
match = parent_field[:cast_type].match(/(.*) \*/)
raise ":cast_type for element_field in array_dynamic can not be determined for #{parent_field}." unless match
field_properties[:cast_type] = match[1]
Expand All @@ -65,9 +60,11 @@ def get_field_class_properties(field, member_name)
class_properties = field.delete(:class_properties)
field_element_field_class = field.key?(:field) ? get_element_field_class(field.delete(:field), field) : {}
field_properties = (field.to_a + class_properties.to_a + field_element_field_class.to_a ).filter_map {|k,v| translate_key_value(k,v) unless INGONRE_PROPERTIES.include?(k) }.to_h
field_properties[:cast_type_is_struct] = true if HIP_STRUCT_TYPES.include?(field[:cast_type])
field_properties[:length_field_path] = "EVENT_PAYLOAD[\"_#{member_name}_length\"]" if field_properties[:type] == 'array_dynamic'


# Special casting case for struct <-> string.
field_properties[:cast_type_is_struct] = true if HIP_STRUCT_TYPES.include?(field[:cast_type])

field_properties
end

Expand Down

0 comments on commit 4e3e42d

Please sign in to comment.