Skip to content
Snippets Groups Projects
Commit da9fb1e0 authored by Anna Wellmann's avatar Anna Wellmann
Browse files

Add more consts in Communicators

parent 8335f916
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !261. Comments created here will be created in the context of that merge request.
......@@ -55,22 +55,22 @@ public:
virtual ~Communicator() = default;
virtual int getBundleID() = 0;
virtual int getNumberOfBundles() = 0;
virtual int getProcessID() const = 0;
virtual int getProcessID(int bundle, int rank) = 0;
virtual bool isRoot() const = 0;
virtual void *getNativeCommunicator() = 0;
virtual int getBundleID() const = 0;
virtual int getNumberOfBundles() const = 0;
virtual int getProcessID() const = 0;
virtual int getProcessID(int bundle, int rank) const = 0;
virtual bool isRoot() const = 0;
virtual void *getNativeCommunicator() = 0;
virtual void sendSerializedObject(std::stringstream &ss, int target) = 0;
virtual void receiveSerializedObject(std::stringstream &ss, int source) = 0;
virtual int getRoot() = 0;
virtual int getBundleRoot() = 0;
virtual int getProcessRoot() = 0;
virtual int getNumberOfProcessesInBundle(int bundle) = 0;
virtual void barrier() = 0;
virtual void abort(int errorcode) = 0;
virtual int getRoot() const = 0;
virtual int getBundleRoot() const = 0;
virtual int getProcessRoot() const = 0;
virtual int getNumberOfProcessesInBundle(int bundle) const = 0;
virtual void barrier() = 0;
virtual void abort(int errorcode) = 0;
virtual std::vector<std::string> gather(const std::string &str) = 0;
virtual std::vector<int> gather(std::vector<int> &values) = 0;
......
......@@ -20,7 +20,7 @@ namespace vf::parallel
std::shared_ptr<Communicator> MPICommunicator::getInstance()
{
std::lock_guard<std::mutex> myLock(instantiation_mutex);
if (!instance){
if (!instance) {
instance = std::shared_ptr<MPICommunicator>(new MPICommunicator);
}
return instance;
......@@ -96,23 +96,23 @@ std::vector<unsigned long long> MPICommunicator::gather(std::vector<unsigned lon
//////////////////////////////////////////////////////////////////////////
int MPICommunicator::getProcessID() const { return PID; }
//////////////////////////////////////////////////////////////////////////
int MPICommunicator::getProcessID(int /*bundle*/, int /*rank*/) { return PID; }
int MPICommunicator::getProcessID(int /*bundle*/, int /*rank*/) const { return PID; }
//////////////////////////////////////////////////////////////////////////
int MPICommunicator::getNumberOfProcesses() const { return numprocs; }
//////////////////////////////////////////////////////////////////////////
void *MPICommunicator::getNativeCommunicator() { return &comm; }
//////////////////////////////////////////////////////////////////////////
int MPICommunicator::getBundleID() { return 0; }
int MPICommunicator::getBundleID() const { return 0; }
//////////////////////////////////////////////////////////////////////////
int MPICommunicator::getNumberOfBundles() { return 1; }
int MPICommunicator::getNumberOfBundles() const { return 1; }
//////////////////////////////////////////////////////////////////////////
int MPICommunicator::getRoot() { return root; }
int MPICommunicator::getRoot() const { return root; }
//////////////////////////////////////////////////////////////////////////
int MPICommunicator::getBundleRoot() { return 0; }
int MPICommunicator::getBundleRoot() const { return 0; }
//////////////////////////////////////////////////////////////////////////
int MPICommunicator::getProcessRoot() { return 0; }
int MPICommunicator::getProcessRoot() const { return 0; }
//////////////////////////////////////////////////////////////////////////
int MPICommunicator::getNumberOfProcessesInBundle(int /*bundle*/) { return numprocs; }
int MPICommunicator::getNumberOfProcessesInBundle(int /*bundle*/) const { return numprocs; }
//////////////////////////////////////////////////////////////////////////
bool MPICommunicator::isRoot() const { return PID == root; }
//////////////////////////////////////////////////////////////////////////
......
......@@ -33,16 +33,16 @@ public:
~MPICommunicator() override;
static std::shared_ptr<Communicator> getInstance();
int getBundleID() override;
int getNumberOfBundles() override;
int getBundleID() const override;
int getNumberOfBundles() const override;
int getProcessID() const override;
int getProcessID(int bundle, int rank) override;
int getProcessID(int bundle, int rank) const override;
int getNumberOfProcesses() const override;
void *getNativeCommunicator() override;
int getRoot() override;
int getBundleRoot() override;
int getProcessRoot() override;
int getNumberOfProcessesInBundle(int bundle) override;
int getRoot() const override;
int getBundleRoot() const override;
int getProcessRoot() const override;
int getNumberOfProcessesInBundle(int bundle) const override;
bool isRoot() const override;
void abort(int errorcode) override;
......
......@@ -45,21 +45,21 @@ namespace vf::parallel
return instance;
}
//////////////////////////////////////////////////////////////////////////
int NullCommunicator::getBundleID() { return 0; }
int NullCommunicator::getBundleID() const { return 0; }
//////////////////////////////////////////////////////////////////////////
int NullCommunicator::getNumberOfBundles() { return 0; }
int NullCommunicator::getNumberOfBundles() const { return 0; }
//////////////////////////////////////////////////////////////////////////
int NullCommunicator::getProcessID() const { return 0; }
int NullCommunicator::getProcessID() const { return 0; }
//////////////////////////////////////////////////////////////////////////
int NullCommunicator::getNumberOfProcesses() { return 0; }
int NullCommunicator::getNumberOfProcesses() const { return 1; }
//////////////////////////////////////////////////////////////////////////
void *NullCommunicator::getNativeCommunicator() { return NULL; }
//////////////////////////////////////////////////////////////////////////
int NullCommunicator::getRoot() { return 0; }
int NullCommunicator::getRoot() const { return 0; }
//////////////////////////////////////////////////////////////////////////
int NullCommunicator::getBundleRoot() { return 0; }
int NullCommunicator::getBundleRoot() const { return 0; }
//////////////////////////////////////////////////////////////////////////
int NullCommunicator::getProcessRoot() { return 0; }
int NullCommunicator::getProcessRoot() const { return 0; }
//////////////////////////////////////////////////////////////////////////
std::vector<std::string> NullCommunicator::gather(const std::string & /*str*/) { return std::vector<std::string>(); }
//////////////////////////////////////////////////////////////////////////
......@@ -68,10 +68,10 @@ namespace vf::parallel
//////////////////////////////////////////////////////////////////////////
void NullCommunicator::receiveSerializedObject(std::stringstream &ss, int source) {}
int NullCommunicator::getProcessID(int bundle, int rank) { return 0; }
int NullCommunicator::getProcessID(int bundle, int rank) const { return 0; }
bool NullCommunicator::isRoot() const { return true; }
int NullCommunicator::getNumberOfProcessesInBundle(int bundle) {return 0;}
int NullCommunicator::getNumberOfProcessesInBundle(int bundle) const {return 0;}
void NullCommunicator::barrier() {}
void NullCommunicator::abort(int errorcode) {}
......@@ -101,11 +101,6 @@ namespace vf::parallel
void NullCommunicator::send(real *sbuf, int count_s, int nb_rank) const {};
double NullCommunicator::reduceSum(double quantityPerProcess) const { return 0.0; };
int NullCommunicator::getNumberOfProcesses() const
{
return 1;
}
  • Author Maintainer

    This function was already defined in line 54, but returning 0 instead of 1. Was this intentional? What is the correct behavior?

  • Owner

    True. Actually I do not know. Return 1 makes more sense to me, as we always have 1 process at least.

  • Please register or sign in to reply
int NullCommunicator::mapCudaDevicesOnHosts(const std::vector<unsigned int> &devices, int numberOfDevices) const
{
return 0;
......
......@@ -46,21 +46,21 @@ class NullCommunicator : public Communicator
public:
static std::shared_ptr<Communicator> getInstance();
int getBundleID() override;
int getNumberOfBundles() override;
int getBundleID() const override;
int getNumberOfBundles() const override;
int getProcessID() const override;
int getProcessID(int bundle, int rank) override;
int getNumberOfProcesses();
int getProcessID(int bundle, int rank) const override;
int getNumberOfProcesses() const override;
bool isRoot() const override;
void *getNativeCommunicator() override;
void sendSerializedObject(std::stringstream &ss, int target) override;
void receiveSerializedObject(std::stringstream &ss, int source) override;
int getRoot() override;
int getBundleRoot() override;
int getProcessRoot() override;
int getNumberOfProcessesInBundle(int bundle) override;
int getRoot() const override;
int getBundleRoot() const override;
int getProcessRoot() const override;
int getNumberOfProcessesInBundle(int bundle) const override;
void barrier() override;
void abort(int errorcode) override;
......@@ -90,7 +90,6 @@ public:
void send(real *sbuf, int count_s, int nb_rank) const override;
double reduceSum(double quantityPerProcess) const override;
int getNumberOfProcesses() const override;
int mapCudaDevicesOnHosts(const std::vector<unsigned int> &devices, int numberOfDevices) const override;
void receiveSend(real *buffer_send, int size_buffer_send, real *buffer_receive, int size_buffer_recv,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment