From 66ccc8288e243eb242ca9a680c717d05e6fc41e9 Mon Sep 17 00:00:00 2001 From: Dan Petrisko Date: Fri, 1 Sep 2023 02:35:01 -0700 Subject: [PATCH] Adding HOST_TYPE parameter to configuration rom --- hardware/hardware.mk | 1 + libraries/bsg_manycore_config.cpp | 5 +++++ libraries/bsg_manycore_config.h | 8 +++++++- libraries/bsg_manycore_cuda.cpp | 6 +++--- libraries/bsg_manycore_memsys.c | 1 - libraries/platforms/hammerblade-vcs/execution.mk | 2 ++ .../Makefile.machine.include | 3 +++ .../Makefile.machine.include | 3 +++ .../Makefile.machine.include | 3 +++ .../pod_X1Y1_ruche_X16Y8_hbm/Makefile.machine.include | 3 +++ .../Makefile.machine.include | 3 +++ .../Makefile.machine.include | 3 +++ .../Makefile.machine.include | 3 +++ .../Makefile.machine.include | 3 +++ machines/pod_X1Y1_ruche_X8Y4_hbm/Makefile.machine.include | 3 +++ .../Makefile.machine.include | 3 +++ .../Makefile.machine.include | 3 +++ .../pod_X2Y2_ruche_X16Y8_hbm/Makefile.machine.include | 3 +++ .../pod_X4Y4_ruche_X16Y8_hbm/Makefile.machine.include | 3 +++ 19 files changed, 57 insertions(+), 5 deletions(-) diff --git a/hardware/hardware.mk b/hardware/hardware.mk index 584504b02..8df60408f 100644 --- a/hardware/hardware.mk +++ b/hardware/hardware.mk @@ -175,6 +175,7 @@ $(BSG_MACHINE_PATH)/bsg_bladerunner_configuration.rom: $(BSG_MACHINE_PATH)/Makef @echo $(call dec2bin,$(BSG_MACHINE_IO_EP_CREDITS)) >> $@.temp @echo $(call dec2bin,0) >> $@.temp @echo $(call hex2bin,$(CHIP_ID)) >> $@.temp + @echo $(call dec2bin,$(BSG_MACHINE_HOST_TYPE)) >> $@.temp @cat $(BSG_MACHINE_PATH)/bsg_bladerunner_memsys.rom >> $@.temp mv $@.temp $@ diff --git a/libraries/bsg_manycore_config.cpp b/libraries/bsg_manycore_config.cpp index b7298eca3..d2f391045 100644 --- a/libraries/bsg_manycore_config.cpp +++ b/libraries/bsg_manycore_config.cpp @@ -193,6 +193,11 @@ int hb_mc_config_init(const hb_mc_config_raw_t raw[HB_MC_CONFIG_MAX], CHECK_FIELD(HB_MC_CONFIG_IO_HOST_CREDITS_CAP, idx >= HB_MC_HOST_CREDITS_MIN && idx <= HB_MC_HOST_CREDITS_MAX); config->io_host_credits_cap = idx; + // Host type + idx = raw[HB_MC_CONFIG_HOST_TYPE]; + CHECK_FIELD(HB_MC_CONFIG_HOST_TYPE, idx >= HB_MC_HOST_TYPE_PC && idx <= HB_MC_HOST_TYPE_BLACKPARROT); + config->host_type = idx; + err = hb_mc_memsys_init(&raw[HB_MC_CONFIG_MEMSYS], &config->memsys); if (err != HB_MC_SUCCESS) { bsg_pr_err("%s: Failed to initialize memory system: %s\n", diff --git a/libraries/bsg_manycore_config.h b/libraries/bsg_manycore_config.h index 0956dfaa4..db2b5814f 100644 --- a/libraries/bsg_manycore_config.h +++ b/libraries/bsg_manycore_config.h @@ -65,6 +65,10 @@ extern "C" { #define HB_MC_HOST_CREDITS_MIN 1 #define HB_MC_HOST_CREDITS_MAX 32 + // PC is off-die x86/ARM, BlackParrot is on-die host + #define HB_MC_HOST_TYPE_PC 0 + #define HB_MC_HOST_TYPE_BLACKPARROT 1 + typedef hb_mc_rom_word_t hb_mc_config_raw_t; /* Compilation Metadata */ @@ -108,6 +112,7 @@ extern "C" { uint32_t io_host_credits_cap; uint32_t io_endpoint_max_out_credits; uint32_t chip_id; + uint32_t host_type; hb_mc_memsys_t memsys; } hb_mc_config_t; @@ -142,7 +147,8 @@ extern "C" { HB_MC_CONFIG_IO_HOST_CREDITS_CAP = 26, HB_MC_CONFIG_IO_EP_MAX_OUT_CREDITS = 27, HB_MC_CONFIG_CHIP_ID = 28, - HB_MC_CONFIG_MEMSYS = 29, + HB_MC_CONFIG_HOST_TYPE = 29, + HB_MC_CONFIG_MEMSYS = 30, HB_MC_CONFIG_MAX=HB_MC_CONFIG_MEMSYS + HB_MC_MEMSYS_ROM_IDX_MAX, } hb_mc_config_id_t; diff --git a/libraries/bsg_manycore_cuda.cpp b/libraries/bsg_manycore_cuda.cpp index 6df811f60..f1a2e0df4 100644 --- a/libraries/bsg_manycore_cuda.cpp +++ b/libraries/bsg_manycore_cuda.cpp @@ -2105,7 +2105,7 @@ int hb_mc_device_pod_dma_to_device(hb_mc_device_t *device, hb_mc_pod_id_t pod_id hb_mc_pod_t *pod = &device->pods[pod_id]; // flush cache - if (!device->mc->config.memsys.dma2cache) { + if (device->mc->config.host_type == HB_MC_HOST_TYPE_PC) { err = hb_mc_manycore_pod_flush_vcache(device->mc, pod->pod_coord); if (err != HB_MC_SUCCESS) { bsg_pr_err("%s: failed to flush victim cache: %s\n", @@ -2138,7 +2138,7 @@ int hb_mc_device_pod_dma_to_device(hb_mc_device_t *device, hb_mc_pod_id_t pod_id } // invalidate cache - if (!device->mc->config.memsys.dma2cache) { + if (device->mc->config.host_type == HB_MC_HOST_TYPE_PC) { err = hb_mc_manycore_pod_invalidate_vcache(device->mc, pod->pod_coord); if (err != HB_MC_SUCCESS) { return err; @@ -2159,7 +2159,7 @@ int hb_mc_device_pod_dma_to_host(hb_mc_device_t *device, hb_mc_pod_id_t pod_id, // flush cache hb_mc_pod_t *pod = &device->pods[pod_id]; - if (!device->mc->config.memsys.dma2cache) { + if (device->mc->config.host_type == 0) { err = hb_mc_manycore_pod_flush_vcache(device->mc, pod->pod_coord); if (err != HB_MC_SUCCESS) { bsg_pr_err("%s: failed to flush victim cache: %s\n", diff --git a/libraries/bsg_manycore_memsys.c b/libraries/bsg_manycore_memsys.c index 45eabfad7..6d574918a 100644 --- a/libraries/bsg_manycore_memsys.c +++ b/libraries/bsg_manycore_memsys.c @@ -77,7 +77,6 @@ int hb_mc_memsys_set_features(hb_mc_memsys_t *memsys) memsys->feature_cache = 1; memsys->feature_dma = 0; } - memsys->dma2cache = 0; return HB_MC_SUCCESS; } diff --git a/libraries/platforms/hammerblade-vcs/execution.mk b/libraries/platforms/hammerblade-vcs/execution.mk index 60159bb3d..c21177cc6 100644 --- a/libraries/platforms/hammerblade-vcs/execution.mk +++ b/libraries/platforms/hammerblade-vcs/execution.mk @@ -35,6 +35,8 @@ RISCV_DEFINES += -Dbsg_tiles_X=$(BSG_MACHINE_POD_TILES_X) RISCV_DEFINES += -Dbsg_tiles_Y=$(BSG_MACHINE_POD_TILES_Y) include $(BSG_F1_DIR)/examples/cuda/riscv.mk +# TODO: This will always dump waves. To not dump waves, pass TRACE="" +# We should do this automatically on exec.log (not debug.log) %.log: ZYNQPARROT_EXECUTION_DIR ?= $(ZYNQPARROT_DIR)/cosim/hammerblade-example/vcs %.log: loader.o clr.riscv $(MAKE) -C $(ZYNQPARROT_EXECUTION_DIR) clean diff --git a/machines/pod_X1Y1_mesh_X2Y2_hbm_one_pseudo_channel/Makefile.machine.include b/machines/pod_X1Y1_mesh_X2Y2_hbm_one_pseudo_channel/Makefile.machine.include index f936280d5..b3db69d09 100644 --- a/machines/pod_X1Y1_mesh_X2Y2_hbm_one_pseudo_channel/Makefile.machine.include +++ b/machines/pod_X1Y1_mesh_X2Y2_hbm_one_pseudo_channel/Makefile.machine.include @@ -110,6 +110,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X1Y1_mesh_X2Y2_hbm_one_pseudo_channel_blackparrot/Makefile.machine.include b/machines/pod_X1Y1_mesh_X2Y2_hbm_one_pseudo_channel_blackparrot/Makefile.machine.include index 3bc780903..11d46f773 100644 --- a/machines/pod_X1Y1_mesh_X2Y2_hbm_one_pseudo_channel_blackparrot/Makefile.machine.include +++ b/machines/pod_X1Y1_mesh_X2Y2_hbm_one_pseudo_channel_blackparrot/Makefile.machine.include @@ -108,6 +108,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 1 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X1Y1_ruche_X16Y16_hbm_one_pseudo_channel/Makefile.machine.include b/machines/pod_X1Y1_ruche_X16Y16_hbm_one_pseudo_channel/Makefile.machine.include index 7756f92d7..acf40988f 100644 --- a/machines/pod_X1Y1_ruche_X16Y16_hbm_one_pseudo_channel/Makefile.machine.include +++ b/machines/pod_X1Y1_ruche_X16Y16_hbm_one_pseudo_channel/Makefile.machine.include @@ -110,6 +110,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X1Y1_ruche_X16Y8_hbm/Makefile.machine.include b/machines/pod_X1Y1_ruche_X16Y8_hbm/Makefile.machine.include index b2dcd7153..529c7c5db 100644 --- a/machines/pod_X1Y1_ruche_X16Y8_hbm/Makefile.machine.include +++ b/machines/pod_X1Y1_ruche_X16Y8_hbm/Makefile.machine.include @@ -107,6 +107,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X1Y1_ruche_X16Y8_hbm_one_pseudo_channel/Makefile.machine.include b/machines/pod_X1Y1_ruche_X16Y8_hbm_one_pseudo_channel/Makefile.machine.include index b31f12f12..74fddf17e 100644 --- a/machines/pod_X1Y1_ruche_X16Y8_hbm_one_pseudo_channel/Makefile.machine.include +++ b/machines/pod_X1Y1_ruche_X16Y8_hbm_one_pseudo_channel/Makefile.machine.include @@ -110,6 +110,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X1Y1_ruche_X32Y16_hbm_one_pseudo_channel/Makefile.machine.include b/machines/pod_X1Y1_ruche_X32Y16_hbm_one_pseudo_channel/Makefile.machine.include index 99629ab33..d5870058d 100644 --- a/machines/pod_X1Y1_ruche_X32Y16_hbm_one_pseudo_channel/Makefile.machine.include +++ b/machines/pod_X1Y1_ruche_X32Y16_hbm_one_pseudo_channel/Makefile.machine.include @@ -110,6 +110,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X1Y1_ruche_X4Y2_hbm_one_pseudo_channel/Makefile.machine.include b/machines/pod_X1Y1_ruche_X4Y2_hbm_one_pseudo_channel/Makefile.machine.include index c5dc34068..47d786965 100644 --- a/machines/pod_X1Y1_ruche_X4Y2_hbm_one_pseudo_channel/Makefile.machine.include +++ b/machines/pod_X1Y1_ruche_X4Y2_hbm_one_pseudo_channel/Makefile.machine.include @@ -110,6 +110,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X1Y1_ruche_X4Y4_hbm_one_pseudo_channel/Makefile.machine.include b/machines/pod_X1Y1_ruche_X4Y4_hbm_one_pseudo_channel/Makefile.machine.include index 65520b5c2..418947765 100644 --- a/machines/pod_X1Y1_ruche_X4Y4_hbm_one_pseudo_channel/Makefile.machine.include +++ b/machines/pod_X1Y1_ruche_X4Y4_hbm_one_pseudo_channel/Makefile.machine.include @@ -110,6 +110,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X1Y1_ruche_X8Y4_hbm/Makefile.machine.include b/machines/pod_X1Y1_ruche_X8Y4_hbm/Makefile.machine.include index 36e1f22b8..b8185b02e 100644 --- a/machines/pod_X1Y1_ruche_X8Y4_hbm/Makefile.machine.include +++ b/machines/pod_X1Y1_ruche_X8Y4_hbm/Makefile.machine.include @@ -107,6 +107,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X1Y1_ruche_X8Y4_hbm_one_pseudo_channel/Makefile.machine.include b/machines/pod_X1Y1_ruche_X8Y4_hbm_one_pseudo_channel/Makefile.machine.include index 02a2306f2..82d2c3fd9 100644 --- a/machines/pod_X1Y1_ruche_X8Y4_hbm_one_pseudo_channel/Makefile.machine.include +++ b/machines/pod_X1Y1_ruche_X8Y4_hbm_one_pseudo_channel/Makefile.machine.include @@ -109,6 +109,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X1Y1_ruche_X8Y8_hbm_one_pseudo_channel/Makefile.machine.include b/machines/pod_X1Y1_ruche_X8Y8_hbm_one_pseudo_channel/Makefile.machine.include index 4a139e805..73356b2cb 100644 --- a/machines/pod_X1Y1_ruche_X8Y8_hbm_one_pseudo_channel/Makefile.machine.include +++ b/machines/pod_X1Y1_ruche_X8Y8_hbm_one_pseudo_channel/Makefile.machine.include @@ -110,6 +110,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X2Y2_ruche_X16Y8_hbm/Makefile.machine.include b/machines/pod_X2Y2_ruche_X16Y8_hbm/Makefile.machine.include index c4340a01a..c8531b1c4 100644 --- a/machines/pod_X2Y2_ruche_X16Y8_hbm/Makefile.machine.include +++ b/machines/pod_X2Y2_ruche_X16Y8_hbm/Makefile.machine.include @@ -107,6 +107,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others. diff --git a/machines/pod_X4Y4_ruche_X16Y8_hbm/Makefile.machine.include b/machines/pod_X4Y4_ruche_X16Y8_hbm/Makefile.machine.include index 03000b15b..4db23be25 100644 --- a/machines/pod_X4Y4_ruche_X16Y8_hbm/Makefile.machine.include +++ b/machines/pod_X4Y4_ruche_X16Y8_hbm/Makefile.machine.include @@ -107,6 +107,9 @@ BSG_MACHINE_IO_EP_CREDITS = 32 BSG_MACHINE_IO_HOST_CREDITS = $(BSG_MACHINE_IO_EP_CREDITS) BSG_MACHINE_IO_REMOTE_LOAD_CAP = $(BSG_MACHINE_IO_EP_CREDITS) +# Host type 0 = off-chip 1 = BlackParrot +BSG_MACHINE_HOST_TYPE = 0 + ##################### Constants and Computations ##################### # Aliases required for memsys.mk, and others.