Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target: Add VLT_NUM_THREADS to configure threads used by verilator #148

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions target/common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ EVENTVIS_PY ?= $(UTIL_DIR)/trace/eventvis.py
# a two-liner with the OS on the first line, hence the tail -n1
VERILATOR_ROOT ?= $(dir $(shell $(VERILATOR_SEPP) which verilator | tail -n1))..
VLT_ROOT ?= ${VERILATOR_ROOT}
VLT_NUM_THREADS ?= 1

MATCH_END := '/+incdir+/ s/$$/\/*\/*/'
MATCH_BGN := 's/+incdir+//g'
Expand Down Expand Up @@ -86,7 +87,13 @@ VLT_FLAGS += -Wno-UNSIGNED
VLT_FLAGS += -Wno-UNOPTFLAT
VLT_FLAGS += -Wno-fatal
VLT_FLAGS += --unroll-count 1024
ifneq ($(VLT_NUM_THREADS), 1)
VLT_FLAGS += --threads $(VLT_NUM_THREADS)
endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can drop the if statement, as Verilator should by default behave as if --threads 1 is passed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is true for Verilator 5 but not the verilator 4 that the repo currently supports until #76 lands.
That said I think you're right and we can drop this as this is almost certainly a premature optimization and I doubt single-threaded usage will see a measureable difference.

VLT_CFLAGS += -std=c++14 -pthread
ifneq ($(VLT_NUM_THREADS), 1)
VLT_CFLAGS += -DVL_THREADED=1
endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find much information on this, but perhaps we can also always add this flag, and remove the if statement. I guess it shouldn't break the single-threaded case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Information is sadly very sparse on the flag and I only found it referenced through GitHub issues such as verilator/verilator#3668 (comment)
I had to add it as I was getting compilation errors as verilator requires it to be defined when using multiple threads.
I added a comment to clarify.

VLT_CFLAGS +=-I ${VLT_BUILDDIR} -I $(VLT_ROOT)/include -I $(VLT_ROOT)/include/vltstd -I $(VLT_FESVR)/include -I $(TB_DIR) -I ${MKFILE_DIR}/test

ANNOTATE_FLAGS ?= -q --keep-time --addr2line=$(ADDR2LINE)
Expand Down
3 changes: 3 additions & 0 deletions target/snitch_cluster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ VLT_COBJ += $(VLT_BUILDDIR)/tb/tb_bin.o
VLT_COBJ += $(VLT_BUILDDIR)/vlt/verilated.o
VLT_COBJ += $(VLT_BUILDDIR)/vlt/verilated_dpi.o
VLT_COBJ += $(VLT_BUILDDIR)/vlt/verilated_vcd_c.o
ifneq ($(VLT_NUM_THREADS), 1)
VLT_COBJ += $(VLT_BUILDDIR)/vlt/verilated_threads.o
endif
zero9178 marked this conversation as resolved.
Show resolved Hide resolved
# Bootdata
VLT_COBJ += $(VLT_BUILDDIR)/generated/bootdata.o

Expand Down
Loading