[OMPI users] Best way to send on mpi c, architecture dependent data type
Hello. I'm using OpenMPI 3.1.3 on x64 CPU and two ARMv8( Raspberry pi 3). But i'm having some issues with data types that are architecture dependent, like 'long'. For example, if you send data in one process to other on this way: if (my_rank != 0) { long size; char* array_data; array_data = malloc(size); //Initialize data... /* Send size first*/ MPI_Ssend(&size, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD); /* Send data*/ MPI_Ssend(array_data, size, MPI_BYTE, 0, 0, MPI_COMM_WORLD); }else{ char* data_of_procs[num_procs-1]; long size_data_procs[num_procs-1]; int i; for(i=0;i___ users mailing list users@lists.open-mpi.org https://lists.open-mpi.org/mailman/listinfo/users
Re: [OMPI users] Best way to send on mpi c, architecture dependent data type
Sergio, I think your best option here is to install an aarch64 (read 64bits ARM) distro on your raspberry pi 3. /* FWIW, the default raspberry distro is 32bits so it can run on all raspberry pi models */ If you cannot/do not wish to go that way, make sure Open MPI is built with --enable-heterogeneous This is lightly tested in the release branches, so I suggest you use Open MPI 4.0.1rc1. IIRC, Open MPI will transparently handle this scenario with the same datatype having different sizes (or endianness, but that does not apply here) on different nodes. Cheers, Gilles On 3/14/2019 7:10 AM, Sergio None wrote: Hello. I'm using OpenMPI 3.1.3 on x64 CPU and two ARMv8( Raspberry pi 3). But i'm having some issues with data types that are architecture dependent, like 'long'. For example, if you send data in one process to other on this way: if (my_rank != 0) { long size; char* array_data; array_data = malloc(size); //Initialize data... /* Send size first*/ MPI_Ssend(&size, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD); /* Send data*/ MPI_Ssend(array_data, size, MPI_BYTE, 0, 0, MPI_COMM_WORLD); }else{ char* data_of_procs[num_procs-1]; long size_data_procs[num_procs-1]; int i; for(i=0;i MPI_Recv(&size_data_procs[i], 1, MPI_LONG, i+1, 0, MPI_COMM_WORLD, &status); data_of_procs[i] = malloc(size_data_procs[i]); if (data_of_procs[i] == NULL) perror("Error on malloc"); MPI_Recv(data_of_procs[i], size_data_procs[i], MPI_BYTE, i+1, 0, MPI_COMM_WORLD, &status); } } Probably you get an error of malloc saying to you: "can't allocate this memory". This fail because long in x86 are 8bytes and in arm compiler is 4bytes. For solve, instead of use long, you need to use int that have the same size in both architectures. Other option could be serialize long. So my question is: there any way to pass data that don't depend of architecture? ___ users mailing list users@lists.open-mpi.org https://lists.open-mpi.org/mailman/listinfo/users ___ users mailing list users@lists.open-mpi.org https://lists.open-mpi.org/mailman/listinfo/users
Re: [OMPI users] Best way to send on mpi c, architecture dependent data type
C99 fixed-width integer types are your friend. https://www.mpi-forum.org/docs/mpi-2.2/mpi22-report/node44.htm Jeff On Wed, Mar 13, 2019 at 3:12 PM Sergio None wrote: > Hello. > > I'm using OpenMPI 3.1.3 on x64 CPU and two ARMv8( Raspberry pi 3). > > But i'm having some issues with data types that are architecture > dependent, like 'long'. > > For example, if you send data in one process to other on this way: > > if (my_rank != 0) { >long size; >char* array_data; > >array_data = malloc(size); >//Initialize data... > >/* Send size first*/ >MPI_Ssend(&size, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD); > >/* Send data*/ >MPI_Ssend(array_data, size, MPI_BYTE, 0, 0, MPI_COMM_WORLD); > > }else{ >char* data_of_procs[num_procs-1]; >long size_data_procs[num_procs-1]; >int i; >for(i=0;i /* Receive size*/ > MPI_Recv(&size_data_procs[i], 1, MPI_LONG, i+1, 0, MPI_COMM_WORLD, > &status); > data_of_procs[i] = malloc(size_data_procs[i]); > if (data_of_procs[i] == NULL) perror("Error on malloc"); > MPI_Recv(data_of_procs[i], size_data_procs[i], MPI_BYTE, i+1, 0, > MPI_COMM_WORLD, &status); >} > } > > Probably you get an error of malloc saying to you: "can't allocate this > memory". This fail because long in x86 are 8bytes and in arm compiler is > 4bytes. For solve, instead of use long, you need to use int that have the > same size in both architectures. Other option could be serialize long. > > So my question is: there any way to pass data that don't depend of > architecture? > > > > ___ > users mailing list > users@lists.open-mpi.org > https://lists.open-mpi.org/mailman/listinfo/users -- Jeff Hammond jeff.scie...@gmail.com http://jeffhammond.github.io/ ___ users mailing list users@lists.open-mpi.org https://lists.open-mpi.org/mailman/listinfo/users