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

make: parallel build #1202

Merged
merged 14 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
253 changes: 9 additions & 244 deletions library/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
####################################################################################
## Copyright (c) 2018 - 2023 Analog Devices, Inc.
### SPDX short identifier: BSD-1-Clause
## Auto-generated, do not modify!
####################################################################################
####################################################################################

Expand All @@ -11,252 +10,18 @@ include ../quiet.mk
.PHONY: all lib clean clean-all
all: lib

_LIBS := $(shell find . -mindepth 2 -name Makefile -exec dirname {} \; | sort)

clean:
$(MAKE) -C ad463x_data_capture clean
$(MAKE) -C axi_ad3552r clean
$(MAKE) -C axi_ad4858 clean
$(MAKE) -C axi_ad5766 clean
$(MAKE) -C axi_ad7606x clean
$(MAKE) -C axi_ad7616 clean
$(MAKE) -C axi_ad7768 clean
$(MAKE) -C axi_ad777x clean
$(MAKE) -C axi_ad9122 clean
$(MAKE) -C axi_ad9250 clean
$(MAKE) -C axi_ad9265 clean
$(MAKE) -C axi_ad9361 clean
$(MAKE) -C axi_ad9434 clean
$(MAKE) -C axi_ad9467 clean
$(MAKE) -C axi_ad9625 clean
$(MAKE) -C axi_ad9671 clean
$(MAKE) -C axi_ad9684 clean
$(MAKE) -C axi_ad9739a clean
$(MAKE) -C axi_ad9783 clean
$(MAKE) -C axi_ad9963 clean
$(MAKE) -C axi_adaq8092 clean
$(MAKE) -C axi_adc_decimate clean
$(MAKE) -C axi_adc_trigger clean
$(MAKE) -C axi_adrv9001 clean
$(MAKE) -C axi_clkgen clean
$(MAKE) -C axi_clock_monitor clean
$(MAKE) -C axi_dac_interpolate clean
$(MAKE) -C axi_dmac clean
$(MAKE) -C axi_fan_control clean
$(MAKE) -C axi_fmcadc5_sync clean
$(MAKE) -C axi_generic_adc clean
$(MAKE) -C axi_gpreg clean
$(MAKE) -C axi_hdmi_rx clean
$(MAKE) -C axi_hdmi_tx clean
$(MAKE) -C axi_i2s_adi clean
$(MAKE) -C axi_intr_monitor clean
$(MAKE) -C axi_laser_driver clean
$(MAKE) -C axi_logic_analyzer clean
$(MAKE) -C axi_ltc235x clean
$(MAKE) -C axi_ltc2387 clean
$(MAKE) -C axi_pulse_gen clean
$(MAKE) -C axi_pwm_gen clean
$(MAKE) -C axi_rd_wr_combiner clean
$(MAKE) -C axi_spdif_rx clean
$(MAKE) -C axi_spdif_tx clean
$(MAKE) -C axi_sysid clean
$(MAKE) -C axi_tdd clean
$(MAKE) -C cn0363/cn0363_dma_sequencer clean
$(MAKE) -C cn0363/cn0363_phase_data_sync clean
$(MAKE) -C cordic_demod clean
$(MAKE) -C data_offload clean
$(MAKE) -C intel/adi_jesd204 clean
$(MAKE) -C intel/avl_adxcfg clean
$(MAKE) -C intel/avl_adxcvr clean
$(MAKE) -C intel/avl_adxcvr_octet_swap clean
$(MAKE) -C intel/avl_adxphy clean
$(MAKE) -C intel/avl_dacfifo clean
$(MAKE) -C intel/axi_adxcvr clean
$(MAKE) -C intel/common/intel_mem_asym clean
$(MAKE) -C intel/common/intel_serdes clean
$(MAKE) -C intel/jesd204_phy clean
$(MAKE) -C intel/util_clkdiv clean
$(MAKE) -C jesd204/ad_ip_jesd204_tpl_adc clean
$(MAKE) -C jesd204/ad_ip_jesd204_tpl_dac clean
$(MAKE) -C jesd204/axi_jesd204_common clean
$(MAKE) -C jesd204/axi_jesd204_rx clean
$(MAKE) -C jesd204/axi_jesd204_tx clean
$(MAKE) -C jesd204/jesd204_common clean
$(MAKE) -C jesd204/jesd204_rx clean
$(MAKE) -C jesd204/jesd204_rx_static_config clean
$(MAKE) -C jesd204/jesd204_soft_pcs_rx clean
$(MAKE) -C jesd204/jesd204_soft_pcs_tx clean
$(MAKE) -C jesd204/jesd204_tx clean
$(MAKE) -C jesd204/jesd204_tx_static_config clean
$(MAKE) -C jesd204/jesd204_versal_gt_adapter_rx clean
$(MAKE) -C jesd204/jesd204_versal_gt_adapter_tx clean
$(MAKE) -C spi_engine/axi_spi_engine clean
$(MAKE) -C spi_engine/spi_axis_reorder clean
$(MAKE) -C spi_engine/spi_engine_execution clean
$(MAKE) -C spi_engine/spi_engine_interconnect clean
$(MAKE) -C spi_engine/spi_engine_offload clean
$(MAKE) -C sysid_rom clean
$(MAKE) -C util_adcfifo clean
$(MAKE) -C util_axis_fifo clean
$(MAKE) -C util_axis_fifo_asym clean
$(MAKE) -C util_axis_resize clean
$(MAKE) -C util_axis_upscale clean
$(MAKE) -C util_bsplit clean
$(MAKE) -C util_cdc clean
$(MAKE) -C util_cic clean
$(MAKE) -C util_dacfifo clean
$(MAKE) -C util_dec256sinc24b clean
$(MAKE) -C util_delay clean
$(MAKE) -C util_do_ram clean
$(MAKE) -C util_extract clean
$(MAKE) -C util_fir_dec clean
$(MAKE) -C util_fir_int clean
$(MAKE) -C util_gmii_to_rgmii clean
$(MAKE) -C util_hbm clean
$(MAKE) -C util_i2c_mixer clean
$(MAKE) -C util_mfifo clean
$(MAKE) -C util_mii_to_rmii clean
$(MAKE) -C util_pack/util_cpack2 clean
$(MAKE) -C util_pack/util_upack2 clean
$(MAKE) -C util_pad clean
$(MAKE) -C util_pulse_gen clean
$(MAKE) -C util_rfifo clean
$(MAKE) -C util_sigma_delta_spi clean
$(MAKE) -C util_tdd_sync clean
$(MAKE) -C util_var_fifo clean
$(MAKE) -C util_wfifo clean
$(MAKE) -C xilinx/axi_adcfifo clean
$(MAKE) -C xilinx/axi_adxcvr clean
$(MAKE) -C xilinx/axi_dacfifo clean
$(MAKE) -C xilinx/axi_xcvrlb clean
$(MAKE) -C xilinx/util_adxcvr clean
$(MAKE) -C xilinx/util_clkdiv clean
FORCE:
$(_LIBS): FORCE
$(MAKE) -C $@ $(TARGET)

