[OMPI devel] Wrong Endianness in Open MPI for external32 representation
Hello, It seems for me that the endianness is wrong in Open MPI's I/O for the external32 data representation. :O Find attached my test programs which write the integer -30 and the double 16.25 into a file. Here the output on my Linux system: mpicc c-xdr.c -o c-xdr mpicc mpi-io-external32.c -o mpi-io-external32 ./c-xdr Output file: c-xdr.dat hexdump c-xdr.dat 000 e2ff 3040 0040 00c ./mpi-io-external32 Output file: mpi-io-external32.dat hexdump mpi-io-external32.dat 000 ffe2 4000 4030 00c Best regards Christoph Niethammer -- Christoph Niethammer High Performance Computing Center Stuttgart (HLRS) Nobelstrasse 19 70569 Stuttgart Tel: ++49(0)711-685-87203 email: nietham...@hlrs.de http://www.hlrs.de/people/niethammer#include #include int main(int argc, char* argv[]) { FILE *fp; XDR xdr_output; char filename[] = "c-xdr.dat"; printf("Output file: %s\n", filename); int i = -30; double d = 16.25; fp = fopen(filename, "w+"); xdrstdio_create(&xdr_output, fp, XDR_ENCODE); xdr_int(&xdr_output, &i); xdr_double(&xdr_output, &d); return 0; } #include #include int main(int argc, char* argv[]) { MPI_Comm comm; int comm_rank = 0; int comm_size = 1; MPI_File fh; MPI_Status status; MPI_Offset disp; MPI_Datatype etype; MPI_Datatype filetype; char datarep[] = "external32"; int rc; int i; char filename[] = "mpi-io-external32.dat"; printf("Output file: %s\n", filename); int N = -30; double d = 16.25; MPI_Init(&argc, &argv); comm = MPI_COMM_WORLD; MPI_Comm_rank(comm, &comm_rank); MPI_Comm_size(comm, &comm_size); //printf("Hello %d/%d\n", comm_rank, comm_size); rc = MPI_File_open(comm, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh); if(rc != MPI_SUCCESS) { printf("Error %d when opening file %s\n", rc, filename); } rc = MPI_File_set_view(fh, 0, MPI_INT, MPI_INT, datarep, MPI_INFO_NULL); if(rc != MPI_SUCCESS) { printf("Error %d when setting file view\n", rc); } if(comm_rank == 0) { //printf("Rank %d writing data...\n", comm_rank); MPI_File_write_shared(fh, &N, 1, MPI_INT, &status); MPI_File_write_shared(fh, &d, 1, MPI_DOUBLE, &status); } MPI_Barrier(comm); MPI_File_close(&fh); MPI_Finalize(); return 0; }
Re: [OMPI devel] Wrong Endianness in Open MPI for external32 representation
the way you launch the app, you will be using ROMIO, and I am not 100% sure about how the data representation stuff is integrated with OMPI. I am pretty sure that we are not doing the right thing for OMPIO, but I will look into later this week. Thanks Edgar On 4/29/2014 7:03 AM, Christoph Niethammer wrote: > Hello, > > It seems for me that the endianness is wrong in Open MPI's I/O for the > external32 data representation. :O > > Find attached my test programs which write the integer -30 and the double > 16.25 into a file. > Here the output on my Linux system: > > mpicc c-xdr.c -o c-xdr > mpicc mpi-io-external32.c -o mpi-io-external32 > ./c-xdr > Output file: c-xdr.dat > hexdump c-xdr.dat > 000 e2ff 3040 0040 > 00c > ./mpi-io-external32 > Output file: mpi-io-external32.dat > hexdump mpi-io-external32.dat > 000 ffe2 4000 4030 > 00c > > > Best regards > Christoph Niethammer > > -- > > Christoph Niethammer > High Performance Computing Center Stuttgart (HLRS) > Nobelstrasse 19 > 70569 Stuttgart > > Tel: ++49(0)711-685-87203 > email: nietham...@hlrs.de > http://www.hlrs.de/people/niethammer > > > > ___ > devel mailing list > de...@open-mpi.org > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/devel > Link to this post: > http://www.open-mpi.org/community/lists/devel/2014/04/14648.php > -- Edgar Gabriel Associate Professor Parallel Software Technologies Lab http://pstl.cs.uh.edu Department of Computer Science University of Houston Philip G. Hoffman Hall, Room 524Houston, TX-77204, USA Tel: +1 (713) 743-3857 Fax: +1 (713) 743-3335 signature.asc Description: OpenPGP digital signature
Re: [OMPI devel] Wrong Endianness in Open MPI for external32 representation
Edgar and Christoph, i do not think ROMIO supports this yet. from ompi/mca/io/romio/romio/README "This version of ROMIO includes everything defined in the MPI I/O chapter except support for file interoperability [...]" i also ran ompi/mca/io/romio/romio/test/external32.c : on a x86_64 box (little endian) $ ./external32 native datarep is LITTLE ENDIAN external32 datarep is LITTLE ENDIAN internal datarep is LITTLE ENDIAN on a ppc64 box (big endian) $ ./external32 native datarep is BIG ENDIAN external32 datarep is BIG ENDIAN internal datarep is BIG ENDIAN that being said : with mpich (trunk), on a x86_64 box : $ ./external32.mpich native datarep is LITTLE ENDIAN external32 datarep is BIG ENDIAN internal datarep is LITTLE ENDIAN here is the output of mpi-io-external32 (with mpich) : $ ./mpi-io-external32.mpich Output file: mpi-io-external32.dat [-1] Block at address 0x00c6f0e8 is corrupted (probably write past end) [-1] Block being freed allocated in rc/mpich/src/mpi/romio/mpi-io/mpiu_external32.c[159] [-1] Block cookie should be f0e0d0c9 but was e2ff4c054000 $ od -t x1 ./mpi-io-external32.dat 000 ff ff ff e2 00 00 00 00 40 30 40 00 MPI_INT was written big endian (good) but MPI_DOUBLE was written little endian (bad) my conclusion is that the ROMIO included in OpenMPI is a few steps behind the one provided with MPICH and/but MPICH ROMIO does not fully support file interoperability Cheers, Gilles On 2014/04/29 22:27, Edgar Gabriel wrote: > the way you launch the app, you will be using ROMIO, and I am not 100% > sure about how the data representation stuff is integrated with OMPI. I > am pretty sure that we are not doing the right thing for OMPIO, but I > will look into later this week. > > Thanks > Edgar > > On 4/29/2014 7:03 AM, Christoph Niethammer wrote: >> Hello, >> >> It seems for me that the endianness is wrong in Open MPI's I/O for the >> external32 data representation. :O >> >> Find attached my test programs which write the integer -30 and the double >> 16.25 into a file. >> Here the output on my Linux system: >> >> mpicc c-xdr.c -o c-xdr >> mpicc mpi-io-external32.c -o mpi-io-external32 >> ./c-xdr >> Output file: c-xdr.dat >> hexdump c-xdr.dat >> 000 e2ff 3040 0040 >> 00c >> ./mpi-io-external32 >> Output file: mpi-io-external32.dat >> hexdump mpi-io-external32.dat >> 000 ffe2 4000 4030 >> 00c >> >> >> Best regards >> Christoph Niethammer >> >> -- >> >> Christoph Niethammer >> High Performance Computing Center Stuttgart (HLRS) >> Nobelstrasse 19 >> 70569 Stuttgart >> >> Tel: ++49(0)711-685-87203 >> email: nietham...@hlrs.de >> http://www.hlrs.de/people/niethammer >>