Recent

Author Topic: How to use YMM registers and 256bits instructions?  (Read 11779 times)

ciammaruca

  • New Member
  • *
  • Posts: 20
How to use YMM registers and 256bits instructions?
« on: October 31, 2014, 04:20:28 pm »
hi,
even if i can see in debug registers window the list of YMM registers (ymm0h....) i can't use it:
"Error: Invalid register name".
And for vmovdqa: "Unrecognized opcode vmovdqa"
what are the correct names?
saluti

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: How to use YMM registers and 256bits instructions?
« Reply #1 on: October 31, 2014, 04:50:06 pm »
Maybe you are using an old compiler. Access support is very new

ciammaruca

  • New Member
  • *
  • Posts: 20
Re: How to use YMM registers and 256bits instructions?
« Reply #2 on: October 31, 2014, 11:05:30 pm »
hi,
my cpu is a AMD E1-2500, and flags, as in cpuinfo, are:
flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid aperfmperf eagerfpu pni pclmulqdq monitor ssse3 cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt topoext perfctr_nb perfctr_l2 arat xsaveopt hw_pstate proc_feedback npt lbrv svm_lock nrip_save tsc_scale flushbyasid decodeassists pausefilter pfthr
lazarus 1.2.4+dfsg1 version


Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: How to use YMM registers and 256bits instructions?
« Reply #3 on: October 31, 2014, 11:52:23 pm »
What errors do you get, and what version of FPC do you have?

asm
  vmovdqa ymm0, ymm1
end;

Works fine for me. AVX 1 support has been in the compiler since 2012 it looks like.

sam707

  • Guest
Re: How to use YMM registers and 256bits instructions?
« Reply #4 on: October 31, 2014, 11:55:28 pm »
whatever is your cpu smart and have power, if the software does not support the features, it is useless. the support of cpu other than ATHLON64 in FPC is VERY NEW

please open a terminal (cmd box under windows), setect the path where FPC compiler is istalled

and enter the following commands

fpc -i

you ll get the supporterd features and cpu by the compiler
« Last Edit: October 31, 2014, 11:58:58 pm by sam707 »

sam707

  • Guest
Re: How to use YMM registers and 256bits instructions?
« Reply #5 on: November 01, 2014, 12:06:44 am »
another way to use assembly instructions (I did not check but in delphi it worked fine) is

1 - write your asm routine apart
2 - compile the routine with your assembler that knows the instructions
3 - link to the executable

example : I have asm code in file mynasmutils.asm containing procedure called ExtractR

I use nasm assembler to compile mynasmutils.asm to mynasmutils.o

in a lazarus unit I then do

Code: [Select]
Unit myextprocs;

interface

uses
  ...

   procedure ExtractR; external;

implementation

{$L mynasmutils.o}

end.
« Last Edit: November 01, 2014, 12:23:32 am by sam707 »

sam707

  • Guest
Re: How to use YMM registers and 256bits instructions?
« Reply #6 on: November 01, 2014, 12:11:07 am »
note on my above answer

it is just a template,  you MUST know about calling conventions and declare the external procedures according to them ... ask google "free pascal calling conventions"

to be able to {$L ink} other obj files comming from other languages/assemblers
« Last Edit: November 01, 2014, 12:13:08 am by sam707 »

sam707

  • Guest
Re: How to use YMM registers and 256bits instructions?
« Reply #7 on: November 01, 2014, 12:53:22 am »
Quote
The Free Pascal compiler supports AVX and AVX2 with the -CfAVX and -CfAVX2 switches from version 2.7.1

I use that free pascal compiler ;) but it is a "development branch"

quote is from that page :

http://en.wikipedia.org/wiki/Advanced_Vector_Extensions

so if u use 2.6 meant to be "stable" compiler, it surely cant access these asm instructions

use either what I explained earlier either the trick I explain below

...

I have a brand new cpu with an instruction called xxchg256r that I know is coded FA01FCB4 in hexa

procedure myproc;
begin

asm
  db 0fah
  db 01h
  db 0fch
  db 0b4h
end;
end;

assuming there is no operand to that instruction and assuming I use intel style asm notation

in case of operands need, go deeper and code them with db or dw or dq... following the "obscure" hex codes

If  I need such things one day, I would prefer using nasm assembler 1) i am inlove with it (the only asm that have -O1 -O.. -O3 multipass optimizations by default) ... 2) the {$LINK} way in pascal sources makes my code beautiful and maintainable
« Last Edit: November 01, 2014, 01:14:26 am by sam707 »

ciammaruca

  • New Member
  • *
  • Posts: 20
Re: How to use YMM registers and 256bits instructions?
« Reply #8 on: November 01, 2014, 06:47:28 am »
this is my linux ubuntu fpc -i:
fpc -i
Free Pascal Compiler version 2.6.4

Compiler Date      : 2014/07/13
Compiler CPU Target: x86_64

Supported targets:
  Linux for x86-64
  FreeBSD for x86-64
  Win64 for x64
  Darwin for x86_64
  Solaris for x86-64 (under development)
  OpenBSD for x86-64 (under development)
  NetBSD for x86-64 (under development)

Supported CPU instruction sets:
  ATHLON64

Supported FPU instruction sets:
  SSE64
  SSE3


sam707

  • Guest
Re: How to use YMM registers and 256bits instructions?
« Reply #9 on: November 01, 2014, 07:37:11 am »
this is mine

Code: [Select]
Free Pascal Compiler version 2.7.1

Compiler Date      : 2014/10/30
Compiler CPU Target: x86_64

Supported targets:
  Linux for x86-64
  FreeBSD for x86-64
  Win64 for x64
  Darwin for x86_64
  Solaris for x86-64 (under development)
  OpenBSD for x86-64 (under development)
  NetBSD for x86-64 (under development)

Supported CPU instruction sets:
  ATHLON64,COREI,COREAVX,COREAVX2

Supported FPU instruction sets:
  SSE64,SSE3,SSSE3,SSE41,SSE42,AVX,AVX2

Supported inline assembler modes:
  STANDARD
  GAS
  INTEL
  ATT

Supported ABI targets:
  DEFAULT

Supported Optimizations:
  REGVAR
  STACKFRAME
  PEEPHOLE
  LOOPUNROLL
  TAILREC
  CSE
  DFA
  USERBP
  ORDERFIELDS
  FASTMATH
  REMOVEEMPTYPROCS
  CONSTPROP

Supported Whole Program Optimizations:
  All
  DEVIRTCALLS
  OPTVMTS
  SYMBOLLIVENESS

Supported Microcontroller types:

This program comes under the GNU General Public Licence
For more information read COPYING.v2

Please report bugs in our bug tracker on:
                 http://bugs.freepascal.org

More information may be found on our WWW pages (including directions
for mailing lists useful for asking questions or discussing potential
new features, etc.):
                 http://www.freepascal.org

support has been added for AVX in 2.7 version branch, as said wikipedia (CoreAVX)

and most important ... FPU instructions set supports AVX too, unlike your 2.6 version
« Last Edit: November 01, 2014, 07:45:57 am by sam707 »

ciammaruca

  • New Member
  • *
  • Posts: 20
Re: How to use YMM registers and 256bits instructions?
« Reply #10 on: November 01, 2014, 08:36:33 am »
hi,
ok, i've downloaded the new Free Pascal Compiler version 2.7.1. But how to compile and install it in linux ubuntu?
thanks

sam707

  • Guest
Re: How to use YMM registers and 256bits instructions?
« Reply #11 on: November 01, 2014, 09:20:42 am »
2 options

1) use fpcup https://bitbucket.org/reiniero/fpcup

and build the 2.7.1 fpc compiler from scratch (svn download branch 2.7.1). you'll need a svn client software.

2) as I did, get CodeTyphon 4.8
http://www.pilotlogic.com/sitejoom/index.php/wiki/84-wiki/codetyphon-studio/80-codetyphon-download

wich automates totally the 2.7.1 fpc compiler build within few clicks only

I selected the 2) with the 4.80 version of CodeTyphon and I'm very happy with, about stability and power! I tried CodeTyphon 5.00 and 5.10 but there are some bugs around assembly disassembler and empty options boxes that I have signaled on their forum
« Last Edit: November 01, 2014, 09:39:23 am by sam707 »

ciammaruca

  • New Member
  • *
  • Posts: 20
[SOLVED] Re: How to use YMM registers and 256bits instructions?
« Reply #12 on: November 01, 2014, 04:19:46 pm »
ok, solved, thanks.
I've used fpcup.
For linux ubuntu, first install these:
sudo apt-get install build-essential gdb subversion unzip mingw32-binutils
then download fpcup at:
https://bitbucket.org/reiniero/fpcup/downloads
then compile lazarus and freepascal in trunk version:
./fpcup_linux_x64 --fpcURL="http://svn.freepascal.org/svn/fpc/trunk"
Now freepascal is at version 2.7.1: YMM registers and 256bits instructions work fine!
« Last Edit: November 01, 2014, 04:26:34 pm by ciammaruca »

sam707

  • Guest
Re: How to use YMM registers and 256bits instructions?
« Reply #13 on: November 01, 2014, 09:45:15 pm »
fine ;)

 

TinyPortal © 2005-2018