Safe CFlags - GCC 12.2.1

See my Post on “Experimental Gentoo Image”

1 Like

What were the results for:


time echo "scale=5000; 4*a(1)" | bc -l -q ; cat /proc/cpuinfo | grep "model name"; cat /proc/meminfo  | grep MemTotal

On each ? (Not everyone has hardware yet)

Here are the results


VISIONFIVE2
time echo "scale=5000; 4*a(1)" | bc -l -q ; cat /proc/cpuinfo | grep "model name"; cat /proc/meminfo  | grep MemTotal
3.141592653589793238462643383279502884197169399375105820974944592307\
81640628620899862803482534211706798214808651328230664709384460955058\
22317253594081284811174502841027019385211055596446229489549303819644\
28810975665933446128475648233786783165271201909145648566923460348610\
45432664821339360726024914127372458700660631558817488152092096282925\
40917153643678925903600113305305488204665213841469519415116094330572\
70365759591953092186117381932611793105118548074462379962749567351885\
75272489122793818301194912983367336244065664308602139494639522473719\
07021798609437027705392171762931767523846748184676694051320005681271\
45263560827785771342757789609173637178721468440901224953430146549585\
37105079227968925892354201995611212902196086403441815981362977477130\
99605187072113499999983729780499510597317328160963185950244594553469\
08302642522308253344685035261931188171010003137838752886587533208381\
42061717766914730359825349042875546873115956286388235378759375195778\
18577805321712268066130019278766111959092164201989380952572010654858\
63278865936153381827968230301952035301852968995773622599413891249721\
77528347913151557485724245415069595082953311686172785588907509838175\
46374649393192550604009277016711390098488240128583616035637076601047\
10181942955596198946767837449448255379774726847104047534646208046684\
25906949129331367702898915210475216205696602405803815019351125338243\
00355876402474964732639141992726042699227967823547816360093417216412\
19924586315030286182974555706749838505494588586926995690927210797509\
30295532116534498720275596023648066549911988183479775356636980742654\
25278625518184175746728909777727938000816470600161452491921732172147\
72350141441973568548161361157352552133475741849468438523323907394143\
33454776241686251898356948556209921922218427255025425688767179049460\
16534668049886272327917860857843838279679766814541009538837863609506\
80064225125205117392984896084128488626945604241965285022210661186306\
74427862203919494504712371378696095636437191728746776465757396241389\
08658326459958133904780275900994657640789512694683983525957098258226\
20522489407726719478268482601476990902640136394437455305068203496252\
45174939965143142980919065925093722169646151570985838741059788595977\
29754989301617539284681382686838689427741559918559252459539594310499\
72524680845987273644695848653836736222626099124608051243884390451244\
13654976278079771569143599770012961608944169486855584840635342207222\
58284886481584560285060168427394522674676788952521385225499546667278\
23986456596116354886230577456498035593634568174324112515076069479451\
09659609402522887971089314566913686722874894056010150330861792868092\
08747609178249385890097149096759852613655497818931297848216829989487\
22658804857564014270477555132379641451523746234364542858444795265867\
82105114135473573952311342716610213596953623144295248493718711014576\
54035902799344037420073105785390621983874478084784896833214457138687\
51943506430218453191048481005370614680674919278191197939952061419663\
42875444064374512371819217999839101591956181467514269123974894090718\
64942319615679452080951465502252316038819301420937621378559566389377\
87083039069792077346722182562599661501421503068038447734549202605414\
66592520149744285073251866600213243408819071048633173464965145390579\
62685610055081066587969981635747363840525714591028970641401109712062\
80439039759515677157700420337869936007230558763176359421873125147120\
53292819182618612586732157919841484882916447060957527069572209175671\
16722910981690915280173506712748583222871835209353965725121083579151\
36988209144421006751033467110314126711136990865851639831501970165151\
16851714376576183515565088490998985998238734552833163550764791853589\
32261854896321329330898570642046752590709154814165498594616371802709\
81994309924488957571282890592323326097299712084433573265489382391193\
25974636673058360414281388303203824903758985243744170291327656180937\
73444030707469211201913020330380197621101100449293215160842444859637\
66983895228684783123552658213144957685726243344189303968642624341077\
32269780280731891544110104468232527162010526522721116603966655730925\
47110557853763466820653109896526918620564769312570586356620185581007\
29360659876486117910453348850346113657686753249441668039626579787718\
55608455296541266540853061434443185867697514566140680070023787765913\
44017127494704205622305389945613140711270004078547332699390814546646\
45880797270826683063432858785698305235808933065757406795457163775254\
20211495576158140025012622859413021647155097925923099079654737612551\
76567513575178296664547791745011299614890304639947132962107340437518\
95735961458901938971311179042978285647503203198691514028708085990480\
10941214722131794764777262241425485454033215718530614228813758504306\
33217518297986622371721591607716692547487389866549494501146540628433\
66393790039769265672146385306736096571209180763832716641627488880078\
69256029022847210403172118608204190004229661711963779213375751149595\
01566049631862947265473642523081770367515906735023507283540567040386\
74351362222477158915049530984448933309634087807693259939780541934144\
73774418426312986080998886874132604720

