COMP 73307336 Advanced Parallel and Distributed Computing OddEven
COMP 7330/7336 Advanced Parallel and Distributed Computing Odd-Even Sort Implementation Dr. Xiao Qin Auburn University http: //www. eng. auburn. edu/~xqin@auburn. edu Slides are adopted from Drs. Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar 2
Review: Odd-Even Transposition Sorting n = 8 elements, using the odd-even transposition sort algorithm. During each phase, n = 8 elements are compared. 3
Review: Sequential odd-even transposition sort algorithm 4
Review: Parallel Odd-Even Transposition 5
Parallel Odd-Even Transposition • Consider a block of n/p elements per processor. • The first step is a local sort. • In each subsequent step, the compare exchange operation is replaced by the compare split operation. • The parallel run time of the formulation is 6
Parallel Odd-Even Transposition • The parallel formulation is cost-optimal for p = O(log n). • The isoefficiency function of this parallel formulation is Θ(p 2 p). 7
Sending and Receiving Messages Simultaneously To exchange messages, MPI provides the following function: int MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype senddatatype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvdatatype, int source, int recvtag, MPI_Comm comm, MPI_Status *status) The arguments include arguments to the send and receive functions. If we wish to use the same buffer for both send and receive, we can use: int MPI_Sendrecv_replace(void *buf, int count, MPI_Datatype datatype, int dest, int sendtag, int source, int recvtag, MPI_Comm comm, MPI_Status *status)
Parallel Odd-Even - Implementation 9
Parallel Odd-Even - Implementation 10
Parallel Odd-Even - Implementation 11
Parallel Odd-Even - Implementation 12
Parallel Odd-Even - Implementation 13
Parallel Odd-Even - Implementation 14
- Slides: 13