Given an undirected connected graph, output all pair shortest path.
Because the input is an undirected graph, we only need to compute half of all distance. So simply modified Floyd Warshall algorithm to do some optimization based on above.
Under fully distributed graph model's rule, every process hold's a vertex and can only send the message to its neighbors.
詳細過程如下:
sync 版本掌握兩個原則
- 每個 process 只會知道任意點到自己的最短距離。
- 傳送過程分為兩個 phase。
Important:
由於 MPI_Isend 的內部運作機制是會在 memory allocate 一塊空間存放 MPI_Request ,再透過 MPI_Isend api 中你所指定的 pointer 去指向他。因此當今天使用了 MPI_Isend 後沒有去 free 掉這段空間就會導致 memory leak,而當 MPI_Isend 的次數一龐大起來就很容易 crash。
因此記得 任何的 MPI_Isend 後都必須要接 MPI_Wait/MPI_Test 以 free 掉這段存放 MPI_Request 的記憶體空間。而做法可以利用下次 MPI_Isend 前已經確保對方收到時在 call MPI_Wait,如此就不會發生相互等待的 dead lock。
