FreeNOS
|
Implements a Message Passing Interface (MPI) for communication between local cores. More...
#include <MpiTarget.h>
Public Member Functions | |
MpiTarget () | |
Constructor. More... | |
virtual Result | initialize (int *argc, char ***argv) |
Initialize the backend. More... | |
virtual Result | terminate () |
Terminate the backend. More... | |
virtual Result | getCommRank (MPI_Comm comm, int *rank) |
Retrieve communication rank (core id) More... | |
virtual Result | getCommSize (MPI_Comm comm, int *size) |
Retrieve communication size (total cores) More... | |
virtual Result | send (const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) |
Synchronous send data. More... | |
virtual Result | receive (void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status) |
Synchronous receive data. More... | |
Private Member Functions | |
Result | initializeMaster (int *argc, char ***argv) |
Initialize the master. More... | |
Result | initializeSlave (int *argc, char ***argv) |
Initialize a slave. More... | |
Result | createReadChannel (const Size coreId, const Address memoryBase) |
Create a new MPI channel for reading. More... | |
Result | createWriteChannel (const Size coreId, const Address memoryBase) |
Create a new MPI channel for writing. More... | |
Address | getMemoryBaseRead (const Size coreId) const |
Get memory address for MPI read communication. More... | |
Address | getMemoryBaseWrite (const Size coreId) const |
Get memory address for MPI write communication. More... | |
Private Attributes | |
Size | m_coreId |
Core identifier is a unique number on each core. More... | |
Size | m_coreCount |
Total number of cores. More... | |
Memory::Range | m_memChannelBase |
Memory base address for local MPI communication. More... | |
Index< MemoryChannel, MaximumChannels > | m_readChannels |
Stores all channels for receiving data from other cores. More... | |
Index< MemoryChannel, MaximumChannels > | m_writeChannels |
Stores all channels for sending data to other cores. More... | |
Static Private Attributes | |
static const Size | MaximumChannels = 128u |
Maximum number of communication channels. More... | |
Additional Inherited Members | |
Public Types inherited from MpiBackend | |
typedef int | Result |
Result code. More... | |
Static Public Member Functions inherited from AbstractFactory< MpiBackend > | |
static MpiBackend * | create () |
Abstract function to create an instance of T. More... | |
Implements a Message Passing Interface (MPI) for communication between local cores.
Definition at line 40 of file MpiTarget.h.
MpiTarget::MpiTarget | ( | ) |
Constructor.
Definition at line 37 of file MpiTarget.cpp.
References m_memChannelBase, and MemoryBlock::set().
|
private |
Create a new MPI channel for reading.
coreId | Source coreId for reading |
memoryBase | Physical memory base address |
Definition at line 345 of file MpiTarget.cpp.
References Channel::Consumer, coreId, DEBUG, ERROR, Index< T, N >::insertAt(), m_coreId, m_readChannels, MPI_ERR_NO_MEM, MPI_SUCCESS, PAGESIZE, and MemoryChannel::setPhysical().
Referenced by initializeMaster(), and initializeSlave().
|
private |
Create a new MPI channel for writing.
coreId | Destination coreId for writing |
memoryBase | Physical memory base address |
Definition at line 367 of file MpiTarget.cpp.
References coreId, DEBUG, ERROR, Index< T, N >::insertAt(), m_coreId, m_writeChannels, MPI_ERR_NO_MEM, MPI_SUCCESS, PAGESIZE, Channel::Producer, and MemoryChannel::setPhysical().
Referenced by initializeMaster(), and initializeSlave().
|
virtual |
Retrieve communication rank (core id)
comm | Communication reference |
rank | Output the communication rank number |
Implements MpiBackend.
Definition at line 64 of file MpiTarget.cpp.
References m_coreId, and MPI_SUCCESS.
|
virtual |
Retrieve communication size (total cores)
comm | Communication reference |
size | Output the communication size |
Implements MpiBackend.
Definition at line 71 of file MpiTarget.cpp.
References m_coreCount, and MPI_SUCCESS.
Get memory address for MPI read communication.
coreId | Core identifier |
Definition at line 389 of file MpiTarget.cpp.
References assert, coreId, m_coreCount, m_coreId, m_memChannelBase, PAGESIZE, and Memory::Range::phys.
Referenced by initializeMaster(), and initializeSlave().
Get memory address for MPI write communication.
coreId | Core identifier |
Definition at line 405 of file MpiTarget.cpp.
References assert, coreId, m_coreCount, m_coreId, m_memChannelBase, PAGESIZE, and Memory::Range::phys.
Referenced by initializeMaster(), and initializeSlave().
|
virtual |
Initialize the backend.
Implements MpiBackend.
Definition at line 44 of file MpiTarget.cpp.
References MemoryBlock::compare(), initializeMaster(), initializeSlave(), and MPI_SUCCESS.
|
private |
Initialize the master.
Definition at line 159 of file MpiTarget.cpp.
References Memory::Range::access, assert, BufferedFile::buffer(), MemoryBlock::compare(), CoreClient::createProcess(), createReadChannel(), createWriteChannel(), DEBUG, Number::Dec, ERROR, CoreClient::getCoreCount(), getMemoryBaseRead(), getMemoryBaseWrite(), Lz4Decompressor::getUncompressedSize(), Number::Hex, Lz4Decompressor::initialize(), m_coreCount, m_coreId, m_memChannelBase, MapContiguous, MPI_ERR_BAD_FILE, MPI_ERR_NO_MEM, MPI_ERR_SPAWN, MPI_SUCCESS, NULL, PAGESIZE, Memory::Range::phys, BufferedFile::read(), Lz4Decompressor::read(), Memory::Readable, SELF, MemoryBlock::set(), Memory::Range::size, BufferedFile::size(), BufferedFile::Success, Core::Success, API::Success, Lz4Decompressor::Success, Memory::User, Memory::Range::virt, VMCtl(), and Memory::Writable.
Referenced by initialize().
|
private |
Initialize a slave.
Definition at line 299 of file MpiTarget.cpp.
References assert, createReadChannel(), createWriteChannel(), Number::Dec, ERROR, getMemoryBaseRead(), getMemoryBaseWrite(), Number::Hex, m_coreCount, m_coreId, m_memChannelBase, MaximumChannels, MPI_ERR_ARG, MPI_SUCCESS, Memory::Range::phys, and String::toLong().
Referenced by initialize().
|
virtual |
Synchronous receive data.
buf | Output data buffer |
count | Number of data items |
datatype | Type of data |
source | Source to receive data from (core id) |
tag | Optional data identifier to receive |
comm | Communication reference |
status | Output the MPI status |
Implements MpiBackend.
Definition at line 118 of file MpiTarget.cpp.
References Index< T, N >::get(), MPIMessage::integer, m_readChannels, MPI_ERR_RANK, MPI_ERR_UNSUPPORTED_DATAREP, MPI_INT, MPI_SUCCESS, MPI_UNSIGNED_CHAR, ProcessCtl(), MemoryChannel::read(), Schedule, SELF, Channel::Success, and MPIMessage::uchar.
|
virtual |
Synchronous send data.
buf | Input data buffer |
count | Number of data items |
datatype | Type of data |
dest | Destination to send to (core id) |
tag | Optional data identifier to send |
comm | Communication reference |
Implements MpiBackend.
Definition at line 78 of file MpiTarget.cpp.
References Index< T, N >::get(), MPIMessage::integer, m_writeChannels, MPI_ERR_RANK, MPI_ERR_UNSUPPORTED_DATAREP, MPI_INT, MPI_SUCCESS, MPI_UNSIGNED_CHAR, ProcessCtl(), Schedule, SELF, Channel::Success, MPIMessage::uchar, and MemoryChannel::write().
|
virtual |
Terminate the backend.
Implements MpiBackend.
Definition at line 59 of file MpiTarget.cpp.
References MPI_SUCCESS.
|
private |
Total number of cores.
Definition at line 204 of file MpiTarget.h.
Referenced by getCommSize(), getMemoryBaseRead(), getMemoryBaseWrite(), initializeMaster(), and initializeSlave().
|
private |
Core identifier is a unique number on each core.
Definition at line 201 of file MpiTarget.h.
Referenced by createReadChannel(), createWriteChannel(), getCommRank(), getMemoryBaseRead(), getMemoryBaseWrite(), initializeMaster(), and initializeSlave().
|
private |
Memory base address for local MPI communication.
Definition at line 207 of file MpiTarget.h.
Referenced by getMemoryBaseRead(), getMemoryBaseWrite(), initializeMaster(), initializeSlave(), and MpiTarget().
|
private |
Stores all channels for receiving data from other cores.
Definition at line 210 of file MpiTarget.h.
Referenced by createReadChannel(), and receive().
|
private |
Stores all channels for sending data to other cores.
Definition at line 213 of file MpiTarget.h.
Referenced by createWriteChannel(), and send().
|
staticprivate |
Maximum number of communication channels.
Definition at line 45 of file MpiTarget.h.
Referenced by initializeSlave().