Is this the SIMD alignment? If so, the docs say > In order to guarantee proper alignment for SIMD, therefore, in > case your program is ever linked against a SIMD-using FFTW, we > recommend allocating your transform data with fftw_malloc and > de-allocating it with fftw_free. These have exactly the same > interface and behavior as malloc/free, except that for a SIMD > FFTW they ensure that the returned pointer has the necessary > alignment (by calling memalign or its equivalent on your OS). > > You are not required to use fftw_malloc. You can allocate > your data in any way that you like, from malloc to new (in > C++) to a fixed-size array declaration. If the array happens > not to be properly aligned, FFTW will not use the SIMD > extensions. Since fftw_malloc only ever needs to be used for > real and complex arrays, we provide two convenient wrapper > routines fftw_alloc_real(N) and fftw_alloc_complex(N) that > are equivalent to (double*)fftw_malloc(sizeof(double) * N) > and (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * N), > respectively (or their equivalents in other precisions).
which suggests that it should work and that the crash is from some other place. Does the piddle data change alignment between one call and the next? If that were the case it might explain the problem. I think a feature request for improved memory allocation is definitely something of interest for PDL going forwards. However, it is invasive enough, low level, and very tricky to debug and get right so would need to be implemented and verified fully and extensively before any merge into the release PDL. If you had a branch with a work-in-progress, we could always push a CPAN developers release from that instead of master. If the problem is changing alignment in PDL (maybe from the make physical stuff), you might work around the problem by checking alignment and then correcting it at runtime if needed. --Chris On Sun, Dec 1, 2013 at 6:36 AM, Dima Kogan <[email protected]> wrote: > Dima Kogan <[email protected]> writes: > >> I'll reply to this when a fix is ready > > OK. > > The issue is the alignment of the memory in the piddles. FFTW wants at > least 16 bytes of alignment, which is what we appear to get on 64-bit > platforms. On 32-bit platforms we get 8 bytes sometimes, which makes > things crash. The best thing to do, I think, is to allocate aligned > memory in PDL itself, instead of PDL::FFTW3. This is a common thing for > a client library to want, anyway, so others could benefit from this. > > I'm assuming there's a very small number of places in PDL where all the > memory allocation code goes through. I think I see where this is done, > but my fixes don't appear to have an effect. Anybody know where this is? > So far I've tweaked pdl_malloc() in pdlcore.c.PL and get_malloc() in > CType.pm. Any others? > > To be clear, I'm not pushing these yet. First I'd like to get them > working. Once they DO work, is there any opposition to making this > change in PDL proper? Do all of our platforms have memalign or an > equivalent? > > dima > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
