* * *

Author Topic: AVX and SSE support question  (Read 1877 times)

dzjorrit

  • Newbie
  • Posts: 2
AVX and SSE support question
« on: May 25, 2016, 10:22:03 am »
Hi,
I have the following code:

const
  vectorsize = 4;
type
  tVector=array[0..vectorsize-1] of single;

function vectoradd(a,b:tVector):tVector;
begin
  result:=a+b;
end;
   
This compiles fine when SSE and vector processing are enabled.

But when I increase vectorsize to 8 and enable the AVX compiler options I get this error:
Compile Project, Target: project1.exe: Exit code 1, Errors: 1
unit1.pas(60,12) Error: Internal error 200610072

Is AVX not properly supported yet by fpc or is this a bug?

I'm using lazarus 64bit version 1.6 with fpc 3.0.0 on Windows 10 x64 with AMD A10 AVX enabled processor.

Thanks!
Jorrit





Thaddy

  • Hero Member
  • *****
  • Posts: 3031
Re: AVX and SSE support question
« Reply #1 on: May 25, 2016, 10:51:56 am »
Which FPC version are you using? That's really important, because AVX is only properly supported from 3.0 and higher.

Ah, I see, 3.0. In that case: how did you compile? An internal error should never happen and should be reported on bugs.freepascal.org. If you ever see an internal error it is a bug by definition.

When you file your bug report give as much information as possible and preferably a complete code example that reproduces the bug.
« Last Edit: May 25, 2016, 10:59:27 am by Thaddy »

dzjorrit

  • Newbie
  • Posts: 2
Re: AVX and SSE support question
« Reply #2 on: May 25, 2016, 11:49:38 am »
Ok, thanks, I will file a bug report soon. I use a new lazarus project only adding the code I produced in my post and having these compiler options specified:
-O4
-CfAVX
-CpCOREAVX
-OpCOREAVX
-Sv
-XX
-CX

Pascal Fan

  • Newbie
  • Posts: 2
Re: AVX and SSE support question
« Reply #3 on: June 11, 2016, 05:46:05 am »
I noticed something else related to the vector processing.  I was playing around with this code this evening, trying a few things, and I noticed that when I used the code posted in this thread with a vector size of 4, and enabled SSE and vector processing with FPC 3.0, I got the same internal error as the poster got when using AVX with a size of 8, if I did an "a xor b" operation instead of an "a + b" operation.  If I did the "a + b" operation as shown in this thread, it works with SSE, but an xor operation will trigger the internal error.  I suspect this isn't correct, because it seems like an xor operation should be possible, and in any event the internal error seems like it's not the correct response.  Anyhow, I thought I should mention it because it looks like there might be some issues with the SSE vector processing as well.
« Last Edit: June 11, 2016, 05:51:36 am by Pascal Fan »

shobits1

  • Sr. Member
  • ****
  • Posts: 264
  • .
Re: AVX and SSE support question
« Reply #4 on: June 11, 2016, 06:13:26 am »
maybe you should refrain from using -O4 since the compiler help screens contains the following:
Code: [Select]
  -O<x>  Optimizations:
      -O-        Disable optimizations
      -O1        Level 1 optimizations (quick and debugger friendly)
      -O2        Level 2 optimizations (-O1 + quick optimizations)
      -O3        Level 3 optimizations (-O2 + slow optimizations)
      -O4        Level 4 optimizations (-O3 + optimizations which might have unexpected side effects)

maybe I'm wrong.

Pascal Fan

  • Newbie
  • Posts: 2
Re: AVX and SSE support question
« Reply #5 on: June 11, 2016, 06:54:07 am »
That's a totally valid point, and you're absolutely correct,  but what I forgot to mention in my post is that my compiles were done with -O3, not the -O4 the original poster used.  So I do think there might be a legitimate bug here.  But you are absolutely correct that -O4 is probably not a good idea!

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus