1

MPI を使用して、依存関係のあるプログラムとほぼ同じように動作するコードを生成しようとしています。X がモデル化しようとしているタスクの数 (switch ステートメントのケース数など) よりも大きい多数のプロセッサ (mpirun -np X など) を使用すると、すべて正常に動作します。私のプログラム モデルには、タスクのリスト、各タスクの実行時間、およびタスク間の一連の依存関係があります。次のような MPI コードを生成しました (実際のケースでは、50 から 600 のタスクがあります)。

int main(int argc, char* argv[]) {
  mpi::environment env(argc, argv);
  mpi::communicator world;
  long execution_times [4] = {9, 4, 3, 6};

  switch (world.rank()) {
    case 1: {
      std::cout << "1: Awake" << std::endl;
      mpi::request req[1];
      req[0] = world.irecv(0, 0);
      mpi::wait_all(req, req + 1);
      std::cout << "1: Recv notice from pred 0" << std::endl;
      time_t start;
      start = time(NULL);
      std::cout << "1: Started compute" << std::endl;
      while ((time(NULL)-start) < execution_times[1]);
      std::cout << "1: Finished compute in " << (time(NULL)-start) << std::endl;
      mpi::request sreq[3];
      sreq[0] = world.isend(5, 0);
      sreq[1] = world.isend(23, 0);
      sreq[2] = world.isend(42, 0);
      mpi::wait_all(sreq, sreq + 3);
      std::cout << "1: Sent notice to succ 5" << std::endl;
      std::cout << "1: Sent notice to succ 23" << std::endl;
      std::cout << "1: Sent notice to succ 42" << std::endl;
      break; }
    // Other cases excluded for brevity...
   }
   return 0;
}

私はこれをうまくコンパイルしg++ -L/usr/local/lib -lmpi -lmpi_cxx -lboost_serialization -lboost_mpi test.cppて実行することができますmpirun -np 4 a.out

ただし、プロセッサの数を超えるケースに達すると、常に例外が発生します。

hamiltont$ mpirun -np 2 a.out 
0: Awake
0: Started compute
0: Finished compute in 0
1: Awake
1: Recv notice from pred 0
1: Started compute
libc++abi.dylib: terminate called throwing an exception
hamiltont$ mpirun -np 3 a.out 
0: Awake
0: Started compute
0: Finished compute in 0
1: Awake
1: Recv notice from pred 0
1: Started compute
2: Awake
2: Recv notice from pred 0
2: Started compute
libc++abi.dylib: terminate called throwing an exception

プロセッサの数を 2 から 3 に増やすと、もう 1 つのケースを正常に実行できることに注意してください。MPIについて理解していないことがあると思います

完全な例外:

libc++abi.dylib: terminate called throwing an exception
[MacBook-Pro:47495] *** Process received signal ***
[MacBook-Pro:47495] Signal: Abort trap: 6 (6)
[MacBook-Pro:47495] Signal code:  (0)
[MacBook-Pro:47495] [ 0] 2   libsystem_c.dylib                   0x00007fff91e9b8ea _sigtramp + 26
[MacBook-Pro:47495] [ 1] 3   ???                                 0x0000000000000000 0x0 + 0
[MacBook-Pro:47495] [ 2] 4   libc++abi.dylib                     0x00007fff8f29ca17 abort_message + 257
[MacBook-Pro:47495] [ 3] 5   libc++abi.dylib                     0x00007fff8f29a3c6 _ZL17default_terminatev + 28
[MacBook-Pro:47495] [ 4] 6   libobjc.A.dylib                     0x00007fff94857887 _ZL15_objc_terminatev + 111
[MacBook-Pro:47495] [ 5] 7   libc++abi.dylib                     0x00007fff8f29a3f5 _ZL19safe_handler_callerPFvvE + 8
[MacBook-Pro:47495] [ 6] 8   libc++abi.dylib                     0x00007fff8f29a450 __cxa_bad_typeid + 0
[MacBook-Pro:47495] [ 7] 9   libc++abi.dylib                     0x00007fff8f29b5b7 _ZL23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception + 0
[MacBook-Pro:47495] [ 8] 10  a.out                               0x00000001086a818e _ZN5boost15throw_exceptionINS_3mpi9exceptionEEEvRKT_ + 158
[MacBook-Pro:47495] [ 9] 11  libboost_mpi.dylib                  0x0000000108a061e7 _ZNK5boost3mpi12communicator5isendEii + 111
[MacBook-Pro:47495] [10] 12  a.out                               0x0000000108676fc9 main + 1257
[MacBook-Pro:47495] [11] 13  libdyld.dylib                       0x00007fff911837e1 start + 0
[MacBook-Pro:47495] [12] 14  ???                                 0x0000000000000001 0x0 + 1
[MacBook-Pro:47495] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 0 with PID 47495 on node MacBook-Pro.local exited on signal 6 (Abort trap: 6).
4

0 に答える 0