A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mpi-interface.cc
Go to the documentation of this file.
1/*
2 * Copyright 2013. Lawrence Livermore National Security, LLC.
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Steven Smith <smith84@llnl.gov>
7 */
8
9/**
10 * @file
11 * @ingroup mpi
12 * Implementation of class ns3::MpiInterface.
13 */
14
15#include "mpi-interface.h"
16
19
20#include <ns3/global-value.h>
21#include <ns3/log.h>
22#include <ns3/string.h>
23
24namespace ns3
25{
26
27NS_LOG_COMPONENT_DEFINE("MpiInterface");
28
29ParallelCommunicationInterface* MpiInterface::g_parallelCommunicationInterface = nullptr;
30
31void
37
40{
42 {
44 }
45 else
46 {
47 return 0;
48 }
49}
50
53{
55 {
57 }
58 else
59 {
60 return 1;
61 }
62}
63
64bool
66{
68 {
70 }
71 else
72 {
73 return false;
74 }
75}
76
77void
79{
80 StringValue simulationTypeValue;
81 bool useDefault = true;
82
83 if (GlobalValue::GetValueByNameFailSafe("SimulatorImplementationType", simulationTypeValue))
84 {
85 std::string simulationType = simulationTypeValue.Get();
86
87 // Set communication interface based on the simulation type being used.
88 // Defaults to synchronous.
89 if (simulationType == "ns3::NullMessageSimulatorImpl")
90 {
92 useDefault = false;
93 }
94 else if (simulationType == "ns3::DistributedSimulatorImpl")
95 {
97 useDefault = false;
98 }
99 }
100
101 // User did not specify a valid parallel simulator; use the default.
102 if (useDefault)
103 {
105 GlobalValue::Bind("SimulatorImplementationType",
106 StringValue("ns3::DistributedSimulatorImpl"));
107 NS_LOG_WARN("SimulatorImplementationType was set to non-parallel simulator; setting type "
108 "to ns3::DistributedSimulatorImp");
109 }
110}
111
112void
113MpiInterface::Enable(int* pargc, char*** pargv)
114{
116
118}
119
120void
121MpiInterface::Enable(MPI_Comm communicator)
122{
125}
126
127void
133
134MPI_Comm
140
141void
149
150} // namespace ns3
static void Bind(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
static bool GetValueByNameFailSafe(std::string name, AttributeValue &value)
Finds the GlobalValue with the given name and returns its value.
static ParallelCommunicationInterface * g_parallelCommunicationInterface
Static instance of the instantiated parallel controller.
static MPI_Comm GetCommunicator()
Return the communicator used to run ns-3.
static void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Send a packet to a remote node.
static bool IsEnabled()
Returns enabled state of parallel environment.
static void Destroy()
Deletes storage used by the parallel environment.
static uint32_t GetSystemId()
Get the id number of this rank.
static uint32_t GetSize()
Get the number of ranks used by ns-3.
static void Disable()
Clean up the ns-3 parallel communications interface.
static void Enable(int *pargc, char ***pargv)
Setup the parallel communication interface.
static void SetParallelSimulatorImpl()
Common enable logic.
Interface between ns-3 and MPI for the Null Message distributed simulation implementation.
virtual void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)=0
Send a packet to a remote node.
virtual void Enable(int *pargc, char ***pargv)=0
Setup the parallel communication interface.
virtual bool IsEnabled()=0
Returns enabled state of parallel environment.
virtual MPI_Comm GetCommunicator()=0
Return the communicator used to run ns-3.
virtual uint32_t GetSystemId()=0
Get the id number of this rank.
virtual void Destroy()=0
Deletes storage used by the parallel environment.
virtual uint32_t GetSize()=0
Get the number of ranks used by ns-3.
virtual void Disable()=0
Clean up the ns-3 parallel communications interface.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
Definition string.h:45
std::string Get() const
Definition string.cc:20
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Declaration of classes ns3::SentBuffer and ns3::GrantedTimeWindowMpiInterface.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
Declaration of class ns3::MpiInterface.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Declaration of classes ns3::NullMessageSentBuffer and ns3::NullMessageMpiInterface.