Binary compatibility between Intel CPU and PowerPC CPU

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Binary compatibility between Intel CPU and PowerPC CPU

Roland Turcan - RoTurSoft
Hello FPC-Pascal users discussions!

What is the best way to keep the binary compatibility among different
CPU architectures.

I need to make our own database engine compatible and other binary
files, that user still can use our data from i386 or PowerPC computer.

I really don't like the idea to change the order of all numeric
variables on PowerPC, because it costs time of CPU.

There must be easier way how to keep the compatibility.

Could you give me some hints for better solution.

--
Best regards, TRoland
http://www.rotursoft.sk
http://exekutor.rotursoft.sk

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Binary compatibility between Intel CPU and PowerPC CPU

Francisco Reyes-2
Roland Turcan writes:

> I need to make our own database engine compatible and other binary
> files, that user still can use our data from i386 or PowerPC computer.

Do you mean you are trying to keep your binary data files compatible between
these two architectures?

I don't have an answer, but it was not clear (at leat to me) from your post
what you are trying to do.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Binary compatibility between Intel CPU and PowerPC CPU

Adriaan van Os-2
In reply to this post by Roland Turcan - RoTurSoft
Roland Turcan wrote:

> Hello FPC-Pascal users discussions!
>
> What is the best way to keep the binary compatibility among different
> CPU architectures.
>
> I need to make our own database engine compatible and other binary
> files, that user still can use our data from i386 or PowerPC computer.
>
> I really don't like the idea to change the order of all numeric
> variables on PowerPC, because it costs time of CPU.
>
> There must be easier way how to keep the compatibility.
>
> Could you give me some hints for better solution.

Whether you "like the idea" or not, the best way is as follows:

- add a byte to the header of source data that indicates the endianness, high-endian for PowerPC,
low-endian for i386
- perform byte swapping if the endianness of source data is different from the endianness of the
current CPU

With "source data" I mean
- reading files
- reading data over a network

This is best built-into a streaming toolbox, so that it happens automatically.

Adriaan van Os
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Binary compatibility between Intel CPU and PowerPC CPU

Adriaan van Os-2
Adriaan van Os wrote:

> Roland Turcan wrote:
>> Hello FPC-Pascal users discussions!
>>
>> What is the best way to keep the binary compatibility among different
>> CPU architectures.
>>
>> I need to make our own database engine compatible and other binary
>> files, that user still can use our data from i386 or PowerPC computer.
>>
>> I really don't like the idea to change the order of all numeric
>> variables on PowerPC, because it costs time of CPU.
>>
>> There must be easier way how to keep the compatibility.
>>
>> Could you give me some hints for better solution.
>
> Whether you "like the idea" or not, the best way is as follows:
>
> - add a byte to the header of source data that indicates the endianness,
> high-endian for PowerPC, low-endian for i386
> - perform byte swapping if the endianness of source data is different
> from the endianness of the current CPU
>
> With "source data" I mean
> - reading files
> - reading data over a network
>
> This is best built-into a streaming toolbox, so that it happens
> automatically.

I forgot to mention:
- write data in the endianness of the current CPU

To me, this is obvious, but for example Postgres always transfers data high-endian over a network,
which is ridicuous. So, for example if they send binary data from an i386 machine to another i386
machine, they perform byte-swapping twice, unnecessary,

Regards,

Adriaan van Os
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Binary compatibility between Intel CPU and PowerPC CPU

Jeff Wormsley
In reply to this post by Roland Turcan - RoTurSoft
Well, the (inefficient / multiplatform - choose one) way is to not store
data as binary, instead using something like XML.  Probably not an
option, but there will be a tradeoff and a penalty no matter what.  One
way would be store the data in the endianness of the consistently slower
platform (so as not to further slow down a system that is already
slow).  Another would be to pick the endianness of the most popular
platform for your product so that it performs as well as possible where
the most users are.  Its a decision you'll have to make on your own, though.

Jeff.

Roland Turcan wrote:

> Hello FPC-Pascal users discussions!
>
> What is the best way to keep the binary compatibility among different
> CPU architectures.
>
> I need to make our own database engine compatible and other binary
> files, that user still can use our data from i386 or PowerPC computer.
>
> I really don't like the idea to change the order of all numeric
> variables on PowerPC, because it costs time of CPU.
>
> There must be easier way how to keep the compatibility.
>
> Could you give me some hints for better solution.
>
>  