real	1m9.992s
user	1m9.969s
sys	0m0.001s
MemTotal:        8118100 kB

RASPBERRY PI 4
time echo "scale=5000; 4*a(1)" | bc -l -q ; cat /proc/cpuinfo | grep "model name"; cat /proc/meminfo  | grep MemTotal
3.141592653589793238462643383279502884197169399375105820974944592307\
81640628620899862803482534211706798214808651328230664709384460955058\
22317253594081284811174502841027019385211055596446229489549303819644\
28810975665933446128475648233786783165271201909145648566923460348610\
45432664821339360726024914127372458700660631558817488152092096282925\
40917153643678925903600113305305488204665213841469519415116094330572\
70365759591953092186117381932611793105118548074462379962749567351885\
75272489122793818301194912983367336244065664308602139494639522473719\
07021798609437027705392171762931767523846748184676694051320005681271\
45263560827785771342757789609173637178721468440901224953430146549585\
37105079227968925892354201995611212902196086403441815981362977477130\
99605187072113499999983729780499510597317328160963185950244594553469\
08302642522308253344685035261931188171010003137838752886587533208381\
42061717766914730359825349042875546873115956286388235378759375195778\
18577805321712268066130019278766111959092164201989380952572010654858\
63278865936153381827968230301952035301852968995773622599413891249721\
77528347913151557485724245415069595082953311686172785588907509838175\
46374649393192550604009277016711390098488240128583616035637076601047\
10181942955596198946767837449448255379774726847104047534646208046684\
25906949129331367702898915210475216205696602405803815019351125338243\
00355876402474964732639141992726042699227967823547816360093417216412\
19924586315030286182974555706749838505494588586926995690927210797509\
30295532116534498720275596023648066549911988183479775356636980742654\
25278625518184175746728909777727938000816470600161452491921732172147\
72350141441973568548161361157352552133475741849468438523323907394143\
33454776241686251898356948556209921922218427255025425688767179049460\
16534668049886272327917860857843838279679766814541009538837863609506\
80064225125205117392984896084128488626945604241965285022210661186306\
74427862203919494504712371378696095636437191728746776465757396241389\
08658326459958133904780275900994657640789512694683983525957098258226\
20522489407726719478268482601476990902640136394437455305068203496252\
45174939965143142980919065925093722169646151570985838741059788595977\
29754989301617539284681382686838689427741559918559252459539594310499\
72524680845987273644695848653836736222626099124608051243884390451244\
13654976278079771569143599770012961608944169486855584840635342207222\
58284886481584560285060168427394522674676788952521385225499546667278\
23986456596116354886230577456498035593634568174324112515076069479451\
09659609402522887971089314566913686722874894056010150330861792868092\
08747609178249385890097149096759852613655497818931297848216829989487\
22658804857564014270477555132379641451523746234364542858444795265867\
82105114135473573952311342716610213596953623144295248493718711014576\
54035902799344037420073105785390621983874478084784896833214457138687\
51943506430218453191048481005370614680674919278191197939952061419663\
42875444064374512371819217999839101591956181467514269123974894090718\
64942319615679452080951465502252316038819301420937621378559566389377\
87083039069792077346722182562599661501421503068038447734549202605414\
66592520149744285073251866600213243408819071048633173464965145390579\
62685610055081066587969981635747363840525714591028970641401109712062\
80439039759515677157700420337869936007230558763176359421873125147120\
53292819182618612586732157919841484882916447060957527069572209175671\
16722910981690915280173506712748583222871835209353965725121083579151\
36988209144421006751033467110314126711136990865851639831501970165151\
16851714376576183515565088490998985998238734552833163550764791853589\
32261854896321329330898570642046752590709154814165498594616371802709\
81994309924488957571282890592323326097299712084433573265489382391193\
25974636673058360414281388303203824903758985243744170291327656180937\
73444030707469211201913020330380197621101100449293215160842444859637\
66983895228684783123552658213144957685726243344189303968642624341077\
32269780280731891544110104468232527162010526522721116603966655730925\
47110557853763466820653109896526918620564769312570586356620185581007\
29360659876486117910453348850346113657686753249441668039626579787718\
55608455296541266540853061434443185867697514566140680070023787765913\
44017127494704205622305389945613140711270004078547332699390814546646\
45880797270826683063432858785698305235808933065757406795457163775254\
20211495576158140025012622859413021647155097925923099079654737612551\
76567513575178296664547791745011299614890304639947132962107340437518\
95735961458901938971311179042978285647503203198691514028708085990480\
10941214722131794764777262241425485454033215718530614228813758504306\
33217518297986622371721591607716692547487389866549494501146540628433\
66393790039769265672146385306736096571209180763832716641627488880078\
69256029022847210403172118608204190004229661711963779213375751149595\
01566049631862947265473642523081770367515906735023507283540567040386\
74351362222477158915049530984448933309634087807693259939780541934144\
73774418426312986080998886874132604720

real	1m45.397s
user	1m45.378s
sys	0m0.010s
MemTotal:        7999720 kB
1 Like

Seems U74 on 7110 supports v1.0 version of bitmanip extension… do we really need 0p93?

Without this option in clang an error occurred. Not needed by gcc.

$ clang -O -march=rv64imafdc_zba_zbb a.c
clang: error: invalid arch name ‘rv64imafdc_zba_zbb’, requires ‘-menable-experimental-extensions’ for experimental extension ‘zba’
$ clang -O -march=rv64imafdc_zba_zbb a.c -menable-experimental-extensions
clang: error: invalid arch name ‘rv64imafdc_zba_zbb’, experimental extension requires explicit version number ‘zba’
$ clang -v
Debian clang version 13.0.1-6
Target: riscv64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/…/lib/gcc/riscv64-linux-gnu/11
Selected GCC installation: /usr/bin/…/lib/gcc/riscv64-linux-gnu/11

1 Like

For clang only, try -march=native -mtune=native

1 Like

So - final thoughts for gcc 12.2.1

COMMON_FLAGS="-O2 -pipe -fomit-frame-pointer"
OPT_FLAGS="--param l1-cache-size=32 --param l2-cache-size=2048"
CFLAGS="-mabi=lp64d -march=rv64imafdc_zicsr_zba_zbb -mcpu=sifive-u74 -mtune=sifive-7-series ${COMMON_FLAGS} ${OPT_FLAGS}"
CXXFLAGS="-mabi=lp64d -march=rv64imafdc_zicsr_zba_zbb -mcpu=sifive-u74 -mtune=sifive-7-series ${COMMON_FLAGS} ${OPT_FLAGS}"

There is no performance difference measured with nbench between 0.93 and 1.0 zba / zbb

4 Likes

nbench is a pointless toy benchmark. I really only care about Geekbench (closed source), and SPECint (paid source). On the latter Zba gives a minor but measurable uplift.

1 Like

You can download a Preview of GeekBench here

Yes I’m aware since it was first released more than a year ago, but as the source aren’t available it doesn’t allow you to see the impact of the “B” extension. FWIW, I don’t think it’s quite fair to compare GB/RISC-V to GB on x86 or Arm as the sources they use have assembly speed-paths for many of the applications, and especially some of them benefit enormously from hardware accelerators (eg. encryption instructions and SIMD). This is part of the reason they didn’t add official RISC-V support to GB 6.0 [1].

[1] personal communication with John F. Poole “I’m not sure what we’ll need to do to support RISC-V since we’re using Embree for the ray tracing workload.”

1 Like

I don’t see any advantages of precompiled binarys with unknown compilerflags and sources.

A few days ago I find this site:
https://elinux.org/RPi_Performance
maybe there are some reliable benchmark-tools.

Edit @tommythorn
How do you measure the difference between 0.93 and 1.0 zbb extension?

Be very careful with that particular combination of flags, what you’re essentially telling the compiler to do is produce a binary that dies with a SIGILL on anything but the exact same hardware that it was built on. With RISC-V it’s probably not so bad because there aren’t that many different CPUs around, but with x86 it’s a huge headache because gcc in particular seems to want to insert one single instruction in every binary that won’t execute on any other CPU stepping or variant.

3 Likes

Have any of you installed a GUI on the Visionfive2 under gentoo and if so did which one did you install? Xorg or wayland etc?

2 Likes

Not now, but I think these use flags are the key (opengl is not supported by the precompiled driver) Binary Video Blob

USE="$USE egl eglfs gles gles1 gles2 gles2-only -opengl gles3 vulkan"

If you unzip the binary blob driver, there are a lot of files to overwrite:

riscv /usr/src/img-gpu-powervr-bin-1.17.6210866 # ls -R
.:
staging  target

./staging:
usr

./staging/usr:
include  lib

./staging/usr/include:
CL  drv  EGL  GLES  GLES2  GLES3  KHR  spirv  vulkan

./staging/usr/include/CL:
cl_egl.h  cl_ext.h  cl_gl.h  cl.h  cl_half.h  cl_icd.h  cl_platform.h  cl_version.h  opencl.h

./staging/usr/include/drv:
CL  EGL  GLES  GLES3

./staging/usr/include/drv/CL:
cl_ext.h  cl_img_external_semaphore.h  cl_img_external_semaphore_sync_fd.h  cl_img_safety_mechanisms.h  cl_img_semaphore.h

./staging/usr/include/drv/EGL:
eglext.h

./staging/usr/include/drv/GLES:
glext.h

./staging/usr/include/drv/GLES3:
glimgext.h

./staging/usr/include/EGL:
eglext.h  egl.h  eglplatform.h

./staging/usr/include/GLES:
glext.h  gl.h  glplatform.h

./staging/usr/include/GLES2:
gl2ext.h  gl2.h  gl2platform.h

./staging/usr/include/GLES3:
gl32.h  gl3ext.h  gl3.h  gl3platform.h

./staging/usr/include/KHR:
khrplatform.h

./staging/usr/include/spirv:
extinst.glsl.std.450.grammar.json    GLSL.std.450.h  spirv.core.grammar.json
extinst.opencl.std.100.grammar.json  OpenCL.std.h    spirv.hpp

./staging/usr/include/vulkan:
vk_icd.h  vk_layer.h  vk_platform.h  vulkan_core.h  vulkan.h  vulkan_wayland.h  vulkan_xcb.h  vulkan_xlib.h

./staging/usr/lib:
libapicommon.a                         libOpenCL.so                         libsutu_display.so
libcompute.a                           libOpenCL.so.1                       libsutu_display.so.1.17.6210866
libcomputehwr.a                        libpds.a                             libsync_linux.a
libdbm.a                               libperf_sim.a                        libufwriter.so
libffcommon.a                          libpixfmts.a                         libufwriter.so.1.17.6210866
libffpfo.a                             libpvr_dri_support.so                libuscasm.a
libfftb.a                              libpvr_dri_support.so.1.17.6210866   libuscdisasm.a
libfftnl.a                             libPVROCL.so                         libusclink.a
libGLESv1_CM_PVR_MESA.so               libPVROCL.so.1                       libusc.so
libGLESv1_CM_PVR_MESA.so.1.17.6210866  libPVROCL.so.1.17.6210866            libusc.so.1.17.6210866
libGLESv1_CM.so                        libPVRScopeServices.so               libutil_linux.a
libGLESv1_CM.so.1                      libPVRScopeServices.so.1.17.6210866  libvertexunpack.a
libGLESv2_PVR_MESA.so                  libpvrtld.a                          libVK_IMG.so
libGLESv2_PVR_MESA.so.1.17.6210866     librenderpass.a                      libVK_IMG.so.1
libGLESv2.so                           librogue2d.a                         libVK_IMG.so.1.17.6210866
libGLESv2.so.2                         libslotpacking.a                     libvulkan-1.so
libglslcompiler.so                     libspecobj.a                         libvulkan.so
libglslcompiler.so.1.17.6210866        libsrv_um.so                         libvulkan.so.0
libglsllink.a                          libsrv_um.so.1.17.6210866            libvulkan.so.1
libIMGeglsup.a                         libsrv_um_static.a                   libvulkan.so.1.17.6210866
libimgelf.a                            libsrvut.a                           pkgconfig

./staging/usr/lib/pkgconfig:
glesv2.pc  glesv3.pc  vulkan.pc

./target:
etc  lib  usr

./target/etc:
init.d  OpenCL  vulkan

./target/etc/init.d:
rc.pvr

./target/etc/OpenCL:
vendors

./target/etc/OpenCL/vendors:
IMG.icd

./target/etc/vulkan:
icd.d

./target/etc/vulkan/icd.d:
icdconf.json

./target/lib:
firmware

./target/lib/firmware:
rgx.fw.36.50.54.182  rgx.sh.36.50.54.182

./target/usr:
lib  local

./target/usr/lib:
libGLESv1_CM_PVR_MESA.so               libpvr_dri_support.so                libufwriter.so.1.17.6210866
libGLESv1_CM_PVR_MESA.so.1.17.6210866  libpvr_dri_support.so.1.17.6210866   libusc.so
libGLESv1_CM.so                        libPVROCL.so                         libusc.so.1.17.6210866
libGLESv1_CM.so.1                      libPVROCL.so.1                       libVK_IMG.so
libGLESv2_PVR_MESA.so                  libPVROCL.so.1.17.6210866            libVK_IMG.so.1
libGLESv2_PVR_MESA.so.1.17.6210866     libPVRScopeServices.so               libVK_IMG.so.1.17.6210866
libGLESv2.so                           libPVRScopeServices.so.1.17.6210866  libvulkan-1.so
libGLESv2.so.2                         libsrv_um.so                         libvulkan.so
libglslcompiler.so                     libsrv_um.so.1.17.6210866            libvulkan.so.0
libglslcompiler.so.1.17.6210866        libsutu_display.so                   libvulkan.so.1
libOpenCL.so                           libsutu_display.so.1.17.6210866      libvulkan.so.1.17.6210866
libOpenCL.so.1                         libufwriter.so

./target/usr/local:
bin

./target/usr/local/bin:
hwperfbin2jsont     pdump              pvrhtbd      pvr_memory_test         rgx_blit_test      rgx_twiddling_test
hwperfjsonmerge.py  pdump_optimise.py  pvrhwperf    pvr_mutex_perf_test_mx  rgx_compute_test   rogue2d_fbctest
ocl_extended_test   pvrdebug           pvrlogdump   pvrsrvctl               rgx_kicksync_test  rogue2d_unittest
ocl_unit_test       pvrhtb2txt         pvrlogsplit  pvrtld                  rgx_triangle_test

Ok I try to overwrite these files. After starting swaywm, I get these errors:

00:00:00.048 [wlr] [EGL] command: eglQueryDeviceStringEXT, error: EGL_BAD_PARAMETER (0x300c), message: "eglQueryDeviceStringEXT"
00:00:00.048 [wlr] [EGL] command: eglQueryDeviceStringEXT, error: EGL_BAD_PARAMETER (0x300c), message: "eglQueryDeviceStringEXT"
MESA-LOADER: failed to open starfive: /usr/lib64/dri/starfive_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib64/dri, suffix _dri)
kmsro: driver missing
00:00:00.443 [wlr] [render/egl.c:312] Software rendering detected, please use the WLR_RENDERER_ALLOW_SOFTWARE environment variable to proceed
00:00:00.444 [wlr] [render/egl.c:554] Failed to initialize EGL context
00:00:00.444 [wlr] [render/gles2/renderer.c:679] Could not initialize EGL
00:00:00.557 [wlr] [backend/libinput/backend.c:111] libinput initialization failed, no input devices
00:00:00.557 [wlr] [backend/libinput/backend.c:112] Set WLR_LIBINPUT_NO_DEVICES=1 to suppress this check
00:00:00.558 [wlr] [backend/multi/backend.c:33] Failed to initialize backend.
00:00:00.558 [sway/server.c:302] Failed to start backend
2023-02-08 12:15:22 - [swaybg-1.2.0/main.c:582] wl_display_roundtrip failed

I have Installed xfce and have it up and running. Now to emerge firefox and other apps :slightly_smiling_face:

1 Like

I‘m also installing gentoo … hehe incidently I also decided to give xfce a try, maybe because the debian image uses it.

The thing I don‘t know yet is how i get graphics running, what exactly did you do to have x or wayland to display anything?

One thing i already read somewhere is that I would need to force lightdm to something like 1920x1080 because there are problems woth 3840x2160

1 Like

This is going to require at a minimum the binary IMG_GPU drivers and a heavily patched Mesa.

Someone else will probably get this going before I do but I am working on ebuilds: I have an ebuild for the binary driver but still working on Mesa. One thing to note is that Mesa has had large changes from the VF2 version (especially with Vulkan code) and I don’t want to rework these patches so I am not updating from 21.2.1.

We really could use some video stuff being opened, upstreamed, or otherwise maintained without enormous amounts of hacks on Mesa.

Here are some of the extra steps I took after completing the install of xorg and xfce as per the Gentoo docs.

From the Debian image copy (This was the key to get it to even start)

/usr/local/etc/X11/xorg.conf to your image under /etc/X11

make sure that the

.xinitrc file for your normal user account contains

exec startxfce4

Download the GPU files from

extract them and change the owner to root:root

then copy the contents of both the staging and target files to / for both versions starting with the oldest version.

Reboot and try to log on as your normal user.

If it fails look at /var/log/Xorg.0.log

Also look in the home directory of the user you tried to log in as and see the contents of the

.xsession-errors

emerge any programs it cannot load.