Пономаренко Роман
http://t.me/rerand0m
rerandom@ispras.ru
Спецификация, описывающая программный интерфейс передачи сообщений.
Версия 1.0 была опубликована 5 мая 1994г.
В настоящий момент актуальной является версия 4.0. (с 09.06.2021)
$ mpic++ -show g++ -Wl,-rpath -Wl,/usr/lib -Wl,--enable-new-dtags -lmpi_cxx -lmpi $ mpic++ main.cpp $ mpiexec --use-hwthread-cpus --mca opal_warn_on_missing_libcuda 0 a.out Hello from processor rerand0m-main rank 10 out of 16 Hello from processor rerand0m-main rank 12 out of 16 Hello from processor rerand0m-main rank 13 out of 16 Hello from processor rerand0m-main rank 14 out of 16 Hello from processor rerand0m-main rank 1 out of 16 Hello from processor rerand0m-main rank 2 out of 16 Hello from processor rerand0m-main rank 5 out of 16 Hello from processor rerand0m-main rank 6 out of 16 Hello from processor rerand0m-main rank 9 out of 16 Hello from processor rerand0m-main rank 11 out of 16 Hello from processor rerand0m-main rank 15 out of 16 Hello from processor rerand0m-main rank 0 out of 16 Hello from processor rerand0m-main rank 3 out of 16 Hello from processor rerand0m-main rank 7 out of 16 Hello from processor rerand0m-main rank 4 out of 16 Hello from processor rerand0m-main rank 8 out of 16
$ mpic++ -show clang++ -I/opt/homebrew/Cellar/open-mpi/4.1.4_2/include -L/opt/homebrew/Cellar/open-mpi/4.1.4_2/lib -L/opt/homebrew/opt/libevent/lib -lmpi $ mpic++ main.cpp $ # fix mac os error "A system call failed during shared memory initialization..." $ export TMPDIR=/tmp $ mpiexec --use-hwthread-cpus --mca opal_warn_on_missing_libcuda 0 a.out Hello from processor MacBook-Pro-Roman.local rank 7 out of 10 Hello from processor MacBook-Pro-Roman.local rank 5 out of 10 Hello from processor MacBook-Pro-Roman.local rank 0 out of 10 Hello from processor MacBook-Pro-Roman.local rank 1 out of 10 Hello from processor MacBook-Pro-Roman.local rank 2 out of 10 Hello from processor MacBook-Pro-Roman.local rank 3 out of 10 Hello from processor MacBook-Pro-Roman.local rank 6 out of 10 Hello from processor MacBook-Pro-Roman.local rank 4 out of 10 Hello from processor MacBook-Pro-Roman.local rank 8 out of 10 Hello from processor MacBook-Pro-Roman.local rank 9 out of 10
int MPI_Send(const void *buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm)
int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
MPI_Comm comm, MPI_Status *status)
Написать программу, в которой первый процесс генерирует некое случайное число и передаёт его второму процессу.
Второй (и каждый последующий, кроме последнего) получает число, увеличивает его на свой номер и передаёт следующему по цепочке.
Последний, приняв число выводит его на экран.
![]()
int MPI_Get_count(const MPI_Status *status, MPI_Datatype datatype, int *count)
int MPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status)
struct MPI_Status {
int MPI_SOURCE;
int MPI_TAG;
int MPI_ERROR;
};
int MPI_Isend(const void *buf, int count, MPI_Datatype datatype, int dest,
int tag, MPI_Comm comm, MPI_Request *request)
int MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
int source, int tag, MPI_Comm comm, MPI_Request *request)
int MPI_Wait(MPI_Request *request, MPI_Status *status)
int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status)
int MPI_Iprobe(int source, int tag, MPI_Comm comm, int *flag,
MPI_Status *status)
Когда это необходимо?
Какие методы измерения времени работы программы вы знаете?
double MPI_Wtime()