Skip to content

Commit

Permalink
#18325: resolve global namespace pollution by command_queue_interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nhuang-tt committed Feb 26, 2025
1 parent 5fc77c9 commit fe78f74
Show file tree
Hide file tree
Showing 461 changed files with 1,171 additions and 677 deletions.
2 changes: 2 additions & 0 deletions tests/tt_eager/integration_tests/test_bert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "ttnn/operations/experimental/transformer/split_query_key_value_and_split_heads/split_query_key_value_and_split_heads.hpp"
#include "ttnn/operations/experimental/transformer/concatenate_heads/concatenate_heads.hpp"

using namespace tt::tt_metal;

using Parameters = std::map<std::string, Tensor>;
using ttnn::operations::unary::UnaryOpType;
using ttnn::operations::unary::UnaryWithParam;
Expand Down
1 change: 1 addition & 0 deletions tests/tt_eager/ops/test_average_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using tt::tt_metal::DataType;
using tt::tt_metal::IDevice;
using tt::tt_metal::Layout;
using tt::tt_metal::Tensor;
using namespace tt::tt_metal;

Tensor run_avg_pool_2d_resnet(ttnn::Shape& tensor_shape, IDevice* device) {
using ttnn::operations::experimental::auto_format::AutoFormat;
Expand Down
2 changes: 1 addition & 1 deletion tests/tt_eager/ops/test_bmm_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main(int argc, char** argv) {
ttnn::operations::matmul::Matmul{
/*program_config=*/std::nullopt,
/*bcast_batch=*/std::nullopt,
operation::DEFAULT_OUTPUT_MEMORY_CONFIG,
tt::tt_metal::operation::DEFAULT_OUTPUT_MEMORY_CONFIG,
/*output_dtype=*/std::nullopt,
/*compute_kernel_config=*/std::nullopt,
/*untilize_out=*/false,
Expand Down
1 change: 1 addition & 0 deletions tests/tt_eager/ops/test_eltwise_binary_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ using tt::tt_metal::IDevice;
using tt::tt_metal::Layout;
using tt::tt_metal::OwnedStorage;
using tt::tt_metal::Tensor;
using namespace tt::tt_metal;

template <typename BinaryFunction>
Tensor host_function(const Tensor& input_tensor_a, const Tensor& input_tensor_b) {
Expand Down
3 changes: 2 additions & 1 deletion tests/tt_eager/ops/test_eltwise_unary_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ using tt::tt_metal::IDevice;
using tt::tt_metal::Layout;
using tt::tt_metal::OwnedStorage;
using tt::tt_metal::Tensor;
using namespace tt::tt_metal;

namespace detail {
float sqrt(float x) { return std::sqrt(x); }
Expand Down Expand Up @@ -159,7 +160,7 @@ namespace tt_metal {
template <bool approx_value = false>
struct exp_with_param {
static Tensor fn(const tt::tt_metal::Tensor& t) {
return ttnn::exp(t, approx_value, operation::DEFAULT_OUTPUT_MEMORY_CONFIG);
return ttnn::exp(t, approx_value, tt::tt_metal::operation::DEFAULT_OUTPUT_MEMORY_CONFIG);
}
};
} // namespace tt_metal
Expand Down
1 change: 1 addition & 0 deletions tests/tt_eager/ops/test_fold_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using namespace tt;
using namespace tt::tt_metal;
using namespace constants;
using namespace tt::tt_metal;

void run_fold(IDevice* device, const ttnn::Shape& shape) {
Tensor input_tensor = ttnn::random::random(shape).to_layout(Layout::ROW_MAJOR).to_device(device);
Expand Down
1 change: 1 addition & 0 deletions tests/tt_eager/ops/test_sfpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// #include "tt_gdb/tt_gdb.hpp"

using std::vector;
using namespace tt::tt_metal;

// SFPU maps -> relevant kernels, golden functions, comparison functions
std::map<std::string, std::map<std::string, std::string>> sfpu_op_to_hlk_op_name = {};
Expand Down
1 change: 1 addition & 0 deletions tests/tt_eager/ops/test_sliding_window_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

using std::vector;
using tt::tt_metal::Tensor;
using namespace tt::tt_metal;
using namespace ttnn::operations::sliding_window;

// From owned_buffer of type bfloat16 of create float vector for convolution operation.
Expand Down
2 changes: 2 additions & 0 deletions tests/tt_eager/tensors/test_raw_host_memory_pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
*/

using namespace tt::tt_metal;

template <typename DataType>
struct NDArray {
ttnn::Shape shape;
Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/distributed/test_mesh_sub_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace tt::tt_metal::distributed::test {
namespace {

using namespace tt::tt_metal;
using MeshSubDeviceTestSuite = GenericMeshDeviceFixture;

TEST_F(MeshSubDeviceTestSuite, SyncWorkloadsOnSubDevice) {
Expand Down
2 changes: 2 additions & 0 deletions tests/tt_metal/test_utils/test_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <sstream>
#include "metal_soc_descriptor.h"

using namespace tt::tt_metal; // test only

namespace test_args {

template <class T>
Expand Down
4 changes: 2 additions & 2 deletions tests/tt_metal/tt_fabric/common/fabric_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class ControlPlaneFixture : public ::testing::Test {
class FabricFixture : public ::testing::Test {
protected:
tt::ARCH arch_;
std::map<chip_id_t, IDevice*> devices_map_;
std::vector<IDevice*> devices_;
std::map<chip_id_t, tt::tt_metal::IDevice*> devices_map_;
std::vector<tt::tt_metal::IDevice*> devices_;
bool slow_dispatch_;

void SetUp() override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "fabric_fixture.hpp"
#include "tt_metal/llrt/tt_cluster.hpp"

using namespace tt::tt_metal;

namespace tt::tt_fabric {

TEST_F(FabricFixture, TestAsyncWrite) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <tt-metalium/tt_metal.hpp>
#include "tt_metal/impl/allocator/algorithms/free_list.hpp"

using namespace tt::tt_metal;

// TODO: Add a variant with randomized allocations and deallocations
TEST(FreeListAllocator, TestDirectedSeriesOfAllocDealloc) {
constexpr uint32_t max_size_bytes = 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <tt-metalium/allocator.hpp>
#include "tt_metal/impl/allocator/algorithms/free_list_opt.hpp"

using namespace tt::tt_metal;

// UDL to convert integer literals to SI units
constexpr size_t operator"" _KiB(unsigned long long x) { return x * 1024; }
constexpr size_t operator"" _MiB(unsigned long long x) { return x * 1024 * 1024; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// FIXME: ARCH_NAME specific
#include "dev_mem_map.h"

using namespace tt::tt_metal;

namespace unit_tests::test_l1_banking_allocator {

uint64_t get_alloc_limit(const tt::tt_metal::IDevice* device) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class CompileProgramWithKernelPathEnvVarFixture : public ::testing::Test {
}

const chip_id_t device_id = 0;
this->device_ = CreateDevice(device_id);
this->program_ = CreateProgram();
this->device_ = tt::tt_metal::CreateDevice(device_id);
this->program_ = tt::tt_metal::CreateProgram();
}

void TearDown() override {
if (!IsSkipped()) {
CloseDevice(this->device_);
tt::tt_metal::CloseDevice(this->device_);
}
}

Expand All @@ -34,7 +34,8 @@ class CompileProgramWithKernelPathEnvVarFixture : public ::testing::Test {
this->program_,
kernel_file,
core,
tt_metal::DataMovementConfig{.processor = DataMovementProcessor::RISCV_1, .noc = NOC::RISCV_1_default});
tt_metal::DataMovementConfig{
.processor = tt::tt_metal::DataMovementProcessor::RISCV_1, .noc = tt::tt_metal::NOC::RISCV_1_default});
}

void setup_kernel_dir(const string& orig_kernel_file, const string& new_kernel_file) {
Expand All @@ -55,8 +56,8 @@ class CompileProgramWithKernelPathEnvVarFixture : public ::testing::Test {
}
}

IDevice* device_;
Program program_;
tt::tt_metal::IDevice* device_;
tt::tt_metal::Program program_;

private:
bool are_preconditions_satisfied() { return this->are_env_vars_set() && this->is_kernel_dir_valid(); }
Expand Down
2 changes: 2 additions & 0 deletions tests/tt_metal/tt_metal/api/test_blockfloat_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <gtest/gtest.h>
#include <tt-metalium/blockfloat_common.hpp>

using namespace tt::tt_metal;

namespace {

void roundtrip_test_for_mantissa_rounding_with_bfp8(
Expand Down
2 changes: 2 additions & 0 deletions tests/tt_metal/tt_metal/api/test_buffer_region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "device_fixture.hpp"

using namespace tt::tt_metal;

TEST_F(DeviceSingleCardBufferFixture, TestInvalidBufferRegion) {
const InterleavedBufferConfig& buffer_config{
.device = this->device_, .size = 2048, .page_size = 32, .buffer_type = BufferType::DRAM};
Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/api/test_direct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

using std::vector;
using namespace tt;
using namespace tt::tt_metal;
using namespace tt::test_utils;
using namespace tt::test_utils::df;

Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/api/test_dram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <tt-metalium/logger.hpp>

using namespace tt;
using namespace tt::tt_metal;

namespace unit_tests_common::dram::test_dram {
struct DRAMConfig {
Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/api/test_dram_to_l1_multicast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <tt-metalium/logger.hpp>

using namespace tt;
using namespace tt::tt_metal;

namespace unit_tests_common::dram::test_dram_to_l1_multicast {

Expand Down
2 changes: 2 additions & 0 deletions tests/tt_metal/tt_metal/api/test_global_circular_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <tt-metalium/global_circular_buffer.hpp>
#include "tt_metal/include/tt_metal/program.hpp"

using namespace tt::tt_metal;

TEST_F(DispatchFixture, TensixCreateGlobalCircularBuffers) {
CoreRangeSet cores(CoreRange({1, 1}, {1, 1}));
CoreRangeSet cores2(CoreRange({1, 1}, {2, 2}));
Expand Down
2 changes: 2 additions & 0 deletions tests/tt_metal/tt_metal/api/test_global_semaphores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <tt-metalium/host_api.hpp>
#include <tt-metalium/global_semaphore.hpp>

using namespace tt::tt_metal;

TEST_F(DispatchFixture, InitializeGlobalSemaphores) {
CoreRangeSet cores(CoreRange({0, 0}, {1, 1}));

Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/api/test_kernel_creation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "compile_program_with_kernel_path_env_var_fixture.hpp"

using namespace tt;
using namespace tt::tt_metal;

// Ensures we can successfully create kernels on available compute grid
TEST_F(DispatchFixture, TensixCreateKernelsOnComputeCores) {
Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/api/test_noc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using namespace tt;
using namespace tt::test_utils;
using namespace tt::tt_metal;

namespace unit_tests::basic::test_noc {

Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/api/test_semaphores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

using std::vector;
using namespace tt;
using namespace tt::tt_metal;

namespace unit_tests::initialize_semaphores {

Expand Down
2 changes: 2 additions & 0 deletions tests/tt_metal/tt_metal/api/test_shape_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <tt-metalium/shape_base.hpp>

using namespace tt::tt_metal;

TEST(TensorShapeBaseTests, General4D) {
tt::tt_metal::ShapeBase vec({20, 30, 40, 50});
EXPECT_EQ(vec.view().size(), vec.view().size());
Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/api/test_simple_dram_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "tt_metal/test_utils/stimulus.hpp"

using tt::tt_metal::IDevice;
using namespace tt::tt_metal;
using namespace tt::test_utils;
using namespace tt::test::buffer::detail;

Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/api/test_simple_l1_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "tt_metal/test_utils/stimulus.hpp"

using tt::tt_metal::IDevice;
using namespace tt::tt_metal;
using namespace tt::test_utils;
using namespace tt::test::buffer::detail;

Expand Down
1 change: 1 addition & 0 deletions tests/tt_metal/tt_metal/api/test_soc_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "tt_metal/test_utils/env_vars.hpp"

using namespace tt;
using namespace tt::tt_metal;
using namespace tt::test_utils;

namespace unit_tests::basic::soc_desc {
Expand Down
4 changes: 4 additions & 0 deletions tests/tt_metal/tt_metal/common/command_queue_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <tt-metalium/rtoptions.hpp>
#include "llrt.hpp"

namespace tt::tt_metal {

class CommandQueueFixture : public DispatchFixture {
protected:
tt::tt_metal::IDevice* device_;
Expand Down Expand Up @@ -160,3 +162,5 @@ class CommandQueueMultiDeviceFixture : public DispatchFixture {
};

class CommandQueueMultiDeviceProgramFixture : public CommandQueueMultiDeviceFixture {};

} // namespace tt::tt_metal
4 changes: 4 additions & 0 deletions tests/tt_metal/tt_metal/common/device_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <tt-metalium/device_pool.hpp>
#include "llrt.hpp"

namespace tt::tt_metal {

class DeviceFixture : public DispatchFixture {
protected:
void SetUp() override {
Expand Down Expand Up @@ -113,3 +115,5 @@ class DeviceSingleCardFastSlowDispatchFixture : public DeviceSingleCardFixture {
}
}
};

} // namespace tt::tt_metal
4 changes: 4 additions & 0 deletions tests/tt_metal/tt_metal/common/dispatch_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <tt-metalium/device_pool.hpp>
#include "llrt.hpp"

namespace tt::tt_metal {

// A dispatch-agnostic test fixture
class DispatchFixture : public ::testing::Test {
public:
Expand Down Expand Up @@ -129,3 +131,5 @@ class DispatchFixture : public ::testing::Test {
}
}
};

} // namespace tt::tt_metal
4 changes: 3 additions & 1 deletion tests/tt_metal/tt_metal/common/matmul_test_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <tt-metalium/command_queue.hpp>
#include "llrt.hpp"

using namespace tt;
namespace tt::tt_metal {

inline std::vector<bfloat16> select_columns(std::vector<bfloat16> data, int M, int K, int N) {
if (N == K) {
Expand Down Expand Up @@ -154,3 +154,5 @@ inline bool move_tiles_to_dram(
EnqueueWriteBuffer(cq, buffer, tiles, false);
return pass;
}

} // namespace tt::tt_metal
6 changes: 5 additions & 1 deletion tests/tt_metal/tt_metal/common/multi_device_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "umd/device/types/cluster_descriptor_types.h"
#include "tt_metal/test_utils/env_vars.hpp"

namespace tt::tt_metal {

class MultiDeviceFixture : public DispatchFixture {
protected:
void SetUp() override { this->arch_ = tt::get_arch_from_string(tt::test_utils::get_umd_arch_name()); }
Expand Down Expand Up @@ -96,7 +98,7 @@ class MeshDeviceFixtureBase : public ::testing::Test {
magic_enum::enum_name(*config_.mesh_device_type));
}
// Use ethernet dispatch for more than 1 CQ on T3K/N300
DispatchCoreType core_type = (config_.num_cqs >= 2) ? DispatchCoreType::ETH : DispatchCoreType::WORKER;
auto core_type = (config_.num_cqs >= 2) ? DispatchCoreType::ETH : DispatchCoreType::WORKER;
mesh_device_ = MeshDevice::create(
MeshDeviceConfig{.mesh_shape = get_mesh_shape(*mesh_device_type)},
0,
Expand Down Expand Up @@ -178,3 +180,5 @@ class T3000MultiCQMeshDeviceFixture : public MeshDeviceFixtureBase {
T3000MultiCQMeshDeviceFixture() :
MeshDeviceFixtureBase(Config{.mesh_device_type = MeshDeviceType::T3000, .num_cqs = 2}) {}
};

} // namespace tt::tt_metal
Loading

0 comments on commit fe78f74

Please sign in to comment.