avx2 32-byte alignment

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

avx2 32-byte alignment

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)


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: avx2 32-byte alignment

Jonas Maebe-2

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


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: avx2 32-byte alignment

Adriaan van Os-2
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:
>
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: avx2 32-byte alignment

Jonas Maebe-2
Adriaan van Os wrote:
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: avx2 32-byte alignment

Marco van de Voort
In reply to this post by Jonas Maebe-2
In our previous episode, Jonas Maebe said:
> > 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

I skipped over it looking for a $dataalign. $codealign for dataalignement, a
bit of a misnomer.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: avx2 32-byte alignment

Marco van de Voort
In reply to this post by Adriaan van Os-2
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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: avx2 32-byte alignment

Marco van de Voort
In reply to this post by Marco van de Voort
In our previous episode, Marco van de Voort said:
> >
> > http://www.freepascal.org/docs-html/3.0.0/prog/progsu9.html
>
> I skipped over it looking for a $dataalign. $codealign for dataalignement, a
> bit of a misnomer.

Oh, and thanks, obviously :-)
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: avx2 32-byte alignment

Adriaan van Os-2
In reply to this post by Marco van de Voort
Marco van de Voort wrote:

> 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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal