external data representation

Eric Salo (salo@mrjones.engr.sgi.com)
Mon, 17 Mar 1997 18:18:41 -0800

At the last meeting, we concluded that a single set of lengths could describe
the sizes of elementary C and FORTRAN datatypes in a 32-bit environment across
a wide variety of architectures. But there was a bit of uncertainty with regard
to the C 'long double' type, and in fact my own original guess about the size
of this type on SGI machines turns out to have been wrong.

At great personal expense, I have put together the following test code which I
now make freely available to everyone:

#include <stdio.h>

main()
{
printf("sizeof(char) = %d\n", sizeof(char));
printf("sizeof(short) = %d\n", sizeof(short));
printf("sizeof(int) = %d\n", sizeof(int));
printf("sizeof(long) = %d\n", sizeof(long));
printf("sizeof(long long) = %d\n", sizeof(long long));
printf("sizeof(float) = %d\n", sizeof(float));
printf("sizeof(double) = %d\n", sizeof(double));
printf("sizeof(long double) = %d\n", sizeof(long double));
}

I built and ran this code under three different environemnts:

(a) MIPS O32

> cc -o32 test.c
cfe: Warning 728: mpi.c, line 12: Long double not supported; double assumed.
printf("sizeof(long double) = %d\n", sizeof(long double));
--------------------------------------------^
> a.out
sizeof(char) = 1
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 4
sizeof(long long) = 8
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 8

(b) MIPS N32

> cc -n32 test.c
> a.out
sizeof(char) = 1
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 4
sizeof(long long) = 8
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 16

(c) MIPS 64

> cc -64 mpi.c
> a.out
sizeof(char) = 1
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 8
sizeof(long long) = 8
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 16

Conclusion:

Since o32 is for legacy codes only, a 16-byte MPI_LONG_DOUBLE would be the
appropriate size for us.

Next vendor...

-- 
Eric Salo    Silicon Graphics Inc.    salo@sgi.com