Last change
on this file since 167 was
167,
checked in by (none), 14 years ago
|
Simeo: added final project and also older proof of concept code.
We used Git for version control, so look at the Git repo
in SIMEO/Simeo/ for more info.
|
File size:
837 bytes
|
Rev | Line | |
---|
[167] | 1 | #include <stdio.h> |
---|
| 2 | #include "MPIChannel.h" |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | MPIChannel::MPIChannel(int dest, int tag, MPI_Comm comm) |
---|
| 6 | : Channel() |
---|
| 7 | { |
---|
| 8 | m_dest = dest; |
---|
| 9 | m_tag = tag; |
---|
| 10 | m_comm = comm; |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | MPIChannel::~MPIChannel() |
---|
| 14 | { |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | MPI_Comm MPIChannel::getMPIComm() |
---|
| 18 | { |
---|
| 19 | return m_comm; |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | int MPIChannel::getDest() |
---|
| 23 | { |
---|
| 24 | return m_dest; |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | int MPIChannel::getTag() |
---|
| 28 | { |
---|
| 29 | return m_tag; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | int MPIChannel::read(void *buf, channel_datatype_t datatype, size_t count) |
---|
| 33 | { |
---|
| 34 | MPI_Status status; |
---|
| 35 | MPI_Recv(buf, count, datatype, m_dest, m_tag, MPI_COMM_WORLD, &status); |
---|
| 36 | return 0; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | int MPIChannel::write(const void *buf, channel_datatype_t datatype, size_t count) |
---|
| 40 | { |
---|
| 41 | MPI_Send((void *) buf, count, datatype, m_dest, m_tag, MPI_COMM_WORLD); |
---|
| 42 | return 0; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | int MPIChannel::available() |
---|
| 46 | { |
---|
| 47 | int flag; |
---|
| 48 | MPI_Status status; |
---|
| 49 | |
---|
| 50 | MPI_Iprobe(m_dest, m_tag, MPI_COMM_WORLD, &flag, &status); |
---|
| 51 | |
---|
| 52 | return flag; |
---|
| 53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.