【正文】
ctions to perform */ MPI_Datatype type, /* type of elements */ MPI_Op operator, /* reduction operator */ int root, /* process getting result(s) */ MPI_Comm m /* municator */ ) Copyright 169。 The McGrawHill Companies, Inc. Permission required for reproduction or display. MPI_Datatype Options ? MPI_CHAR ? MPI_DOUBLE ? MPI_FLOAT ? MPI_INT ? MPI_LONG ? MPI_LONG_DOUBLE ? MPI_SHORT ? MPI_UNSIGNED_CHAR ? MPI_UNSIGNED ? MPI_UNSIGNED_LONG ? MPI_UNSIGNED_SHORT Copyright 169。 The McGrawHill Companies, Inc. Permission required for reproduction or display. MPI_Op Options ? MPI_BAND ? MPI_BOR ? MPI_BXOR ? MPI_LAND ? MPI_LOR ? MPI_LXOR ? MPI_MAX ? MPI_MAXLOC ? MPI_MIN ? MPI_MINLOC ? MPI_PROD ? MPI_SUM Copyright 169。 The McGrawHill Companies, Inc. Permission required for reproduction or display. Our Call to MPI_Reduce() MPI_Reduce (amp。count, amp。global_count, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD)。 Only process 0 will get the result if (!id) printf (There are %d different solutions\n, global_count)。 Copyright 169。 The McGrawHill Companies, Inc. Permission required for reproduction or display. Execution of Second Program % mpirun np 3 seq2 0) 0110111110011001 0) 1110111111011001 1) 1110111110011001 1) 1010111111011001 2) 1010111110011001 2) 0110111111011001 2) 1110111110111001 1) 0110111110111001 0) 1010111110111001 Process 1 is done Process 2 is done Process 0 is done There are 9 different solutions Copyright 169。 The McGrawHill Companies, Inc. Permission required for reproduction or display. Benchmarking the Program ? MPI_Barrier ? barrier synchronization ? MPI_Wtick ? timer resolution ? MPI_Wtime ? current time Copyright 169。 The McGrawHill Companies, Inc. Permission required for reproduction or display. Benchmarking Code double elapsed_time。 … MPI_Init (amp。argc, amp。argv)。 MPI_Barrier (MPI_COMM_WORLD)。 elapsed_time = MPI_Wtime()。 … MPI_Reduce (…)。 elapsed_time += MPI_Wtime()。 Copyright 169。 The McGrawHill Companies, Inc. Permission required for reproduction or display. Benchmarking Results Processors Time (sec) 1 2 3 4 5 Copyright 169。 The McGrawHill Companies, Inc. Permission required for reproduction or display. Benchmarking Results 051015201 2 3 4 5P r o c e s s o r sTime (msec)E x e cu tio n T i m eP e r f e ct S p e e dIm p r o v e m e n tCopyright 169。 The McGrawHill Companies, Inc. Permission required for reproduction or display. Summary (1/2) ? Messagepassing programming follows naturally from task/channel model ? Portability of messagepassing programs ? MPI most widely adopted standard Copyright 169。 The McGrawHill Companies, Inc. Permission required for reproduction or display. Summary (2/2) ? MPI functions introduced ?MPI_Init ?MPI_Comm_rank ?MPI_Comm_size ?MPI_Reduce ?MPI_Finalize ?MPI_Barrier ?MPI_Wtime ?MPI_Wtick