Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120661449
communicator.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jul 6, 02:21
Size
7 KB
Mime Type
text/x-c
Expires
Tue, Jul 8, 02:21 (2 d)
Engine
blob
Format
Raw Data
Handle
27224380
Attached To
rAKA akantu
communicator.cc
View Options
/**
* Copyright (©) 2010-2023 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This file is part of Akantu
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*/
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
#if defined(AKANTU_USE_MPI)
#include "mpi_communicator_data.hh"
#endif
/* -------------------------------------------------------------------------- */
namespace akantu {
#if defined(AKANTU_USE_MPI)
int MPICommunicatorData::is_externaly_initialized = 0;
#endif
Int InternalCommunicationRequest::counter = 0;
/* -------------------------------------------------------------------------- */
InternalCommunicationRequest::InternalCommunicationRequest(Idx source, Idx dest)
: source(source), destination(dest) {
this->id = counter++;
}
/* -------------------------------------------------------------------------- */
InternalCommunicationRequest::~InternalCommunicationRequest() = default;
/* -------------------------------------------------------------------------- */
void InternalCommunicationRequest::printself(std::ostream & stream,
int indent) const {
std::string space(indent, AKANTU_INDENT);
stream << space << "CommunicationRequest [" << std::endl;
stream << space << " + id : " << id << std::endl;
stream << space << " + source : " << source << std::endl;
stream << space << " + destination : " << destination << std::endl;
stream << space << "]" << std::endl;
}
/* -------------------------------------------------------------------------- */
Communicator::~Communicator() {
auto * event = new FinalizeCommunicatorEvent(*this);
this->sendEvent(*event);
delete event;
}
/* -------------------------------------------------------------------------- */
Communicator & Communicator::getStaticCommunicator() {
AKANTU_DEBUG_IN();
if (!static_communicator) {
int nb_args = 0;
char ** null = nullptr;
static_communicator =
std::make_unique<Communicator>(nb_args, null, private_member{});
}
AKANTU_DEBUG_OUT();
return *static_communicator;
}
/* -------------------------------------------------------------------------- */
Communicator & Communicator::getStaticCommunicator(int & argc, char **& argv) {
if (!static_communicator) {
static_communicator =
std::make_unique<Communicator>(argc, argv, private_member{});
}
return getStaticCommunicator();
}
} // namespace akantu
#ifdef AKANTU_USE_MPI
#include "communicator_mpi_inline_impl.hh"
#else
#include "communicator_dummy_inline_impl.hh"
#endif
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Template instantiation */
/* -------------------------------------------------------------------------- */
#define AKANTU_COMM_INSTANTIATE_NOINT(T) \
template void Communicator::probe<T>(int sender, int tag, \
CommunicationStatus & status) const; \
template bool Communicator::asyncProbe<T>( \
int sender, int tag, CommunicationStatus & status) const;
#define AKANTU_COMM_INSTANTIATE_INT(T, INT) \
template void Communicator::sendImpl<T, INT>( \
const T * buffer /*NOLINT*/, INT size, int receiver, int tag, \
const CommunicationMode & mode) const; \
template void Communicator::receiveImpl<T, INT>( \
T * buffer /*NOLINT*/, INT size, int sender, int tag) const; \
template CommunicationRequest Communicator::asyncSendImpl<T, INT>( \
const T * buffer /*NOLINT*/, INT size, int receiver, int tag, \
const CommunicationMode & mode) const; \
template CommunicationRequest Communicator::asyncReceiveImpl<T, INT>( \
T * buffer /* NOLINT */, INT size, int sender, int tag) const; \
template void Communicator::allGatherImpl<T, INT>(T * values /*NOLINT*/, \
INT nb_values) const; \
template void Communicator::allGatherVImpl<T, INT>( \
T * values /*NOLINT*/, const INT * nb_values) const; \
template void Communicator::gatherImpl<T, INT>( \
T * values /*NOLINT*/, INT nb_values, int root) const; \
template void Communicator::gatherImpl<T, INT>( \
T * values /*NOLINT*/, INT nb_values, T * gathered /*NOLINT*/, \
INT nb_gathered) const; \
template void Communicator::gatherVImpl<T, INT>( \
T * values /*NOLINT*/, INT * nb_values, int root) const; \
template void Communicator::broadcastImpl<T, INT>( \
T * values /*NOLINT*/, INT nb_values, int root) const; \
template void Communicator::allReduceImpl<T, INT>( \
T * values /*NOLINT*/, INT nb_values, SynchronizerOperation op) const; \
template void Communicator::scanImpl<T, INT>( \
T * values /*NOLINT*/, T * /*NOLINT*/, INT nb_values, \
SynchronizerOperation op) const; \
template void Communicator::exclusiveScanImpl<T, INT>( \
T * values /*NOLINT*/, T * /*NOLINT*/, INT nb_values, \
SynchronizerOperation op) const;
#define AKANTU_COMM_INSTANTIATE(T) \
AKANTU_COMM_INSTANTIATE_NOINT(T) \
AKANTU_COMM_INSTANTIATE_INT(T, int) \
AKANTU_COMM_INSTANTIATE_INT(T, long) \
AKANTU_COMM_INSTANTIATE_INT(T, long long)
namespace {
using SCMinMaxLoc_real_int = SCMinMaxLoc<Real, int>;
}
#if !defined(DOXYGEN)
AKANTU_COMM_INSTANTIATE(bool)
AKANTU_COMM_INSTANTIATE(Real)
// After some tests int32_t and int64_t do not cover all cases
AKANTU_COMM_INSTANTIATE(int)
AKANTU_COMM_INSTANTIATE(long)
AKANTU_COMM_INSTANTIATE(long long)
AKANTU_COMM_INSTANTIATE(unsigned int)
AKANTU_COMM_INSTANTIATE(unsigned long)
AKANTU_COMM_INSTANTIATE(unsigned long long)
AKANTU_COMM_INSTANTIATE(char)
AKANTU_COMM_INSTANTIATE(NodeFlag)
AKANTU_COMM_INSTANTIATE(SCMinMaxLoc_real_int)
#endif
} // namespace akantu
Event Timeline
Log In to Comment