Skip to content

Commit

Permalink
Let cali_mpi_init() work after MPI_Init() with PMPI (LLNL#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme authored May 13, 2020
1 parent acddb0e commit e376020
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 3 additions & 8 deletions src/caliper/Caliper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1932,7 +1932,8 @@ Caliper::is_initialized()
return GlobalData::s_init_lock == 0;
}

/// \brief Add a list of available caliper services.
/// \brief Add a list of %Caliper service specs.
///
/// Adds services that will be made available by %Caliper. This does *not*
/// activate the services automatically, they must still be listed in the
/// CALI_SERVICES_ENABLE configuration variable at runtime.
Expand All @@ -1949,17 +1950,11 @@ Caliper::is_initialized()
///
/// Caliper::add_services(my_services);
/// \endcode
///
/// This is only effective _before_ %Caliper is initialized, and should be
/// called e.g. during static initialization or from a library constructor.

void
Caliper::add_services(const CaliperService* s)
{
if (is_initialized())
Log(0).stream() << "add_services(): Caliper is already initialized - cannot add new services" << std::endl;
else
services::add_service_specs(s);
services::add_service_specs(s);
}

void
Expand Down
6 changes: 5 additions & 1 deletion src/mpi-rt/setup_mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ mpirt_constructor()
nullptr
};

Caliper::add_init_hook(setup_mpi);
if (Caliper::is_initialized())
setup_mpi();
else
Caliper::add_init_hook(setup_mpi);

Caliper::add_services(services);

add_global_config_specs(controllers);
Expand Down

0 comments on commit e376020

Please sign in to comment.