int main(int argc,char *argv[]) {
  int iter;

  MPI_Init(&argc, &argv);
  initdata();
  //  MPI_Barrier(MPI_COMM_WORLD);
  write_frame(0);
  MPI_Barrier(MPI_COMM_WORLD);
  for (iter = 1; iter <= nsteps; iter++) {
    exchange_ghost_cells();
    //MPI_Barrier(MPI_COMM_WORLD);
    update();
    //MPI_Barrier(MPI_COMM_WORLD); 
    // write_frame(iter);
    //MPI_Barrier(MPI_COMM_WORLD); 
  }
  MPI_Finalize();
}
Example #2
0
/* Executes the simulation. */
int main(int argc, char *argv[]) {
  MPI_Init(&argc, &argv);
  initialize();
  write_frame();
  printf("nx = %d", nx);
  for (time=1; time < nsteps; time++) {
    exchange_ghost_cells();
    update();
    if (time%wstep==0)
      write_frame();
  }
  MPI_Finalize();
  free(u);
  free(u_new);
  if (rank == 0)
    free(buf);
  return 0;
}
/* main: executes simulation, creates one output file for each time
 * step */
int main(int argc,char *argv[]) {
  int iter;

  MPI_Init(&argc, &argv);
  assert(argc==2);
  init(argv[1]);
  write_frame(0);
  for (iter = 1; iter <= nsteps; iter++) {
    exchange_ghost_cells();
    update();
    if (iter%wstep==0) write_frame(iter);
  }
  MPI_Finalize();
  free(u);
  free(u_new);
  if (rank == 0) {
    gdImageDestroy(previm);
    gdImageGifAnimEnd(file);
    fclose(file);
    free(buf);
    free(colors);
  }
  return 0;
}
Example #4
0
/*-----------------------------------------------------------
 * Programme principal
 *----------------------------------------------------------*/
int main (int argc, char **argv) {
  struct ctx_s ctx;
  int i;
  int *recopy;
  double timer_start, timer_end;
  double runtime;
  char output[256];

  /* Initialisation MPI */
  initalize_mpi(argc, argv, &ctx);

  /* Initialisation de la taille du domain (grille carree) */
  ctx.X = GRIDSZ / ctx.size;
  ctx.Y = GRIDSZ;
  ctx.grid = init_grid(&ctx);
  randomize_grid(&ctx, ctx.grid);
  ctx.grid_next = init_grid(&ctx);
  fprintf(stderr, "Starting task %d (%dx%d)\n", ctx.rank, ctx.X, ctx.Y);

  /* Initialisation affichage */
  sprintf(output, "output/Rank%d", ctx.rank);
  display_init(&ctx, output, GRIDSZ,GRIDSZ,0 ); // taille 0 pour la 3ieme dimension signifie une grille 2D

  /* Mettre la case au milieu du sous-domaine de la tache 0 en feu ! */
  if (ctx.rank == 0) {
    ctx.grid[(ctx.X+2)/2][(ctx.Y+2)/2] = burning;
  }

  recopy = recopy_grid(&ctx, ctx.grid);
  gather_grid(&ctx, recopy);

  timer_start = get_timer();
  for (i=0; i < MAX_STEPS; ++i) {
    int **swap;
    /* Nombre de cellules mises à jour depuis le pas
     * de temps precedent */
    int nb_updated_cells;
    /* Si la simulation est terminee */
    int leave;

    exchange_ghost_cells(&ctx);

    nb_updated_cells = update_cells(&ctx);

    leave = check_final_conditions(&ctx, nb_updated_cells);
    if (leave) break;

    swap = ctx.grid;
    ctx.grid = ctx.grid_next;
    ctx.grid_next = swap;

    recopy = recopy_grid(&ctx, ctx.grid);
    gather_grid(&ctx, recopy);
    if (ctx.rank == 0 && i%10 == 0) {
      fprintf(stderr, "..[%d]", i);
    }
  }
  timer_end = get_timer();

  if (ctx.rank == 0) {
    fprintf(stderr, "\n");
  }

  display_finalize(&ctx);
  runtime = diff_time(timer_end, timer_start);
  print_time (&ctx, runtime);

  /* Fin de la simulation */
  finalize_mpi(&ctx);
  exit(0);
}