octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fftw and memory alignment


From: John W. Eaton
Subject: Re: fftw and memory alignment
Date: Tue, 17 Feb 2004 10:44:43 -0600

On 17-Feb-2004, David Bateman <address@hidden> wrote:

| There are two problems with unknown alignments.
| 
| 1) It is slower if it isn't 16 byte aligned since SIMD instructions can't be
|    use
| 2) Have to track the alignment in the planning code.
| 
| This idea is pretty much what I thought was worth doing in Array.h but
| it might be quite complex since there are places where the pointer
| itself is copied and not the data. Could try it though...

Even if you extract a pointer to data out of the Array class, I think
the ArrayRep destructor is still responsible for freeing the storage.

So I think it would work for Array<double>, because there is no
constructor or destructor for double.  But what about for objects that
have constructors and destructors?  In that case, if you do

  FOO *array = new FOO [N];

the constructor for FOO will be called N times, and then when you do

  delete [] array;

the destructor for FOO is called N times.  So in this case, after you
allocate the buffer, you will need to use placement new (or
equivalent) to ensure that the constructors are called for each object
that you want to store starting at your offset in the buffer, then you
will need to use placement delete to free the objects in the array
before freeing the buffer.

Since we only need this for double and complex objects, it would
probably make sense to rewrite the allocator for the ArrayRep class so
that it can be specialized for those types.  Then I think we can
continue to use the simpler method for other types.

jwe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]