- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我之前的帖子中,我需要在 10 台计算机之间分发 pgm 文件的数据。在 Jonathan Dursi 和 Shawn Chin 的帮助下,我集成了代码。
我可以编译我的程序,但它出现了段错误。我跑了但什么也没发生mpirun -np 10 ./exmpi_2 balloons.pgm output.pgm
结果是
[ubuntu:04803] *** Process received signal ***
[ubuntu:04803] Signal: Segmentation fault (11)
[ubuntu:04803] Signal code: Address not mapped (1)
[ubuntu:04803] Failing at address: 0x7548d0c
[ubuntu:04803] [ 0] [0x86b410]
[ubuntu:04803] [ 1] /lib/tls/i686/cmov/libc.so.6(fclose+0x1a0) [0x186b00]
[ubuntu:04803] [ 2] ./exmpi_2(main+0x78e) [0x80492c2]
[ubuntu:04803] [ 3] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x141bd6]
[ubuntu:04803] [ 4] ./exmpi_2() [0x8048aa1]
[ubuntu:04803] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 1 with PID 4803 on node ubuntu exited on signal 11 (Segmentation fault).
--------------------------------------------------------------------------
valgrind mpirun -np 10 ./exmpi_2 balloons.pgm output.pgm
==4632== Memcheck, a memory error detector
==4632== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==4632== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==4632== Command: mpirun -np 10 ./exmpi_2 2.pgm 10.pgm
==4632==
==4632== Syscall param sched_setaffinity(mask) points to unaddressable byte(s)
==4632== at 0x4215D37: syscall (syscall.S:31)
==4632== by 0x402B335: opal_paffinity_linux_plpa_api_probe_init (plpa_api_probe.c:56)
==4632== by 0x402B7CC: opal_paffinity_linux_plpa_init (plpa_runtime.c:37)
==4632== by 0x402B93C: opal_paffinity_linux_plpa_have_topology_information (plpa_map.c:494)
==4632== by 0x402B180: linux_module_init (paffinity_linux_module.c:119)
==4632== by 0x40BE2C3: opal_paffinity_base_select (paffinity_base_select.c:64)
==4632== by 0x40927AC: opal_init (opal_init.c:295)
==4632== by 0x4046767: orte_init (orte_init.c:76)
==4632== by 0x804A82E: orterun (orterun.c:540)
==4632== by 0x804A3EE: main (main.c:13)
==4632== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==4632==
[ubuntu:04638] *** Process received signal ***
[ubuntu:04639] *** Process received signal ***
[ubuntu:04639] Signal: Segmentation fault (11)
[ubuntu:04639] Signal code: Address not mapped (1)
[ubuntu:04639] Failing at address: 0x7548d0c
[ubuntu:04639] [ 0] [0xc50410]
[ubuntu:04639] [ 1] /lib/tls/i686/cmov/libc.so.6(fclose+0x1a0) [0xde4b00]
[ubuntu:04639] [ 2] ./exmpi_2(main+0x78e) [0x80492c2]
[ubuntu:04639] [ 3] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xd9fbd6]
[ubuntu:04639] [ 4] ./exmpi_2() [0x8048aa1]
[ubuntu:04639] *** End of error message ***
[ubuntu:04640] *** Process received signal ***
[ubuntu:04640] Signal: Segmentation fault (11)
[ubuntu:04640] Signal code: Address not mapped (1)
[ubuntu:04640] Failing at address: 0x7548d0c
[ubuntu:04640] [ 0] [0xdad410]
[ubuntu:04640] [ 1] /lib/tls/i686/cmov/libc.so.6(fclose+0x1a0) [0xe76b00]
[ubuntu:04640] [ 2] ./exmpi_2(main+0x78e) [0x80492c2]
[ubuntu:04640] [ 3] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xe31bd6]
[ubuntu:04640] [ 4] ./exmpi_2() [0x8048aa1]
[ubuntu:04640] *** End of error message ***
[ubuntu:04641] *** Process received signal ***
[ubuntu:04641] Signal: Segmentation fault (11)
[ubuntu:04641] Signal code: Address not mapped (1)
[ubuntu:04641] Failing at address: 0x7548d0c
[ubuntu:04641] [ 0] [0xe97410]
[ubuntu:04641] [ 1] /lib/tls/i686/cmov/libc.so.6(fclose+0x1a0) [0x1e8b00]
[ubuntu:04641] [ 2] ./exmpi_2(main+0x78e) [0x80492c2]
[ubuntu:04641] [ 3] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x1a3bd6]
[ubuntu:04641] [ 4] ./exmpi_2() [0x8048aa1]
[ubuntu:04641] *** End of error message ***
[ubuntu:04642] *** Process received signal ***
[ubuntu:04642] Signal: Segmentation fault (11)
[ubuntu:04642] Signal code: Address not mapped (1)
[ubuntu:04642] Failing at address: 0x7548d0c
[ubuntu:04642] [ 0] [0x92d410]
[ubuntu:04642] [ 1] /lib/tls/i686/cmov/libc.so.6(fclose+0x1a0) [0x216b00]
[ubuntu:04642] [ 2] ./exmpi_2(main+0x78e) [0x80492c2]
[ubuntu:04642] [ 3] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x1d1bd6]
[ubuntu:04642] [ 4] ./exmpi_2() [0x8048aa1]
[ubuntu:04642] *** End of error message ***
[ubuntu:04643] *** Process received signal ***
[ubuntu:04643] Signal: Segmentation fault (11)
[ubuntu:04643] Signal code: Address not mapped (1)
[ubuntu:04643] Failing at address: 0x7548d0c
[ubuntu:04643] [ 0] [0x8f4410]
[ubuntu:04643] [ 1] /lib/tls/i686/cmov/libc.so.6(fclose+0x1a0) [0x16bb00]
[ubuntu:04643] [ 2] ./exmpi_2(main+0x78e) [0x80492c2]
[ubuntu:04643] [ 3] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x126bd6]
[ubuntu:04643] [ 4] ./exmpi_2() [0x8048aa1]
[ubuntu:04643] *** End of error message ***
[ubuntu:04638] Signal: Segmentation fault (11)
[ubuntu:04638] Signal code: Address not mapped (1)
[ubuntu:04638] Failing at address: 0x7548d0c
[ubuntu:04638] [ 0] [0x4f6410]
[ubuntu:04638] [ 1] /lib/tls/i686/cmov/libc.so.6(fclose+0x1a0) [0x222b00]
[ubuntu:04638] [ 2] ./exmpi_2(main+0x78e) [0x80492c2]
[ubuntu:04638] [ 3] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x1ddbd6]
[ubuntu:04638] [ 4] ./exmpi_2() [0x8048aa1]
[ubuntu:04638] *** End of error message ***
[ubuntu:04644] *** Process received signal ***
[ubuntu:04644] Signal: Segmentation fault (11)
[ubuntu:04644] Signal code: Address not mapped (1)
[ubuntu:04644] Failing at address: 0x7548d0c
[ubuntu:04644] [ 0] [0x61f410]
[ubuntu:04644] [ 1] /lib/tls/i686/cmov/libc.so.6(fclose+0x1a0) [0x1a3b00]
[ubuntu:04644] [ 2] ./exmpi_2(main+0x78e) [0x80492c2]
[ubuntu:04644] [ 3] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x15ebd6]
[ubuntu:04644] [ 4] ./exmpi_2() [0x8048aa1]
[ubuntu:04644] *** End of error message ***
[ubuntu:04645] *** Process received signal ***
[ubuntu:04645] Signal: Segmentation fault (11)
[ubuntu:04645] Signal code: Address not mapped (1)
[ubuntu:04645] Failing at address: 0x7548d0c
[ubuntu:04645] [ 0] [0x7a3410]
[ubuntu:04645] [ 1] /lib/tls/i686/cmov/libc.so.6(fclose+0x1a0) [0x1d5b00]
[ubuntu:04645] [ 2] ./exmpi_2(main+0x78e) [0x80492c2]
[ubuntu:04645] [ 3] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x190bd6]
[ubuntu:04645] [ 4] ./exmpi_2() [0x8048aa1]
[ubuntu:04645] *** End of error message ***
[ubuntu:04647] *** Process received signal ***
[ubuntu:04647] Signal: Segmentation fault (11)
[ubuntu:04647] Signal code: Address not mapped (1)
[ubuntu:04647] Failing at address: 0x7548d0c
[ubuntu:04647] [ 0] [0xf54410]
[ubuntu:04647] [ 1] /lib/tls/i686/cmov/libc.so.6(fclose+0x1a0) [0x2bab00]
[ubuntu:04647] [ 2] ./exmpi_2(main+0x78e) [0x80492c2]
[ubuntu:04647] [ 3] /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0x275bd6]
[ubuntu:04647] [ 4] ./exmpi_2() [0x8048aa1]
[ubuntu:04647] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 2 with PID 4639 on node ubuntu exited on signal 11 (Segmentation fault).
--------------------------------------------------------------------------
6 total processes killed (some possibly by mpirun during cleanup)
==4632==
==4632== HEAP SUMMARY:
==4632== in use at exit: 158,751 bytes in 1,635 blocks
==4632== total heap usage: 10,443 allocs, 8,808 frees, 15,854,537 bytes allocated
==4632==
==4632== LEAK SUMMARY:
==4632== definitely lost: 81,655 bytes in 112 blocks
==4632== indirectly lost: 5,108 bytes in 91 blocks
==4632== possibly lost: 1,043 bytes in 17 blocks
==4632== still reachable: 70,945 bytes in 1,415 blocks
==4632== suppressed: 0 bytes in 0 blocks
==4632== Rerun with --leak-check=full to see details of leaked memory
==4632==
==4632== For counts of detected and suppressed errors, rerun with: -v
==4632== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 96 from 9)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mpi.h"
#include <syscall.h>
#define SIZE_X 640
#define SIZE_Y 480
int main(int argc, char **argv)
{
FILE *FR,*FW;
int ierr;
int rank, size;
int ncells;
int greys[SIZE_X][SIZE_Y];
int rows,cols, maxval;
int mystart, myend, myncells;
const int IONODE=0;
int *disps, *counts, *mydata;
int *data;
int i,j,temp1;
char dummy[50]="";
ierr = MPI_Init(&argc, &argv);
if (argc != 3) {
fprintf(stderr,"Usage: %s infile outfile\n",argv[0]);
fprintf(stderr,"outputs the negative of the input file.\n");
return -1;
}
ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
ierr = MPI_Comm_size(MPI_COMM_WORLD, &size);
if (ierr) {
fprintf(stderr,"Catastrophic MPI problem; exiting\n");
MPI_Abort(MPI_COMM_WORLD,1);
}
if (rank == IONODE) {
//if (read_pgm(argv[1], &greys, &rows, &cols, &maxval)) {
// fprintf(stderr,"Could not read file; exiting\n");
// MPI_Abort(MPI_COMM_WORLD,2);
rows=SIZE_X;
cols=SIZE_Y;
maxval=255;
FR=fopen(argv[1], "r+");
fgets(dummy,50,FR);
do{ fgets(dummy,50,FR); } while(dummy[0]=='#');
fgets(dummy,50,FR);
for (j = 0; j <cols; j++)
{
for (i = 0; i <rows; i++)
{
fscanf(FR,"%d",&temp1);
greys[i][j] = temp1;
}
}
}
ncells = rows*cols;
disps = (int *)malloc(size * sizeof(int));
counts= (int *)malloc(size * sizeof(int));
data = &(greys[0][0]); /* we know all the data is contiguous */
/* everyone calculate their number of cells */
ierr = MPI_Bcast(&ncells, 1, MPI_INT, IONODE, MPI_COMM_WORLD);
myncells = ncells/size;
mystart = rank*myncells;
myend = mystart + myncells - 1;
if (rank == size-1) myend = ncells-1;
myncells = (myend-mystart)+1;
mydata = (int *)malloc(myncells * sizeof(int));
/* assemble the list of counts. Might not be equal if don't divide evenly. */
ierr = MPI_Gather(&myncells, 1, MPI_INT, counts, 1, MPI_INT, IONODE, MPI_COMM_WORLD);
if (rank == IONODE) {
disps[0] = 0;
for (i=1; i<size; i++) {
disps[i] = disps[i-1] + counts[i-1];
}
}
/* scatter the data */
ierr = MPI_Scatterv(data, counts, disps, MPI_INT, mydata, myncells, MPI_INT, IONODE, MPI_COMM_WORLD);
/* everyone has to know maxval */
ierr = MPI_Bcast(&maxval, 1, MPI_INT, IONODE, MPI_COMM_WORLD);
for (i=0; i<myncells; i++)
mydata[i] = maxval-mydata[i];
/* Gather the data */
ierr = MPI_Gatherv(mydata, myncells, MPI_INT, data, counts, disps, MPI_INT, IONODE, MPI_COMM_WORLD);
if (rank == IONODE)
{
// write_pgm(argv[2], greys, rows, cols, maxval);
FW=fopen(argv[2], "w");
fprintf(FW,"P2\n%d %d\n255\n",rows,cols);
for(j=0;j<cols;j++)
for(i=0;i<rows;i++)
fprintf(FW,"%d ", greys[i][j]);
}
free(mydata);
if (rank == IONODE) {
free(counts);
free(disps);
//free(&(greys[0][0]));
//free(greys);
}
fclose(FR);
fclose(FW);
MPI_Finalize();
return 0;
}
最佳答案
恭喜;代码几乎完全完美地运行,它几乎在最后几行代码中消失了。
使用 valgrind 时这个问题会更清楚一些,但是您必须更棘手地使用 MPI 运行 valgrind —— 或者任何涉及程序启动器的东西。代替:valgrind mpirun -np 10 ./exmpi_2 balloons.pgm output.pgm
它做了一个 mpirun 的 valgrind,你并不真正关心,你想做mpirun -np 10 valgrind ./exmpi_2 balloons.pgm output.pgm
-- 也就是说,您要启动 10 个 valgrind,每个运行一个进程的 exmpi_2。如果你这样做(并且你已经用 -g 编译过),你会在最后发现 valgrind 输出如下:
==6303== Access not within mapped region at address 0x1
==6303== at 0x387FA60C17: fclose@@GLIBC_2.2.5 (in /lib64/libc-2.5.so)
==6303== by 0x401222: main (pgm.c:124)
fclose()
s,当只有一个进程拥有
fopen()
的句柄时ed 文件放在首位。简单更换
fclose(FR);
fclose(FW);
if (rank == IONODE) {
fclose(FR);
fclose(FW);
}
关于segmentation-fault - 使用 Open MPI 运行并行程序时发生段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5247526/
This question already has an answer here: Character constant too long for it's type (1个答案) 1年前关闭。 我是
每次我执行 Scala 程序时,Eclipse 都会创建一个新的“运行配置”。这样做的问题是我需要自定义默认的运行配置(需要更改工作路径)。因此,我第一次创建和自定义运行配置时一切正常,但任何后续尝试
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 5 年前。 Improv
基本上我正在做的是创建一个充当启动器的 swing 应用程序。它所做的只是为用户提供了 3 个选项,他们可以从中选择打开一个新的 java 应用程序。 3 个不同的 java 应用程序都有不同的主题,
这个问题已经有答案了: Make a py2exe exe run without a console? (2 个回答) 已关闭 9 年前。 我不希望在打开 python 应用程序时在后台打开 cmd
我曾经尝试编译一个我为国际象棋游戏编写的 C 程序(感谢 YouTube 的 Bluefever Software 提供的教程),但是当我去编译该程序时,我执行了这行代码: C:\TDM-GCC-64
这是一段代码,通过从一个文件获取输入并在另一个文件中给出输出来执行数字的平方。 #include #include void main() { FILE *fp1, *fp2; char
#include using namespace std; class foo { private: static int cnt; // number in memory stat
我做了一个简单的 hello world 程序。我单击“开始调试”,窗口显示“项目已过期。您要构建它吗?”当我单击"is"时,下一个窗口显示“存在构建错误。您要继续并运行上次成功的构建吗?”。我再次选
这是一个程序,有人在其中输入密码并尝试三次猜密码。当我编译它时,我遇到了多个错误,其中一个包括第 13 行,它基本上说它找不到包含在 Password_Program 类中的类似函数。 #includ
我想将我的游戏导出到 .jar 文件中。它导出;当我运行它时,框架出现了,但面板没有加载。我的框架和面板位于两个不同的类文件中,但我认为这没有什么区别。而且,它在 Eclipse 中完全可以工作。我在
我粘贴了程序以从 codenameone 开发人员指南中创建一个按钮,并且我在 netbeans 中使用了该代码,但是当我单击“运行”时,它在模拟器中没有显示任何内容 最佳答案 您删除了 hi.sho
当我执行这个程序时,它并没有终止。 例如,如果我给它输入 A,输出将是: 65 7 1000001 0 65 7 1000001 ... 我的代码: #include #include void
考虑下面的基本客户端和服务器程序(只是骨架/说明我的问题)。客户端启动与服务器的连接,提示用户输入消息,然后发送到服务器并打印到屏幕。 如果我在循环中间突然退出客户端程序(例如通过关闭终端窗口),有时
我运行一个非常简单的单线程 Java 程序。当我在 Ubuntu 下使用命令检查线程时 ps -eLf 它显示操作系统级别有 14 个线程。我希望当程序有一个线程时只有一个线程,如果程序有 x 个线程
当我从命令行运行类似以下内容的代码时,真正发生了什么? > scala hello.scala 是否有hello.class生成,执行然后丢弃?还是在这种情况下Scala表现得像翻译一样?我只是在想,
程序正在从网络摄像机接收以字节为单位的图像数据,然后处理图像。程序第一次启动时使用470Mb RAM,每1秒增加到15Mb,一直持续到没有足够的空间而计算机挂起。 方法 getImage() 每 10
当我运行我的 selenium 程序时,它显示错误,如何解决这个问题? import org.openqa.selenium.By; public class sss { public sta
我写了一个简单的程序,试图查看内存中的变化,但没有任何变化。无论我是否运行代码,总是会出现大约 20% 左右的直线水平线。 #include using namespace std; int main
我是 c/c++ 领域的新手,我已经在虚拟机上沉迷太久了。 我正在修改我们在整个公司使用的现有 C++ 工具。该工具正在所有主要操作系统(Windows、Mac、Ubuntu、Solaris 等)上使
我是一名优秀的程序员,十分优秀!