Skip to content

Commit

Permalink
Merge pull request #1991 from Pinata-Consulting/makefile-num-cores-su…
Browse files Browse the repository at this point in the history
…rprise-reduction

makefile: reduce surprises, NUM_CORES can now be specified on command line
  • Loading branch information
maliberty committed May 8, 2024
2 parents 3766633 + 8ba5932 commit d3715ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions flow/Makefile
Expand Up @@ -241,24 +241,24 @@ export RTLMP_RPT_FILE ?= partition.txt
export RTLMP_BLOCKAGE_FILE ?= $(OBJECTS_DIR)/rtlmp/partition.txt.blockage

#-------------------------------------------------------------------------------
ifeq (, $(strip $(NPROC)))
ifeq (,$(strip $(NUM_CORES)))
# Linux (utility program)
NPROC := $(shell nproc 2>/dev/null)
NUM_CORES := $(shell nproc 2>/dev/null)

ifeq (, $(strip $(NPROC)))
ifeq (,$(strip $(NUM_CORES)))
# Linux (generic)
NPROC := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
NUM_CORES := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
endif
ifeq (, $(strip $(NPROC)))
ifeq (,$(strip $(NUM_CORES)))
# BSD (at least FreeBSD and Mac OSX)
NPROC := $(shell sysctl -n hw.ncpu 2>/dev/null)
NUM_CORES := $(shell sysctl -n hw.ncpu 2>/dev/null)
endif
ifeq (, $(strip $(NPROC)))
ifeq (,$(strip $(NUM_CORES)))
# Fallback
NPROC := 1
NUM_CORES := 1
endif
endif
export NUM_CORES := $(NPROC)
export NUM_CORES

export LSORACLE_CMD ?= $(shell command -v lsoracle)
ifeq ($(LSORACLE_CMD),)
Expand All @@ -278,7 +278,7 @@ YOSYS_FLAGS += -v 3
export TIME_BIN ?= /usr/bin/time
TIME_CMD = $(TIME_BIN) -f 'Elapsed time: %E[h:]min:sec. CPU time: user %U sys %S (%P). Peak memory: %MKB.'
TIME_TEST = $(shell $(TIME_CMD) echo foo 2>/dev/null)
ifeq (, $(strip $(TIME_TEST)))
ifeq (,$(strip $(TIME_TEST)))
TIME_CMD = $(TIME_BIN)
endif

Expand Down
2 changes: 1 addition & 1 deletion flow/util/distributed.py
Expand Up @@ -488,7 +488,7 @@ def openroad(base_dir, parameters, flow_variant, path=''):
make_command += f'make -C {base_dir}/flow DESIGN_CONFIG=designs/'
make_command += f'{args.platform}/{args.design}/config.mk'
make_command += f' FLOW_VARIANT={flow_variant} {parameters}'
make_command += f' NPROC={args.openroad_threads} SHELL=bash'
make_command += f' NUM_PROCS={args.openroad_threads} SHELL=bash'
run_command(make_command,
timeout=args.timeout,
stderr_file=f'{log_path}error-make-finish.log',
Expand Down

0 comments on commit d3715ff

Please sign in to comment.