Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 199361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:01:01+00:00 2026-05-11T17:01:01+00:00

I would like to use the FFTW C library from Delphi 2009 and according

  • 0

I would like to use the FFTW C library from Delphi 2009 and according to this documentation;

http://www.fftw.org/install/fftw_usage_from_delphi.txt

to increase the performance inside the FFTW library (such that it can use SIMD extensions) arrays passed in of either Single (float) or Double (double) need to be aligned either at 4 or 8 byte boundaries. I found documentation talking about alignment of record structures, but nothing specific about arrays. Is there a way to do this in Delphi 2009.

So the code (copied from the above documentation) would look like this;

var
      in, out : Array of Single; // Array aligned at 4 byte boundary
      plan : Pointer;

    {$APPTYPE CONSOLE}

    begin

      ...  

      SetLength(in, N);
      SetLength(out, N);

      plan := _fftwf_plan_dft_1d(dataLength, @in[0], @out[0],
                                 FFTW_FORWARD, FFTW_ESTIMATE);

Also in the above documentation they talk about 8 and 16 byte boundaries but it looks to me it should be 4 and 8 byte boundaries, if any could clear that up to that would be great.

Thanks,
Bruce

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:01:01+00:00Added an answer on May 11, 2026 at 5:01 pm

    Delphi provides no way to control the alignment of any memory it allocates. You’re left to either rely on the documented behavior for the memory manager currently installed, or allocate memory with some slack space and then align it yourself, as Mghie demonstrates.

    If you’re concerned that Delphi’s memory manager is not providing the desired alignment for dynamic arrays, then you can go ahead and use the memory functions provided by the DLL. The note you cite mentions _fftwf_malloc and _fftwf_free, but then it gives some kind of warning that memory allocated from _fftwf_malloc “may not be accessed directly from Delphi.” That can’t be what the authors meant to say, though, because that’s not how memory works in Windows. The authors probably meant to say that memory allocated by _fftwf_malloc cannot be freed by Delphi’s FreeMem, and memory allocated by Delphi’s GetMem cannot be freed by _fftwf_free. That’s nothing special, though; you always need to keep your memory-management functions paired together.

    If you use _fftwf_malloc to get your array, then you can access it through an ordinary pointer type. For example:

    var
      dataIn, dataOut: PDouble;
    begin
      dataIn := _fftwf_malloc(...);
      dataOut := _fftwf_malloc(...);
      _fftwf_plan_dft_1d(dataLength, dataIn, dataOut,
                         FFTW_FORWARD, FFTW_ESTIMATE);
    

    As of Delphi 2009, you can even use array syntax on those pointers:

    dataIn[0] := 3.5;
    dataIn[2] := 7.3;
    

    In order to enable that, use the {$POINTERMATH ON} compiler directive; it’s not enabled by default except for the character-pointer types.

    The disadvantage to manually allocating arrays like this is that you lose range checking. If you index beyond the end of an array, you won’t get an easy-to-recognize ERangeError exception anymore. You’ll get corrupted memory, access violations, or mysteriously crashing programs instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like use from Spring.NET Aspect library Logging aspect together with log4Net. I
I would like to use integrated authentication to access a SQL database from a
I would like to use a single haml/mustache template, like this: .foo %h2 {{title}}
Would like to use the return of: http://maps.google.de/maps/suggest?q=ham&cp=1&hl=de&gl=de&v=2&json=b as a JSON object in a
I would like use unmanaged code from C in C#. I built a DLL
Designing my RESTful API, I would like use following URI http://[HOST]/[PLANET]/[LAT];[LONG] e.g. http://myserver/earth/50.2;29.1 What
I would like to use the group_by method, but instead of using a column
I would like to use complex numbers as defined in C99, but I need
I would like to use HTML 4.01 Strict, and used a DOCTYPE of it
I would like to use KVO in the following context: 1) In touchesBegan:withEvent: I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.