Skip to content

Commit

Permalink
Add hooks for libmpifort_cray function names
Browse files Browse the repository at this point in the history
Signed-off-by: Wileam Yonatan Phan <wileamyonatan.phan@amd.com>
  • Loading branch information
wilephan-amd committed Jan 30, 2025
1 parent 8deebb6 commit d637338
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions source/bin/rocprof-sys-instrument/module_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ module_function::is_routine_constrained() const
return _report("Skipping", "function-constraint", 2);
}

static std::regex exclude("(rocprofsys|rocprof-sys|tim::|MPI_Init|MPI_"
"Finalize|dyninst|DYNINST|tm_clones)",
static std::regex exclude("(rocprofsys|rocprof-sys|tim::|MPI_Init|mpi_init_"
"|MPI_Finalize|mpi_finalize_|dyninst|DYNINST|tm_clones)",
regex_opts);
// static std::regex exclude_printf("(|v|f)printf$", regex_opts);
static std::regex exclude_cxx(
Expand Down
6 changes: 4 additions & 2 deletions source/bin/rocprof-sys-instrument/rocprof-sys-instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,8 +1689,10 @@ main(int argc, char** argv)
{ "rocprofsys_user_stop_thread_trace" });
#if ROCPROFSYS_USE_MPI > 0 || ROCPROFSYS_USE_MPI_HEADERS > 0
// if any of the below MPI functions are found, enable MPI support
for(const auto* itr : { "MPI_Init", "MPI_Init_thread", "MPI_Finalize",
"MPI_Comm_rank", "MPI_Comm_size" })
for(const auto* itr :
{ "MPI_Init", "MPI_Init_thread", "MPI_Finalize", "MPI_Comm_rank", "MPI_Comm_size",
"mpi_init_", "mpi_init_thread_", "mpi_finalize_", "mpi_comm_rank_",
"mpi_comm_size_" })
{
if(find_function(app_image, itr) != nullptr)
{
Expand Down
24 changes: 19 additions & 5 deletions source/lib/rocprof-sys/library/components/mpi_gotcha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,22 @@ mpi_gotcha::configure()
reject_bindings.emplace("MPI_Init");
reject_bindings.emplace("MPI_Init_thread");
reject_bindings.emplace("MPI_Finalize");
mpi_gotcha_t::template configure<0, int, int*, char***>("mpi_init_");
mpi_gotcha_t::template configure<1, int, int*, char***, int, int*>(
"mpi_init_thread_");
mpi_gotcha_t::template configure<2, int>("mpi_finalize_");
reject_bindings.emplace("mpi_init_");
reject_bindings.emplace("mpi_init_thread_");
reject_bindings.emplace("mpi_finalize_");
#if defined(ROCPROFSYS_USE_MPI_HEADERS) && ROCPROFSYS_USE_MPI_HEADERS > 0
mpi_gotcha_t::template configure<3, int, comm_t, int*>("MPI_Comm_rank");
mpi_gotcha_t::template configure<4, int, comm_t, int*>("MPI_Comm_size");
reject_bindings.emplace("MPI_Comm_rank");
reject_bindings.emplace("MPI_Comm_size");
mpi_gotcha_t::template configure<3, int, comm_t, int*>("mpi_comm_rank_");
mpi_gotcha_t::template configure<4, int, comm_t, int*>("mpi_comm_size_");
reject_bindings.emplace("mpi_comm_rank_");
reject_bindings.emplace("mpi_comm_size_");
#endif
};
}
Expand Down Expand Up @@ -281,12 +292,12 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::incoming, comm_t _comm, int
ROCPROFSYS_BASIC_DEBUG_F("%s()\n", _data.tool_id.c_str());

rocprofsys_push_trace_hidden(_data.tool_id.c_str());
if(_data.tool_id == "MPI_Comm_rank")
if(_data.tool_id == "MPI_Comm_rank" || _data.tool_id == "mpi_comm_rank_")
{
m_comm_val = (uintptr_t) _comm; // NOLINT
m_rank_ptr = _val;
}
else if(_data.tool_id == "MPI_Comm_size")
else if(_data.tool_id == "MPI_Comm_size" || _data.tool_id == "mpi_comm_size_")
{
m_comm_val = (uintptr_t) _comm; // NOLINT
m_size_ptr = _val;
Expand All @@ -305,7 +316,8 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::outgoing, int _retval)

if(!settings::use_output_suffix()) settings::use_output_suffix() = true;

if(_retval == tim::mpi::success_v && _data.tool_id.find("MPI_Init") == 0)
if(_retval == tim::mpi::success_v &&
(_data.tool_id.find("MPI_Init") == 0 || _data.tool_id.find("mpi_init_") == 0))
{
rocprofsys_mpi_set_attr();
// rocprof-sys will set this environement variable to true in binary rewrite mode
Expand Down Expand Up @@ -339,7 +351,8 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::outgoing, int _retval)
}
}
}
else if(_retval == tim::mpi::success_v && _data.tool_id.find("MPI_Comm_") == 0)
else if(_retval == tim::mpi::success_v && (_data.tool_id.find("MPI_Comm_") == 0 ||
_data.tool_id.find("mpi_comm_") == 0))
{
auto_lock_t _lk{ type_mutex<mpi_gotcha>() };
if(m_comm_val != null_comm())
Expand All @@ -356,7 +369,8 @@ mpi_gotcha::audit(const gotcha_data_t& _data, audit::outgoing, int _retval)
: std::max<int>(m_size, _get_rank() + 1);
};

if(_data.tool_id == "MPI_Comm_rank" || _data.tool_id == "MPI_Comm_size")
if(_data.tool_id == "MPI_Comm_rank" || _data.tool_id == "MPI_Comm_size" ||
_data.tool_id == "mpi_comm_rank_" || _data.tool_id == "mpi_comm_size_")
{
_comm_entry.rank = m_rank = std::max<int>(_comm_entry.rank, _get_rank());
_comm_entry.size = m_size = std::max<int>(_comm_entry.size, _get_size());
Expand Down

0 comments on commit d637338

Please sign in to comment.