- rank = smpi_comm_rank(comm);
- size = smpi_comm_size(comm);
+ rank = comm->rank();
+ size = comm->size();
/* segment is segment size in number of elements (not bytes) */
*/
if (root != 0) {
if (rank == root) {
- smpi_mpi_send(buf, count, datatype, 0, tag, comm);
+ Request::send(buf, count, datatype, 0, tag, comm);
} else if (rank == 0) {
- smpi_mpi_recv(buf, count, datatype, root, tag, comm, &status);
+ Request::recv(buf, count, datatype, root, tag, comm, &status);
}
}
while (sent_count < (size - 1)) {
for (i = 1; i < size; i++) {
- smpi_mpi_iprobe(i, MPI_ANY_TAG, comm, &flag_array[i],
+ Request::iprobe(i, MPI_ANY_TAG, comm, &flag_array[i],
MPI_STATUSES_IGNORE);
}
/* message arrive */
if ((flag_array[i] == 1) && (already_sent[i] == 0)) {
- smpi_mpi_recv(temp_buf, 1, MPI_CHAR, i, tag, comm, &status);
+ Request::recv(temp_buf, 1, MPI_CHAR, i, tag, comm, &status);
header_buf[header_index] = i;
header_index++;
sent_count++;
if (header_index != 0) {
header_buf[header_index] = -1;
to = header_buf[0];
- smpi_mpi_send(header_buf, HEADER_SIZE, MPI_INT, to, tag, comm);
- smpi_mpi_send(buf, count, datatype, to, tag, comm);
+ Request::send(header_buf, HEADER_SIZE, MPI_INT, to, tag, comm);
+ Request::send(buf, count, datatype, to, tag, comm);
}
/* randomly MPI_Send to one */
if (already_sent[i] == 0) {
header_buf[0] = i;
header_buf[1] = -1;
- smpi_mpi_send(header_buf, HEADER_SIZE, MPI_INT, i, tag, comm);
- smpi_mpi_send(buf, count, datatype, i, tag, comm);
+ Request::send(header_buf, HEADER_SIZE, MPI_INT, i, tag, comm);
+ Request::send(buf, count, datatype, i, tag, comm);
already_sent[i] = 1;
sent_count++;
break;
else {
/* send 1-byte message to root */
- smpi_mpi_send(temp_buf, 1, MPI_CHAR, 0, tag, comm);
+ Request::send(temp_buf, 1, MPI_CHAR, 0, tag, comm);
/* wait for header and data, forward when required */
- smpi_mpi_recv(header_buf, HEADER_SIZE, MPI_INT, MPI_ANY_SOURCE, tag, comm,
+ Request::recv(header_buf, HEADER_SIZE, MPI_INT, MPI_ANY_SOURCE, tag, comm,
&status);
- smpi_mpi_recv(buf, count, datatype, MPI_ANY_SOURCE, tag, comm, &status);
+ Request::recv(buf, count, datatype, MPI_ANY_SOURCE, tag, comm, &status);
/* search for where it is */
int myordering = 0;
/* send header followed by data */
if (header_buf[myordering + 1] != -1) {
- smpi_mpi_send(header_buf, HEADER_SIZE, MPI_INT, header_buf[myordering + 1],
+ Request::send(header_buf, HEADER_SIZE, MPI_INT, header_buf[myordering + 1],
tag, comm);
- smpi_mpi_send(buf, count, datatype, header_buf[myordering + 1], tag, comm);
+ Request::send(buf, count, datatype, header_buf[myordering + 1], tag, comm);
}
}
}
//iteration++;
//start = MPI_Wtime();
for (i = 1; i < size; i++) {
- smpi_mpi_iprobe(i, MPI_ANY_TAG, comm, &flag_array[i],
+ Request::iprobe(i, MPI_ANY_TAG, comm, &flag_array[i],
&temp_status_array[i]);
}
//total = MPI_Wtime() - start;
for (i = 1; i < size; i++) {
/* message arrive */
if ((flag_array[i] == 1) && (already_sent[i] == 0)) {
- smpi_mpi_recv(&temp_buf[i], 1, MPI_CHAR, i, tag, comm,
+ Request::recv(&temp_buf[i], 1, MPI_CHAR, i, tag, comm,
&status);
header_buf[header_index] = i;
header_index++;
//start = MPI_Wtime();
/* send header */
- smpi_mpi_send(header_buf, HEADER_SIZE, MPI_INT, to, tag, comm);
+ Request::send(header_buf, HEADER_SIZE, MPI_INT, to, tag, comm);
//total = MPI_Wtime() - start;
//total *= 1000;
if (0 == 1) {
//if (header_index == 1) {
- smpi_mpi_send(buf, count, datatype, to, tag, comm);
+ Request::send(buf, count, datatype, to, tag, comm);
}
/* send data - pipeline */
else {
for (i = 0; i < pipe_length; i++) {
- smpi_mpi_send((char *)buf + (i * increment), segment, datatype, to, tag, comm);
+ Request::send((char *)buf + (i * increment), segment, datatype, to, tag, comm);
}
- //smpi_mpi_waitall((pipe_length), send_request_array, send_status_array);
+ //Request::waitall((pipe_length), send_request_array, send_status_array);
}
//total = MPI_Wtime() - start;
//total *= 1000;
to = i;
//start = MPI_Wtime();
- smpi_mpi_send(header_buf, HEADER_SIZE, MPI_INT, to, tag, comm);
+ Request::send(header_buf, HEADER_SIZE, MPI_INT, to, tag, comm);
/* still need to chop data so that we can use the same non-root code */
for (j = 0; j < pipe_length; j++) {
- smpi_mpi_send((char *)buf + (j * increment), segment, datatype, to, tag,
+ Request::send((char *)buf + (j * increment), segment, datatype, to, tag,
comm);
}
- //smpi_mpi_send(buf,count,datatype,to,tag,comm);
- //smpi_mpi_wait(&request,MPI_STATUS_IGNORE);
+ //Request::send(buf,count,datatype,to,tag,comm);
+ //Request::wait(&request,MPI_STATUS_IGNORE);
//total = MPI_Wtime() - start;
//total *= 1000;
} /* while loop */
for(i=0; i<size; i++)
- if(to_clean[i]!=0)smpi_mpi_recv(&temp_buf[i], 1, MPI_CHAR, i, tag, comm,
+ if(to_clean[i]!=0)Request::recv(&temp_buf[i], 1, MPI_CHAR, i, tag, comm,
&status);
//total = MPI_Wtime() - start2;
//total *= 1000;
/* none root */
else {
/* send 1-byte message to root */
- smpi_mpi_send(temp_buf, 1, MPI_CHAR, 0, tag, comm);
+ Request::send(temp_buf, 1, MPI_CHAR, 0, tag, comm);
/* wait for header forward when required */
- request = smpi_mpi_irecv(header_buf, HEADER_SIZE, MPI_INT, MPI_ANY_SOURCE, tag, comm);
- smpi_mpi_wait(&request, MPI_STATUS_IGNORE);
+ request = Request::irecv(header_buf, HEADER_SIZE, MPI_INT, MPI_ANY_SOURCE, tag, comm);
+ Request::wait(&request, MPI_STATUS_IGNORE);
/* search for where it is */
int myordering = 0;
/* send header when required */
if (header_buf[myordering + 1] != -1) {
- smpi_mpi_send(header_buf, HEADER_SIZE, MPI_INT, header_buf[myordering + 1],
+ Request::send(header_buf, HEADER_SIZE, MPI_INT, header_buf[myordering + 1],
tag, comm);
}
if (0 == -1) {
//if (header_buf[1] == -1) {
- request = smpi_mpi_irecv(buf, count, datatype, 0, tag, comm);
- smpi_mpi_wait(&request, MPI_STATUS_IGNORE);
+ request = Request::irecv(buf, count, datatype, 0, tag, comm);
+ Request::wait(&request, MPI_STATUS_IGNORE);
//printf("\t\tnode %d ordering = %d receive data from root\n",rank,myordering);
} else {
for (i = 0; i < pipe_length; i++) {
- recv_request_array[i] = smpi_mpi_irecv((char *)buf + (i * increment), segment, datatype, MPI_ANY_SOURCE,
+ recv_request_array[i] = Request::irecv((char *)buf + (i * increment), segment, datatype, MPI_ANY_SOURCE,
tag, comm);
}
}
/* send data */
if (header_buf[myordering + 1] != -1) {
for (i = 0; i < pipe_length; i++) {
- smpi_mpi_wait(&recv_request_array[i], MPI_STATUS_IGNORE);
- send_request_array[i] = smpi_mpi_isend((char *)buf + (i * increment), segment, datatype,
+ Request::wait(&recv_request_array[i], MPI_STATUS_IGNORE);
+ send_request_array[i] = Request::isend((char *)buf + (i * increment), segment, datatype,
header_buf[myordering + 1], tag, comm);
}
- smpi_mpi_waitall((pipe_length), send_request_array, send_status_array);
+ Request::waitall((pipe_length), send_request_array, send_status_array);
}else{
- smpi_mpi_waitall(pipe_length, recv_request_array, recv_status_array);
+ Request::waitall(pipe_length, recv_request_array, recv_status_array);
}
}