Add PMIx plugin

Proof of concept for now.
This commit is contained in:
Dennis Klein
2019-02-01 16:10:33 +01:00
committed by Dennis Klein
parent c0771c81d6
commit 1191c3cda5
7 changed files with 234 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
################################################################################
# Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
# #
# This software is distributed under the terms of the #
# GNU Lesser General Public Licence (LGPL) version 3, #
# copied verbatim in the file "LICENSE" #
################################################################################
set(plugin FairMQPlugin_pmix)
add_library(${plugin} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/PMIx.cxx ${CMAKE_CURRENT_SOURCE_DIR}/PMIx.h)
target_link_libraries(${plugin} FairMQ PMIx::libpmix)
target_include_directories(${plugin} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(${plugin} PROPERTIES
CXX_VISIBILITY_PRESET hidden
VERSION ${PROJECT_GIT_VERSION}
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
)
install(TARGETS ${plugin}
EXPORT ${PROJECT_EXPORT_SET}
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
)

View File

@@ -0,0 +1,60 @@
/********************************************************************************
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include "PMIx.h"
#include <FairMQLogger.h>
#include <fairmq/Tools.h>
#include <stdexcept>
namespace fair
{
namespace mq
{
namespace plugins
{
PMIx::PMIx(const std::string& name,
const Plugin::Version version,
const std::string& maintainer,
const std::string& homepage,
PluginServices* pluginServices)
: Plugin(name, version, maintainer, homepage, pluginServices)
, fPid(getpid())
{
auto rc = PMIx_Init(&fPMIxProc, NULL, 0);
if (rc != PMIX_SUCCESS) {
throw std::runtime_error(tools::ToString("Client ns ", fPMIxProc.nspace,
" rank ", fPMIxProc.rank,
" pid ", fPid,
": PMIx_Init failed: ", rc));
}
LOG(info) << "Client ns " << fPMIxProc.nspace << " rank " << fPMIxProc.rank << " pid " << fPid
<< ": Running";
}
PMIx::~PMIx()
{
LOG(info) << "Client ns " << fPMIxProc.nspace << " rank " << fPMIxProc.rank << " pid " << fPid
<< ": Finalizing";
auto rc = PMIx_Finalize(NULL, 0);
if (rc != PMIX_SUCCESS) {
throw std::runtime_error(tools::ToString("Client ns ", fPMIxProc.nspace,
" rank ", fPMIxProc.rank,
" pid ", fPid,
": PMIx_Finalize failed: ", rc));
}
LOG(info) << "Client ns " << fPMIxProc.nspace << " rank " << fPMIxProc.rank << " pid " << fPid
<< ": PMIx_Finalize successfully completed";
}
} /* namespace plugins */
} /* namespace mq */
} /* namespace fair */

View File

@@ -0,0 +1,64 @@
/********************************************************************************
* Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#ifndef FAIR_MQ_PLUGINS_PMIX
#define FAIR_MQ_PLUGINS_PMIX
#include <fairmq/Plugin.h>
#include <fairmq/Version.h>
#include <pmix.h>
#include <sys/types.h>
#include <unistd.h>
namespace fair
{
namespace mq
{
namespace plugins
{
class PMIx : public Plugin
{
public:
PMIx(const std::string& name,
const Plugin::Version version,
const std::string& maintainer,
const std::string& homepage,
PluginServices* pluginServices);
~PMIx();
private:
pmix_proc_t fPMIxProc;
pid_t fPid;
};
Plugin::ProgOptions PMIxProgramOptions()
{
boost::program_options::options_description options{"PMIx Plugin"};
options.add_options()(
"pmix-dummy", boost::program_options::value<int>()->default_value(0), "Dummy.");
return options;
}
REGISTER_FAIRMQ_PLUGIN(
PMIx, // Class name
pmix, // Plugin name (string, lower case chars only)
(Plugin::Version{FAIRMQ_VERSION_MAJOR,
FAIRMQ_VERSION_MINOR,
FAIRMQ_VERSION_PATCH}), // Version
"FairRootGroup <fairroot@gsi.de>", // Maintainer
"https://github.com/FairRootGroup/FairMQ", // Homepage
PMIxProgramOptions // custom program options for the plugin
)
} /* namespace plugins */
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_PLUGINS_DDS */