|
[Sponsors] |
April 2, 2005, 13:11 |
MPI and parallel computation
|
#1 |
Guest
Posts: n/a
|
Hi All,
I have a problem of parallel computation. I use C language and MPI. My code can be compiled and no any error occurs. However, when I run the executable, there is error information as following: ttjw3@oberon:~/scri/parallel> mpicc -o lbm lbm.c ttjw3@oberon:~/scri/parallel> mpirun -np 2 lbm /home/ttjw3/tem/mpich-1.2.6/bin/mpirun.ch_shmem: line 91: 18145 Segmentation fault /home/ttjw3/scri/parallel/lbm ttjw3@oberon:~/scri/parallel> It is appreciated to share any experience of the problem. Thanks in advance. |
|
April 2, 2005, 14:26 |
Re: MPI and parallel computation
|
#2 |
Guest
Posts: n/a
|
It could be resulted from index dismatch, for example, you allocate a memory size of a matrix and routine uses larger index.
It is hard to tell the cause without looking the code itself, why don't you post the code here if it is not too lengthy. Someone may find the error. Kim |
|
April 3, 2005, 05:38 |
Re: MPI and parallel computation
|
#3 |
Guest
Posts: n/a
|
agree with wang
|
|
April 3, 2005, 06:12 |
Re: MPI and parallel computation
|
#4 |
Guest
Posts: n/a
|
agree with you
|
|
April 3, 2005, 07:40 |
Re: MPI and parallel computation
|
#5 |
Guest
Posts: n/a
|
Thanks! There are two strange problems. One is that some codes can run in my present machine, and some codes have this problem. My code has been run successfully on other machines. But it can ben run on the present machine. The below example is from MPI manual. It is simpler than my code. But there is the same problem.
ttjw3@oberon:~/jwang/tem/mpich-1.2.6/examples/basic> mpicc -o pcp pcp.c ttjw3@oberon:~/jwang/tem/mpich-1.2.6/examples/basic> ttjw3@oberon:~/jwang/tem/mpich-1.2.6/examples/basic> mpirun -np 2 pcp /home/ttjw3/jwang/tem/mpich-1.2.6/bin/mpirun.ch_shmem: line 91: 21168 Segmentation fault /home/ttjw3/jwang/tem/mpich-1.2.6/examples/basic/pcp ttjw3@oberon:~/jwang/tem/mpich-1.2.6/examples/basic> /* pcp from SUT, in MPI */ #include "mpi.h" #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> #define BUFSIZE 256*1024 #define CMDSIZE 80 char from_path[1024], fromname[1024], to_path[1024], toname[1024], origdir[1024], cmd[1024]; int main( int argc, char *argv[] ) { int myrank, mystatus, allstatus, done, numread; char controlmsg[CMDSIZE]; int statrc, infd, outfd; char *c, buf[BUFSIZE]; struct stat statbuf; FILE *infp, *outfp; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &myrank ); if (getcwd(origdir,1024) == NULL) { fprintf(stderr,"failed to getcwd\n"); exit(-1); } if ( myrank == 0 ) { if ((c = (char*)strrchr(argv[1],'/')) != NULL) { strncpy(from_path,argv[1],c-argv[1]); from_path[c-argv[1]] = '\0'; strcpy(fromname,c+1); fromname[strlen(c)] = '\0'; chdir(from_path); } else { strcpy(fromname,argv[1]); } sprintf(cmd,"tar cf - %s",fromname); if ((infp = popen(cmd,"r")) == NULL) { fprintf(stderr,"popen r failed\n"); strcpy( controlmsg, "exit" ); MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD ); MPI_Finalize(); exit(-1); } else { infd = fileno(infp); sprintf( controlmsg, "ready" ); MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD ); } } else { MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD ); if ( strcmp( controlmsg, "exit" ) == 0 ) { MPI_Finalize(); exit( -1 ); } } chdir(origdir); if ( myrank == 0 ) strcpy( controlmsg, fromname ); MPI_Bcast( controlmsg, CMDSIZE, MPI_CHAR, 0, MPI_COMM_WORLD ); strcpy(fromname,controlmsg); strcpy(toname,argv[2]); statrc = stat(argv[2], &statbuf); if (statrc >= 0) { if (S_ISDIR(statbuf.st_mode)) { chdir(argv[2]); } } if ((c = (char*)strrchr(argv[2],'/')) != NULL) { strncpy(to_path,argv[2],c-argv[2]); to_path[c-argv[2]] = '\0'; strcpy(toname,c+1); toname[strlen(c)] = '\0'; chdir(to_path); } sprintf(cmd,"tar xf - "); if ((outfp = popen(cmd,"w")) == NULL) { fprintf(stderr,"popen w failed\n"); mystatus = -1; } else { outfd = fileno(outfp); mystatus = 0; } MPI_Allreduce( &mystatus, &allstatus, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD ); if ( allstatus == -1 ) { if ( myrank == 0 ) fprintf(stderr,"output file %s could not be opened\n", controlmsg ); MPI_Finalize(); return( -1 ); } /* at this point all files have been successfully opened */ done = 0; while ( !done ) { if ( myrank == 0 ) numread = read( infd, buf, BUFSIZE ); MPI_Bcast( &numread, 1, MPI_INT, 0, MPI_COMM_WORLD ); if ( numread > 0 ) { MPI_Bcast( buf, numread, MPI_BYTE, 0, MPI_COMM_WORLD ); write( outfd, buf, numread ); /* master makes a copy too */ } else { if ( myrank == 0 ) pclose(infp); pclose( outfp ); done = 1; } } /* if file existed but was not a dir */ if (statrc < 0 || ! S_ISDIR(statbuf.st_mode)) { if (strcmp(fromname,toname) != 0) { rename(fromname,toname); } } MPI_Finalize(); return 0; } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
problem in the CFX12.1 parallel computation | BalanceChen | ANSYS | 2 | July 7, 2011 11:26 |
HP MPI warning...Distributed parallel processing | Peter | CFX | 10 | May 14, 2011 07:17 |
Is Testsuite on the way or not | lakeat | OpenFOAM Installation | 6 | April 28, 2008 12:12 |
PROBLEM IN PARALLEL PROGRAMMING WITH MPI | Niavarani | Main CFD Forum | 1 | April 20, 2004 07:51 |
MPI and parallel computation | Wang | Main CFD Forum | 7 | April 15, 2004 12:25 |