#include #include "mpi.h" int bcast_linear_segment_size; int bcast_linear(void *buf,int count, MPI_Datatype datatype, int root, MPI_Comm comm) { int tag = 5000; MPI_Status status; MPI_Request req; int rank,phase,pipe_length; int i,j; int last_count; int send_size; int total_node; int *send_to; int *recv_from; int *sequence; MPI_Comm_rank(MPI_COMM_WORLD,&rank); MPI_Comm_size(MPI_COMM_WORLD,&total_node); // TOPOLOGY UNAWARE send_to = (int *) malloc (total_node * sizeof (int)); recv_from = (int *) malloc (total_node * sizeof (int)); sequence = (int *) malloc (total_node * sizeof (int)); for (i=0;i= sequence[rank]) && (i < (pipe_length + sequence[rank]))) MPI_Send(buf+(bcast_linear_segment_size*(i-sequence[rank])),bcast_linear_segment_size,datatype,send_to[rank],tag,MPI_COMM_WORLD); if ((recv_from[rank] != -1) && (i >= sequence[rank] -1) && (i = sequence[rank]) && (i < (pipe_length + sequence[rank]))) { if (i == (pipe_length + sequence[rank] - 1)) send_size = last_count; MPI_Send(buf+(bcast_linear_segment_size*(i-sequence[rank])),send_size,datatype,send_to[rank],tag,MPI_COMM_WORLD); } if ((recv_from[rank] != -1) && (i >= sequence[rank] -1) && (i