|
List Info
Thread: LAM: error using complex numbers array
|
|
| LAM: error using complex numbers array |

|
2007-09-26 06:15:12 |
|
Hi, I'm working on some code which requires me to send arrays of complex numbers from a processor to a different processor. The array is received successfully at the other end but still it gives some
segmentation faults. For example, in the following code, I send an array of size 64 from processor 0 (master processor) to processor 1. If i print the data received at processor 1, it prints successfully.
But the code exits giving segmentation faults (as listed below this code). Could you please give me some pointers to solve this problem. Thank you in advance. -rohit #include "mpi.h"
#include <stdio.h> #include <stdlib.h> #define TEST 1 #define PRINT(A,k,LL) for(k=0;k<LL;k++) { print_complex(A[k]); fflush(stdout);
}
#define FLUSH fflush(std out) #define SIZE 64 typedef float Complex[2]; int main(int argc, char **argv) { int myrank,nprocs; int tag0=10; MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&nprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myrank); MPI_Barrier(MPI_COMM_WORLD); if(myrank==0) { int i=0;
Complex *input_to_p0 = (Complex*)malloc(SIZE*sizeof(Complex)); for(i=0;i<SIZE;i++) { input_to_p0[i][0] = (float)(4*i); input_to_p0[i][1] = (float)(4*i);
} MPI_Send(input_to_p0,SIZE,MPI_2COMPLEX,1,tag0,MPI_COMM_WORLD); free(input_to_p0); } else if(myrank == 1) {
int i=0; Complex *input_from_p0 = (Complex*)malloc(SIZE*sizeof(Complex)); //Receive the array from processor 0 (of size SIZE) MPI_Recv(input_from_p0,SIZE,MPI_2COMPLEX,
0,tag0,MPI_COMM_WORLD,MPI_STATUS_IGNORE); #if !TEST printf("n input receiverd from p0 (I am in p1) n"); PRINT(input_from_p0,i,SIZE); FLUSH;
//received successfully #endif free(input_from_p0); } MPI_Finalize(); return 0;
}
------------------------------------------------------------------------- Error - [abhogi:03371] *** Process received signal *** [abhogi:03371] Signal: Segmentation fault (11) [abhogi:03371] Signal code: Address not mapped (1)
[abhogi:03371] Failing at address: 0xfd7258 [abhogi:03371] [ 0] [0xcbe440] [abhogi:03371] [ 1] /opt/openmpi/lib/libopen-pal.so.0(free+0xb4) [0x138004] [abhogi:03371] [ 2] bin/fft(main+0x121) [0x8049461]
[abhogi:03371] [ 3] /lib/libc.so.6(__libc_start_main+0xdc) [0x17af2c] [abhogi:03371] [ 4] bin/fft [0x80488f1] [abhogi:03371] *** End of error message *** mpirun noticed that job rank 0 with PID 13726 on node saveri exited on
signal 15 (Terminated). 1 additional process aborted (not shown) {where abhogi and saveri are the names of the two computers I am interacting}
|
| Re: LAM: error using complex numbers
array |