$(MAKE) -C interfaces clean
clean: TARGET:=clean
clean: $(_LIBS)
clean-all: clean


clean-all:clean


lib:
$(MAKE) -C ad463x_data_capture
$(MAKE) -C axi_ad3552r
$(MAKE) -C axi_ad4858
$(MAKE) -C axi_ad5766
$(MAKE) -C axi_ad7606x
$(MAKE) -C axi_ad7616
$(MAKE) -C axi_ad7768
$(MAKE) -C axi_ad777x
$(MAKE) -C axi_ad9122
$(MAKE) -C axi_ad9250
$(MAKE) -C axi_ad9265
$(MAKE) -C axi_ad9361
$(MAKE) -C axi_ad9434
$(MAKE) -C axi_ad9467
$(MAKE) -C axi_ad9625
$(MAKE) -C axi_ad9671
$(MAKE) -C axi_ad9684
$(MAKE) -C axi_ad9739a
$(MAKE) -C axi_ad9783
$(MAKE) -C axi_ad9963
$(MAKE) -C axi_adaq8092
$(MAKE) -C axi_adc_decimate
$(MAKE) -C axi_adc_trigger
$(MAKE) -C axi_adrv9001
$(MAKE) -C axi_clkgen
$(MAKE) -C axi_clock_monitor
$(MAKE) -C axi_dac_interpolate
$(MAKE) -C axi_dmac
$(MAKE) -C axi_fan_control
$(MAKE) -C axi_fmcadc5_sync
$(MAKE) -C axi_generic_adc
$(MAKE) -C axi_gpreg
$(MAKE) -C axi_hdmi_rx
$(MAKE) -C axi_hdmi_tx
$(MAKE) -C axi_i2s_adi
$(MAKE) -C axi_intr_monitor
$(MAKE) -C axi_laser_driver
$(MAKE) -C axi_logic_analyzer
$(MAKE) -C axi_ltc235x
$(MAKE) -C axi_ltc2387
$(MAKE) -C axi_pulse_gen
$(MAKE) -C axi_pwm_gen
$(MAKE) -C axi_rd_wr_combiner
$(MAKE) -C axi_spdif_rx
$(MAKE) -C axi_spdif_tx
$(MAKE) -C axi_sysid
$(MAKE) -C axi_tdd
$(MAKE) -C cn0363/cn0363_dma_sequencer
$(MAKE) -C cn0363/cn0363_phase_data_sync
$(MAKE) -C cordic_demod
$(MAKE) -C data_offload
$(MAKE) -C intel/adi_jesd204
$(MAKE) -C intel/avl_adxcfg
$(MAKE) -C intel/avl_adxcvr
$(MAKE) -C intel/avl_adxcvr_octet_swap
$(MAKE) -C intel/avl_adxphy
$(MAKE) -C intel/avl_dacfifo
$(MAKE) -C intel/axi_adxcvr
$(MAKE) -C intel/common/intel_mem_asym
$(MAKE) -C intel/common/intel_serdes
$(MAKE) -C intel/jesd204_phy
$(MAKE) -C intel/util_clkdiv
$(MAKE) -C jesd204/ad_ip_jesd204_tpl_adc
$(MAKE) -C jesd204/ad_ip_jesd204_tpl_dac
$(MAKE) -C jesd204/axi_jesd204_common
$(MAKE) -C jesd204/axi_jesd204_rx
$(MAKE) -C jesd204/axi_jesd204_tx
$(MAKE) -C jesd204/jesd204_common
$(MAKE) -C jesd204/jesd204_rx
$(MAKE) -C jesd204/jesd204_rx_static_config
$(MAKE) -C jesd204/jesd204_soft_pcs_rx
$(MAKE) -C jesd204/jesd204_soft_pcs_tx
$(MAKE) -C jesd204/jesd204_tx
$(MAKE) -C jesd204/jesd204_tx_static_config
$(MAKE) -C jesd204/jesd204_versal_gt_adapter_rx
$(MAKE) -C jesd204/jesd204_versal_gt_adapter_tx
$(MAKE) -C spi_engine/axi_spi_engine
$(MAKE) -C spi_engine/spi_axis_reorder
$(MAKE) -C spi_engine/spi_engine_execution
$(MAKE) -C spi_engine/spi_engine_interconnect
$(MAKE) -C spi_engine/spi_engine_offload
$(MAKE) -C sysid_rom
$(MAKE) -C util_adcfifo
$(MAKE) -C util_axis_fifo
$(MAKE) -C util_axis_fifo_asym
$(MAKE) -C util_axis_resize
$(MAKE) -C util_axis_upscale
$(MAKE) -C util_bsplit
$(MAKE) -C util_cdc
$(MAKE) -C util_cic
$(MAKE) -C util_dacfifo
$(MAKE) -C util_dec256sinc24b
$(MAKE) -C util_delay
$(MAKE) -C util_do_ram
$(MAKE) -C util_extract
$(MAKE) -C util_fir_dec
$(MAKE) -C util_fir_int
$(MAKE) -C util_gmii_to_rgmii
$(MAKE) -C util_hbm
$(MAKE) -C util_i2c_mixer
$(MAKE) -C util_mfifo
$(MAKE) -C util_mii_to_rmii
$(MAKE) -C util_pack/util_cpack2
$(MAKE) -C util_pack/util_upack2
$(MAKE) -C util_pad
$(MAKE) -C util_pulse_gen
$(MAKE) -C util_rfifo
$(MAKE) -C util_sigma_delta_spi
$(MAKE) -C util_tdd_sync
$(MAKE) -C util_var_fifo
$(MAKE) -C util_wfifo
$(MAKE) -C xilinx/axi_adcfifo
$(MAKE) -C xilinx/axi_adxcvr
$(MAKE) -C xilinx/axi_dacfifo
$(MAKE) -C xilinx/axi_xcvrlb
$(MAKE) -C xilinx/util_adxcvr
$(MAKE) -C xilinx/util_clkdiv

