GMP and Win32 Memory Management

Jim White mathimagics at yahoo.co.uk
Sat Dec 2 00:09:30 CET 2006


Following a recent "accident" (ie. a stupid series of
self-compunding blunders on my part!) on my home PC, I
have lost a large proportion of my GMP-based
computational methods research projects.

"Lost" is perhaps a little inaccurate - they remain,
but have been peppered with large 4KB holes, as though
hit by a cluster bomb!

In thinking about reconstruction, I have been thinking
also about ways my (software) integration of GMP and
VB6 might be made smarter.

The sort of applications I write are typically
experiments relating to elementary function evaluation
(functions such as those provided, and provided very
well, by MPFR).

Since my original code was evolved, not designed, it's
full of INIT's and CLEAR's, so an obvious
starting-point is some sort of centralised "register
allocation" system.

Now memory management is one of the few areas where
Windoh's (the NT-derived OS versions, to be specific)
actually has a a desirable feature, and one that can
be used to advantage here.

The feature is called "memory-mapped files". Stripped
down, this basically means you can create your own
arbitrary virtual address space, which the OS will
then page either directly to the paging disk, or to
any file you care to provide.

The potential benefits (that I think are) here are
both performance-related and functional. From a
performance POV, this allows virtually instantaneous
creation of contiguous virtual arrays of arbitrary
(well, to 4GB, anyway) size.

>From a functional aspect, we can implement a "Save all
key variables" and "restore all key variables" feature
without doing any IO at all.  At the end of any
execution, the mapped file is itself an IMAGE of all
variables that were allocated in that address space.

To avoid potential problems such as the automatic
resizing that can occur with mpz_t items, I think the
best way to avoid this would be to implement the model
as a "total solution" - as a set of "Custom
Allocation" routines ("alloc" and "free" delegates).


Ideas/comments would be welcome .....
    

Jim White
ANU, Canberra

Send instant messages to your online friends http://uk.messenger.yahoo.com 


More information about the gmp-discuss mailing list