================ Lösungsvorschlag ================ ---- CODE (type=cpp) ---------------------------------------------------------- template void exchange_with_neighbors(Matrix& A, /* ranks of the neighbors */ int previous, int next, /* data type for an inner row, i.e. without the border */ MPI_Datatype rowtype) { MPI_Request requests[4]; int request_index = 0; MPI_Irecv(&A(0, 1), 1, rowtype, previous, 0, MPI_COMM_WORLD, &requests[request_index++]); MPI_Irecv(&A(A.numRows-1, 1), 1, rowtype, next, 0, MPI_COMM_WORLD, &requests[request_index++]); MPI_Isend(&A(1, 1), 1, rowtype, previous, 0, MPI_COMM_WORLD, &requests[request_index++]); MPI_Isend(&A(A.numRows-2, 1), 1, rowtype, next, 0, MPI_COMM_WORLD, &requests[request_index++]); for (auto& request: requests) { MPI_Status status; MPI_Wait(&request, &status); } } ------------------------------------------------------------------------------- ---- SHELL (path=session22) --------------------------------------------------- mpic++ -g -O3 -std=c++11 \ -I. -I/home/numerik/pub/hpc/session22 \ $(pkg-config --cflags gdk-pixbuf-2.0) \ -o jacobi jacobi.cpp $(pkg-config --libs gdk-pixbuf-2.0) mpic++ -g -O3 -std=c++11 \ -I. -I/home/numerik/pub/hpc/session22 \ $(pkg-config --cflags gdk-pixbuf-2.0) \ -o jacobi-nb jacobi-nb.cpp $(pkg-config --libs gdk-pixbuf-2.0) time mpirun -np 4 jacobi time mpirun -np 4 jacobi-nb ------------------------------------------------------------------------------- :navigate: up -> doc:index back -> doc:session22/page05 next -> doc:session22/page07