Esempio n. 1
0
static void 
pass_its_neighbor(const int rank, const int size, int* buf)
{  
  int i;
  MPI_Request request[2];
  MPI_Status status[2];

  MPI_Irecv((void*)buf, 1, MPI_INT, ((rank+size-1)%size), COMM_TAG, MPI_COMM_WORLD, &request[0]);
  MPI_Isend((void*)&rank, 1, MPI_INT, ((rank+1)%size), COMM_TAG, MPI_COMM_WORLD, &request[1]);
  MPI_Waitall(2, request, status);

  int remain = COMPUTE_UNIT * SLEEP_FOR_COMPUTE_SEC;
  for (i=0; i < COMPUTE_UNIT; i++) 
    {
      sleep(SLEEP_FOR_COMPUTE_SEC);
      remain -= SLEEP_FOR_COMPUTE_SEC;
      if (rank == 0) 
        LMON_say_msg ( "APP", "%d secs remain", remain);
    }

  if (rank == 0) 
    LMON_say_msg ( "APP", "size of this program is %d\n", size); 

  MPI_Barrier(MPI_COMM_WORLD);
}
Esempio n. 2
0
int main(int argc, char* argv[]) {
  int size, rank, i;
  int buf;

  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD, &size);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);

  init_FETCH_ME_DBL_ARRAY();
  signal(SIGUSR1, sighandler);
  global_rank = rank;
  if (rank == 0)
    fprintf(stdout, "[LMON APP] singal handler installed for signum=%d\n",
            SIGUSR1);

  while (global_stall == 1) {
    if (rank == 0)
      LMON_say_msg("APP", "stall for %d secs", SLEEP_FOR_COMPUTE_SEC);
    sleep(SLEEP_FOR_COMPUTE_SEC);
  }

  if (rank == 0) fprintf(stdout, "The hang unlocked\n");

  pass_its_neighbor(rank, size, &buf);

  int remain = COMPUTE_UNIT * SLEEP_FOR_COMPUTE_SEC;
  for (i = 0; i < COMPUTE_UNIT; i++) {
    sleep(SLEEP_FOR_COMPUTE_SEC);
    remain -= SLEEP_FOR_COMPUTE_SEC;
    if (rank == 0) LMON_say_msg("APP", "%d secs remain", remain);
  }

  if (rank == 0) LMON_say_msg("APP", "size of this program is %d\n", size);

  MPI_Finalize();
  return EXIT_SUCCESS;
}