Re: [OMPI users] 1D and 2D arrays allocate memory by maloc() and MPI_Send and MPI_Recv problem.

2012-08-07 Thread Paweł Jaromin
Hi

2012/8/7 George Bosilca <bosi...@eecs.utk.edu>:
> All MPI operations (including MPI_Send and MPI_Recv) consider any type of 
> buffers (input and output) as a contiguous entity.

I tried use 1D array (instead of 2D) to have contiguous data - but
result was the same :(

>
> Therefore, you have two options:
>
> 1. Have a loop around MPI_Send & MPI_Recv similar to the allocation section.


How do You see this loop - byte per byte ??

>
> 2. Build an MPI Datatype representing the non-contiguous memory layout you 
> really intend to send between peers.
>

I'm not enough good programmer to do that :( - as You can see I'm a a
beginner. Maybe more details how do that ??  an  example ??


>   george.
>
> On Aug 7, 2012, at 10:33 , Paweł Jaromin wrote:
>
>> Hello all
>>
>> Sorry, may be this is a stupid question, bat a have a big problem with
>> maloc() and  matrix arrays.
>> I want to make a program that do very simple thing like matriA *
>> matrixB = matrixC.
>> Because I need more matrix size than 100x100 (5000x5000), I have to
>> use maloc() for memory allocation.
>> First I tried this way:
>>
>> The typical form for dynamically allocating an NxM array of type T is:
>> T **a = malloc(sizeof *a * N);
>> if (a)
>> {
>>  for (i = 0; i < N; i++)
>>  {
>>a[i] = malloc(sizeof *a[i] * M);
>>  }
>> }
>> // the arrays are created before  split to nodes
>>
>> No problem with create, fill array,but the problem started when I have
>> send and receive it.
>> Of course before  send I calculated "cont" for MPI_Send.
>> To be shore, that the count for MPI_Send i MPI_Recv is the same I also
>> send "count".
>>
>> count = rows*matrix_size*sizeof (double); //part of matrix
>> MPI_Send(, 1, MPI_INT, dest, mtype,MPI_COMM_WORLD);
>> MPI_Send([offset][0], count, MPI_DOUBLE, dest, mtype, 
>> MPI_COMM_WORLD);
>>
>> from worker side the code looks like:
>>
>> MPI_Recv(, 1, MPI_INT, source, mtype, MPI_COMM_WORLD, );
>> MPI_Recv([0][0], countA, MPI_DOUBLE, source, mtype,
>> MPI_COMM_WORLD, );
>>
>>
>> An error looks like:
>>
>> [pawcioj-VirtualBox:01700] *** Process received signal ***
>> [pawcioj-VirtualBox:01700] Signal: Segmentation fault (11)
>> [pawcioj-VirtualBox:01700] Signal code: Address not mapped (1)
>> [pawcioj-VirtualBox:01700] Failing at address: 0x88fa000
>> [pawcioj-VirtualBox:01700] [ 0] [0xc2740c]
>> [pawcioj-VirtualBox:01700] [ 1]
>> /usr/lib/openmpi/lib/openmpi/mca_pml_ob1.so(+0x906c) [0x17606c]
>> [pawcioj-VirtualBox:01700] [ 2]
>> /usr/lib/openmpi/lib/openmpi/mca_pml_ob1.so(+0x6a1b) [0x173a1b]
>> [pawcioj-VirtualBox:01700] [ 3]
>> /usr/lib/openmpi/lib/openmpi/mca_btl_sm.so(+0x3ae6) [0x7b7ae6]
>> [pawcioj-VirtualBox:01700] [ 4]
>> /usr/lib/libopen-pal.so.0(opal_progress+0x81) [0x406fa1]
>> [pawcioj-VirtualBox:01700] [ 5]
>> /usr/lib/openmpi/lib/openmpi/mca_pml_ob1.so(+0x48e5) [0x1718e5]
>> [pawcioj-VirtualBox:01700] [ 6] /usr/lib/libmpi.so.0(MPI_Recv+0x165) 
>> [0x1ef9d5]
>> [pawcioj-VirtualBox:01700] [ 7] macierz_V.02(main+0x927) [0x8049870]
>> [pawcioj-VirtualBox:01700] [ 8] /lib/libc.so.6(__libc_start_main+0xe7)
>> [0xddfce7]
>> [pawcioj-VirtualBox:01700] [ 9] macierz_V.02() [0x8048b71]
>> [pawcioj-VirtualBox:01700] *** End of error message ***
>> --
>> mpirun noticed that process rank 1 with PID 1700 on node
>> pawcioj-VirtualBox exited on signal 11 (Segmentation fault).
>>
>>
>> Because I have no result, I tied do that by 1D array but the problem
>> seems similar.
>>
>> Probably I do something wrong, so I would like to ask you about advice
>> how do that proper or maybe link to useful tutorial.
>> I spend two weeks to find out how do that but unfortunately without result 
>> :(.
>>
>>
>>
>> --
>> --
>> pozdrawiam
>>
>> Paweł Jaromin
>>
>> ___
>> users mailing list
>> us...@open-mpi.org
>> http://www.open-mpi.org/mailman/listinfo.cgi/users
>
>
> ___
> users mailing list
> us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/users



-- 
--
pozdrawiam

Paweł Jaromin



[OMPI users] 1D and 2D arrays allocate memory by maloc() and MPI_Send and MPI_Recv problem.

2012-08-07 Thread Paweł Jaromin
Hello all

Sorry, may be this is a stupid question, bat a have a big problem with
maloc() and  matrix arrays.
I want to make a program that do very simple thing like matriA *
matrixB = matrixC.
Because I need more matrix size than 100x100 (5000x5000), I have to
use maloc() for memory allocation.
First I tried this way:

The typical form for dynamically allocating an NxM array of type T is:
T **a = malloc(sizeof *a * N);
if (a)
{
  for (i = 0; i < N; i++)
  {
a[i] = malloc(sizeof *a[i] * M);
  }
}
// the arrays are created before  split to nodes

No problem with create, fill array,but the problem started when I have
send and receive it.
Of course before  send I calculated "cont" for MPI_Send.
To be shore, that the count for MPI_Send i MPI_Recv is the same I also
send "count".

count = rows*matrix_size*sizeof (double); //part of matrix
MPI_Send(, 1, MPI_INT, dest, mtype,MPI_COMM_WORLD);
MPI_Send([offset][0], count, MPI_DOUBLE, dest, mtype, MPI_COMM_WORLD);

from worker side the code looks like:

MPI_Recv(, 1, MPI_INT, source, mtype, MPI_COMM_WORLD, );
MPI_Recv([0][0], countA, MPI_DOUBLE, source, mtype,
MPI_COMM_WORLD, );


An error looks like:

[pawcioj-VirtualBox:01700] *** Process received signal ***
[pawcioj-VirtualBox:01700] Signal: Segmentation fault (11)
[pawcioj-VirtualBox:01700] Signal code: Address not mapped (1)
[pawcioj-VirtualBox:01700] Failing at address: 0x88fa000
[pawcioj-VirtualBox:01700] [ 0] [0xc2740c]
[pawcioj-VirtualBox:01700] [ 1]
/usr/lib/openmpi/lib/openmpi/mca_pml_ob1.so(+0x906c) [0x17606c]
[pawcioj-VirtualBox:01700] [ 2]
/usr/lib/openmpi/lib/openmpi/mca_pml_ob1.so(+0x6a1b) [0x173a1b]
[pawcioj-VirtualBox:01700] [ 3]
/usr/lib/openmpi/lib/openmpi/mca_btl_sm.so(+0x3ae6) [0x7b7ae6]
[pawcioj-VirtualBox:01700] [ 4]
/usr/lib/libopen-pal.so.0(opal_progress+0x81) [0x406fa1]
[pawcioj-VirtualBox:01700] [ 5]
/usr/lib/openmpi/lib/openmpi/mca_pml_ob1.so(+0x48e5) [0x1718e5]
[pawcioj-VirtualBox:01700] [ 6] /usr/lib/libmpi.so.0(MPI_Recv+0x165) [0x1ef9d5]
[pawcioj-VirtualBox:01700] [ 7] macierz_V.02(main+0x927) [0x8049870]
[pawcioj-VirtualBox:01700] [ 8] /lib/libc.so.6(__libc_start_main+0xe7)
[0xddfce7]
[pawcioj-VirtualBox:01700] [ 9] macierz_V.02() [0x8048b71]
[pawcioj-VirtualBox:01700] *** End of error message ***
--
mpirun noticed that process rank 1 with PID 1700 on node
pawcioj-VirtualBox exited on signal 11 (Segmentation fault).


Because I have no result, I tied do that by 1D array but the problem
seems similar.

Probably I do something wrong, so I would like to ask you about advice
how do that proper or maybe link to useful tutorial.
I spend two weeks to find out how do that but unfortunately without result :(.



-- 
--
pozdrawiam

Paweł Jaromin



Re: [OMPI users] sndlib problem by mpicc compiler

2012-07-31 Thread Paweł Jaromin
2012/7/30 Jeff Squyres <jsquy...@cisco.com>:
> On Jul 30, 2012, at 12:48 PM, Paweł Jaromin wrote:
>
>> make all
>> Building file: ../src/snd_0.1.c
>> Invoking: GCC C Compiler
>> mpicc -I/usr/include/mpi -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP
>> -MF"src/snd_0.1.d" -MT"src/snd_0.1.d" -o "src/snd_0.1.o"
>> "../src/snd_0.1.c"
>> ../src/snd_0.1.c:24: warning: return type defaults to 'int'
>> ../src/snd_0.1.c: In function 'main':
>> ../src/snd_0.1.c:45: warning: unused variable 'outfile'
>> ../src/snd_0.1.c:42: warning: unused variable 'FILE_OUT'
>> ../src/snd_0.1.c:41: warning: unused variable 'FILE_NAME'
>> ../src/snd_0.1.c:40: warning: unused variable 'AF_setup'
>> ../src/snd_0.1.c:38: warning: unused variable 'snd_buffor'
>> ../src/snd_0.1.c:37: warning: unused variable 'i'
>> ../src/snd_0.1.c: In function 'print_usage':
>> ../src/snd_0.1.c:29: warning: control reaches end of non-void function
>> Finished building: ../src/snd_0.1.c
>
> You might want to fix these warnings.  The first one and the last one seem 
> like they could cause nondeterminism.

Sorry, in the code is big mes, but I`am sure it not effects my
problem. - I tried another ways to solve the problem.

>
> Also, you shouldn't be adding -I/usr/include/mpi.  mpicc will add the right 
> -I option for you (e.g., do you know for sure that your MPI header files are 
> in /usr/include/mpi?).  It's useless at best, and harmful at worst (E.g., if 
> some other MPI implementation is installed into /usr/include/mpi).
>

I don't know why, but in Eclipse I had to add option -l. Was not
enought  #include mpi/mpi.h - problem "undefined references" in linker
:(.

>> no MPI -program which was based on
>>
>>  Build of configuration Debug for project snd_test 
>>
>> make all
>> Building file: ../main.c
>> Invoking: GCC C Compiler
>> gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d"
>> -MT"main.d" -o "main.o" "../main.c"
>> Finished building: ../main.c
>>
>> Building target: snd_test
>> Invoking: GCC C Linker
>> gcc  -o "snd_test"  ./main.o   -lsndfile
>> Finished building target: snd_test
>
> I notice that you're not including -Wall and a bunch of other compiler flags 
> in the non-MPI install.
>
> I also notice that you're not compiling the same .c files at all.
>
> So if I'm understanding this thread right -- and I may well not be -- it 
> seems like you're saying:
>
> - when I use gcc to compile main.c, the program runs file
> - when I used mpicc to compile ../src/snd_0.1.c, the program fails
>
> If that's the case, your comparing apples to oranges here.

Not exactly, maybe I show You my thinking:

Because I need to procesing  wav files, I wanted load it into array,
then by MPI_Scater send   to nodes. I haveI found a code that does
this, and then i try use with MPI (sndfile lib). "main" in "snd_test"
is exactly this code, witch copmpile and runs without problems. So,
after that I copied it into MPI program to master node "rank == 0". I
expected run the same way like in no MPI program. It means, that I
compare normal code with the same code in MPI runs by node 0.

Jeff, Thank you for your commitment, but I'm afraid about
misunderstanding. I try clarify the problem as good as I can, but I
feel that You don't understand me. Maybe my english is not enough good
:(.I hope, background above, give you bigger view for what I want to
do. Maybe You have suggestion, how do it or good example how deal with
it.

>
> --
> Jeff Squyres
> jsquy...@cisco.com
> For corporate legal information go to: 
> http://www.cisco.com/web/about/doing_business/legal/cri/
>
>
> ___
> users mailing list
> us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/users



-- 
--
pozdrawiam

Paweł Jaromin



Re: [OMPI users] sndlib problem by mpicc compiler

2012-07-30 Thread Paweł Jaromin
normal MPI compiling:

 Build of configuration Debug for project snd_0.1 

make all
Building file: ../src/snd_0.1.c
Invoking: GCC C Compiler
mpicc -I/usr/include/mpi -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP
-MF"src/snd_0.1.d" -MT"src/snd_0.1.d" -o "src/snd_0.1.o"
"../src/snd_0.1.c"
../src/snd_0.1.c:24: warning: return type defaults to 'int'
../src/snd_0.1.c: In function 'main':
../src/snd_0.1.c:45: warning: unused variable 'outfile'
../src/snd_0.1.c:42: warning: unused variable 'FILE_OUT'
../src/snd_0.1.c:41: warning: unused variable 'FILE_NAME'
../src/snd_0.1.c:40: warning: unused variable 'AF_setup'
../src/snd_0.1.c:38: warning: unused variable 'snd_buffor'
../src/snd_0.1.c:37: warning: unused variable 'i'
../src/snd_0.1.c: In function 'print_usage':
../src/snd_0.1.c:29: warning: control reaches end of non-void function
Finished building: ../src/snd_0.1.c

Building target: snd_0.1
Invoking: GCC C Linker
mpicc  -o "snd_0.1"  ./src/snd_0.1.o   -lsndfile -laudiofile
Finished building target: snd_0.1


 Build Finished 


MPI with option --showme:

 Build of configuration Debug for project snd_0.1 

make all
Building file: ../src/snd_0.1.c
Invoking: GCC C Compiler
mpicc --showme -I/usr/include/mpi -O0 -g3 -Wall -c -fmessage-length=0
-MMD -MP -MF"src/snd_0.1.d" -MT"src/snd_0.1.d" -o "src/snd_0.1.o"
"../src/snd_0.1.c"
gcc -I/usr/lib/openmpi/include -I/usr/lib/openmpi/include/openmpi
-pthread -I/usr/include/mpi -O0 -g3 -Wall -c -fmessage-length=0 -MMD
-MP -MFsrc/snd_0.1.d -MTsrc/snd_0.1.d -o src/snd_0.1.o
../src/snd_0.1.c
gcc: ./src/snd_0.1.o: No file or directory
make: *** [libsnd_0.1] Error 1
Finished building: ../src/snd_0.1.c

Building target: libsnd_0.1
Invoking: GCC C Linker
mpicc -shared -o "libsnd_0.1"  ./src/snd_0.1.o   -lsndfile

 Build Finished 



no MPI -program which was based on

 Build of configuration Debug for project snd_test 

make all
Building file: ../main.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d"
-MT"main.d" -o "main.o" "../main.c"
Finished building: ../main.c

Building target: snd_test
Invoking: GCC C Linker
gcc  -o "snd_test"  ./main.o   -lsndfile
Finished building target: snd_test


 Build Finished 


2012/7/30 TERRY DONTJE <terry.don...@oracle.com>:
> Please show me how you are compiling the program under gcc and mpicc.  Plus
> do a "mpicc --showme".
>
> --td
>
>
> On 7/30/2012 8:33 AM, Paweł Jaromin wrote:
>
> This situation is also strange for me, I spend 2 days to find a bug :(.
>
> Unfortunately I am not  a professional  C/C++ programmer, but I have
> to make this program. Please have a look in a picture from link below,
> maybe it will be more clear.
>
> http://vipjg.nazwa.pl/sndfile_error.png
>
>
>
>
>
>
>
>
>
> 2012/7/30 TERRY DONTJE <terry.don...@oracle.com>:
>
> On 7/30/2012 6:11 AM, Paweł Jaromin wrote:
>
> Hello
>
> Thanks for fast answer, but the problem looks a little different.
>
> Of course, I use this code only for master node (rank 0), because only
> this node has an access to file.
>
> As You can see i use "if" clause to check sndFile for NULL:
>
> if (sndFile == NULL)
>
> and it returns not NULL value, so the code can run forward.
> I have found the problem during check array:
>
>
>  long numFrames = sf_readf_float(sndFile, snd_buffor, 
> sfinfo.frames);
>
>  // Check correct number of samples loaded
>  if (numFrames != sfinfo.frames) {
> fprintf(stderr, "Did not read enough frames for 
> source\n");
> sf_close(sndFile);
> free(snd_buffor);
> MPI_Finalize();
> return 1;
>  }
>
> So, after that I went to debuger to check variables (I use Eclipse PTP
> and sdm enviroment), then after inicjalization variable "sndFile" has
> "no value" not "NULL" . Unfortunatelly sndFile has still the same
> value to the end of program :(.
>
> What do you mean by sndFile has "no value"?  There isn't a special "no
> value" value to a variable unless you are debugging a code that somehow had
> some variable optimized out at the particular line you are interested in.
>
> Declarations:
>   FILE*outfile = NULL ;
>   SF_INFO sfinfo ;
>   SNDFILE *sndFile= NULL;
>
> Very interesting is , that "sfinfo" from the same library  works per

Re: [OMPI users] sndlib problem by mpicc compiler

2012-07-30 Thread Paweł Jaromin
Hello

Thanks for fast answer, but the problem looks a little different.

Of course, I use this code only for master node (rank 0), because only
this node has an access to file.

As You can see i use "if" clause to check sndFile for NULL:

if (sndFile == NULL)

and it returns not NULL value, so the code can run forward.
I have found the problem during check array:


   long numFrames = sf_readf_float(sndFile, snd_buffor, 
sfinfo.frames);

   // Check correct number of samples loaded
   if (numFrames != sfinfo.frames) {
  fprintf(stderr, "Did not read enough frames for 
source\n");
  sf_close(sndFile);
  free(snd_buffor);
  MPI_Finalize();
  return 1;
   }

So, after that I went to debuger to check variables (I use Eclipse PTP
and sdm enviroment), then after inicjalization variable "sndFile" has
"no value" not "NULL" . Unfortunatelly sndFile has still the same
value to the end of program :(.
Declarations:
FILE*outfile = NULL ;
SF_INFO sfinfo ;
SNDFILE *sndFile= NULL;

Very interesting is , that "sfinfo" from the same library  works perfect.
At the end of this story, I modified the program without MPI , then
compiled it by gcc (not mpicc) and it works fine (in debuger sndFile
has proper value).

I hope, now is clear.



2012/7/30 TERRY DONTJE <terry.don...@oracle.com>:
> I am not sure I am understanding the problem correctly so let me describe it
> back to you with a couple clarifications.
>
> So your program using sf_open compiles successfully when using gcc and
> mpicc.  However, when you run the executable compiled using mpicc sndFile is
> null?
>
> If the above is right can you tell us how you ran the code?
> Will the code run ok if ran with "mpirun -np 1" on the same machine you run
> the gcc code normally?
> When the mpicc compiled code sf_open call returns NULL what does the
> successive sf_strerror report?
> My wild guess is when you run the mpicc compiled code one of the processes
> is on a node that doesn't have access to the file passed to sf_open.
>
> --td
>
> On 7/28/2012 1:08 PM, Paweł Jaromin wrote:
>
> Hello all
>
> Because I try make a program to parallel procesing sound files, I use
> libsndfile library to load and write wav files. Sytuation is strange,
> because when I compile the program by gcc is good (no parallel), but
> if I do it by mpicc is a problem with sndFile variable.
>
>// Open sound file
>SF_INFO sndInfo;
>SNDFILE *sndFile = sf_open(argv[1], SFM_READ, );
>if (sndFile == NULL) {
>   fprintf(stderr, "Error reading source file '%s': %s\n", argv[1],
> sf_strerror(sndFile));
>   return 1;
>}
>
> This code run witout an error, but variable is "No value"
>
> Maybe somone can help me ??
>
>
> --
> Terry D. Dontje | Principal Software Engineer
> Developer Tools Engineering | +1.781.442.2631
> Oracle - Performance Technologies
> 95 Network Drive, Burlington, MA 01803
> Email terry.don...@oracle.com
>
>
>
>
> ___
> users mailing list
> us...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/users



-- 
--
pozdrawiam

Paweł Jaromin



[OMPI users] sndlib problem by mpicc compiler

2012-07-28 Thread Paweł Jaromin
Hello all

Because I try make a program to parallel procesing sound files, I use
libsndfile library to load and write wav files. Sytuation is strange,
because when I compile the program by gcc is good (no parallel), but
if I do it by mpicc is a problem with sndFile variable.

   // Open sound file
   SF_INFO sndInfo;
   SNDFILE *sndFile = sf_open(argv[1], SFM_READ, );
   if (sndFile == NULL) {
  fprintf(stderr, "Error reading source file '%s': %s\n", argv[1],
sf_strerror(sndFile));
  return 1;
   }

This code run witout an error, but variable is "No value"

Maybe somone can help me ??

-- 
----
pozdrawiam

Paweł Jaromin