David said:
Hi all:
I am processing a 3D bitmaps(essentially ~1024 2D bitmaps with a size of 1MB
each).
If I want read large amount of radom data from this series, how could I
buffer the file to get optimized performance?
If the access pattern is "radom" there isn't much you
can do. Load as much as you can manage into memory and hope
your next "radom" access is for something already loaded; if
it isn't, throw something away and load the piece you're
trying to get at. The selection of what to pre-load, what
to throw away, and how much to load for an out-of-memory
experience depends on the access patterns. Some patterns
will lend themselves to exploitation, others won't.
The C pieces you'll need will probably be fopen (with
"rb" mode, most likely), fseek, fread, and fclose, along
with the usual memory-management stuff. I mention fclose
because your system may not permit you to have 1024 file
streams open simultaneously; you may need to "multiplex"
the large number of files across a smaller number of FILE*
streams by closing and re-opening as necessary. The
FOPEN_MAX macro in <stdio.h> gives an approximation to the
number of streams you can open simultaneously, but the
value should be treated only as an approximation.
With WinXP pro/512MB memories
and no other big programmes running at the same time.
Irrelevant detail. Well, highly relevant in some ways,
but not to your question (if there is one) about the C
programming language. Windows-oriented newsgroups may have
suggestions that go beyond what C itself can provide.