mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Merge topic 'mpi-init' into release-1.9
90c7e7707 Initialize DIY in vtkm::cont::Initialize Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Vicente Bolea <vicente.bolea@kitware.com> Merge-request: !2880
This commit is contained in:
commit
15f9c168f6
8
docs/changelog/mpi-init.md
Normal file
8
docs/changelog/mpi-init.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Initialize DIY in vtkm::cont::Initialize
|
||||
|
||||
This has the side effect of initialing MPI_Init (and will also
|
||||
call MPI_Finalize at program exit). However, if the calling
|
||||
code has already called MPI_Init, then nothing will happen.
|
||||
Thus, if the calling code wants to manage MPI_Init/Finalize,
|
||||
it can do so as long as it does before it initializes VTK-m.
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include <vtkm/cont/internal/OptionParser.h>
|
||||
#include <vtkm/cont/internal/OptionParserArguments.h>
|
||||
|
||||
#include <vtkm/thirdparty/diy/environment.h>
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
@ -114,7 +116,7 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts)
|
||||
const std::string loggingHelp = " " + loggingFlag +
|
||||
" <#|INFO|WARNING|ERROR|FATAL|OFF> \tSpecify a log level (when logging is enabled).";
|
||||
|
||||
// initialize logging first -- it'll pop off the options it consumes:
|
||||
// initialize logging and diy first -- they'll pop off the options they consume:
|
||||
if (argc == 0 || argv == nullptr)
|
||||
{
|
||||
vtkm::cont::InitLogging();
|
||||
@ -123,6 +125,19 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts)
|
||||
{
|
||||
vtkm::cont::InitLogging(argc, argv, loggingFlag);
|
||||
}
|
||||
if (!vtkmdiy::mpi::environment::initialized())
|
||||
{
|
||||
if (argc == 0 || argv == nullptr)
|
||||
{
|
||||
// If initialized, will be deleted on program exit (calling MPI_Finalize if necessary)
|
||||
static vtkmdiy::mpi::environment diyEnvironment;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If initialized, will be deleted on program exit (calling MPI_Finalize if necessary)
|
||||
static vtkmdiy::mpi::environment diyEnvironment(argc, argv);
|
||||
}
|
||||
}
|
||||
|
||||
{ // Parse VTKm options
|
||||
std::vector<opt::Descriptor> usage;
|
||||
@ -359,8 +374,9 @@ InitializeResult Initialize(int& argc, char* argv[], InitializeOptions opts)
|
||||
VTKM_CONT
|
||||
InitializeResult Initialize()
|
||||
{
|
||||
vtkm::cont::InitLogging();
|
||||
return InitializeResult{};
|
||||
int argc = 0;
|
||||
char** argv = nullptr;
|
||||
return Initialize(argc, argv);
|
||||
}
|
||||
}
|
||||
} // end namespace vtkm::cont
|
||||
|
Loading…
Reference in New Issue
Block a user