$(MAKE) -C interfaces
lib: TARGET:=
lib: $(_LIBS)

####################################################################################
####################################################################################
28 changes: 16 additions & 12 deletions library/scripts/library.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLEAN_TARGET += tb/libraries

GENERIC_DEPS += $(HDL_LIBRARY_PATH)../scripts/adi_env.tcl

.PHONY: all intel intel_dep xilinx xilinx_dep clean clean-all
.PHONY: all intel intel_dep xilinx clean clean-all

all: intel xilinx

Expand Down Expand Up @@ -83,22 +83,26 @@ ifneq ($(XILINX_DEPS),)

XILINX_DEPS += $(GENERIC_DEPS)
XILINX_DEPS += $(HDL_LIBRARY_PATH)scripts/adi_ip_xilinx.tcl
XILINX_DEPS += $(foreach dep,$(XILINX_LIB_DEPS),$(HDL_LIBRARY_PATH)$(dep)/component.xml)
_XILINX_LIB_DEPS = $(foreach dep,$(XILINX_LIB_DEPS),$(HDL_LIBRARY_PATH)$(dep)/component.xml)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also do this to library/Makefile ?
I mean, move the project list to a variable to be used as a dependencies, so we can also use the -j .
There, I think it is better to keep the list instead of globing.

(if not, I can do it later also)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I'll have a look

