Gas64 (no more use of gcc, only gas) WDS / LNX

User projects written in or related to FreeBASIC.
robert
Posts: 148
Joined: Aug 06, 2019 18:45

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby robert » Nov 23, 2020 22:17

SARG wrote:Hi all,

A new version with a lot of internal changes. Don't forget to set the option -gen gas64 when using fbc

The file contains the exes for WDS 1.07 / 1.08 and only the modifications for 1.07 not yet in github.
http://users.freebasic-portal.de/sarg/fbc64_gas64_W.zip

For 1.08 the sources (github fbc master + lastest modifications not yet included) can be found here --> https://github.com/SARG-FB/fbc/tree/gas64_rev

Hi SARG:

How are the fbc, unit and log test makefiles modified to use -gen gas64?

In the fbc makefile I changed

Code: Select all


FBFLAGS := -maxerr 1


to

Code: Select all


FBFLAGS := -gen gas64 -maxerr 1



but I am not sure if that is correct or sufficient. I have no idea how to modify the test makefiles.

Using the makefiles, as is, your GitHub repo compiled and tested without error on my Windows 10 and Fedora 33 64 bit machines.

Thank you

Robert
SARG
Posts: 1247
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby SARG » Nov 23, 2020 23:45

Hi robert,

I don't use makefiles so my answer is what I understand after looking them.

For fbc preferably use

Code: Select all

ALLFBCFLAGS += -gen gas64

As FBFLAGS is also used for linking. You could add -R and if you see a64 files the compiler uses gas64.

For the tests use the option 'GEN' with makefile for selecting the version: GEN gas64.

The tests you did were made with gcc not gas64 so it's normal you didn't get any problem :-)

FYI gas64 is now included in the master Github which is up to date (except when there are very recent changes). And before each new version can be pulled, the test suite is automatically executed.
srvaldez
Posts: 2689
Joined: Sep 25, 2005 21:54

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby srvaldez » Nov 23, 2020 23:59

I am probably not understanding the question, but I run the tests as follows
make unit-tests GEN=gas64
make log-tests GEN=gas64
or
make unit-tests GEN=gcc
make log-tests GEN=gcc
robert
Posts: 148
Joined: Aug 06, 2019 18:45

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby robert » Nov 24, 2020 2:03

Thank you SARG and srvaldez. Exactly what I wanted to know.
jj2007
Posts: 2090
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby jj2007 » Feb 28, 2021 8:09

@Sarg: please check this thread, and compare against FB64
SARG
Posts: 1247
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby SARG » Feb 28, 2021 10:51

jj2007 wrote:@Sarg: please check this thread, and compare against FB64
I'll do but for you what does mean FB64 ?
gas, gas64, gcc32 and gcc64 are less ambiguous.
jj2007
Posts: 2090
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby jj2007 » Feb 28, 2021 12:24

SARG wrote:for you what does mean FB64 ?
gen gcc -Wc -O2 -s console, FreeBASIC Compiler - Version 1.07.1 (2019-09-27), built for win64 (64bit)

It compiles fine with fbc64_gas64.exe -t 2000 -gen gas64 -g -Wc -O2 -s but the timings look different.

Code: Select all

#Define elements 150000000   ' thread Integer data types in 32-bit and 64-bit
if (sizeof(any ptr))=8 Then
   Print "sizes in 64-bit code:"
else
   Print "sizes in 32-bit code:"
endif
Print sizeof(integer), "integer"
Print sizeof(long), "long"

Dim shared As long longvar(elements)
Dim shared As integer intvar(elements)
Dim As long tmp, ms
Dim As integer sumi
Dim As long suml
Dim As double ti, tl
for n as integer=0 to elements-1   ' create an array of random integers and longs
   tmp=Rnd()*16
   longvar(n)=tmp
   intvar(n)=tmp
next
ti=Timer()
for n as integer=0 to elements-1   ' sum of integers
   sumi+=intvar(n)
next
ti=Timer()-ti
tl=Timer()
for n as integer=0 to elements-1   ' sum of longs
   suml+=longvar(n)
next
tl=Timer()-tl
ms=1000*ti
Print "Sum integer=";sumi;" added in ";ms;" ms"
ms=1000*tl
Print "Sum long   =";suml;" added in ";ms;" ms"
sleep
SARG
Posts: 1247
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby SARG » Feb 28, 2021 18:30

@jj2007 What do you want to prove ? that an alone guy in 2 years does less well than a very skilled team during many years ;-)

Gas64 uses one only pass I guess that with a second pass more optimizations could be made and therefore executions be speed up.
I have to study the asm code generated by gcc with -O2 maybe I can optimize something in gas64 but that's unlikely.

Btw -Wc -O2 and -g are useless with gas64. In 1.08 the stack size is increased to 2048 for 64bit.

A timer is added when filling the array.

