Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://angel.cmc.msu.ru/~ifed/teraflops/Goritskaya_MPI2.pdf
Äàòà èçìåíåíèÿ: Thu Mar 4 12:27:28 2010
Äàòà èíäåêñèðîâàíèÿ: Mon Oct 1 19:36:28 2012
Êîäèðîâêà:
MPI-2:


MPI-2:
RMA ­ RMA- , ()



­ , ­ , 3


MPI_Put() MPI_Get() MPI_Accumulate()


RMA
«» ­ , RMA- ,


«»
«» ­ , RMA- (contiguous) «» «» ­ , «» - , RMA-


«»
int MPI_Wi MPI_Aint MPI_Info MPI_Win


n_create(void *base, size, int disp_unit, info, MPI_Comm comm, *win)





IN base IN size ( ) IN disp_unit ( ) IN info info () IN comm () OUT win , ()


«»
MPI_WIN_BASE - «»


MPI_Win_get_attr(win, MPI_WIN_BASE, &base, &flag)

MPI_WIN_SIZE - «»


MPI_Win_get_attr(win, MPI_WIN_SIZE, &size, &flag) MPI_Win_get_attr(win,MPI_WIN_DISP_UNIT, &disp_unit,&flag)

MPI_WIN_DISP_UNIT ­


, «»


int MPI_Win_get_group(MPI_Win win, MPI_Group *group)



int MPI_Win_free(MPI_Win *win)


INOUT win ()

( MPI_WIN_NULL) , , win , RMA «» win



­ MPI_Put, MPI_Get, MPI_Accumulate ­ ( , )


int MPI_Put(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank, MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win)














IN origin_addr ( ) IN origin_count ( ) IN origin_datatype () IN target_rank ( ) IN target_disp ( ) IN target_count ( ) IN target_datatype () IN win ,


int MPI_Get(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank, MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win)














OUT origin_addr ( ) IN origin_count ( ) IN origin_datatype () IN target_rank ( ) IN target_disp ( ) IN target_count ( ) IN target_datatype () IN win ,


int MPI_Accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank, MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win)












IN origin_addr () IN origin_count ( ) IN origin_datatype () IN target_rank ( ) IN target_disp ( ) IN target_count ( ) IN target_datatype () IN op - MPI_Reduce () IN win ()



int MPI_Win_fence(int assert, MPI_Win wi n )




IN assert () (assert = 0) IN win ()

MPI_WIN_FENCE , get, put accumulate, fence.



