Skip to content

Commit

Permalink
Enable clang tests/ device/ (#312)
Browse files Browse the repository at this point in the history
### Issue
Related to #47 , a follow up
from #203

### Description
Enabling clang practically repo-wide

### List of the changes
- Removed device/.clang-format and tests/.clang-format which were
previously disabling it.
- Left over src/.clang-format, since these are copied files from
external repo.
- Ran `pre-commit run --all-files`

### Testing
Code builds.

### API Changes
There are no API changes in this PR.
  • Loading branch information
broskoTT authored Nov 18, 2024
1 parent 852999c commit f749fc1
Show file tree
Hide file tree
Showing 80 changed files with 6,207 additions and 3,844 deletions.
2 changes: 0 additions & 2 deletions device/.clang-format

This file was deleted.

12 changes: 8 additions & 4 deletions device/architecture_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ namespace tt::umd {

std::unique_ptr<architecture_implementation> architecture_implementation::create(tt::ARCH architecture) {
switch (architecture) {
case tt::ARCH::BLACKHOLE: return std::make_unique<blackhole_implementation>();
case tt::ARCH::GRAYSKULL: return std::make_unique<grayskull_implementation>();
case tt::ARCH::WORMHOLE_B0: return std::make_unique<wormhole_implementation>();
default: return nullptr;
case tt::ARCH::BLACKHOLE:
return std::make_unique<blackhole_implementation>();
case tt::ARCH::GRAYSKULL:
return std::make_unique<grayskull_implementation>();
case tt::ARCH::WORMHOLE_B0:
return std::make_unique<wormhole_implementation>();
default:
return nullptr;
}
}

Expand Down
7 changes: 4 additions & 3 deletions device/architecture_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <vector>

#include "device/tlb.h"
#include "device/xy_pair.h"
#include "device/tt_arch_types.h"
#include "device/xy_pair.h"

struct tt_driver_host_address_params;
struct tt_driver_eth_interface_params;
Expand All @@ -22,7 +22,7 @@ struct tt_driver_noc_params;
namespace tt::umd {

class architecture_implementation {
public:
public:
virtual ~architecture_implementation() = default;

virtual tt::ARCH get_architecture() const = 0;
Expand Down Expand Up @@ -65,7 +65,8 @@ class architecture_implementation {
virtual std::tuple<xy_pair, xy_pair> multicast_workaround(xy_pair start, xy_pair end) const = 0;
virtual tlb_configuration get_tlb_configuration(uint32_t tlb_index) const = 0;
virtual std::optional<std::tuple<std::uint64_t, std::uint64_t>> describe_tlb(std::int32_t tlb_index) const = 0;
virtual std::pair<std::uint64_t, std::uint64_t> get_tlb_data(std::uint32_t tlb_index, const tlb_data& data) const = 0;
virtual std::pair<std::uint64_t, std::uint64_t> get_tlb_data(
std::uint32_t tlb_index, const tlb_data& data) const = 0;

virtual tt_driver_host_address_params get_host_address_params() const = 0;
virtual tt_driver_eth_interface_params get_eth_interface_params() const = 0;
Expand Down
8 changes: 4 additions & 4 deletions device/blackhole/blackhole_coordinate_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#include "device/coordinate_manager.h"

class BlackholeCoordinateManager : public CoordinateManager {

public:
BlackholeCoordinateManager(const tt_xy_pair& worker_grid_size, const std::vector<tt_xy_pair>& workers, std::size_t harvesting_mask)
: CoordinateManager(worker_grid_size, workers, harvesting_mask) {}
BlackholeCoordinateManager(
const tt_xy_pair& worker_grid_size, const std::vector<tt_xy_pair>& workers, std::size_t harvesting_mask) :
CoordinateManager(worker_grid_size, workers, harvesting_mask) {}

tt_translated_coords to_translated_coords(tt_logical_coords logical_coords) override;

tt_logical_coords to_logical_coords(tt_translated_coords translated_coords) override;

protected:
protected:
std::set<std::size_t> get_x_coordinates_to_harvest(std::size_t harvesting_mask) override;
};
20 changes: 9 additions & 11 deletions device/blackhole/blackhole_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

#include "blackhole_implementation.h"

#include "src/firmware/riscv/blackhole/host_mem_address_map.h"
#include "src/firmware/riscv/blackhole/eth_interface.h"

#include "device/cluster.h"
#include "src/firmware/riscv/blackhole/eth_interface.h"
#include "src/firmware/riscv/blackhole/host_mem_address_map.h"

constexpr std::uint32_t NOC_ADDR_LOCAL_BITS = 36; // source: noc_parameters.h, common for WH && BH
constexpr std::uint32_t NOC_ADDR_NODE_ID_BITS = 6; // source: noc_parameters.h, common for WH && BH
constexpr std::uint32_t NOC_ADDR_LOCAL_BITS = 36; // source: noc_parameters.h, common for WH && BH
constexpr std::uint32_t NOC_ADDR_NODE_ID_BITS = 6; // source: noc_parameters.h, common for WH && BH

namespace tt::umd {

Expand All @@ -26,18 +25,17 @@ std::tuple<xy_pair, xy_pair> blackhole_implementation::multicast_workaround(xy_p
}

tlb_configuration blackhole_implementation::get_tlb_configuration(uint32_t tlb_index) const {

// If TLB index is in range for 4GB tlbs (8 TLBs after 202 TLBs for 2MB)
if (tlb_index >= blackhole::TLB_COUNT_2M && tlb_index < blackhole::TLB_COUNT_2M + blackhole::TLB_COUNT_4G) {
return tlb_configuration {
return tlb_configuration{
.size = blackhole::DYNAMIC_TLB_4G_SIZE,
.base = blackhole::DYNAMIC_TLB_4G_BASE,
.cfg_addr = blackhole::DYNAMIC_TLB_4G_CFG_ADDR,
.index_offset = tlb_index - blackhole::TLB_BASE_INDEX_4G,
.offset = blackhole::TLB_4G_OFFSET,
};
}

return tlb_configuration{
.size = blackhole::DYNAMIC_TLB_2M_SIZE,
.base = blackhole::DYNAMIC_TLB_2M_BASE,
Expand Down Expand Up @@ -73,17 +71,17 @@ std::optional<std::tuple<std::uint64_t, std::uint64_t>> blackhole_implementation

std::pair<std::uint64_t, std::uint64_t> blackhole_implementation::get_tlb_data(
std::uint32_t tlb_index, const tlb_data& data) const {

if (tlb_index < blackhole::TLB_COUNT_2M) {
return data.apply_offset(blackhole::TLB_2M_OFFSET);
} else {
throw std::runtime_error("Invalid TLB index for Blackhole arch");
}

}

tt_driver_host_address_params blackhole_implementation::get_host_address_params() const {
return {::blackhole::host_mem::address_map::ETH_ROUTING_BLOCK_SIZE, ::blackhole::host_mem::address_map::ETH_ROUTING_BUFFERS_START};
return {
::blackhole::host_mem::address_map::ETH_ROUTING_BLOCK_SIZE,
::blackhole::host_mem::address_map::ETH_ROUTING_BUFFERS_START};
}

tt_driver_eth_interface_params blackhole_implementation::get_eth_interface_params() const {
Expand Down
96 changes: 61 additions & 35 deletions device/blackhole/blackhole_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#pragma once

#include <array>
#include <stdexcept>

#include "device/architecture_implementation.h"
#include "device/tlb.h"
#include <stdexcept>

namespace tt::umd {

Expand Down Expand Up @@ -59,30 +59,8 @@ enum class arc_message_type {

// DEVICE_DATA
static constexpr std::array<xy_pair, 24> DRAM_LOCATIONS = {
{{0, 0},
{0, 1},
{0, 11},
{0, 2},
{0, 10},
{0, 3},
{0, 9},
{0, 4},
{0, 8},
{0, 5},
{0, 7},
{0, 6},
{9, 0},
{9, 1},
{9, 11},
{9, 2},
{9, 10},
{9, 3},
{9, 9},
{9, 4},
{9, 8},
{9, 5},
{9, 7},
{9, 6}}};
{{0, 0}, {0, 1}, {0, 11}, {0, 2}, {0, 10}, {0, 3}, {0, 9}, {0, 4}, {0, 8}, {0, 5}, {0, 7}, {0, 6},
{9, 0}, {9, 1}, {9, 11}, {9, 2}, {9, 10}, {9, 3}, {9, 9}, {9, 4}, {9, 8}, {9, 5}, {9, 7}, {9, 6}}};

static constexpr std::array<xy_pair, 1> ARC_LOCATIONS = {{{8, 0}}};
static constexpr std::array<xy_pair, 1> PCI_LOCATIONS = {{{11, 0}}};
Expand Down Expand Up @@ -113,14 +91,14 @@ static constexpr uint32_t BROADCAST_TLB_INDEX = 0; // TODO: Copied from worm
static constexpr uint32_t STATIC_TLB_CFG_ADDR = 0x1fc00000;

static constexpr uint32_t TLB_COUNT_2M = 202;
static constexpr uint32_t TLB_BASE_2M = 0; // 0 in BAR0
static constexpr uint32_t TLB_BASE_2M = 0; // 0 in BAR0
static constexpr uint32_t TLB_BASE_INDEX_2M = 0;
static constexpr uint32_t TLB_2M_SIZE = 2 * 1024 * 1024;

static constexpr uint32_t TLB_CFG_REG_SIZE_BYTES = 12;

static constexpr uint32_t TLB_COUNT_4G = 8;
static constexpr uint32_t TLB_BASE_4G = 0; // 0 in BAR4
static constexpr uint32_t TLB_BASE_4G = 0; // 0 in BAR4
static constexpr uint32_t TLB_BASE_INDEX_4G = TLB_COUNT_2M;
static constexpr uint64_t TLB_4G_SIZE = 4ULL * 1024ULL * 1024ULL * 1024ULL;
static constexpr uint64_t DYNAMIC_TLB_4G_SIZE = TLB_4G_SIZE;
Expand Down Expand Up @@ -168,59 +146,108 @@ static constexpr uint32_t MSG_TYPE_SETUP_IATU_FOR_PEER_TO_PEER = 0x97;
} // namespace blackhole

class blackhole_implementation : public architecture_implementation {
public:
public:
tt::ARCH get_architecture() const override { return tt::ARCH::BLACKHOLE; }

uint32_t get_arc_message_arc_get_harvesting() const override {
return static_cast<uint32_t>(blackhole::arc_message_type::ARC_GET_HARVESTING);
}

uint32_t get_arc_message_arc_go_busy() const override {
return static_cast<uint32_t>(blackhole::arc_message_type::ARC_GO_BUSY);
}

uint32_t get_arc_message_arc_go_long_idle() const override {
return static_cast<uint32_t>(blackhole::arc_message_type::ARC_GO_LONG_IDLE);
}

uint32_t get_arc_message_arc_go_short_idle() const override {
return static_cast<uint32_t>(blackhole::arc_message_type::ARC_GO_SHORT_IDLE);
}

uint32_t get_arc_message_deassert_riscv_reset() const override {
return static_cast<uint32_t>(blackhole::arc_message_type::DEASSERT_RISCV_RESET);
}

uint32_t get_arc_message_get_aiclk() const override {
return static_cast<uint32_t>(blackhole::arc_message_type::GET_AICLK);
}

uint32_t get_arc_message_setup_iatu_for_peer_to_peer() const override {
return static_cast<uint32_t>(blackhole::arc_message_type::SETUP_IATU_FOR_PEER_TO_PEER);
}

uint32_t get_arc_message_test() const override { return static_cast<uint32_t>(blackhole::arc_message_type::TEST); }
uint32_t get_arc_csm_mailbox_offset() const override { throw std::runtime_error("Not supported for Blackhole arch"); return 0; }

uint32_t get_arc_csm_mailbox_offset() const override {
throw std::runtime_error("Not supported for Blackhole arch");
return 0;
}

uint32_t get_arc_reset_arc_misc_cntl_offset() const override { return blackhole::ARC_RESET_ARC_MISC_CNTL_OFFSET; }

uint32_t get_arc_reset_scratch_offset() const override { return blackhole::ARC_RESET_SCRATCH_OFFSET; }

uint32_t get_dram_channel_0_peer2peer_region_start() const override {
return blackhole::DRAM_CHANNEL_0_PEER2PEER_REGION_START;
}

uint32_t get_dram_channel_0_x() const override { return blackhole::DRAM_CHANNEL_0_X; }

uint32_t get_dram_channel_0_y() const override { return blackhole::DRAM_CHANNEL_0_Y; }

uint32_t get_broadcast_tlb_index() const override { return blackhole::BROADCAST_TLB_INDEX; }

uint32_t get_dynamic_tlb_2m_base() const override { return blackhole::DYNAMIC_TLB_2M_BASE; }

uint32_t get_dynamic_tlb_2m_size() const override { return blackhole::DYNAMIC_TLB_2M_SIZE; }
uint32_t get_dynamic_tlb_16m_base() const override { throw std::runtime_error("No 16MB TLBs for Blackhole arch"); return 0; }
uint32_t get_dynamic_tlb_16m_size() const override { throw std::runtime_error("No 16MB TLBs for Blackhole arch"); return 0; }
uint32_t get_dynamic_tlb_16m_cfg_addr() const override { throw std::runtime_error("No 16MB TLBs for Blackhole arch"); return 0; }

uint32_t get_dynamic_tlb_16m_base() const override {
throw std::runtime_error("No 16MB TLBs for Blackhole arch");
return 0;
}

uint32_t get_dynamic_tlb_16m_size() const override {
throw std::runtime_error("No 16MB TLBs for Blackhole arch");
return 0;
}

uint32_t get_dynamic_tlb_16m_cfg_addr() const override {
throw std::runtime_error("No 16MB TLBs for Blackhole arch");
return 0;
}

uint32_t get_mem_large_read_tlb() const override { return blackhole::MEM_LARGE_READ_TLB; }

uint32_t get_mem_large_write_tlb() const override { return blackhole::MEM_LARGE_WRITE_TLB; }

uint32_t get_static_tlb_cfg_addr() const override { return blackhole::STATIC_TLB_CFG_ADDR; }
uint32_t get_static_tlb_size() const override { return blackhole::STATIC_TLB_SIZE; }

uint32_t get_static_tlb_size() const override { return blackhole::STATIC_TLB_SIZE; }

uint32_t get_reg_tlb() const override { return blackhole::REG_TLB; }
uint32_t get_tlb_base_index_16m() const override { throw std::runtime_error("No 16MB TLBs for Blackhole arch"); return 0; }

uint32_t get_tlb_base_index_16m() const override {
throw std::runtime_error("No 16MB TLBs for Blackhole arch");
return 0;
}

uint32_t get_tensix_soft_reset_addr() const override { return blackhole::TENSIX_SOFT_RESET_ADDR; }

uint32_t get_grid_size_x() const override { return blackhole::GRID_SIZE_X; }

uint32_t get_grid_size_y() const override { return blackhole::GRID_SIZE_Y; }

uint32_t get_tlb_cfg_reg_size_bytes() const override { return blackhole::TLB_CFG_REG_SIZE_BYTES; }

uint32_t get_small_read_write_tlb() const override { return blackhole::MEM_SMALL_READ_WRITE_TLB; }

const std::vector<uint32_t>& get_harvesting_noc_locations() const override {
return blackhole::HARVESTING_NOC_LOCATIONS;
}

const std::vector<uint32_t>& get_t6_x_locations() const override { return blackhole::T6_X_LOCATIONS; }

const std::vector<uint32_t>& get_t6_y_locations() const override { return blackhole::T6_Y_LOCATIONS; }

std::tuple<xy_pair, xy_pair> multicast_workaround(xy_pair start, xy_pair end) const override;
Expand All @@ -231,7 +258,6 @@ class blackhole_implementation : public architecture_implementation {
tt_driver_host_address_params get_host_address_params() const override;
tt_driver_eth_interface_params get_eth_interface_params() const override;
tt_driver_noc_params get_noc_params() const override;

};

} // namespace tt::umd
Loading

0 comments on commit f749fc1

Please sign in to comment.