Gas32 : 5145 / 525 / 525
Gas64 : 3008 / 536 / 605 -------------------------------------> total = 4149, not so bad.
Gcc64 no optim : 10891 / 529 / 524
Gcc -02: 10010 / 128 / 153 ---------------------------------- --> total = 10291
A surprise without the first timer Gcc -02 : 159 / 100 ?????

Code: Select all

#Define elements 150000000   ' thread Integer data types in 32-bit and 64-bit
if (sizeof(any ptr))=8 Then
   Print "sizes in 64-bit code:"
else
   Print "sizes in 32-bit code:"
endif
Print sizeof(integer), "integer"
Print sizeof(long), "long"

Dim shared As long longvar(elements)
Dim shared As integer intvar(elements)
Dim As long tmp, ms
Dim As integer sumi
Dim As long suml
Dim As double ti, tl, tp
tp=Timer()
for n as integer=0 to elements-1   ' create an array of random integers and longs
   tmp=Rnd()*16
   longvar(n)=tmp
   intvar(n)=tmp
next
tp=Timer()-tp
ms=1000*tp
print "Fill array=";ms

ti=Timer()
for n as integer=0 to elements-1   ' sum of integers
   sumi+=intvar(n)
next
ti=Timer()-ti
tl=Timer()
for n as integer=0 to elements-1   ' sum of longs
   suml+=longvar(n)
next
tl=Timer()-tl
ms=1000*ti
Print "Sum integer=";sumi;" added in ";ms;" ms"
ms=1000*tl
Print "Sum long   =";suml;" added in ";ms;" ms"
sleep
jj2007
Posts: 2090
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby jj2007 » Feb 28, 2021 20:52

Code: Select all

sizes in 64-bit code:
 8            integer
 4            long
Fill array= 7752
Sum integer= 1199937252 added in  190 ms
Sum long   = 1199937252 added in  98 ms

Code: Select all

FreeBASIC Compiler - Version 1.07.1 (2019-09-27), built for win64 (64bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
standalone

*** 161 ms for fbc.exe -gen gcc -Wc -O2 -s console
SARG
Posts: 1247
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby SARG » Feb 28, 2021 22:48

161 ms time for what ?
jj2007
Posts: 2090
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby jj2007 » Mar 01, 2021 5:45

SARG wrote:161 ms time for what ?
Sorry, I copied from the output window: my IDE measures the compile time, too - not interesting in this context.
SARG wrote:@jj2007 What do you want to prove ? that an alone guy in 2 years does less well than a very skilled team during many years ;-)
You are doing fantastic work, SARG. And I am sure you want to beat that bloody gcc compiler ;-)
SARG
Posts: 1247
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby SARG » Mar 01, 2021 10:54

jj2007 wrote:You are doing fantastic work, SARG. And I am sure you want to beat that bloody gcc compiler ;-)

Thanks, fortunately you understood my joke ;-)

My purpose is more to have the possibility to debug efficiently therefore gcc with O2 and gas64 are not competiting in the same class.
However by doing a second pass (or better more upstream) one could get better optimizations with (small) side effect of increasing compilation time. Maybe my next project after fbdebugger for Linux.

Hard to beat that..... But the code is not complex so use of only registers is easy.

Code: Select all

for n as integer=0 to elements-1   ' sum of integers
   sumi+=intvar(n)
next

gas64, many writes to memory

Code: Select all

   .Lt_0014:
   mov r11, QWORD PTR -128[rbp]
   shl r11, 3
   lea r10, INTVAR$[rip+0] #NO
   mov r8, QWORD PTR [r10+r11]
   add QWORD PTR -80[rbp], r8
   inc QWORD PTR -128[rbp]
   cmp QWORD PTR -128[rbp], 149999999
   jle .Lt_0014

gcc64 -O2, all is in registers

Code: Select all

.L4:
   mov   rsi, rdx
   add   rsi, QWORD PTR 0[rbp+rax*8]
   add   rax, 1
   cmp   rax, 150000000
   mov   rdx, rsi
   jne   .L4
srvaldez
Posts: 2689
Joined: Sep 25, 2005 21:54

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby srvaldez » May 03, 2021 10:59

hello SARG :-)
I found a small problem when moving a constant into a register without size suffix, example

Code: Select all

asm
   mov edi,1
end asm

Error: no such instruction: `found AN ERROR:prevpart empty????????'
if you add size suffix then it's OK

Code: Select all

asm
   mov edi,1L
end asm

tested with the latest Git repo
SARG
Posts: 1247
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby SARG » May 03, 2021 22:56

Hi srvaldez

You found one ;-) thank you for the report.

The issue is not related to constants but it happens if there is only one character just after the comma.
I was assuming at least one space after the comma.....

No problem with these asm lines.
mov edi, 1
mov edi,12

A fix is waiting its commit.
srvaldez
Posts: 2689
Joined: Sep 25, 2005 21:54

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Postby srvaldez » May 04, 2021 10:51

thank you SARG :-)

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 12 guests