Changes between Initial Version and Version 1 of MPITransformation


Ignore:
Timestamp:
04/01/14 16:06:35 (12 years ago)
Author:
zmanchun
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MPITransformation

    v1 v1  
     1Given an MPI program:
     2
     3{{{
     4#include <mpi.h>
     5 ...
     6#include <stdio.h>
     7
     8int a, b, ...;
     9
     10... function(){
     11  ...
     12}
     13...
     14
     15int main(){
     16  ....
     17}
     18}}}
     19
     20It is translate to a CIVL-C program:
     21
     22{{{
     23#include <mpi.h> // all included files are moved above to the new file scope.
     24...
     25#include <stdio.h>
     26
     27$input int argc;//optional, only necessary when the original main function has arguments.
     28$input char** argv;//optional, only necessary when the original main function has arguments.
     29$input int NPROCS;
     30$gcomm GCOMM_WORLD = $gcomm_create($here, NPROCS);
     31
     32void MPI_Process(int _rank){
     33  ...
     34}
     35
     36void main(){
     37  $proc procs[NPROCS];
     38   
     39  for(int i = 0; i < NPROCS; i++){
     40    procs[i] = $spawn MPI_Process(i);
     41  }
     42  for(int i = 0; i < NPROCS; i++){
     43    $wait(procs[i]);
     44  }
     45  $gcomm_destroy(GCOMM_WORLD);
     46}
     47}}}
     48
     49Whereas `MPI_Process()` is a wrapper of the original MPI program with some additional :
     50
     51{{{
     52void MPI_Process(){
     53  $comm MPI_COMM_WORLD = $comm_create(...);
     54 
     55  //SLIGHTLY-MODIFIED ORIGINAL PROGRAM;
     56  int a, b, ...;
     57  ... function(){...}
     58  ...
     59  ... __main(){...} // renamed main() to __main()
     60  ....
     61  //ORIGINAL PROGRAM ENDS HERE;
     62  __main();
     63  $comm_destroy(MPI_COMM_WORLD);
     64}
     65}}}