From 44e0090f3a197477e2e958312e811dabbad9e9f2 Mon Sep 17 00:00:00 2001 From: Austin Ho Date: Thu, 16 May 2024 16:07:32 +0000 Subject: [PATCH] #0: Remove zero length noc transaction checks from noc apis. Depend on watcher to catch this instead --- .../hw/inc/grayskull/noc_nonblocking_api.h | 90 +++++++++---------- .../hw/inc/wormhole/noc_nonblocking_api.h | 90 +++++++++---------- 2 files changed, 84 insertions(+), 96 deletions(-) diff --git a/tt_metal/hw/inc/grayskull/noc_nonblocking_api.h b/tt_metal/hw/inc/grayskull/noc_nonblocking_api.h index d4120b87c6c..cebf0e1dddc 100644 --- a/tt_metal/hw/inc/grayskull/noc_nonblocking_api.h +++ b/tt_metal/hw/inc/grayskull/noc_nonblocking_api.h @@ -47,14 +47,12 @@ inline __attribute__((always_inline)) bool noc_cmd_buf_ready(uint32_t noc, uint3 } inline __attribute__((always_inline)) void ncrisc_noc_fast_read(uint32_t noc, uint32_t cmd_buf, uint64_t src_addr, uint32_t dest_addr, uint32_t len_bytes) { - if (len_bytes > 0) { - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, dest_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, (uint32_t)src_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_MID, src_addr >> 32); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); - noc_reads_num_issued[noc] += 1; - } + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, dest_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, (uint32_t)src_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_MID, src_addr >> 32); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); + noc_reads_num_issued[noc] += 1; } inline __attribute__((always_inline)) bool ncrisc_noc_reads_flushed(uint32_t noc) { @@ -62,52 +60,48 @@ inline __attribute__((always_inline)) bool ncrisc_noc_reads_flushed(uint32_t noc } inline __attribute__((always_inline)) void ncrisc_noc_fast_write(uint32_t noc, uint32_t cmd_buf, uint32_t src_addr, uint64_t dest_addr, uint32_t len_bytes, uint32_t vc, bool mcast, bool linked, uint32_t num_dests, bool multicast_path_reserve, bool posted = false) { - if (len_bytes > 0) { - uint32_t noc_cmd_field = - NOC_CMD_CPY | NOC_CMD_WR | - NOC_CMD_VC_STATIC | - NOC_CMD_STATIC_VC(vc) | - (linked ? NOC_CMD_VC_LINKED : 0x0) | - (mcast ? ((multicast_path_reserve ? NOC_CMD_PATH_RESERVE : 0) | NOC_CMD_BRCST_PACKET) : 0x0) | - (posted ? 0 : NOC_CMD_RESP_MARKED); - - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CTRL, noc_cmd_field); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, src_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, (uint32_t)dest_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_MID, dest_addr >> 32); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); - if (posted) { - noc_posted_writes_num_issued[noc] += 1; - } else { - noc_nonposted_writes_num_issued[noc] += 1; - noc_nonposted_writes_acked[noc] += num_dests; - } - } -} + uint32_t noc_cmd_field = + NOC_CMD_CPY | NOC_CMD_WR | + NOC_CMD_VC_STATIC | + NOC_CMD_STATIC_VC(vc) | + (linked ? NOC_CMD_VC_LINKED : 0x0) | + (mcast ? ((multicast_path_reserve ? NOC_CMD_PATH_RESERVE : 0) | NOC_CMD_BRCST_PACKET) : 0x0) | + (posted ? 0 : NOC_CMD_RESP_MARKED); -inline __attribute__((always_inline)) void ncrisc_noc_fast_write_loopback_src(uint32_t noc, uint32_t cmd_buf, uint32_t src_addr, uint64_t dest_addr, uint32_t len_bytes, uint32_t vc, bool mcast, bool linked, uint32_t num_dests, bool multicast_path_reserve) { - if (len_bytes > 0) { - uint32_t noc_cmd_field = - NOC_CMD_CPY | NOC_CMD_WR | - NOC_CMD_VC_STATIC | - NOC_CMD_STATIC_VC(vc) | - (linked ? NOC_CMD_VC_LINKED : 0x0) | - (mcast ? ((multicast_path_reserve ? NOC_CMD_PATH_RESERVE : 0) | NOC_CMD_BRCST_PACKET) : 0x0) | - NOC_CMD_BRCST_SRC_INCLUDE | - NOC_CMD_RESP_MARKED; - - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CTRL, noc_cmd_field); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, src_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, (uint32_t)dest_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_MID, dest_addr >> 32); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CTRL, noc_cmd_field); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, src_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, (uint32_t)dest_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_MID, dest_addr >> 32); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); + if (posted) { + noc_posted_writes_num_issued[noc] += 1; + } else { noc_nonposted_writes_num_issued[noc] += 1; noc_nonposted_writes_acked[noc] += num_dests; } } +inline __attribute__((always_inline)) void ncrisc_noc_fast_write_loopback_src(uint32_t noc, uint32_t cmd_buf, uint32_t src_addr, uint64_t dest_addr, uint32_t len_bytes, uint32_t vc, bool mcast, bool linked, uint32_t num_dests, bool multicast_path_reserve) { + uint32_t noc_cmd_field = + NOC_CMD_CPY | NOC_CMD_WR | + NOC_CMD_VC_STATIC | + NOC_CMD_STATIC_VC(vc) | + (linked ? NOC_CMD_VC_LINKED : 0x0) | + (mcast ? ((multicast_path_reserve ? NOC_CMD_PATH_RESERVE : 0) | NOC_CMD_BRCST_PACKET) : 0x0) | + NOC_CMD_BRCST_SRC_INCLUDE | + NOC_CMD_RESP_MARKED; + + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CTRL, noc_cmd_field); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, src_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, (uint32_t)dest_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_MID, dest_addr >> 32); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); + noc_nonposted_writes_num_issued[noc] += 1; + noc_nonposted_writes_acked[noc] += num_dests; +} + inline __attribute__((always_inline)) void ncrisc_noc_blitz_write_setup(uint32_t noc, uint32_t cmd_buf, uint64_t dest_addr, uint32_t len_bytes, uint32_t vc, uint32_t num_times_to_write) { uint32_t noc_cmd_field = NOC_CMD_CPY | NOC_CMD_WR | diff --git a/tt_metal/hw/inc/wormhole/noc_nonblocking_api.h b/tt_metal/hw/inc/wormhole/noc_nonblocking_api.h index a7efe0ea14f..c3a6684ade7 100644 --- a/tt_metal/hw/inc/wormhole/noc_nonblocking_api.h +++ b/tt_metal/hw/inc/wormhole/noc_nonblocking_api.h @@ -53,14 +53,12 @@ inline __attribute__((always_inline)) bool noc_cmd_buf_ready(uint32_t noc, uint3 } inline __attribute__((always_inline)) void ncrisc_noc_fast_read(uint32_t noc, uint32_t cmd_buf, uint64_t src_addr, uint32_t dest_addr, uint32_t len_bytes) { - if (len_bytes > 0) { - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, dest_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, (uint32_t)src_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_MID, src_addr >> 32); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); - noc_reads_num_issued[noc] += 1; - } + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, dest_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, (uint32_t)src_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_MID, src_addr >> 32); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); + noc_reads_num_issued[noc] += 1; } inline __attribute__((always_inline)) bool ncrisc_noc_reads_flushed(uint32_t noc) { @@ -68,52 +66,48 @@ inline __attribute__((always_inline)) bool ncrisc_noc_reads_flushed(uint32_t noc } inline __attribute__((always_inline)) void ncrisc_noc_fast_write(uint32_t noc, uint32_t cmd_buf, uint32_t src_addr, uint64_t dest_addr, uint32_t len_bytes, uint32_t vc, bool mcast, bool linked, uint32_t num_dests, bool multicast_path_reserve, bool posted = false) { - if (len_bytes > 0) { - uint32_t noc_cmd_field = - NOC_CMD_CPY | NOC_CMD_WR | - NOC_CMD_VC_STATIC | - NOC_CMD_STATIC_VC(vc) | - (linked ? NOC_CMD_VC_LINKED : 0x0) | - (mcast ? ((multicast_path_reserve ? NOC_CMD_PATH_RESERVE : 0) | NOC_CMD_BRCST_PACKET) : 0x0) | - (posted ? 0 : NOC_CMD_RESP_MARKED); - - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CTRL, noc_cmd_field); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, src_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, (uint32_t)dest_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_MID, dest_addr >> 32); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); - if (posted) { - noc_posted_writes_num_issued[noc] += 1; - } else { - noc_nonposted_writes_num_issued[noc] += 1; - noc_nonposted_writes_acked[noc] += num_dests; - } - } -} + uint32_t noc_cmd_field = + NOC_CMD_CPY | NOC_CMD_WR | + NOC_CMD_VC_STATIC | + NOC_CMD_STATIC_VC(vc) | + (linked ? NOC_CMD_VC_LINKED : 0x0) | + (mcast ? ((multicast_path_reserve ? NOC_CMD_PATH_RESERVE : 0) | NOC_CMD_BRCST_PACKET) : 0x0) | + (posted ? 0 : NOC_CMD_RESP_MARKED); -inline __attribute__((always_inline)) void ncrisc_noc_fast_write_loopback_src(uint32_t noc, uint32_t cmd_buf, uint32_t src_addr, uint64_t dest_addr, uint32_t len_bytes, uint32_t vc, bool mcast, bool linked, uint32_t num_dests, bool multicast_path_reserve) { - if (len_bytes > 0) { - uint32_t noc_cmd_field = - NOC_CMD_CPY | NOC_CMD_WR | - NOC_CMD_VC_STATIC | - NOC_CMD_STATIC_VC(vc) | - (linked ? NOC_CMD_VC_LINKED : 0x0) | - (mcast ? ((multicast_path_reserve ? NOC_CMD_PATH_RESERVE : 0) | NOC_CMD_BRCST_PACKET) : 0x0) | - NOC_CMD_BRCST_SRC_INCLUDE | - NOC_CMD_RESP_MARKED; - - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CTRL, noc_cmd_field); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, src_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, (uint32_t)dest_addr); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_MID, dest_addr >> 32); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); - NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CTRL, noc_cmd_field); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, src_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, (uint32_t)dest_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_MID, dest_addr >> 32); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); + if (posted) { + noc_posted_writes_num_issued[noc] += 1; + } else { noc_nonposted_writes_num_issued[noc] += 1; noc_nonposted_writes_acked[noc] += num_dests; } } +inline __attribute__((always_inline)) void ncrisc_noc_fast_write_loopback_src(uint32_t noc, uint32_t cmd_buf, uint32_t src_addr, uint64_t dest_addr, uint32_t len_bytes, uint32_t vc, bool mcast, bool linked, uint32_t num_dests, bool multicast_path_reserve) { + uint32_t noc_cmd_field = + NOC_CMD_CPY | NOC_CMD_WR | + NOC_CMD_VC_STATIC | + NOC_CMD_STATIC_VC(vc) | + (linked ? NOC_CMD_VC_LINKED : 0x0) | + (mcast ? ((multicast_path_reserve ? NOC_CMD_PATH_RESERVE : 0) | NOC_CMD_BRCST_PACKET) : 0x0) | + NOC_CMD_BRCST_SRC_INCLUDE | + NOC_CMD_RESP_MARKED; + + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CTRL, noc_cmd_field); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_TARG_ADDR_LO, src_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_LO, (uint32_t)dest_addr); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_RET_ADDR_MID, dest_addr >> 32); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_AT_LEN_BE, len_bytes); + NOC_CMD_BUF_WRITE_REG(noc, cmd_buf, NOC_CMD_CTRL, NOC_CTRL_SEND_REQ); + noc_nonposted_writes_num_issued[noc] += 1; + noc_nonposted_writes_acked[noc] += num_dests; +} + inline __attribute__((always_inline)) void ncrisc_noc_blitz_write_setup(uint32_t noc, uint32_t cmd_buf, uint64_t dest_addr, uint32_t len_bytes, uint32_t vc, uint32_t num_times_to_write) { uint32_t noc_cmd_field = NOC_CMD_CPY | NOC_CMD_WR |