Hei,

I compiled PETSc with Intel MPI (MPICH) and GCC as compiler (i.e. using
Intel OneAPI together with the supplied mpicxx-compiler). Compilation
and installation worked fine, but running the tests resulted in the
error "Attempting to use an MPI routine before initializing MPICH". A
simple test program (attached) worked fine with the same combination.

What could be the reason for that?

Thanks!

Regards,

Roland Richter
#include <iostream>
#include <mpi.h>
#include <thread>
#include <sstream>
#include <omp.h>
#include <boost/thread.hpp>

int main(int args, char *argv[]) {
    int rank, nprocs, thread_id, nthreads, cxx_procs, omp_procs, boost_procs;
    MPI_Init(&args, &argv);

    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    boost_procs = boost::thread::physical_concurrency();

    omp_set_num_threads((nprocs < boost_procs) ? floor(boost_procs / nprocs) : 1);

    #pragma omp parallel private(thread_id, nthreads, cxx_procs, omp_procs, boost_procs) 
    {
        thread_id = omp_get_thread_num();
        nthreads = omp_get_num_threads();
        cxx_procs = std::thread::hardware_concurrency();
        omp_procs = omp_get_num_procs();
        boost_procs = boost::thread::physical_concurrency();
        std::stringstream omp_stream;
        omp_stream << "I'm thread " << thread_id 
        << " out of " << nthreads 
        << " on MPI process nr. " << rank 
        << " out of " << nprocs 
        << ", while hardware_concurrency reports " << cxx_procs 
        << ", OMP reports " << omp_procs
        << " and boost reports " << boost_procs
        << " processors\n";
        std::cout << omp_stream.str();
    }

    MPI_Finalize();
    return 0;
}

Reply via email to