gpt4 book ai didi

c++ - MPI_Comm_Rank的段错误

转载 作者:行者123 更新时间:2023-12-02 10:29:08 25 4
gpt4 key购买 nike

我必须处理几年前编写的使用MPI和PETSc的代码。
当我尝试运行它时,函数MPI_Comm_rank()出现错误。
这是代码的开头:

int main(int argc,char **argv)
{
double mesure_tps2,mesure_tps1;
struct timeval tv;
time_t curtime2,curtime1;

char help[] = "Solves linear system with KSP.\n\n"; // NB: Petsc est defini dans "fafemo_Constant_Globales.h"


std::cout<< "d�but PetscInitialize" <<std::endl;
(void*) PetscInitialize(&argc,&argv,(char *)0,help);
std::cout<< "d�but PetscInitialize fait" <<std::endl;

int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

PetscFinalize();

}
显然,MPI_Comm_rank()和PetscFinalize()之间有一些代码。
PetscInitialize和PetscFinalize分别调用MPI_INIT和MPI_FINALIZE。
在我的makefil中,我有:
PETSC_DIR=/home/thib/Documents/bibliotheques/petsc-3.13.2
PETSC_ARCH=arch-linux-c-debug
include ${PETSC_DIR}/lib/petsc/conf/variables
include ${PETSC_DIR}/lib/petsc/conf/rules

PETSC36 = -I/home/thib/Documents/bibliotheques/petsc-3.13.2/include -I/home/thib/Documents/bibliotheques/petsc-3.13.2/arch-linux-c-debug/include

Mpi_include=-I/usr/lib/x86_64-linux-gnu/openmpi

#a variable with some files names
fafemo_files = fafemo_CI_CL-def.cc fafemo_Flux.cc fafemo_initialisation_probleme.cc fafemo_FEM_setup.cc fafemo_sorties.cc fafemo_richards_solve.cc element_read_split.cpp point_read_split.cpp read_split_mesh.cpp


PETSC_KSP_LIB_VSOIL=-L/home/thib/Documents/bibliotheques/petsc-3.13.2/ -lpetsc_real -lmpi -lmpi++

fafemo: ${fafemo_files} fafemo_Richards_Main.o
g++ ${CXXFLAGS} -g -o fafemo_CD ${fafemo_files} fafemo_Richards_Main.cc ${PETSC_KSP_LIB_VSOIL} $(PETSC36) ${Mpi_include}
使用g++或mpic++似乎没有任何改变。
它可以编译,但是当我尝试执行时,我有:
[thib-X540UP:03696] Signal: Segmentation fault (11)
[thib-X540UP:03696] Signal code: Address not mapped (1)
[thib-X540UP:03696] Failing at address: 0x44000098
[thib-X540UP:03696] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x3efd0)[0x7fbfa87e4fd0]
[thib-X540UP:03696] [ 1] /usr/lib/x86_64-linux-gnu/libmpi.so.20(MPI_Comm_rank+0x42)[0x7fbfa9533c42]
[thib-X540UP:03696] [ 2] ./fafemo_CD(+0x230c8)[0x561caa6920c8]
[thib-X540UP:03696] [ 3] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fbfa87c7b97]
[thib-X540UP:03696] [ 4] ./fafemo_CD(+0x346a)[0x561caa67246a]
[thib-X540UP:03696] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 0 with PID 0 on node thib-X540UP exited on signal 11 (Segmentation fault).
--------------------------------------------------------------------------

另外,我的计算机上还有其他MPI程序,但我从未遇到过这样的问题。
有谁知道我为什么要得到这个?

最佳答案

如果有人有同样的问题:
当我安装PETSc时,当我已经在计算机上安装了mpi时,便使用--download-mpich运行了./configure。
为了解决该问题,我做了“rm -rf $ {PETSC_ARCH}”并再次运行./configure。

关于c++ - MPI_Comm_Rank的段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62992601/

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