none
ejecutar MPI sin mpiexec (boost MPI - Microsoft MPI v7.1) RRS feed

  • Debate general

  • Buenas,

    Quiero probar MPI point-to-point

    Estoy usando vse2015, windows10, boost mpi 160, Microsoft MPI v7.1, este es mi programa ejemplo

    #include <boost/mpi.hpp>
    #include <iostream>
    #include <boost/serialization/string.hpp>
    #include <thread>
    #include <boost/exception/all.hpp>
    #include <exception>
    
    using namespace std;
    namespace mpi = boost::mpi;
    
    int main(int argc, char* argv[]) {
    
       for (int i = 0; i < argc; ++i) {
          std::cout << "argc " << i << " value " << argv[i] << std::endl;
       }
    
       mpi::environment env(false);
       std::cout << "processor_name " << env.processor_name() <<
          " thread_level: " << env.thread_level() <<
          " is_main_thread: " << env.is_main_thread() << std::endl;
    
       std::this_thread::sleep_for(std::chrono::seconds(2));
    
       mpi::communicator world;
       std::cout << "I am process " << world.rank() << " of " << world.size()
          << "." << std::endl;
    
       do {
          if (world.rank() == 0) {
             try {
                mpi::request reqs[2];
                std::string msg, out_msg = "Hello";
    
                reqs[0] = world.isend(1, 0, out_msg);
                reqs[1] = world.irecv(1, 1, msg);
                mpi::wait_all(reqs, reqs + 2);
                std::cout << msg << "!" << std::endl;
             }
             catch (boost::exception &ex) {
                std::cerr << "[" << world.rank() << "] boost::exception" << boost::diagnostic_information(ex);
             }
             catch (std::exception &ex) {
                std::cerr << "[" << world.rank() << "] std::exception" << ex.what();
             }
             catch (...) {
                std::cerr << "[" << world.rank() << "] exception";
             }
          }
          else {
             try {
                mpi::request reqs[2];
                std::string msg, out_msg = "world";
                reqs[0] = world.isend(0, 1, out_msg);
                reqs[1] = world.irecv(0, 0, msg);
                mpi::wait_all(reqs, reqs + 2);
                std::cout << msg << ", ";
             }
             catch (boost::exception &ex) {
                std::cerr << "[" << world.rank() << "]" << boost::diagnostic_information(ex);
             }
             catch (std::exception &ex) {
                std::cerr << "[" << world.rank() << "]" << ex.what();
             }
             catch (...) {
                std::cerr << "[" << world.rank() << "]" << "exception";
             }
          }
          std::this_thread::sleep_for(std::chrono::seconds(1));
       } while (true);
    
       return 0;
    }

    si ejecuto mpiexec, funciona. la salida es (mpiexec -n 2 app_name.exe)

    argc 0 value boost_mpi_main_MDd_x86_v140.exe
    argc 0 value boost_mpi_main_MDd_x86_v140.exe
    processor_name jagomezw7.indra.es thread_level: single is_main_thread: 1
    processor_name jagomezw7.indra.es thread_level: single is_main_thread: 1
    I am process 0 of 2.
    I am process 1 of 2.
    world!

    si trato de ejecutarlo manualmente me falla, he visto que el arbol de procesos es mpiexec->smpd->app_name/app_name

    si lanzo smpd.exe manualmente sale esto

    set MSMPI_LOCAL_ONLY=1
    smpd.exe -p 8677 -d 2 -localonly

    [-1:67884] Launching SMPD service.
    [-1:67884] smpd listening on port 8677

    si luego ejecuto la aplicacion manualmente, configurando algunas variables de entorno me falla

    SET MSMPI_LOCAL_ONLY=1
    SET PMI_PORT=8677
    SET PMI_RANK_AFFINITIES=affinity_region_67884
    SET PMI_SIZE=2
    SET PMI_RANK=0

    app_name.exe

    argc 0 value boost_mpi_main_MDd_x86_v140.exe
    processor_name jagomezw7.indra.es thread_level: single is_main_thread: 1
    I am process 0 of 1.
    [0] boost::exceptionThrow location unknown (consider using BOOST_THROW_EXCEPTION)
    Dynamic exception type: class boost::exception_detail::clone_impl<struct boost::exception_detail::error_info_injector<class boost::mpi::exception> >
    std::exception::what: MPI_Isend: Invalid rank, error stack:
    MPI_Isend(buf=0x0042C1A4, count=1, MPI_UNSIGNED, dest=1, tag=0, MPI_COMM_WORLD, request=0x001CF228) failed
    Invalid rank has value 1 but must be nonnegative and less than 1

    he probado tambien con estas variables pero no soy capaz de cambiar el PMI_SIZE a 2 (que es lo que espero)

    se puede ejecutar manualmente? como lo tengo que hacer?

    gracias



    jose andres gomez tovar

    miércoles, 23 de noviembre de 2016 15:26