_XILINX_INTF_DEPS = $(foreach dep,$(XILINX_INTERFACE_DEPS),$(HDL_LIBRARY_PATH)$(dep))

xilinx: xilinx_dep component.xml
xilinx: component.xml

component.xml: $(XILINX_DEPS)
.DELETE_ON_ERROR:

component.xml: $(XILINX_DEPS) $(_XILINX_INTF_DEPS) $(_XILINX_LIB_DEPS)
-rm -rf $(CLEAN_TARGET)
$(call build, \
$(VIVADO) $(LIBRARY_NAME)_ip.tcl, \
flock component.xml -c "$(VIVADO) $(LIBRARY_NAME)_ip.tcl", \
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks you for your initiative and effort. This optimization will be appreciated by everyone.

Let me continue with what I would change. There are two issues at this line:

  1. flock creates an empty component.xml, regardless of the success/fail status, an component.xml will result after the make call. So, when someone will call make, for the second time, a library that failed, will not be rebuild. Because the component.xml is there.

  2. We want any error in `the library build to stop the whole build. You wrote this in another commit:
    "Implicitly, this also fixes missing build dependencies such as:
    make: *** No rule to make target '../../../library/axi_clkgen/component.xml', needed by 'adrv9009_zcu102.sdk/system_top.xsa'. Stop."
    This is not a feature for us. If someone uses a release or stable branch, it does not matter that much. But in development it surely does. If a library build fails, the project build that depends on that library will fail in the end.
    With this in mind the uglier scenarios will arise on the support forums. For us, trying to figure out why a project build fails for someone who does not give us the whole log or does not states the modifications of libraries in a reference design.
    Also, working on a project with high resource demands, for which a build takes 3 hours or more will result in wasted time and resources for a developer or for our CI flow.
    My suggestions is to remove the component.xml if the build fails and pass the error status

     $(call build, \
             flock component.xml -c "$(VIVADO) $(LIBRARY_NAME)_ip.tcl", \
             $(LIBRARY_NAME)_ip.log, \
             $(HL)$(LIBRARY_NAME)$(NC) library) || (ERR=$$? && rm component.xml && exit $$ERR);
    

If you have a better solution, please add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @AndreiGrozav,

Thanks for testing this, and apologies for the delay.

  1. flock creates an empty component.xml, regardless of the success/fail status, an component.xml will result after the make call. So, when someone will call make, for the second time, a library that failed, will not be rebuild. Because the component.xml is there.

interesting! I definitely missed that. I like your approach, I can't really find anything within flock to take care of cleaning up if the command fails.

actually, maybe .DELETE_ON_ERROR would work here. I don't know if we want to be more conservative and take care of this in individual targets.

Do you have a preference?

  1. We want any error in `the library build to stop the whole build.

I definitely agree with that, the commit message might be misleading. If I'm not mistaken, this error message happens if you try using make -j before applying any commits from this branch.
Assuming I address the issue in 1. if an IP core build fails the project target won't get run because make will detect an issue in build dependencies. The only difference with master is that it would finish current builds.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a preference.

$(LIBRARY_NAME)_ip.log, \
$(HL)$(LIBRARY_NAME)$(NC) library)

xilinx_dep:
@for lib in $(XILINX_LIB_DEPS); do \
$(MAKE) -C $(HDL_LIBRARY_PATH)$${lib} xilinx || exit $$?; \
done
@for intf in $(XILINX_INTERFACE_DEPS); do \
$(MAKE) -C $(HDL_LIBRARY_PATH)$${intf} xilinx || exit $$?; \
done
$(_XILINX_INTF_DEPS):
$(MAKE) -C $(dir $@) $(notdir $@)

$(_XILINX_LIB_DEPS):
$(MAKE) -C $(dir $@) xilinx