MPI_Win_create (A, ...., &win); MPI_Win_fence (0, win); If (rank == 0) { MPI_Put (....., win); MPI_Put (....., win); ...... MPI_Put (....., win); } MPI_Win_fenc win); MPI_Get (.... , MPI_Win_fenc win); A[rank] = 4; MPI_Win_fenc win); MPI_Put ( ... , MPI_Win_fenc win); e (0, win); e (0,

e (0, win); e (0,


Lock/Unlock
int MPI_Win_lock(int lock_type, int rank, int assert, MPI_Win win)




IN lock_type MPI_LOCK_EXCLUSIVE MPI_LOCK_SHARED () IN rank , ( ) IN assert () IN win () IN rank , ( ) IN win ()

int MPI_Win_unlock(int rank, MPI_Win win)





Lock/Unlock:
If (rank == 0) { MPI_Win_lock (MPI_LOCK_SHARED, 1, 0, win); MPI_Put (outbuf, n, MPI_INT, 1, 0, n, MPI_INT, win); MPI_Win_unlock (1, win); }


:


#include #include #include #include



/* this sample uses 1 side communication ("remote memory access") to get the first and last value of an array on remote processes. */ int main(int argc, char *argv[]){ int i; int nProc, myRank; int *data; int N; int *fl; MPI_Win win; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &myRank); MPI_Comm_size(MPI_COMM_WORLD, &nProc); fl = (int *)calloc(2*nProc, sizeof(int)); /* generate some data */ N = 100; data = (int *)calloc(N, sizeof(int)); for (i=0;i

/* create the window on memory to expose */ MPI_Win_create(data, N*sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win); /* check everything is up to date */ MPI_Win_fence(0, win); for (i=0;i

MPI-2: /


/



MPI-2 I/O:
MPI - . MPI . . . - , .


MPI-2 I/O:
- ( ) - . MPI . - , . - MPI, -. , «» -.


-


MPI-2 I/O:
, -. , : , - . , , ,
, .

- , -. «» . - - ( «» ).


MPI-2 I/O:
MPI - -, ,


- , MPI




« » - , , . « » - , , .

- , MPI_FILE_OPEN MPI_FILE_CLOSE.


MPI-2 I/O:
(MPI_File_open) (MPI_File_set_view) / (MPI_File_write, MPI_File_read) , (., MPI_Wait) (MPI_File_close)



int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *fh)


IN comm () IN filename () IN amode () IN info () OUT fh ()

filename comm amode , info «» ( )



MPI_MODE_RDONLY -- , MPI_MODE_RDWR -- , MPI_MODE_WRONLY -- , MPI_MODE_CREATE -- , , MPI_MODE_EXCL -- , , MPI_MODE_DELETE_ON_CLOSE -- , MPI_MODE_UNIQUE_OPEN -- - , MPI_MODE_SEQUENTIAL -- , MPI_MODE_APPEND -- .



int MPI_File_close(MPI_File *fh)


INOUT fh ()

, fh , fh, , MPI_FILE_CLOSE



int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, char *datarep, MPI_Info info)


I I I I I I

N N N N N N

OUT fh () disp () etype () filetype () datarep () info ()

int MPI_File_get_view(MPI_File fh, MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep)


IN fh OUT OUT OUT

() disp () etype () filetype ()














MPI_FILE_READ_AT_ALL MPI_FILE_WRITE_AT_ALL MPI_FILE_READ_AT_ALL_BEGIN MPI_FILE_READ_AT_ALL_END MPI_FILE_WRITE_AT_ALL_BEGIN MPI_FILE_WRITE_AT_ALL_END MPI_FILE_READ MPI_FILE_WRITE MPI_FILE_IREAD MPI_FILE_IWRITE MPI_FILE_READ_ALL MPI_FILE_WRITE_ALL MPI MPI MPI MPI _FIL _FIL _FIL _FIL E E E E _READ_ALL_BEGIN _READ_ALL_END _WRITE_ALL_BEGIN _WRITE_ALL_END





MPI_FILE_READ_AT MPI_FILE_WRITE_AT MPI_FILE_IREAD_AT MPI_FILE_IWRITE_AT



MPI_FILE_READ_SHARED MPI_FILE_WRITE_SHARED MPI_FILE_IREAD_SHARED MPI_FILE_IWRITE_SHARED

MPI_FILE_READ_ORDERED MPI_FILE_WRITE_ORDERED MPI N MPI MPI IN MPI _FILE_READ_ORDERED_BEGI _FILE_READ_ORDERED_END _FILE_WRITE_ORDERED_BEG _FILE_WRITE_ORDERED_END




( )
int MPI_File_read(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status)




INOUT fh - () OUT buf - () IN count - () IN datatype - () OUT status - (Status)

int MPI_File_write(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status)


INOUT fh - () IN buf - () IN count - () IN datatype - ()


( )
int MPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Status *status)




INOUT fh - () IN offset ­ OUT buf - () IN count - () IN datatype - () OUT status - (Status)

int MPI_File_write_at(MPI_File fh, MPI_Offset offset void *buf, int count, MPI_Datatype datatype, MPI_Status *status)


IN IN IN IN

OUT fh - () offset ­ buf - () count - ()


, )
int MPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, MPI_Status *status)




INOUT fh - () IN offset ­ OUT buf - () IN count - () IN datatype - () OUT status - (Status)

int MPI_File_write_at_all(MPI_File fh, MPI_Offset offset void *buf, int count, MPI_Datatype datatype, MPI_Status *status)


IN IN IN IN

OUT fh - () offset ­ buf - () count - ()


( )
MPI_File fh; MPI_Datatype filetype; MPI_Status status; MPI_Offset offset; int mode; float data[100]; /* other code */ /* set offset and filetype (covered later) */ mode = MPI_MODE_CREATE|MPI_MODE_RDWR; MPI_File_open(MPI_COMM_WORLD, "myfile", mode, MPI_INFO_NULL &fh); MPI_File_set_view(fh, offset, MPI_FLOAT, filetype, "native", MPI_INFO_NULL); MPI_File_write(fh, data, 100, MPI_FLOAT, &status); MPI_File_close(&fh);



=> , , , , ,



int MPI_File_set_atomicity(MPI_File fh, int flag) - ;


INOUT fh () IN flag true , false ()

int MPI_File_get_atomicity(MPI_File fh, int *flag) -


IN fh () INOUT flag true , false ()



int MPI_File_sync(MPI_File fh) ­ , ,


INOUT fh ()

int MPI_File_close(MPI_File fh) ­ ! ­


:



( 4 MPI):
A B --------------------------------|0 1| |||| ----------------|0|1|0|1 |2 3| |||| ----------------- * | | | | | |0 1| |||| ----------------|2|3|2|3 |2 3| |||| --------------------------------<------------> >---< Ng Nb | | | = | | | C ----------------|0|1|0|1 ----------------|2|3|2|3 ----------------|0|1|0|1 ----------------|2|3|2|3 ----------------(R = 2) | | | |