|
2007-09-26 07:29:37 |
|
| Hi,
I suspect you have a mixture of lam and openmpi
in your environment, as indicated by
>> [abhogi:03371] [
1] /opt/openmpi/lib/libopen-pal.so.0(free+0xb4) [0x138004]
Make
sure that your execution environment matches your compile environment, in other
words.
HTH,
mac
mccalla
Hi,
I'm working on some code which requires me to send arrays of complex
numbers from a processor to a different processor. The array is received
successfully at the other end but still it gives some segmentation faults.
For example, in the following code, I send an array of size 64 from
processor 0 (master processor) to processor 1. If i print the data received
at processor 1, it prints successfully. But the code exits giving
segmentation faults (as listed below this code). Could you please give me
some pointers to solve this problem. Thank you in advance. -rohit
#include "mpi.h" #include <stdio.h> #include <stdlib.h>
#define TEST 1 #define PRINT(A,k,LL) for(k=0;k<LL;k++) {
print_complex(A[k]);
fflush(stdout);
}
#define
FLUSH fflush(stdout) #define SIZE 64 typedef float Complex[2];
int main(int argc, char **argv) { int
myrank,nprocs; int tag0=10;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
MPI_Barrier(MPI_COMM_WORLD);
if(myrank==0) {
int i=0;
Complex *input_to_p0 =
(Complex*)malloc(SIZE*sizeof(Complex));
for(i=0;i<SIZE;i++)
{
input_to_p0[i][0] = (float)(4*i);
input_to_p0[i][1] = (float)(4*i);
}
MPI_Send(input_to_p0,SIZE,MPI_2COMPLEX,1,tag0,MPI_COMM_WORLD);
free(input_to_p0);
} else if(myrank == 1)
{
int i=0;
Complex *input_from_p0 = (Complex*)malloc(SIZE*sizeof(Complex));
//Receive the array
from processor 0 (of size SIZE)
MPI_Recv(input_from_p0,SIZE,MPI_2COMPLEX,
0,tag0,MPI_COMM_WORLD,MPI_STATUS_IGNORE); #if !TEST
printf("n input receiverd from p0 (I
am in p1) n");
PRINT(input_from_p0,i,SIZE);
FLUSH;
//received successfully #endif
free(input_from_p0);
} MPI_Finalize();
return 0;
}
-------------------------------------------------------------------------
Error -
[abhogi:03371] *** Process received signal *** [abhogi:03371] Signal:
Segmentation fault (11) [abhogi:03371] Signal code: Address not mapped (1)
[abhogi:03371] Failing at address: 0xfd7258 [abhogi:03371] [ 0]
[0xcbe440] [abhogi:03371] [ 1] /opt/openmpi/lib/libopen-pal.so.0(free+0xb4)
[0x138004] [abhogi:03371] [ 2] bin/fft(main+0x121) [0x8049461]
[abhogi:03371] [ 3] /lib/libc.so.6(__libc_start_main+0xdc) [0x17af2c]
[abhogi:03371] [ 4] bin/fft [0x80488f1] [abhogi:03371] *** End of error
message *** mpirun noticed that job rank 0 with PID 13726 on node saveri
exited on signal 15 (Terminated). 1 additional process aborted (not
shown)
{where abhogi and saveri are the names of the two computers I am
interacting}
|
| Re: LAM: error using complex numbers
array |
  United States |
2007-09-26 23:01:48 |
On Sep 26, 2007, at 5:15 AM, Rohit Prakash wrote:
> MPI_Send(input_to_p0,SIZE,MPI_2COMPLEX,
> 1,tag0,MPI_COMM_WORLD);
>
MPI_2COMPLEX is a special datatype used for MAXLOC and
MINLOC
reductions with Fortran. There is no predefined C datatype
to
describe a complex (since C doesn't have a native complex
datatype).
The easiest way to handle this would be to use
MPI_TYPE_VECTOR to
create a datatype that consists of two consecutive MPI_FLOAT
datatypes.
Hope this helps,
Brian
_______________________________________________
This list is archived at http://www.l
am-mpi.org/MailArchives/lam/
|
|
| Re: LAM: error using complex numbers
array |

|
2007-09-28 03:05:51 |
|
Hi Brian,
Thank you for the info. It really helped.
cheers, Rohit
On 27/09/2007, Brian Barrett < brbarret lam-mpi.org">
brbarret lam-mpi.org> wrote:On Sep 26, 2007, at 5:15 AM, Rohit Prakash wrote:
> MPI_Send(input_to_p0,SIZE,MPI_2COMPLEX, > 1,tag0,MPI_COMM_WORLD); >
MPI_2COMPLEX is a special datatype used for MAXLOC and MINLOC reductions with Fortran. There is no predefined C datatype to
describe a complex (since C doesn't have a native complex datatype).
The easiest way to handle this would be to use MPI_TYPE_VECTOR to create a datatype that consists of two consecutive MPI_FLOAT datatypes.
Hope this helps,
Brian _______________________________________________ This list is archived at http://www.lam-mpi.org/MailArchives/lam/
|
[1-4]
|
|