%.xml:
$(MAKE) -C $(dir $@) $(notdir $@)
endif
35 changes: 16 additions & 19 deletions projects/scripts/project-xilinx.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## SPDX short identifier: BSD-1-Clause
####################################################################################

# Assumes this file is in prpojects/scripts/project-xilinx.mk
# Assumes this file is in projects/scripts/project-xilinx.mk
HDL_PROJECT_PATH := $(subst scripts/project-xilinx.mk,,$(lastword $(MAKEFILE_LIST)))
HDL_LIBRARY_PATH := $(HDL_PROJECT_PATH)../library/

Expand Down Expand Up @@ -74,11 +74,14 @@ M_DEPS += $(HDL_PROJECT_PATH)scripts/adi_project_xilinx.tcl
M_DEPS += $(HDL_PROJECT_PATH)../scripts/adi_env.tcl
M_DEPS += $(HDL_PROJECT_PATH)scripts/adi_board.tcl

M_DEPS += $(foreach dep,$(LIB_DEPS),$(HDL_LIBRARY_PATH)$(dep)/component.xml)
M_DEPS += $(foreach dep,$(LIB_DEPS),$(HDL_LIBRARY_PATH)$(dep)/)

.PHONY: all lib clean clean-all

all: lib $(PROJECT_NAME).sdk/system_top.xsa
all: $(PROJECT_NAME).sdk/system_top.xsa

lib: TARGET:=xilinx
lib: $(M_DEPS)

clean:
-rm -f reference.dcp
Expand All @@ -87,13 +90,9 @@ clean:
$(HL)$(PROJECT_NAME)$(NC) project)
-rm -Rf ${DIR_NAME}

clean-all: clean
@for lib in $(LIB_DEPS); do \
$(MAKE) -C $(HDL_LIBRARY_PATH)$${lib} clean; \
done
@for dir in ${CLEAN_DIRS}; do \
rm -Rf $${dir}; \
done
clean-all: TARGET:=clean
clean-all: clean $(M_DEPS)
@rm -Rf $(CLEAN_DIRS)

MODE ?= "default"

Expand All @@ -115,12 +114,10 @@ $(PROJECT_NAME).sdk/system_top.xsa: $(M_DEPS)
$(PROJECT_NAME)_vivado.log, \
$(HL)$(PROJECT_NAME)$(NC) project)

lib:
@for lib in $(LIB_DEPS); do \
if [ -n "${REQUIRED_VIVADO_VERSION}" ]; then \
$(MAKE) -C $(HDL_LIBRARY_PATH)$${lib} xilinx REQUIRED_VIVADO_VERSION=${REQUIRED_VIVADO_VERSION} || exit $$?; \
else \
$(MAKE) -C $(HDL_LIBRARY_PATH)$${lib} xilinx || exit $$?; \
fi; \
done

FORCE:
$(HDL_LIBRARY_PATH)%/: FORCE
if [ -n "${REQUIRED_VIVADO_VERSION}" ]; then \
$(MAKE) -C $(dir $@) $(TARGET) REQUIRED_VIVADO_VERSION=${REQUIRED_VIVADO_VERSION} || exit $$?; \
else \
$(MAKE) -C $(dir $@) $(TARGET) || exit $$?; \
fi;
6 changes: 3 additions & 3 deletions quiet.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ ifneq ($(VERBOSE),1)
# $(2): Logfile name
# $(3): Textual description of the task
define build
@echo -n "Building $(strip $(3)) [$(HL)$(CURDIR)/$(strip $(2))$(NC)] ..."
@echo $(if $(filter -j%,$(MAKEFLAGS)),,-n) "Building $(strip $(3)) [$(HL)$(CURDIR)/$(strip $(2))$(NC)] ..."
$(strip $(1)) >> $(strip $(2)) 2>&1; \
(ERR=$$?; if [ $$ERR = 0 ]; then \
echo " $(GREEN)OK$(NC)"; \
echo "$(if $(filter -j%,$(MAKEFLAGS)),Build $(strip $(3)) [$(HL)$(CURDIR)/$(strip $(2))$(NC)]) $(GREEN)OK$(NC)"; \
else \
echo " $(RED)FAILED$(NC)"; \
echo "$(if $(filter -j%,$(MAKEFLAGS)),Build $(strip $(3)) [$(HL)$(CURDIR)/$(strip $(2))$(NC)]) $(RED)FAILED$(NC)"; \
echo "For details see $(HL)$(CURDIR)/$(strip $(2))$(NC)"; \
echo ""; \
fi; exit $$ERR)
Expand Down