A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
*/
21
22
#include "
mpi-interface.h
"
23
24
#include <ns3/global-value.h>
25
#include <ns3/string.h>
26
#include <ns3/log.h>
27
28
#include "
null-message-mpi-interface.h
"
29
#include "
granted-time-window-mpi-interface.h
"
30
31
NS_LOG_COMPONENT_DEFINE
(
"MpiInterface"
);
32
33
namespace
ns3 {
34
35
ParallelCommunicationInterface*
MpiInterface::g_parallelCommunicationInterface
= 0;
36
37
void
38
MpiInterface::Destroy
()
39
{
40
NS_ASSERT
(
g_parallelCommunicationInterface
);
41
g_parallelCommunicationInterface
->
Destroy
();
42
}
43
44
uint32_t
45
MpiInterface::GetSystemId
()
46
{
47
if
(
g_parallelCommunicationInterface
)
48
return
g_parallelCommunicationInterface
->
GetSystemId
();
49
else
50
return
0;
51
}
52
53
uint32_t
54
MpiInterface::GetSize
()
55
{
56
if
(
g_parallelCommunicationInterface
)
57
return
g_parallelCommunicationInterface
->
GetSize
();
58
else
59
return
1;
60
}
61
62
bool
63
MpiInterface::IsEnabled
()
64
{
65
if
(
g_parallelCommunicationInterface
)
66
{
67
return
g_parallelCommunicationInterface
->
IsEnabled
();
68
}
69
else
70
{
71
return
false
;
72
}
73
}
74
75
void
76
MpiInterface::Enable
(
int
* pargc,
char
*** pargv)
77
{
78
StringValue
simulationTypeValue;
79
bool
useDefault =
true
;
80
81
if
(
GlobalValue::GetValueByNameFailSafe
(
"SimulatorImplementationType"
, simulationTypeValue))
82
{
83
std::string simulationType = simulationTypeValue.
Get
();
84
85
// Set communication interface based on the simulation type being used.
86
// Defaults to synchronous.
87
if
(simulationType.compare (
"ns3::NullMessageSimulatorImpl"
) == 0)
88
{
89
g_parallelCommunicationInterface
=
new
NullMessageMpiInterface
();
90
useDefault =
false
;
91
}
92
else
if
(simulationType.compare (
"ns3::DistributedSimulatorImpl"
) == 0)
93
{
94
g_parallelCommunicationInterface
=
new
GrantedTimeWindowMpiInterface
();
95
useDefault =
false
;
96
}
97
}
98
99
// User did not specify a valid parallel simulator; use the default.
100
if
(useDefault)
101
{
102
g_parallelCommunicationInterface
=
new
GrantedTimeWindowMpiInterface
();
103
GlobalValue::Bind
(
"SimulatorImplementationType"
,
104
StringValue
(
"ns3::DistributedSimulatorImpl"
));
105
NS_LOG_WARN
(
"SimulatorImplementationType was set to non-parallel simulator; setting type to ns3::DistributedSimulatorImp"
);
106
}
107
108
g_parallelCommunicationInterface
->
Enable
(pargc, pargv);
109
}
110
111
void
112
MpiInterface::SendPacket
(
Ptr<Packet>
p,
const
Time
& rxTime, uint32_t node, uint32_t dev)
113
{
114
NS_ASSERT
(
g_parallelCommunicationInterface
);
115
g_parallelCommunicationInterface
->
SendPacket
(p, rxTime, node, dev);
116
}
117
118
119
void
120
MpiInterface::Disable
()
121
{
122
NS_ASSERT
(
g_parallelCommunicationInterface
);
123
g_parallelCommunicationInterface
->
Disable
();
124
delete
g_parallelCommunicationInterface
;
125
g_parallelCommunicationInterface
= 0;
126
}
127
128
129
}
// namespace ns3
ns3::Time
keep track of time values and allow control of global simulation resolution
Definition:
nstime.h:81
ns3::Ptr< Packet >
ns3::StringValue::Get
std::string Get(void) const
ns3::StringValue
hold variables of type string
Definition:
string.h:19
ns3::ParallelCommunicationInterface::GetSize
virtual uint32_t GetSize()=0
ns3::ParallelCommunicationInterface::Destroy
virtual void Destroy()=0
Deletes storage used by the parallel environment.
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::MpiInterface::Disable
static void Disable()
Terminates the parallel environment.
Definition:
mpi-interface.cc:120
ns3::ParallelCommunicationInterface::IsEnabled
virtual bool IsEnabled()=0
mpi-interface.h
ns3::MpiInterface::Destroy
static void Destroy()
Deletes storage used by the parallel environment.
Definition:
mpi-interface.cc:38
ns3::MpiInterface::Enable
static void Enable(int *pargc, char ***pargv)
Sets up parallel communication interface.
Definition:
mpi-interface.cc:76
ns3::MpiInterface::IsEnabled
static bool IsEnabled()
Definition:
mpi-interface.cc:63
ns3::ParallelCommunicationInterface::Disable
virtual void Disable()=0
Terminates the parallel environment.
ns3::GrantedTimeWindowMpiInterface
Interface between ns-3 and MPI.
Definition:
granted-time-window-mpi-interface.h:91
ns3::ParallelCommunicationInterface::Enable
virtual void Enable(int *pargc, char ***pargv)=0
ns3::GlobalValue::Bind
static void Bind(std::string name, const AttributeValue &value)
Definition:
global-value.cc:150
ns3::GlobalValue::GetValueByNameFailSafe
static bool GetValueByNameFailSafe(std::string name, AttributeValue &value)
finds the GlobalValue with the given name and returns its value
Definition:
global-value.cc:203
ns3::ParallelCommunicationInterface::GetSystemId
virtual uint32_t GetSystemId()=0
ns3::MpiInterface::SendPacket
static void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Definition:
mpi-interface.cc:112
null-message-mpi-interface.h
ns3::MpiInterface::GetSystemId
static uint32_t GetSystemId()
Definition:
mpi-interface.cc:45
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Definition:
log.h:280
ns3::MpiInterface::g_parallelCommunicationInterface
static ParallelCommunicationInterface * g_parallelCommunicationInterface
Static instance of the instantiated parallel controller.
Definition:
mpi-interface.h:102
granted-time-window-mpi-interface.h
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("MpiInterface")
ns3::MpiInterface::GetSize
static uint32_t GetSize()
Definition:
mpi-interface.cc:54
ns3::ParallelCommunicationInterface::SendPacket
virtual void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)=0
ns3::NullMessageMpiInterface
Interface between ns-3 and MPI for the Null Message distributed simulation implementation.
Definition:
null-message-mpi-interface.h:88
src
mpi
model
mpi-interface.cc
Generated on Sat Apr 19 2014 14:07:04 for ns-3 by
1.8.6