Exemplo n.º 1
0
/**
 * @brief Wrapper around MPI_Finalize
 *
 * This method prints the total time spent in MPI processes and during idle time
 * to the stdout. It also frees the node communicator.
 *
 * @return The error code of MPI_Finalize
 */
inline int MyMPI_Finalize() {
    int status = MPI_Comm_free(&MPIGlobal::nodecomm);
    if(status != MPI_SUCCESS) {
        std::cerr << "Error while freeing node communicator!" << std::endl;
        my_exit();
    }

    // deallocate communication buffers
    delete[] MPIGlobal::sendbuffer;
    delete[] MPIGlobal::recvbuffer;

    double locidletime, loccommtime;
    double totidletime, totcommtime;
    locidletime = MPIGlobal::idletimer.value();
    loccommtime = MPIGlobal::commtimer.value();
    // funny detail: calling MyMPI_Reduce below will increase the commtimer
    // we however do not take this (small) extra time in account, because we
    // already stored the old value and that one is communicated
    MyMPI_Reduce(&locidletime, &totidletime, 1, MPI_DOUBLE, MPI_SUM, 0);
    MyMPI_Reduce(&loccommtime, &totcommtime, 1, MPI_DOUBLE, MPI_SUM, 0);
    // we take the average over all MPI processes
    totidletime /= MPIGlobal::size;
    totcommtime /= MPIGlobal::size;
    std::cout << "Spent " << totidletime << "s waiting for other MPI processes"
              << std::endl;
    std::cout << "Spent " << totcommtime << "s in MPI communications"
              << std::endl;
    return MPI_Finalize();
}
/* Affichage à chaque itération et communication de certaines informations à la structure */
void Pastix_Verbose(void *arg, double t0, double t3, double tmp, PASTIX_INT nb_iter)
{
  sopthread_data_t *argument     = (sopthread_data_t *)arg;
  Sopalin_Data_t   *sopalin_data = (Sopalin_Data_t *)(argument->data);
  SolverMatrix     *datacode     = sopalin_data->datacode;
  SopalinParam     *sopar        = sopalin_data->sopar;
  MPI_Comm          pastix_comm  = PASTIX_COMM;
  PASTIX_INT        me           = argument->me;
  sopalin_data->count_iter = nb_iter;
  sopalin_data->stop = tmp;
  MONOTHREAD_BEGIN;
  if (sopar->iparm[IPARM_VERBOSE] > API_VERBOSE_NOT)
    {
      double rst = 0.0;
      double stt, rtt;
      double err, stop = tmp;

      stt = t3 - t0;
      MyMPI_Reduce(&stop, &err, 1, MPI_DOUBLE, MPI_MAX, 0, pastix_comm);
      MyMPI_Reduce(&stt,  &rtt, 1, MPI_DOUBLE, MPI_MAX, 0, pastix_comm);

      if (SOLV_PROCNUM == 0)
        {
          fprintf(stdout, OUT_ITERRAFF_ITER, (int)sopalin_data->count_iter);
          if (sopar->iparm[IPARM_ONLY_RAFF] == API_NO)
            fprintf(stdout, OUT_ITERRAFF_TTS, rst);
          fprintf(stdout, OUT_ITERRAFF_TTT, stt);
          fprintf(stdout, OUT_ITERRAFF_ERR, err);
        }
    }
  MONOTHREAD_END;
}