Download presentation
Presentation is loading. Please wait.
Published byDaniella Stephens Modified over 6 years ago
1
Auburn University http://www.eng.auburn.edu/~xqin
COMP7330/7336 Advanced Parallel and Distributed Computing Odd-Even Sort Implementation Dr. Xiao Qin Auburn University 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
Element i is residing on process Pi
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 Θ(p2p).
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) Send and receive buffers are disjoint This problem is solved by using MPI_Sendrecv_replace
8
Parallel Odd-Even - Implementation
P. 248 Show also the prototype of MPI_Sendrecv()
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
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.