Skip to content

Commit

Permalink
fix makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Applencourt committed Jun 17, 2024
1 parent 5c48364 commit 76d4c15
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 48 deletions.
5 changes: 3 additions & 2 deletions mpi/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ BUILT_SOURCES = \
$(MODIFIED_MPI_HDR) \
$(MPI_PROBES_INCL)

tracer_mpi.c: $(srcdir)/gen_mpi.rb $(MPI_MODEL) $(MPI_PROBES_INCL)
tracer_mpi.c: $(srcdir)/gen_mpi.rb $(srcdir)/tracer_mpi_helpers.include.c $(MPI_MODEL) $(MPI_PROBES_INCL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@

EXTRA_DIST += \
gen_mpi.rb
gen_mpi.rb \
tracer_mpi_helpers.include.c

CLEANFILES += \
tracer_mpi.c
Expand Down
75 changes: 29 additions & 46 deletions mpi/gen_mpi.rb
Original file line number Diff line number Diff line change
@@ -1,86 +1,69 @@
require_relative 'mpi_model'

def common_block(c, provider)
params = c.parameters.collect(&:name)
tp_params = c.parameters.collect do |p|
if p.type.is_a?(YAMLCAst::Pointer) && p.type.type.is_a?(YAMLCAst::Function)
'(void *)(intptr_t)' + p.name
else
p.name
end
end
tracepoint_params = c.tracepoint_parameters.collect(&:name)
c.tracepoint_parameters.each do |p|
puts " #{p.type} #{p.name};"
end
c.tracepoint_parameters.each do |p|
puts p.init unless p.after?
end
tracepoint_params = c.tracepoint_parameters.reject { |p| p.after? }.collect(&:name)
puts <<EOF
tracepoint(#{provider}, #{c.name}_#{START}, #{(tp_params + tracepoint_params).join(', ')});
EOF
tracepoint_params = c.tracepoint_parameters.collect(&:name)
puts " tracepoint(#{provider}, #{c.name}_#{START}, #{(tp_params + tracepoint_params).join(', ')});"

params = c.parameters.collect(&:name)
if c.has_return_type?
puts <<EOF
#{c.type} _retval;
_retval = #{MPI_POINTER_NAMES[c]}(#{params.join(', ')});
EOF
puts " #{c.type} _retval;"
puts " _retval = #{MPI_POINTER_NAMES[c]}(#{params.join(', ')});"
else
puts " #{MPI_POINTER_NAMES[c]}(#{params.join(', ')});"
end
c.tracepoint_parameters.each do |p|
puts p.init if p.after?
end

tracepoint_params = c.tracepoint_parameters.collect(&:name)
tp_params.push '_retval' if c.has_return_type?
puts <<EOF
tracepoint(#{provider}, #{c.name}_#{STOP}, #{(tp_params + tracepoint_params).join(', ')});
EOF
puts " tracepoint(#{provider}, #{c.name}_#{STOP}, #{(tp_params + tracepoint_params).join(', ')});"
puts ' return _retval;' if c.has_return_type?
end

def normal_wrapper(c, provider)
puts <<~EOF
#{c.decl} {
EOF
puts " _init_tracer();" if c.init?

puts "#{c.decl} {"
puts ' _init_tracer();' if c.init?
common_block(c, provider)
puts <<~EOF
}
EOF
puts '}'
puts ''
end

def define_and_find_mpi_symbols()

$mpi_commands.each { |c|
puts <<EOF
#define #{MPI_POINTER_NAMES[c]} #{c.pointer_name}
#{c.decl_pointer(c.pointer_type_name)};
static #{c.pointer_type_name} #{MPI_POINTER_NAMES[c]} = (void *) 0x0;
EOF
}
def define_and_find_mpi_symbols
$mpi_commands.each do |c|
puts <<~EOF
#define #{MPI_POINTER_NAMES[c]} #{c.pointer_name}
#{c.decl_pointer(c.pointer_type_name)};
static #{c.pointer_type_name} #{MPI_POINTER_NAMES[c]} = (void *) 0x0;
puts <<EOF
EOF
end

static void find_mpi_symbols(void * handle, int verbose) {
EOF
$mpi_commands.each { |c|
puts <<EOF
puts 'static void find_mpi_symbols(void * handle, int verbose) {'
$mpi_commands.each do |c|
puts <<EOF
#{MPI_POINTER_NAMES[c]} = (#{c.pointer_type_name})(intptr_t)dlsym(handle, "#{c.name}");
if (!#{MPI_POINTER_NAMES[c]} && verbose)
fprintf(stderr, "THAPI: Missing symbol #{c.name}!\\n");
#{MPI_POINTER_NAMES[c]} = (#{c.pointer_type_name})(intptr_t)dlsym(handle, "#{c.name}");
if (!#{MPI_POINTER_NAMES[c]} && verbose)
fprintf(stderr, "THAPI: Missing symbol #{c.name}!\\n");
EOF
}

puts <<EOF
}
end

EOF
puts '}'
puts ''
end

puts <<~EOF
Expand All @@ -93,7 +76,7 @@ def define_and_find_mpi_symbols()

define_and_find_mpi_symbols

puts File::read(File.join(SRC_DIR,"tracer_mpi_helpers.include.c"))
puts File.read(File.join(SRC_DIR, 'tracer_mpi_helpers.include.c'))

$mpi_commands.each do |c|
normal_wrapper(c, :lttng_ust_mpi)
Expand Down

0 comments on commit 76d4c15

Please sign in to comment.