mpi_wtime()混乱 - 看起来不正确
我正在使用MPI_WTIME()来测量并行应用的速度。
在4个内核上运行该应用程序在0.000061(大约需要30秒)
上运行50个内核,0.000308。 (瞬时)
将工作负载乘以10倍,仍然在50个内核上,时间为0.000752。 (大约2分钟IRL)
int main(int argc, char* argv[]) {
ofstream file;
file.open("primes.txt");
file.close();
MPI_Init(&argc, &argv);
MPI_Status status;
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0)
t1 = MPI_Wtime();
int size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (rank == 0)
Parent parent(size);
else
Child child(size, rank);
if (rank == 0) {
t2 = MPI_Wtime();
}
MPI_Finalize();
if (rank == 0)
printf("Runtime = %f\n", t2 - t1);
}
父母包含一个管理孩子的循环。
这些数字没有任何意义。我在做什么错?
mpi_wtick()为1E-9
I'm using MPI_Wtime() to measure the speed of a parallel application.
Running the application on 4 cores completes in 0.000061 (takes around 30 seconds)
Running on 50 cores, 0.000308. (instantaneous)
Multiplying the workload 10x, still on 50 cores, the time is 0.000752. (around a 2 minutes irl)
int main(int argc, char* argv[]) {
ofstream file;
file.open("primes.txt");
file.close();
MPI_Init(&argc, &argv);
MPI_Status status;
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0)
t1 = MPI_Wtime();
int size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
if (rank == 0)
Parent parent(size);
else
Child child(size, rank);
if (rank == 0) {
t2 = MPI_Wtime();
}
MPI_Finalize();
if (rank == 0)
printf("Runtime = %f\n", t2 - t1);
}
Parent contains a loop to manage children.
These numbers do not make any sense. What am I doing wrong?
MPI_Wtick() is 1e-9
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢@giles Gouaillardet和@Victor Eijkhout回答。
将T1和T2移至本地并添加
mpi_barrier
在每个时间录制之前,我能够得到一个有意义的答案。在4个内核上运行代码的结果为20.277840,听起来正确。
之前,相同的测试给出了0.000061的结果,这根本没有任何意义。
谢谢。
Thanks to @Giles Gouaillardet and @Victor Eijkhout for answering.
After moving t1 and t2 to be local and adding
MPI_Barrier
before each recording of the time, I was able to get an answer that made sense.Running the code on 4 cores gave a result of 20.277840, which sounds correct.
Before, this same test gave a result of 0.000061, which does not make any sense at all.
Thank you.