Exemple #1
0
static void
read_lists (const char *val)
{
  if (! grub_no_autoload)
    {
      read_command_list (val);
      read_fs_list (val);
      read_crypto_list (val);
      read_terminal_list (val);
    }
}
Exemple #2
0
static void
read_lists (const char *val)
{
#ifdef GRUB_MACHINE_EMU
  (void) val;
#else
  read_command_list (val);
  read_fs_list (val);
  read_crypto_list (val);
  read_terminal_list (val);
#endif
}
static void master(char *commandsfile, char *jobid)
{
  int ntasks, rank;
  char *result;
  MPI_Status status;
  int i; //for loop variable
  char *work;
  char *diestring;
  int count;
  int tot_commands;
  char** command_list; // pointer to char*--array of strings--array of commands to execute
  diestring=(char *)malloc(sizeof(char)*SMALL_STRSIZE);
  result=(char *)malloc(sizeof(char)*MED_STRSIZE);
  work=(char *)malloc(sizeof(char)*BIG_STRSIZE);
  /* Find out how many processes there are in the default
     communicator */
  MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
  /* Seed the slaves; send one unit of work to each slave. */
  strcpy(diestring,"XXX"); //if work is null, it means the number of jobs are more than the processors
  printf("MASTER Master received the inputs\ncommands file is %s\n",commandsfile);
  command_list=read_command_list(commandsfile, &tot_commands);
  count=0;
  for (rank = 1; rank < ntasks; ++rank)
  {

    /* Find the next item of work to do */
    printf("MASTER Forloop ranks\n");
    work=get_next_work_item(command_list, count, tot_commands);
    count++; //increment count of how many work requests we have done
    /* Send it to each rank */
    if (work == _NULL)
    {
        MPI_Send(diestring,             /* message buffer */
                BIG_STRSIZE,                 /* one data item */
                MPI_CHAR,           /* data item is an integer */
                rank,              /* destination process rank */
                DIETAG,           /* user chosen message tag */
                MPI_COMM_WORLD);   /* default communicator */
        printf("DIEstring sent \n");
    } //end if work == _NULL
    else
    {
    	printf("MASTER work is %s \n",work);
    	MPI_Send(work,             /* message buffer */
       		BIG_STRSIZE,                 /* one data item */
             	MPI_CHAR,           /* data item is an integer */
             	rank,              /* destination process rank */
             	WORKTAG,           /* user chosen message tag */
             	MPI_COMM_WORLD);   /* default communicator */
     	strcpy(work,"\0"); //initialize it
     	printf("MASTER sent success \n");
    }
    fflush(stdout);
  } //end for rank=1..ntasks

  printf("MASTER First phase is completed\n");
  /* Loop over getting new work requests until there is no more work
     to be done */

  work=get_next_work_item(command_list, count, tot_commands);
  count++; //increment count of how many work requests we have done
  /* Send it to each rank */
  while (work != _NULL)
  {
    /* Receive results from a slave */
    MPI_Recv(result,           /* message buffer */
             MED_STRSIZE,                 /* one data item */
             MPI_CHAR,        /* of type double real */
             MPI_ANY_SOURCE,    /* receive from any sender */
             MPI_ANY_TAG,       /* any type of message */
             MPI_COMM_WORLD,    /* default communicator */
             &status);          /* info about the received message */
    //process the result, update &myfilelist
    /* Send the slave a new work unit */
    MPI_Send(work,             /* message buffer */
             BIG_STRSIZE,                 /* one data item */
             MPI_CHAR,           /* data item is an integer */
             status.MPI_SOURCE, /* to who we just received from */
             WORKTAG,           /* user chosen message tag */
             MPI_COMM_WORLD);   /* default communicator */

    /* Get the next unit of work to be done */
    work=get_next_work_item(command_list, count, tot_commands);
    count++; //increment count of how many work requests we have done
    fflush(stdout);
  }
  printf("MASTER While is skipped\n");
  printf("still here\n");
  /* There's no more work to be done, so receive all the outstanding
     results from the slaves. */

  for (rank = 1; rank < ntasks; ++rank) {
    printf("Rank %d is done\n",rank);
    MPI_Recv(result, MED_STRSIZE, MPI_CHAR, MPI_ANY_SOURCE,
             MPI_ANY_TAG, MPI_COMM_WORLD, &status);
  	 fflush(stdout);

  }
  printf("MASTER All the results are collected, now sending die signals to processors\n");
  /* Tell all the slaves to exit by sending an empty message with the
     DIETAG. */
  for (rank = 1; rank < ntasks; ++rank) {
    MPI_Send(diestring, BIG_STRSIZE, MPI_CHAR, rank, DIETAG, MPI_COMM_WORLD);
  }

 //clean up
 for(i=0;i<tot_commands;i++) { free(command_list[i]); }
 free(command_list);
 printf("MASTER Program finished succesfully \n");
}