A Discrete-Event Network Simulator
API
mpi-interface.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright 2013. Lawrence Livermore National Security, LLC.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Steven Smith <smith84@llnl.gov>
19 */
20
27#include "mpi-interface.h"
28
29#include <ns3/global-value.h>
30#include <ns3/string.h>
31#include <ns3/log.h>
32
35
36namespace ns3 {
37
38NS_LOG_COMPONENT_DEFINE ("MpiInterface");
39
40ParallelCommunicationInterface* MpiInterface::g_parallelCommunicationInterface = 0;
41
42void
44{
47}
48
51{
54 else
55 return 0;
56}
57
60{
63 else
64 return 1;
65}
66
67bool
69{
71 {
73 }
74 else
75 {
76 return false;
77 }
78}
79
80void
82{
83 StringValue simulationTypeValue;
84 bool useDefault = true;
85
86 if (GlobalValue::GetValueByNameFailSafe ("SimulatorImplementationType", simulationTypeValue))
87 {
88 std::string simulationType = simulationTypeValue.Get ();
89
90 // Set communication interface based on the simulation type being used.
91 // Defaults to synchronous.
92 if (simulationType.compare ("ns3::NullMessageSimulatorImpl") == 0)
93 {
95 useDefault = false;
96 }
97 else if (simulationType.compare ("ns3::DistributedSimulatorImpl") == 0)
98 {
100 useDefault = false;
101 }
102 }
103
104 // User did not specify a valid parallel simulator; use the default.
105 if (useDefault)
106 {
108 GlobalValue::Bind ("SimulatorImplementationType",
109 StringValue ("ns3::DistributedSimulatorImpl"));
110 NS_LOG_WARN ("SimulatorImplementationType was set to non-parallel simulator; setting type to ns3::DistributedSimulatorImp");
111 }
112}
113
114void
115MpiInterface::Enable (int* pargc, char*** pargv)
116{
117
119
121}
122
123void
124MpiInterface::Enable (MPI_Comm communicator)
125{
128}
129
130void
132{
134 g_parallelCommunicationInterface->SendPacket (p, rxTime, node, dev);
135}
136
137MPI_Comm
139{
142}
143
144
145void
147{
152}
153
154
155} // 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 void SetParallelSimulatorImpl(void)
Common enable logic.
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.
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.
Hold variables of type string.
Definition: string.h:41
std::string Get(void) const
Definition: string.cc:31
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
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:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
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.