gpt4 book ai didi

c++ - 为什么我的 MPI 应用程序会触发断点?

转载 作者:行者123 更新时间:2023-11-28 05:08:32 24 4
gpt4 key购买 nike

我有一个简单的 MPI 应用程序,用于在输入所需值时将值从进程 0 传递到其他进程,但它在“else”上触发断点。

我错过了什么?

#include "stdafx.h"
#include "mpi.h"
#include "stdio.h"
#include "stdlib.h"

int main(int argc, char* argv[])
{
int rank;
int value;
int size;

MPI_Status status;
MPI_Init(&argc, &argv);

MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);

do
{
if (rank == 0)
{
printf("Enter the value: ");
scanf_s("%d", &value);
MPI_Send(&value, 1, MPI_INT, rank + 1, 0, MPI_COMM_WORLD);
}

else
{
MPI_Recv(&value, 1, MPI_INT, rank - 1, 0, MPI_COMM_WORLD,
&status);

if (rank < size - 1)
MPI_Send(&value, 1, MPI_INT, rank + 1, 0, MPI_COMM_WORLD);
}

printf("Process %d got %d ", rank, value);

} while (value >= 0);

MPI_Finalize();
return 0;
}

这是调试的输出:

'MPIHelloWorld.exe' (Win32): Loaded 'C:\WINDOWS\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.

'MPIHelloWorld.exe' (Win32): Loaded 'C:\WINDOWS\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.

'MPIHelloWorld.exe' (Win32): Loaded 'C:\Program Files (x86)\Bonjour\mdnsNSP.dll'. Cannot find or open the PDB file.

MPIHelloWorld.exe has triggered a breakpoint.

MPIHelloWorld.exe has triggered a breakpoint.

The thread 0x3308 has exited with code 0 (0x0).

The thread 0x1dfc has exited with code 0 (0x0).

The thread 0x2e5c has exited with code 0 (0x0).

The program '[4400] MPIHelloWorld.exe' has exited with code 0 (0x0).

更新:

当我按下 CTRL + 5 时,我在控制台中收到此错误消息:

作业中止:[行列]留言

[0] fatal error MPI_Send 中的 fatal error :无效等级值为 1,但必须为非负且小于 1

最佳答案

好的,我终于找到答案了!

我无法使用 Cluster Debugger for MPI,因为我运行的是 Visual Studio 2015问题是只有 1 个进程在运行。

我打开了 CMD 并使用“mpiexec.exe -n 4 myMpiApp.exe”运行了我的应用程序,它成功了。

关于c++ - 为什么我的 MPI 应用程序会触发断点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44030662/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com