Merge pull request #657 from ucb-bar/dedup-flags
Dedup simulation flags + Small VCS Cleanup
This commit is contained in:
@@ -195,5 +195,5 @@ When building the verilator simulator there are some additional options:
|
|||||||
|
|
||||||
The ``VERILATOR_THREADS=<num>`` option enables the compiled Verilator simulator to use ``<num>`` parallel threads.
|
The ``VERILATOR_THREADS=<num>`` option enables the compiled Verilator simulator to use ``<num>`` parallel threads.
|
||||||
On a multi-socket machine, you will want to make sure all threads are on the same socket by using ``NUMACTL=1`` to enable ``numactl``.
|
On a multi-socket machine, you will want to make sure all threads are on the same socket by using ``NUMACTL=1`` to enable ``numactl``.
|
||||||
By enabling this, you will use CHipyard's ``numa_prefix`` wrapper, which is a simple wrapper around ``numactl`` that runs your verilated simulator like this: ``$(numa_prefix) ./simulator-<name> <simulator-args>``.
|
By enabling this, you will use Chipyard's ``numa_prefix`` wrapper, which is a simple wrapper around ``numactl`` that runs your verilated simulator like this: ``$(numa_prefix) ./simulator-<name> <simulator-args>``.
|
||||||
Note that both these flags are mutually exclusive, you can use either independently (though it makes sense to use ``NUMACTL`` just with ``VERILATOR_THREADS=8`` during a Verilator simulation).
|
Note that both these flags are mutually exclusive, you can use either independently (though it makes sense to use ``NUMACTL`` just with ``VERILATOR_THREADS=8`` during a Verilator simulation).
|
||||||
|
|||||||
23
sims/common-sim-flags.mk
Normal file
23
sims/common-sim-flags.mk
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#----------------------------------------------------------------------------------------
|
||||||
|
# common gcc configuration/optimization
|
||||||
|
#----------------------------------------------------------------------------------------
|
||||||
|
SIM_OPT_CXXFLAGS := -O3
|
||||||
|
|
||||||
|
SIM_CXXFLAGS = \
|
||||||
|
$(CXXFLAGS) \
|
||||||
|
$(SIM_OPT_CXXFLAGS) \
|
||||||
|
-std=c++11 \
|
||||||
|
-I$(RISCV)/include \
|
||||||
|
-I$(dramsim_dir) \
|
||||||
|
-I$(build_dir) \
|
||||||
|
$(EXTRA_SIM_CXXFLAGS)
|
||||||
|
|
||||||
|
SIM_LDFLAGS = \
|
||||||
|
$(LDFLAGS) \
|
||||||
|
-L$(RISCV)/lib \
|
||||||
|
-Wl,-rpath,$(RISCV)/lib \
|
||||||
|
-L$(sim_dir) \
|
||||||
|
-L$(dramsim_dir) \
|
||||||
|
-lfesvr \
|
||||||
|
-ldramsim \
|
||||||
|
$(EXTRA_SIM_LDFLAGS)
|
||||||
@@ -43,14 +43,22 @@ VCS = vcs -full64
|
|||||||
|
|
||||||
VCS_OPTS = $(VCS_CC_OPTS) $(VCS_NONCC_OPTS) $(PREPROC_DEFINES)
|
VCS_OPTS = $(VCS_CC_OPTS) $(VCS_NONCC_OPTS) $(PREPROC_DEFINES)
|
||||||
|
|
||||||
|
#########################################################################################
|
||||||
|
# vcs build paths
|
||||||
|
#########################################################################################
|
||||||
|
model_dir = $(build_dir)/$(long_name)
|
||||||
|
model_dir_debug = $(build_dir)/$(long_name).debug
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
# vcs simulator rules
|
# vcs simulator rules
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
$(sim): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib) $(EXTRA_SIM_REQS)
|
$(sim): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib) $(EXTRA_SIM_REQS)
|
||||||
rm -rf csrc && $(VCS) $(VCS_OPTS) $(EXTRA_SIM_SOURCES) -o $@
|
rm -rf $(model_dir)
|
||||||
|
$(VCS) $(VCS_OPTS) $(EXTRA_SIM_SOURCES) -o $@ -Mdir=$(model_dir)
|
||||||
|
|
||||||
$(sim_debug): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib) $(EXTRA_SIM_REQS)
|
$(sim_debug): $(sim_vsrcs) $(sim_common_files) $(dramsim_lib) $(EXTRA_SIM_REQS)
|
||||||
rm -rf csrc && $(VCS) $(VCS_OPTS) $(EXTRA_SIM_SOURCES) -o $@ \
|
rm -rf $(model_dir_debug)
|
||||||
|
$(VCS) $(VCS_OPTS) $(EXTRA_SIM_SOURCES) -o $@ -Mdir=$(model_dir_debug) \
|
||||||
+define+DEBUG
|
+define+DEBUG
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
@@ -65,10 +73,10 @@ $(output_dir)/%.vpd: $(output_dir)/% $(sim_debug)
|
|||||||
#########################################################################################
|
#########################################################################################
|
||||||
.PHONY: clean clean-sim clean-sim-debug
|
.PHONY: clean clean-sim clean-sim-debug
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(gen_dir) csrc $(sim_prefix)-* ucli.key vc_hdrs.h
|
rm -rf $(gen_dir) $(sim_prefix)-* ucli.key
|
||||||
|
|
||||||
clean-sim:
|
clean-sim:
|
||||||
rm -rf csrc/ $(sim) ucli.key vc_hdrs.h
|
rm -rf $(model_dir) $(build_dir)/vc_hdrs.h $(sim) $(sim).daidir ucli.key
|
||||||
|
|
||||||
clean-sim-debug:
|
clean-sim-debug:
|
||||||
rm -rf csrc/ $(sim_debug) ucli.key vc_hdrs.h
|
rm -rf $(model_dir_debug) $(build_dir)/vc_hdrs.h $(sim_debug) $(sim_debug).daidir ucli.key
|
||||||
|
|||||||
@@ -141,35 +141,19 @@ VERILATOR_NONCC_OPTS = \
|
|||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
# gcc configuration/optimization
|
# gcc configuration/optimization
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
# -flto slows down compilation on small-memory and breaks on firesim-manager
|
include $(base_dir)/sims/common-sim-flags.mk
|
||||||
CXX_OPT_FLAGS := -O3
|
|
||||||
|
|
||||||
VERILATOR_CXXFLAGS = \
|
VERILATOR_CXXFLAGS = \
|
||||||
$(CXXFLAGS) \
|
$(SIM_CXXFLAGS) \
|
||||||
$(RUNTIME_PROFILING_CFLAGS) \
|
$(RUNTIME_PROFILING_CFLAGS) \
|
||||||
$(TRACING_CFLAGS) \
|
$(TRACING_CFLAGS) \
|
||||||
$(CXX_OPT_FLAGS) \
|
|
||||||
-std=c++11 \
|
|
||||||
-D__STDC_FORMAT_MACROS \
|
-D__STDC_FORMAT_MACROS \
|
||||||
-DTEST_HARNESS=V$(VLOG_MODEL) \
|
-DTEST_HARNESS=V$(VLOG_MODEL) \
|
||||||
-DVERILATOR \
|
-DVERILATOR \
|
||||||
-I$(RISCV)/include \
|
|
||||||
-I$(dramsim_dir) \
|
|
||||||
-I$(build_dir) \
|
|
||||||
-include $(build_dir)/$(long_name).plusArgs \
|
-include $(build_dir)/$(long_name).plusArgs \
|
||||||
-include $(build_dir)/verilator.h \
|
-include $(build_dir)/verilator.h
|
||||||
$(EXTRA_SIM_CXXFLAGS)
|
|
||||||
|
|
||||||
VERILATOR_LDFLAGS = \
|
VERILATOR_LDFLAGS = $(SIM_LDFLAGS)
|
||||||
$(LDFLAGS) \
|
|
||||||
-L$(RISCV)/lib \
|
|
||||||
-Wl,-rpath,$(RISCV)/lib \
|
|
||||||
-L$(sim_dir) \
|
|
||||||
-L$(dramsim_dir) \
|
|
||||||
-lfesvr \
|
|
||||||
-lpthread \
|
|
||||||
-ldramsim \
|
|
||||||
$(EXTRA_SIM_LDFLAGS)
|
|
||||||
|
|
||||||
VERILATOR_CC_OPTS = \
|
VERILATOR_CC_OPTS = \
|
||||||
-CFLAGS "$(VERILATOR_CXXFLAGS)" \
|
-CFLAGS "$(VERILATOR_CXXFLAGS)" \
|
||||||
|
|||||||
21
vcs.mk
21
vcs.mk
@@ -14,25 +14,10 @@ RESET_DELAY ?= 777.7
|
|||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
# gcc configuration/optimization
|
# gcc configuration/optimization
|
||||||
#----------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------
|
||||||
CXX_OPT_FLAGS := -O3
|
include $(base_dir)/sims/common-sim-flags.mk
|
||||||
|
|
||||||
VCS_CXXFLAGS = \
|
VCS_CXXFLAGS = $(SIM_CXXFLAGS)
|
||||||
$(CXXFLAGS) \
|
VCS_LDFLAGS = $(SIM_LDFLAGS)
|
||||||
$(CXX_OPT_FLAGS) \
|
|
||||||
-I$(RISCV)/include \
|
|
||||||
-I$(dramsim_dir) \
|
|
||||||
-std=c++11 \
|
|
||||||
$(EXTRA_SIM_CXXFLAGS)
|
|
||||||
|
|
||||||
VCS_LDFLAGS = \
|
|
||||||
$(LDFLAGS) \
|
|
||||||
-L$(RISCV)/lib \
|
|
||||||
-Wl,-rpath,$(RISCV)/lib \
|
|
||||||
-L$(sim_dir) \
|
|
||||||
-L$(dramsim_dir) \
|
|
||||||
-lfesvr \
|
|
||||||
-ldramsim \
|
|
||||||
$(EXTRA_SIM_LDFLAGS)
|
|
||||||
|
|
||||||
# vcs requires LDFLAGS to not include library names (i.e. -l needs to be separate)
|
# vcs requires LDFLAGS to not include library names (i.e. -l needs to be separate)
|
||||||
VCS_CC_OPTS = \
|
VCS_CC_OPTS = \
|
||||||
|
|||||||
Reference in New Issue
Block a user