[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Fix FileSetReader/Writer
From: |
Richard Guenther |
Subject: |
[PATCH] Fix FileSetReader/Writer |
Date: |
Wed, 1 Sep 2004 15:58:33 +0200 (CEST) |
On Wed, 1 Sep 2004, Richard Guenther wrote:
> On Wed, 1 Sep 2004 address@hidden wrote:
>
> > regressions.io.filesetreadertest1 : FAIL
> > Unexpected exit_code, standard error.
> >
> > regressions.io.filesetreadertest2 : FAIL
> > Unexpected exit_code, standard error.
>
> I finally figured out why these fail on ia32 (but not on amd64 and ia64).
> The test data was appearantly generated on a 64bit big-endian host and the
> reader just reads bytes and expects a C++ long to be 64bit everywhere
> (which is not true obviously).
>
> There is also the POOMA_HAS_LONG_LONG define which is set nowhere
> and used only in the FileSetReader/Writer and ElementProperties.
>
> We could check for an appropriate 64bit type during configure and
> use that or just ignore the issue.
Yay, and of course this is not enough, as required alignment for 64bit
datatypes is of course different. We should shoot the one that came up
with
template <class T>
struct OffsetData
{
void reverseBytes();
int nodedata[6*Dim]; // domain data (same format as .layout)
bool isCompressed; // Is the data compressed
Offset_t offset; // offset in sizeof(T) units
T compressedValue; // Data value, if compressed
};
as possibly "portable" structure to write byte-for-byte to a file.
Placing bool between int and long long is surely not a good idea.
Changing the above to
int nodedata[6*Dim]; // domain data (same format as .layout)
union {
bool isCompressed; // Is the data compressed
char pad[8];
} u;
Offset_t offset; // offset in sizeof(T) units
_seems_ to "fix" the problem.
So, is the following patch ok? Tested on ia32, amd64 and ia64 linux.
2004Sep01 Richard Guenther <address@hidden>
* configure: add POOMA_HAS_LONG_LONG and POOMA_INT64
defines.
scripts/configure.ac: check for long long and sizes of
long and long long. Set POOMA_HAS_LONG_LONG and
POOMA_INT64 appropriately.
scripts/configure: regenerate.
src/IO/FileSetReader.h: use POOMA_INT64 for Offset_t,
pad bool inside OffsetData to 64bit using a union.
src/IO/FileSetWriter.h: likewise.
src/IO/FileSetReader.cpp: honour union.
p
Description: Text document
- [PATCH] Fix FileSetReader/Writer,
Richard Guenther <=