Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-11

avx2 32-byte alignment

8 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marco van de Voort

I'm preparing a DLL with AVX2 routines in FPC, since Delphi doesn't seem to have AVX2 support.

I wonder if it is possible to align constants used for shuffling (array[0..31] of byte typically) on 32-byte borders, so that I can use them directly in the code.

Till now I preloaded the constants using unaligned instructions before the loop, but I'm running out of registers in the current iteration.

(win64/x86_64 only btw, but I assume the possible data alignments aren't target dependent)

Reply by email

Adriaan van Os
to Jonas Maebe
Marco van de Voort wrote
'm preparing a DLL with AVX2 routines in FPC, since Delphi doesn't seem to have AVX2 support.

Very interesting. I will be pleased to compare it (on OS X) with Apple's Accelerate framework and with Intel's IPP lib <http://adriaan.biz/intel/ipp.pas.zip>.

Jonas Maebe wrote 7 lines
marcov wrote on Tue, 29 Nov 2016: > I wonder if it is possible to align constants used for shuffling > (array[0..31] of byte typically) on 32-byte borders, http://www.freepascal.org/docs-html/3.0.0/prog/progsu9.html

But that is the code alignment, not the data alignment <http://www.freepascal.org/docs-html/3.0.0/prog/progsu1.html> ?

Also note that it is the OS that specifies the alignment on the stack, so you probably won't get 32-byte alignment for arrays on the stack.

Regards,

Adriaan van Os

Reply by email

Jonas Maebe
to Adriaan van Os
Adriaan van Os wrote 6 lines
Jonas Maebe wrote: > > http://www.freepascal.org/docs-html/3.0.0/prog/progsu9.html But that is the code alignment, not the data alignment <http://www.freepascal.org/docs-html/3.0.0/prog/progsu1.html> ?

It's for everything (there is no such thing as a "code constant" or "code variable"). The directive is named {$codealign xxx} because IIRC originally it only supported changing the alignment of procedures and jump targets.

Also note that it is the OS that specifies the alignment on the stack, so you probably won't get 32-byte alignment for arrays on the stack.

True, although that is a bug in the compiler (it should re-align the stack if necessary). I did not mention this, because FPC does not allow defining constants on the stack.

Jonas

Reply by email

Marco van de Voort
to Adriaan van Os: Very interesting. I will be pleased to compare it (on OS X) with Apple's Accelerate…

In our previous episode, Adriaan van Os said:

Show quoted text 5 lines
> 'm preparing a DLL with AVX2 routines in FPC, since Delphi doesn't seem to > have AVX2 support. Very interesting. I will be pleased to compare it (on OS X) with Apple's Accelerate framework and with Intel's IPP lib <http://adriaan.biz/intel/ipp.pas.zip>.

It's for work, and not (yet) open source. Mostly it is simple fare though, think debayering, rgb-to-rgba conversion, cmyk, color distance, abs difference of images, andmask etc. From my quick look at IPP that is mostly more complicated stuff.

Reply by email

Adriaan van Os
to Marco van de Voort: In our previous episode, Adriaan van Os said: It's for work, and not (yet) open source.…
Marco van de Voort wrote 10 lines
In our previous episode, Adriaan van Os said: >> 'm preparing a DLL with AVX2 routines in FPC, since Delphi doesn't seem to >> have AVX2 support. > Very interesting. I will be pleased to compare it (on OS X) with Apple's Accelerate framework and > with Intel's IPP lib <http://adriaan.biz/intel/ipp.pas.zip>. It's for work, and not (yet) open source. Mostly it is simple fare though, think debayering, rgb-to-rgba conversion, cmyk, color distance, abs difference of images, andmask etc. From my quick look at IPP that is mostly more complicated stuff.

Well, IPP can do the things you mention, apart from more complicated stuff.

Regards,

Adriaan van Os

Reply by email