Skip to content

Commit

Permalink
Move NUM_CIRCULAR_BUFFERS to hw/inc (#14908)
Browse files Browse the repository at this point in the history
### What's changed
- `NUM_CIRCULAR_BUFFERS` moved to `circular_buffer.h`
- FW Includes no longer include `common_runtime_address_map.h`
  • Loading branch information
blozano-tt authored Nov 12, 2024
1 parent a080e2f commit 4f4542d
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 11 deletions.
2 changes: 2 additions & 0 deletions tests/tt_metal/tt_metal/perf_microbenchmark/dispatch/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "tt_metal/impl/dispatch/cq_commands.hpp"
#include "noc/noc_parameters.h"

#include "tt_metal/hostdevcommon/common_runtime_address_map.h" // NOC_0_X

extern bool debug_g;
extern bool use_coherent_data_g;
extern uint32_t dispatch_buffer_page_size_g;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "tt_metal/impl/dispatch/kernels/packet_queue_ctrl.hpp"
#include "tests/tt_metal/tt_metal/perf_microbenchmark/routing/kernels/traffic_gen_test.hpp"

#include "tt_metal/hostdevcommon/common_runtime_address_map.h" // NOC_0_X

#include "llrt/hal.hpp"

Expand Down
3 changes: 0 additions & 3 deletions tt_metal/hostdevcommon/common_runtime_address_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
constexpr static std::uint32_t L1_KERNEL_CONFIG_BASE = MEM_MAP_END;
constexpr static std::uint32_t L1_KERNEL_CONFIG_SIZE = 69 * 1024;

constexpr static std::uint32_t NUM_CIRCULAR_BUFFERS = 32;
constexpr static std::uint32_t UINT32_WORDS_PER_CIRCULAR_BUFFER_CONFIG = 4;

// Helper functions to convert NoC coordinates to NoC-0 coordinates, used in metal as "physical" coordinates.
#define NOC_0_X(noc_index, noc_size_x, x) (noc_index == 0 ? (x) : (noc_size_x-1-(x)))
#define NOC_0_Y(noc_index, noc_size_y, y) (noc_index == 0 ? (y) : (noc_size_y-1-(y)))
Expand Down
2 changes: 1 addition & 1 deletion tt_metal/hw/inc/blackhole/eth_l1_address_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <cstdint>

#include "tt_metal/hostdevcommon/common_runtime_address_map.h"
#include "noc/noc_parameters.h" // L1_ALIGNMENT

namespace eth_l1_mem {

Expand Down
4 changes: 4 additions & 0 deletions tt_metal/hw/inc/blackhole/noc_nonblocking_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include "noc_parameters.h"
#include "dev_msgs.h"

// Helper functions to convert NoC coordinates to NoC-0 coordinates, used in metal as "physical" coordinates.
#define NOC_0_X(noc_index, noc_size_x, x) (noc_index == 0 ? (x) : (noc_size_x-1-(x)))
#define NOC_0_Y(noc_index, noc_size_y, y) (noc_index == 0 ? (y) : (noc_size_y-1-(y)))

////
/*TODO: RT review this file, currently using wormhole b0 copy, check if any changes needed for BH*/
constexpr uint32_t DYNAMIC_NOC_NCRISC_WR_CMD_BUF = 2; // all writes share cmd buf
Expand Down
11 changes: 10 additions & 1 deletion tt_metal/hw/inc/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@

#pragma once

#include "hostdevcommon/common_runtime_address_map.h"
#include <cstdint>

#if defined(KERNEL_BUILD) || defined(FW_BUILD)
#include "risc_attribs.h"
#else
#define tt_l1_ptr
#define tt_reg_ptr
#endif

constexpr static std::uint32_t NUM_CIRCULAR_BUFFERS = 32;
constexpr static std::uint32_t UINT32_WORDS_PER_CIRCULAR_BUFFER_CONFIG = 4;

// The command queue read interface controls reads from the issue region, host owns the issue region write interface
// Commands and data to send to device are pushed into the issue region
Expand Down
1 change: 0 additions & 1 deletion tt_metal/hw/inc/dataflow_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "debug/sanitize_noc.h"
#include "debug/waypoint.h"
#include "eth_l1_address_map.h"
#include "hostdevcommon/common_runtime_address_map.h"
#include "hostdevcommon/common_values.hpp"
#include "risc_attribs.h"
#include "third_party/umd/device/tt_silicon_driver_common.hpp"
Expand Down
1 change: 1 addition & 0 deletions tt_metal/hw/inc/debug/sanitize_noc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "dev_msgs.h"
#include "noc_overlay_parameters.h"
#include "noc_parameters.h"
#include "noc_nonblocking_api.h"

// A couple defines for specifying read/write and multi/unicast
#define DEBUG_SANITIZE_NOC_READ true
Expand Down
4 changes: 4 additions & 0 deletions tt_metal/hw/inc/grayskull/noc_nonblocking_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include "noc_parameters.h"
#include "dev_msgs.h"

// Helper functions to convert NoC coordinates to NoC-0 coordinates, used in metal as "physical" coordinates.
#define NOC_0_X(noc_index, noc_size_x, x) (noc_index == 0 ? (x) : (noc_size_x-1-(x)))
#define NOC_0_Y(noc_index, noc_size_y, y) (noc_index == 0 ? (y) : (noc_size_y-1-(y)))

////

constexpr uint32_t DYNAMIC_NOC_NCRISC_WR_CMD_BUF = 2; // all writes share cmd buf
Expand Down
1 change: 0 additions & 1 deletion tt_metal/hw/inc/risc_attribs.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ union tt_uint64_t {
#define tt_l1_ptr __attribute__((rvtt_l1_ptr))
#define tt_reg_ptr __attribute__((rvtt_reg_ptr))


inline __attribute__((always_inline)) uint64_t tt_l1_load(tt_uint64_t tt_l1_ptr *p)
{
tt_uint64_t v;
Expand Down
1 change: 0 additions & 1 deletion tt_metal/hw/inc/risc_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <cstdint>

#include "eth_l1_address_map.h"
#include "hostdevcommon/common_runtime_address_map.h"
#include "limits.h"
#include "mod_div_lib.h"
#include "noc_overlay_parameters.h"
Expand Down
4 changes: 4 additions & 0 deletions tt_metal/hw/inc/wormhole/noc_nonblocking_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include "noc_parameters.h"
#include "dev_msgs.h"

// Helper functions to convert NoC coordinates to NoC-0 coordinates, used in metal as "physical" coordinates.
#define NOC_0_X(noc_index, noc_size_x, x) (noc_index == 0 ? (x) : (noc_size_x-1-(x)))
#define NOC_0_Y(noc_index, noc_size_y, y) (noc_index == 0 ? (y) : (noc_size_y-1-(y)))

////

// Use VC 1 for unicast writes, and VC 4 for mcast writes
Expand Down
3 changes: 2 additions & 1 deletion tt_metal/impl/buffers/circular_buffer_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

#include "tt_metal/common/logger.hpp"
#include "tt_metal/common/tt_backend_api_types.hpp"
#include "tt_metal/hostdevcommon/common_runtime_address_map.h" // NUM_CIRCULAR_BUFFERS
#include "tt_metal/impl/buffers/buffer.hpp"
#include "tt_metal/impl/tile/tile.hpp"

#include "tt_metal/hw/inc/circular_buffer.h"

namespace tt::tt_metal {
inline namespace v0 {

Expand Down
2 changes: 2 additions & 0 deletions tt_metal/impl/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "tt_metal/tools/profiler/tt_metal_tracy.hpp"
#include "llrt/hal.hpp"

#include "tt_metal/hostdevcommon/common_runtime_address_map.h" // NOC_0_X

namespace tt {

namespace tt_metal {
Expand Down
2 changes: 2 additions & 0 deletions tt_metal/impl/program/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "tt_metal/program.hpp"
#include "tt_metal/third_party/tracy/public/tracy/Tracy.hpp"

#include "tt_metal/hostdevcommon/common_runtime_address_map.h" // L1_KERNEL_CONFIG_SIZE

namespace tt::tt_metal {

namespace {
Expand Down
2 changes: 1 addition & 1 deletion tt_metal/jit_build/data_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "fmt/base.h" // for format_string
#include "tt_metal/common/assert.hpp" // for tt_throw, TT_FATAL
#include "tt_metal/common/base_types.hpp" // for UnpackToDestMode
#include "hostdevcommon/common_runtime_address_map.h" // for NUM_CIRCULAR_B...
#include "tt_metal/hw/inc/circular_buffer.h"

namespace tt {

Expand Down
4 changes: 3 additions & 1 deletion tt_metal/jit_build/genfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@

#include "common/tt_backend_api_types.hpp"
#include "common/utils.hpp"
#include "hostdevcommon/common_runtime_address_map.h"
#include "hostdevcommon/common_runtime_address_map.h" // NOC_0_X
#include "hostdevcommon/common_values.hpp"
#include "jit_build/build.hpp"
#include "jit_build/settings.hpp"

#include "tt_metal/hw/inc/circular_buffer.h"

namespace fs = std::filesystem;

using namespace std;
Expand Down

0 comments on commit 4f4542d

Please sign in to comment.