--
I haven't smoked for 2 years, 4 weeks and 2 days, saving $3,427.14 and
not smoking 22,847.63 cigarettes.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re[2]: Binary compatibility between Intel CPU and PowerPC CPU

Roland Turcan - RoTurSoft
Hello all,

Thanks for all responses and I've got the answer I thought I get, but
I don't like it. :-|

Never mind. I cannot make any change on the data structure which is on
the market about 10 years, but at least I have one advantage. The
software was developed and is still used on i386 platform which means,
that the endian conversion is needed only for PowerPC computers which
are anyway old fashioned and they will vanish soon, because Apple
prefers i386 instead. The question still is, how big effort is for
PowerPC to make endian convertion.

TRoland;

<<< 16.9.2008 19:26 - Jeff Wormsley "[hidden email]" >>>
JW> Well, the (inefficient / multiplatform - choose one) way is to not store
JW> data as binary, instead using something like XML.  Probably not an
JW> option, but there will be a tradeoff and a penalty no matter what.  One
JW> way would be store the data in the endianness of the consistently slower
JW> platform (so as not to further slow down a system that is already
JW> slow).  Another would be to pick the endianness of the most popular
JW> platform for your product so that it performs as well as possible where
JW> the most users are.  Its a decision you'll have to make on your own, though.

JW> Jeff.

JW> Roland Turcan wrote:

>> Hello FPC-Pascal users discussions!
>>
>> What is the best way to keep the binary compatibility among different
>> CPU architectures.
>>
>> I need to make our own database engine compatible and other binary
>> files, that user still can use our data from i386 or PowerPC computer.
>>
>> I really don't like the idea to change the order of all numeric
>> variables on PowerPC, because it costs time of CPU.
>>
>> There must be easier way how to keep the compatibility.
>>
>> Could you give me some hints for better solution.
>>
>>  

JW> --
JW> I haven't smoked for 2 years, 4 weeks and 2 days, saving $3,427.14 and
JW> not smoking 22,847.63 cigarettes.
JW> _______________________________________________
JW> fpc-pascal maillist  -  [hidden email]
JW> http://lists.freepascal.org/mailman/listinfo/fpc-pascal




--
Best regards, TRoland
http://www.rotursoft.sk
http://exekutor.rotursoft.sk

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Binary compatibility between Intel CPU and PowerPC CPU

Vincent Snijders
Roland Turcan schreef:

> Hello all,
>
> Thanks for all responses and I've got the answer I thought I get, but
> I don't like it. :-|
>
> Never mind. I cannot make any change on the data structure which is on
> the market about 10 years, but at least I have one advantage. The
> software was developed and is still used on i386 platform which means,
> that the endian conversion is needed only for PowerPC computers which
> are anyway old fashioned and they will vanish soon, because Apple
> prefers i386 instead. The question still is, how big effort is for
> PowerPC to make endian convertion.
>

There are some useful utilities in the RTL:
http://lazarus-ccr.sourceforge.net/docs/rtl/system/leton.html and friends.

Vincent
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Binary compatibility between Intel CPU and PowerPC CPU

Gustavo Enrique Jimenez
In reply to this post by Adriaan van Os-2
2008/9/16 Adriaan van Os <[hidden email]>:

> Roland Turcan wrote:
>>
>> Hello FPC-Pascal users discussions!
>>
>> What is the best way to keep the binary compatibility among different
>> CPU architectures.
>>
>> I need to make our own database engine compatible and other binary
>> files, that user still can use our data from i386 or PowerPC computer.
>>
>> I really don't like the idea to change the order of all numeric
>> variables on PowerPC, because it costs time of CPU.
>>
>> There must be easier way how to keep the compatibility.
>>
>> Could you give me some hints for better solution.
>
> Whether you "like the idea" or not, the best way is as follows:
>
> - add a byte to the header of source data that indicates the endianness,
> high-endian for PowerPC, low-endian for i386
> - perform byte swapping if the endianness of source data is different from
> the endianness of the current CPU
>
> With "source data" I mean
> - reading files
> - reading data over a network
>
> This is best built-into a streaming toolbox, so that it happens
> automatically.
>
> Adriaan van Os

Don't forget to use packed records (see the Free Pascal Language
Reference Guide). I've used binary files in that way across linux and
windows machines (x86).

Gustavo
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal