verilator optimizations up to 25% speedup
authorSadoon Albader <sadoon@soulserv.xyz>
Fri, 8 Sep 2023 14:47:41 +0000 (17:47 +0300)
committerSadoon Albader <sadoon@soulserv.xyz>
Fri, 8 Sep 2023 14:47:41 +0000 (17:47 +0300)
Makefile

index b764793fcdf5409be33a01f2440cea3717cb2a32..cca51a6c20d02ca083626fa35b9a29b6978565c5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,14 @@
 GHDL ?= ghdl
 GHDLFLAGS=--std=08 -frelaxed
 CFLAGS=-O3 -Wall
+
+ifeq ($(shell uname -m),ppc64le)
+CFLAG_ARCH_OPT=-mcpu=native
+else
+CFLAG_ARCH_OPT=-march=native
+endif
+
+CFLAGS=-O3 -Wall $(CFLAG_ARCH_OPT) -mtune=native
 CXXFLAGS=-g -g
 
 GHDLSYNTH ?= ghdl.so
@@ -250,6 +258,7 @@ microwatt.v: $(synth_files) $(RAM_INIT_FILE)
        $(YOSYS) -m $(GHDLSYNTH) -p "ghdl --std=08 --no-formal $(GHDL_IMAGE_GENERICS) $(GHDL_TARGET_GENERICS) $(synth_files) -e toplevel; write_verilog $@"
 
 THREADS=1 # How many threads should be used for verilator binary
+THREADS=3 # How many threads should be used for verilator binary, 3 is optimal
 # Need to investigate why yosys is hitting verilator warnings, and eventually turn on -Wall
 # --top-module toplevel
 microwatt-verilator: microwatt.v verilator/microwatt-verilator.cpp verilator/uart-verilator.c
@@ -266,6 +275,11 @@ microwatt-verilator: microwatt.v verilator/microwatt-verilator.cpp verilator/uar
            -Wno-WIDTH \
         --savable \
         --trace \
+        --threads-dpi all --x-initial fast \
+        -CFLAGS $(CFLAG_ARCH_OPT) \
+        -CFLAGS -mtune=native \
+        -CFLAGS -O3 \
+       # -CFLAGS -flto #disabled for now, no measured performance benefit \
        #    --unroll-count 256 \
        #    --output-split 5000 \
        #    --output-split-cfuncs 500 \