11f6643lec28 - CS6643 F'11 Lec28 ™ Search directories...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS6643 F '11 Lec28 ™ Search directories, subdirectories for documents (look for .html, .txt, .tex, etc.) ™ Using a dictionary of key words, create a profile vector for each document ™ Store profile vectors Document Classification Problem Document Classification 3 Creating communicators NonNon-blocking communications Pipelining at functional level ‹ ‹ CS6643 F '11 Lec28 Data Dependence Graph (1) CS6643 F '11 Lec28 ™ ™ ManagerManager-worker programs ™ Additional MPI functions Objectives 4 2 CS6643 F '11 Lec28 ™ Number of tasks not known at compile time ™ Tasks do not communicate with each other ™ Time needed to perform tasks varies widely ™ Strategy: map tasks to processes at run time Agglomeration and Mapping CS6643 F '11 Lec28 ™ Most time spent reading documents and generating profile vectors ™ Create two primitive tasks for each document Partitioning and Communication 7 5 CS6643 F '11 Lec28 Can also be viewed as domain partitioning with run-time allocation of data to tasks Manager/worker-style Algorithm CS6643 F '11 Lec28 Data Dependence Graph (2) 8 6 Every process executes same functions Our prior programs are of this type ‹ ‹ CS6643 F '11 Lec28 Identify documents Receive dictionary size from worker 0 Allocate matrix to store document vectors repeat Receive message from worker if message contains document vector Store document vector endif if documents remain then Send worker file name else Send worker termination message endif until all workers terminated Write document vectors to file Manager Pseudocode Manager process has different responsibilities than worker processes An MPI manager/worker program has an early control flow split (manager process one way, worker processes the other way) Manager/worker ‹ ‹ SPMD (single program multiple data) CS6643 F '11 Lec28 ™ ™ Manager/Worker vs. SPMD 11 9 CS6643 F '11 Lec28 Send first request for work to manager if worker 0 then Read dictionary from file endif Broadcast dictionary among workers Build hash table from dictionary if worker 0 then Send dictionary size to manager endif repeat Receive file name from manager if file name is NULL then terminate endif Read document, generate document vector Send document vector to manager forever Worker Pseudocode CS6643 F '11 Lec28 Roles of Manager and Workers 12 10 /* Communicator */ CS6643 F '11 Lec28 int error_code) /* Value returned to calling environment */ MPI_Comm comm, int MPI_Abort ( Header for MPI_Abort CS6643 F '11 Lec28 Task/Channel Graph 15 13 CS6643 F '11 Lec28 Dictionary is broadcast among workers ™ To support workers-only broadcast, need workersworkersworkers-only communicator ™ Can use MPI_Comm_split ™ Manager passes MPI_UNDEFINED as the value of split_key, meaning it will not be part of any new communicator ™ Creating a Workers-only Communicator CS6643 F '11 Lec28 ™ A “quick and dirty” way for one process to terminate all processes in a specified communicator ™ Example use: If manager cannot allocate memory needed to store document profile vectors MPI_Abort 16 14 CS6643 F '11 Lec28 int MPI_Irecv ( void *buffer, int cnt, MPI_Datatype dtype, int src, int tag, MPI_Comm comm, MPI_Request *handle ) Pointer to object that identifies communication operation Function MPI_Irecv CS6643 F '11 Lec28 else /* Worker */ MPI_Comm_split (MPI_COMM_WORLD, 0, id, &worker_comm); if (!id) /* Manager */ MPI_Comm_split (MPI_COMM_WORLD, MPI_UNDEFINED, id, &worker_comm); ... int id; MPI_Comm worker_comm; Workers-only Communicator 19 17 MPI_Isend as soon as value(s) assigned MPI_Irecv as soon as buffer available Can eliminate a message copying step Allows communication / computation overlap ‹ ‹ MPI_Isend, MPI_Irecv initiate operation MPI_Wait blocks until operation complete Calls can be made early CS6643 F '11 Lec28 ) MPI_Status *status MPI_Request *handle, int MPI_Wait ( Function MPI_Wait CS6643 F '11 Lec28 ™ ™ ™ ™ ™ Nonblocking Send/Receive 20 18 src, CS6643 F '11 Lec28 MPI_Comm MPI_Status *status comm, int Blocks until message is available to be received ) tag, int int MPI_Probe ( Function MPI_Probe CS6643 F '11 Lec28 int MPI_Isend ( void *buffer, int cnt, MPI_Datatype dtype, int dest, int tag, MPI_Comm comm, MPI_Request *handle ) Pointer to object that identifies communication operation Function MPI_Isend 23 21 Allocate huge buffer Check length of incoming message, then allocate buffer We’ll take the second alternative ‹ ‹ CS6643 F '11 Lec28 ) int *cnt MPI_Datatype dtype, MPI_Status *status, int MPI_Get_count ( Function MPI_Get_count CS6643 F '11 Lec28 ™ ™ Worker does not know length of longest path name it will receive ™ Alternatives Receiving Path Name 24 22 CS6643 F '11 Lec28 Pipelining CS6643 F '11 Lec28 ™ Middle ground between pre-allocation and preone-atone-at-a-time allocation ™ Pipelining of document processing Enhancements 27 25 1 Documents Allocated per Request Excessive communication overhead Load imbalance CS6643 F '11 Lec28 Time Savings through Pipelining CS6643 F '11 Lec28 Time Allocation Alternatives n/p 28 26 Dynamic number of tasks Variable task lengths No communications between tasks ‹ ‹ ‹ ‹ Create manager/worker program Create workers-only communicator workersNonNon-blocking send/receive Testing for completed communications New tools for “kit” ‹ ‹ ‹ Manager/worker paradigm CS6643 F '11 Lec28 ™ ™ Summary CS6643 F '11 Lec28 if (j > 0) and (w > 0) then assign job to worker j m j – 1; w m w – 1; a m a + 1 elseif (j > 0) then handle an incoming message from workers increment w else get another job increment j endif until (a = n) and (w = p) repeat a m 0 {assigned jobs} j m 0 {available jobs} w m 0 {workers waiting for assignment} Pipelined Manager Pseudocode 31 29 CS6643 F '11 Lec28 MPI_Status *status_array) /* OUT Status records for completed comms */ int *index_array, /* OUT - Indices of completed communications */ int *out_cnt, /* OUT - Number of completed communications */ MPI_Request *handlearray, /* IN Handles of pending receives */ int in_cnt, /* IN - Number of nonblocking receives to check */ int MPI_Testsome ( Function MPI_Testsome 30 ...
View Full Document

This note was uploaded on 01/29/2012 for the course CS 6643 taught by Professor Staff during the Fall '08 term at The University of Texas at San Antonio- San Antonio.

Ask a homework question - tutors are online