Discussions related to Visual Prolog
Martin Meyer
VIP Member
Posts: 328
Joined: 14 Nov 2002 0:01

Sizes of Integer Types

Unread post by Martin Meyer »

Hello Thomas, hi all,

I have run the below predicate test, which displays several byte sizes of integer types and variables, in different VIP builds.

Code: Select all

class predicates     writeByteSize : (Type Var). clauses     writeByteSize(Var) :-         stdIo::write("Bytesize of type variable is ", sizeOf(Var), "\n").   domains     rec8 = rec8(integer8).     rec16 = rec16(integer16).     rec32 = rec32(integer).     rec64 = rec64(integer64).   class predicates     test : (). clauses     test() :-         stdIo::write("compiler version ", compiler_version, "\n"),         stdIo::write("platform bits ", platform_bits, "\n\n"),         hasDomain(integer8, I8),         I8 = 0,         stdIo::write("Bytesize of domain integer8 is ", sizeOfDomain(integer8), "\n"),         stdIo::write("Bytesize of variable I8 is ", sizeOf(I8), "\n"),         writeByteSize(I8),         stdIo::write("\n"),         hasDomain(integer16, I16),         I16 = 0,         stdIo::write("Bytesize of domain integer16 is ", sizeOfDomain(integer16), "\n"),         stdIo::write("Bytesize of variable I16 is ", sizeOf(I16), "\n"),         writeByteSize(I16),         stdIo::write("\n"),         hasDomain(integer, I32),         I32 = 0,         stdIo::write("Bytesize of domain integer is ", sizeOfDomain(integer), "\n"),         stdIo::write("Bytesize of variable I32 is ", sizeOf(I32), "\n"),         writeByteSize(I32),         stdIo::write("\n"),         hasDomain(integer64, I64),         I64 = 0,         stdIo::write("Bytesize of domain integer64 is ", sizeOfDomain(integer64), "\n"),         stdIo::write("Bytesize of variable I64 is ", sizeOf(I64), "\n"),         writeByteSize(I64),         stdIo::write("\n"),         hasDomain(rec8, Rec8),         Rec8 = rec8(0),         stdIo::write("Bytesize of domain rec8 is ", sizeOfDomain(rec8), "\n"),         stdIo::write("Bytesize of variable Rec8 is ", sizeOf(Rec8), "\n"),         writeByteSize(Rec8),         stdIo::write("\n"),         hasDomain(rec16, Rec16),         Rec16 = rec16(0),         stdIo::write("Bytesize of domain rec16 is ", sizeOfDomain(rec16), "\n"),         stdIo::write("Bytesize of variable Rec16 is ", sizeOf(Rec16), "\n"),         writeByteSize(Rec16),         stdIo::write("\n"),         hasDomain(rec32, Rec32),         Rec32 = rec32(0),         stdIo::write("Bytesize of domain rec32 is ", sizeOfDomain(rec32), "\n"),         stdIo::write("Bytesize of variable Rec32 is ", sizeOf(Rec32), "\n"),         writeByteSize(Rec32),         stdIo::write("\n"),          hasDomain(rec64, Rec64),         Rec64 = rec64(0),         stdIo::write("Bytesize of domain rec64 is ", sizeOfDomain(rec64), "\n"),         stdIo::write("Bytesize of variable Rec64 is ", sizeOf(Rec64), "\n"),         writeByteSize(Rec64),         stdIo::write("\n").
Old VIP build 7202 has output this:

Code: Select all

compiler version 7202 platform bits 32   Bytesize of domain integer8 is 1 Bytesize of variable I8 is 1 Bytesize of type variable is 1   Bytesize of domain integer16 is 2 Bytesize of variable I16 is 2 Bytesize of type variable is 2   Bytesize of domain integer is 4 Bytesize of variable I32 is 4 Bytesize of type variable is 4   Bytesize of domain integer64 is 8 Bytesize of variable I64 is 8 Bytesize of type variable is 8   Bytesize of domain rec8 is 4 Bytesize of variable Rec8 is 4 Bytesize of type variable is 4   Bytesize of domain rec16 is 4 Bytesize of variable Rec16 is 4 Bytesize of type variable is 4   Bytesize of domain rec32 is 4 Bytesize of variable Rec32 is 4 Bytesize of type variable is 4   Bytesize of domain rec64 is 8 Bytesize of variable Rec64 is 8 Bytesize of type variable is 8
In the above the only results, which I had not expected, are these of the last 3 lines. Is a variable of type rec64 not stored as a pointer (to a structure of 8 bytes)? On a 32 bit platform pointers have 4 bytes. But last 3 lines state 8 bytes.

