0
我使用MPI並行運行的程序和措施的執行時間。我目前正在通過在「voxelise」函數中給出一個開始和結束索引作爲參數來分割每個進程之間的計算。這將在數據集的不同部分工作,並將結果存儲在「p_voxel_data」中。MPI分段故障
我當時想所有這些子陣列發送到使用「MPI_Gather」,這樣數據可以寫入一個文件,計時器停止根進程。
程序執行很好,當我有「MPI_Gather」行註釋掉,我得到類似的輸出:
Computing time: NODE 3 = 1.07 seconds.
Computing time: NODE 2 = 1.12 seconds.
但當包括該行我得到
"APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)
而且還計算時間爲根節點0顯示爲負號「-1.40737e + 08」 任何人都可以建議我呼籲MPI_Gather的任何問題?
int main(int argc, char** argv)
//-----------------------------
{
int rank;
int nprocs;
MPI_Comm comm;
MPI::Init(argc, argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* Set up data for voxelise function */
. . . . . .
clock_t start(clock());
// Generate the density field
voxelise(density_function,
a,
b,
p_control_point_set,
p_voxel_data,
p_number_of_voxel,
p_voxel_size,
p_centre,
begin,
endInd );
std::vector<float> completeData(512);
std::vector<float> cpData(toProcess);
std::copy(p_voxel_data.begin() + begin, p_voxel_data.begin() + endInd, cpData.begin());
MPI_Gather(&cpData, toProcess, MPI::FLOAT, &completeData, toProcess, MPI::FLOAT, 0, MPI_COMM_WORLD);
// Stop the timer
clock_t end(clock());
float number_of_seconds(float(end - start)/CLOCKS_PER_SEC);
std::cout << "Computing time:\t" << "NODE " << rank << " = " << number_of_seconds << " seconds." <<std::endl;
if(rank == 0) {
MPI::Finalize();
return (EXIT_SUCCESS);
}
這似乎是現在的工作表示感謝。 –