Re: Time-efficient memory-allocation
- From: "Richard B. Gilbert" <rgilbert88@xxxxxxxxxxx>
- Date: Mon, 30 Oct 2006 10:34:21 -0500
Anders Christensen wrote:
Hi NG,
I'm doing a C-program that might use a whole lot of memory (possibly
several GB). Basically the program will be doing Gaussian elimination
on a large matrix; the dimension of the matrix will increase in a
number og repeated steps.
The number of steps is unknown from the beginning: maybe it won't need
more than one iteration to succeed but possibly it'll take more
iterations. For each iteration the number of rows and the number of
columns will grow exponentially. In an iteration each row is extended
s.t. the original row's content should be in the beginning of the
extended row. And extra rows are added. The question is how I should
allocate the huge matrix in an efficient manner?
My approach is to malloc() each row seperately. When increasing the
demension of the matrix, I realloc() the existing rows and malloc()
some extra.
I'd like as little cache-misses as possibly (faster runningtime). And
the process of extending the row's lengths should be as time-efficent
as possible (faster preparing for the next iteration).
I'd appreciate any sugestions or comments.
Kind regards,
Anders
Rather than allocate and reallocate memory, how about just allocating a very big matirx to start with. You need not use all of the space!
Dynamic memory allocation does not make as much sense on today's machines with large virtual memory as it did when you were working with a PDP-11 with 32K of memory!
.
- References:
- Time-efficient memory-allocation
- From: Anders Christensen
- Time-efficient memory-allocation
- Prev by Date: Re: Broken shared object on Solaris 10 x64
- Next by Date: Why does this script not allow the moving of files?
- Previous by thread: Re: Time-efficient memory-allocation
- Next by thread: Sun Solaris Certification - Solaris 9 or Solaris 10
- Index(es):
Relevant Pages
|