I tried it in current VIP build 7501 in 32 bit mode and it has output:

Code: Select all

compiler version 7500 platform bits 32   Bytesize of domain integer8 is 1 Bytesize of variable I8 is 4 Bytesize of type variable is 1   Bytesize of domain integer16 is 2 Bytesize of variable I16 is 4 Bytesize of type variable is 2   Bytesize of domain integer is 4 Bytesize of variable I32 is 4 Bytesize of type variable is 4   Bytesize of domain integer64 is 8 Bytesize of variable I64 is 8 Bytesize of type variable is 8   Bytesize of domain rec8 is 1 Bytesize of variable Rec8 is 1 Bytesize of type variable is 1   Bytesize of domain rec16 is 2 Bytesize of variable Rec16 is 2 Bytesize of type variable is 2   Bytesize of domain rec32 is 4 Bytesize of variable Rec32 is 4 Bytesize of type variable is 4   Bytesize of domain rec64 is 8 Bytesize of variable Rec64 is 8 Bytesize of type variable is 8
Why sizeOf(I8) and sizeOf(I16) yielding result 4 in build 7501?
Are all variables of type rec8 to rec64 not stored as pointers occupying 4 bytes in 32 bit mode?
(I really did it in 7501, even so constant compiler_version says 7500.)

I checked it also in 64 bit mode of the current VIP build. Output shows same picture as before in 32 bit:

Code: Select all

compiler version 7500 platform bits 64   Bytesize of domain integer8 is 1 Bytesize of variable I8 is 4 Bytesize of type variable is 1   Bytesize of domain integer16 is 2 Bytesize of variable I16 is 4 Bytesize of type variable is 2   Bytesize of domain integer is 4 Bytesize of variable I32 is 4 Bytesize of type variable is 4   Bytesize of domain integer64 is 8 Bytesize of variable I64 is 8 Bytesize of type variable is 8   Bytesize of domain rec8 is 1 Bytesize of variable Rec8 is 1 Bytesize of type variable is 1   Bytesize of domain rec16 is 2 Bytesize of variable Rec16 is 2 Bytesize of type variable is 2   Bytesize of domain rec32 is 4 Bytesize of variable Rec32 is 4 Bytesize of type variable is 4   Bytesize of domain rec64 is 8 Bytesize of variable Rec64 is 8 Bytesize of type variable is 8
If the storage of integers in memory has changed between 7202 and 7501, please explain then changes!

Best regards
Martin
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

Integers have not changed, it is the representation of functor domains that have changed. See Functor Domain Layout.
Regards Thomas Linder Puls
PDC
Martin Meyer
VIP Member
Posts: 328
Joined: 14 Nov 2002 0:01

Unread post by Martin Meyer »

Thank you! I understand now about the sizes of variables of type rec8 to rec64. The optimization of functors' memory layout looks very well!

But I still wonder about these lines from the current build:

Code: Select all

Bytesize of domain integer8 is 1 Bytesize of variable I8 is 4 Bytesize of type variable is 1   Bytesize of domain integer16 is 2 Bytesize of variable I16 is 4 Bytesize of type variable is 2
Why is it not Bytesize of variable I8 is 1 and Bytesize of variable I16 is 2 as it used to be in 7202? If these sizeOf-results are intended, please explain them too!

Many Regards
Martin
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

That is a bug.
Regards Thomas Linder Puls
PDC
Martin Meyer
VIP Member
Posts: 328
Joined: 14 Nov 2002 0:01

Unread post by Martin Meyer »

Thank you once again Thomas for the info, I appreciate your good support in this forum a lot!

Regards
Martin
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

This fixed in build 7502.
Regards Thomas Linder Puls
PDC
Post Reply