mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-04-20 06:49:15 +00:00
[CK_TILE] Enable printing more structures in CK-Tile (#2443)
* Add more printing to core cktile * Revert other changes in static encoding pattern * Refactor to using a free print() function * Remove loops and print just the containers * Print tuple with better formatting, fix sequence compilation * Add some tests for print utility * Add print utility header * Print for static_encoding_pattern * add buffer_view printing * Align vector_traits * Fix formatting * Lower-case enum strings Co-authored-by: Christopher Millette <63608002+cgmillette@users.noreply.github.com> * Remove empty comment lines * Fix test with lower-case too * Reduce repeated code in print tests, move helper function closer to type definition, test X&Y * Add test_print_common.hpp * add print.hpp in core.hpp --------- Co-authored-by: Aviral Goel <aviral.goel@amd.com> Co-authored-by: Christopher Millette <63608002+cgmillette@users.noreply.github.com> Co-authored-by: Adam Osewski <19374865+aosewski@users.noreply.github.com>
This commit is contained in:
4
test/ck_tile/utility/CMakeLists.txt
Normal file
4
test/ck_tile/utility/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
message("-- Adding: test/ck_tile/utility/")
|
||||
|
||||
# Add print tests
|
||||
add_subdirectory(print)
|
||||
8
test/ck_tile/utility/print/CMakeLists.txt
Normal file
8
test/ck_tile/utility/print/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
# Print utility tests
|
||||
add_gtest_executable(test_print_sequence test_print_sequence.cpp)
|
||||
add_gtest_executable(test_print_array test_print_array.cpp)
|
||||
add_gtest_executable(test_print_tuple test_print_tuple.cpp)
|
||||
add_gtest_executable(test_print_coordinate_transform test_print_coordinate_transform.cpp)
|
||||
add_gtest_executable(test_print_static_encoding_pattern test_print_static_encoding_pattern.cpp)
|
||||
add_gtest_executable(test_print_buffer_view test_print_buffer_view.cpp)
|
||||
add_gtest_executable(test_print_basic_types test_print_basic_types.cpp)
|
||||
70
test/ck_tile/utility/print/README.md
Normal file
70
test/ck_tile/utility/print/README.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# Print Function Tests
|
||||
|
||||
This directory contains unit tests for testing the print functionality of various data structures and coordinate transformations in the composable_kernel library.
|
||||
|
||||
## Tests Included
|
||||
|
||||
### test_print_sequence.cpp
|
||||
Tests the print functionality for `sequence<...>` containers:
|
||||
- Simple sequences with multiple elements
|
||||
- Single element sequences
|
||||
- Empty sequences
|
||||
- Longer sequences
|
||||
|
||||
### test_print_array.cpp
|
||||
Tests the print functionality for `array<T, N>` containers:
|
||||
- Arrays with integer values
|
||||
- Single element arrays
|
||||
- Empty arrays (size 0)
|
||||
- Arrays with floating point values
|
||||
|
||||
### test_print_tuple.cpp
|
||||
Tests the print functionality for `tuple<...>` containers:
|
||||
- Simple tuples with numbers
|
||||
- Single element tuples
|
||||
- Empty tuples
|
||||
- Mixed type tuples
|
||||
|
||||
### test_print_coordinate_transform.cpp
|
||||
Tests the print functionality for coordinate transformation structures:
|
||||
- `pass_through` transform
|
||||
- `embed` transform
|
||||
- `merge` transform
|
||||
- `unmerge` transform
|
||||
- `freeze` transform
|
||||
|
||||
## Testing Approach
|
||||
|
||||
All tests use Google Test's `CaptureStdout()` functionality to capture the output from print functions and verify the formatting:
|
||||
|
||||
```cpp
|
||||
testing::internal::CaptureStdout();
|
||||
print(object);
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(output, "expected_format");
|
||||
```
|
||||
|
||||
This approach enables testing of print function output without affecting the console during test execution.
|
||||
|
||||
## Building and Running
|
||||
|
||||
The tests are integrated into the CMake build system. To build and run the print tests:
|
||||
|
||||
```bash
|
||||
# Build the specific test
|
||||
make test_print_sequence
|
||||
|
||||
# Run the test
|
||||
./test_print_sequence
|
||||
|
||||
# Or run all print tests using CTest
|
||||
ctest -R "test_print"
|
||||
```
|
||||
|
||||
## Adding New Tests
|
||||
|
||||
To add tests for new data structures:
|
||||
|
||||
1. Create a new test file: `test_print_<structure_name>.cpp`
|
||||
2. Follow the existing pattern using `CaptureStdout()`
|
||||
3. Add the test executable to `CMakeLists.txt`
|
||||
59
test/ck_tile/utility/print/test_print_array.cpp
Normal file
59
test/ck_tile/utility/print/test_print_array.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include "test_print_common.hpp"
|
||||
#include "ck_tile/core/container/array.hpp"
|
||||
#include "ck_tile/core/utility/print.hpp"
|
||||
|
||||
namespace ck_tile {
|
||||
|
||||
class PrintArrayTest : public PrintTest
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(PrintArrayTest, PrintIntArray)
|
||||
{
|
||||
// Test printing array<int, 3>
|
||||
array<int, 3> arr{10, 20, 30};
|
||||
|
||||
std::string output = CapturePrintOutput(arr);
|
||||
|
||||
// The expected format should match the array print function implementation
|
||||
EXPECT_EQ(output, "array{size: 3, data: [10, 20, 30]}");
|
||||
}
|
||||
|
||||
TEST_F(PrintArrayTest, PrintSingleElementArray)
|
||||
{
|
||||
// Test printing array<int, 1>
|
||||
array<int, 1> arr{42};
|
||||
|
||||
std::string output = CapturePrintOutput(arr);
|
||||
|
||||
EXPECT_EQ(output, "array{size: 1, data: [42]}");
|
||||
}
|
||||
|
||||
TEST_F(PrintArrayTest, PrintEmptyArray)
|
||||
{
|
||||
// Test printing array<int, 0> (empty array)
|
||||
array<int, 0> arr{};
|
||||
|
||||
std::string output = CapturePrintOutput(arr);
|
||||
|
||||
EXPECT_EQ(output, "array{size: 0, data: []}");
|
||||
}
|
||||
|
||||
TEST_F(PrintArrayTest, PrintFloatArray)
|
||||
{
|
||||
// Test printing array with float values
|
||||
array<float, 2> arr{3.14f, 2.71f};
|
||||
|
||||
std::string output = CapturePrintOutput(arr);
|
||||
|
||||
// Note: float printing format may vary, so we'll test for basic structure
|
||||
EXPECT_TRUE(output.find("array{size: 2, data: [") == 0);
|
||||
EXPECT_TRUE(output.find("3.14") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("2.71") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("]}") == output.length() - 2);
|
||||
}
|
||||
|
||||
} // namespace ck_tile
|
||||
76
test/ck_tile/utility/print/test_print_basic_types.cpp
Normal file
76
test/ck_tile/utility/print/test_print_basic_types.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include "test_print_common.hpp"
|
||||
#include "ck_tile/core/utility/print.hpp"
|
||||
|
||||
namespace ck_tile {
|
||||
|
||||
class PrintBasicTypesTest : public PrintTest
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(PrintBasicTypesTest, PrintIntArray)
|
||||
{
|
||||
int arr[4] = {1, 2, 3, 4};
|
||||
|
||||
std::string output = CapturePrintOutput(arr);
|
||||
|
||||
EXPECT_EQ(output, "[1, 2, 3, 4]");
|
||||
}
|
||||
|
||||
TEST_F(PrintBasicTypesTest, PrintFloatArray)
|
||||
{
|
||||
float arr[3] = {1.5f, 2.5f, 3.5f};
|
||||
|
||||
std::string output = CapturePrintOutput(arr);
|
||||
|
||||
// Note: floating point formatting may vary, so we check for key elements
|
||||
EXPECT_TRUE(output.find("[") == 0);
|
||||
EXPECT_TRUE(output.find("1.5") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("2.5") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("3.5") != std::string::npos);
|
||||
EXPECT_TRUE(output.back() == ']');
|
||||
EXPECT_TRUE(output.find(", ") != std::string::npos);
|
||||
}
|
||||
|
||||
TEST_F(PrintBasicTypesTest, PrintDoubleArray)
|
||||
{
|
||||
double arr[2] = {10.123, 20.456};
|
||||
|
||||
std::string output = CapturePrintOutput(arr);
|
||||
|
||||
EXPECT_TRUE(output.find("[") == 0);
|
||||
EXPECT_TRUE(output.find("10.123") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("20.456") != std::string::npos);
|
||||
EXPECT_TRUE(output.back() == ']');
|
||||
}
|
||||
|
||||
TEST_F(PrintBasicTypesTest, PrintUnsignedIntArray)
|
||||
{
|
||||
unsigned int arr[3] = {100u, 200u, 300u};
|
||||
|
||||
std::string output = CapturePrintOutput(arr);
|
||||
|
||||
EXPECT_EQ(output, "[100, 200, 300]");
|
||||
}
|
||||
|
||||
TEST_F(PrintBasicTypesTest, PrintCharArray)
|
||||
{
|
||||
char arr[5] = {'a', 'b', 'c', 'd', 'e'};
|
||||
|
||||
std::string output = CapturePrintOutput(arr);
|
||||
|
||||
EXPECT_EQ(output, "[a, b, c, d, e]");
|
||||
}
|
||||
|
||||
TEST_F(PrintBasicTypesTest, PrintSingleElementArray)
|
||||
{
|
||||
int arr[1] = {42};
|
||||
|
||||
std::string output = CapturePrintOutput(arr);
|
||||
|
||||
EXPECT_EQ(output, "[42]");
|
||||
}
|
||||
|
||||
} // namespace ck_tile
|
||||
78
test/ck_tile/utility/print/test_print_buffer_view.cpp
Normal file
78
test/ck_tile/utility/print/test_print_buffer_view.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include "test_print_common.hpp"
|
||||
#include "ck_tile/core/tensor/buffer_view.hpp"
|
||||
#include "ck_tile/core/utility/print.hpp"
|
||||
|
||||
namespace ck_tile {
|
||||
|
||||
class PrintBufferViewTest : public PrintTest
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(PrintBufferViewTest, PrintGenericBufferView)
|
||||
{
|
||||
// Test printing generic address space buffer_view
|
||||
float data[4] = {100.f, 200.f, 300.f, 400.f};
|
||||
auto bv = make_buffer_view<address_space_enum::generic>(&data, 4);
|
||||
|
||||
std::string output = CapturePrintOutput(bv);
|
||||
|
||||
// Verify the output contains expected information
|
||||
EXPECT_TRUE(output.find("buffer_view{AddressSpace: generic") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("p_data_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("buffer_size_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("invalid_element_value_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("}") != std::string::npos);
|
||||
}
|
||||
|
||||
TEST_F(PrintBufferViewTest, PrintGlobalBufferView)
|
||||
{
|
||||
// Test printing global address space buffer_view
|
||||
float data[4] = {100.f, 200.f, 300.f, 400.f};
|
||||
auto bv = make_buffer_view<address_space_enum::global>(&data, 4);
|
||||
|
||||
std::string output = CapturePrintOutput(bv);
|
||||
|
||||
// Verify the output contains expected information
|
||||
EXPECT_TRUE(output.find("buffer_view{AddressSpace: global") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("p_data_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("buffer_size_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("invalid_element_value_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("}") != std::string::npos);
|
||||
}
|
||||
|
||||
TEST_F(PrintBufferViewTest, PrintLdsBufferView)
|
||||
{
|
||||
// Test printing LDS address space buffer_view
|
||||
float data[4] = {100.f, 200.f, 300.f, 400.f};
|
||||
auto bv = make_buffer_view<address_space_enum::lds>(data, 4);
|
||||
|
||||
std::string output = CapturePrintOutput(bv);
|
||||
|
||||
// Verify the output contains expected information
|
||||
EXPECT_TRUE(output.find("buffer_view{AddressSpace: lds") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("p_data_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("buffer_size_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("invalid_element_value_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("}") != std::string::npos);
|
||||
}
|
||||
|
||||
TEST_F(PrintBufferViewTest, PrintVgprBufferView)
|
||||
{
|
||||
// Test printing VGPR address space buffer_view
|
||||
float data[4] = {1.5f, 2.5f, 3.5f, 4.5f};
|
||||
auto bv = make_buffer_view<address_space_enum::vgpr>(data, 4);
|
||||
|
||||
std::string output = CapturePrintOutput(bv);
|
||||
|
||||
// Verify the output contains expected information
|
||||
EXPECT_TRUE(output.find("buffer_view{AddressSpace: vgpr") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("p_data_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("buffer_size_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("invalid_element_value_:") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("}") != std::string::npos);
|
||||
}
|
||||
|
||||
} // namespace ck_tile
|
||||
25
test/ck_tile/utility/print/test_print_common.hpp
Normal file
25
test/ck_tile/utility/print/test_print_common.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/gtest-spi.h>
|
||||
|
||||
#include "ck_tile/core/utility/print.hpp"
|
||||
|
||||
class PrintTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override {}
|
||||
void TearDown() override {}
|
||||
// Helper function to capture and return the output of a print function
|
||||
template <typename T>
|
||||
std::string CapturePrintOutput(const T& type)
|
||||
{
|
||||
using namespace ck_tile;
|
||||
testing::internal::CaptureStdout();
|
||||
print(type);
|
||||
return testing::internal::GetCapturedStdout();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,83 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include "test_print_common.hpp"
|
||||
#include "ck_tile/core/algorithm/coordinate_transform.hpp"
|
||||
#include "ck_tile/core/utility/print.hpp"
|
||||
|
||||
namespace ck_tile {
|
||||
|
||||
class PrintCoordinateTransformTest : public PrintTest
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(PrintCoordinateTransformTest, PrintPassThrough)
|
||||
{
|
||||
// Test printing pass_through transform
|
||||
auto pt = make_pass_through_transform(number<32>{});
|
||||
|
||||
std::string output = CapturePrintOutput(pt);
|
||||
|
||||
// Verify it contains the pass_through identifier and some structure
|
||||
EXPECT_TRUE(output.find("pass_through{") == 0);
|
||||
EXPECT_TRUE(output.find("up_lengths_") != std::string::npos);
|
||||
EXPECT_TRUE(output.back() == '}');
|
||||
}
|
||||
|
||||
TEST_F(PrintCoordinateTransformTest, PrintEmbed)
|
||||
{
|
||||
// Test printing embed transform
|
||||
auto embed_transform = make_embed_transform(make_tuple(number<4>{}, number<8>{}),
|
||||
make_tuple(number<1>{}, number<4>{}));
|
||||
|
||||
std::string output = CapturePrintOutput(embed_transform);
|
||||
|
||||
// Verify it contains the embed identifier and key fields
|
||||
EXPECT_TRUE(output.find("embed{") == 0);
|
||||
EXPECT_TRUE(output.find("up_lengths_") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("coefficients_") != std::string::npos);
|
||||
EXPECT_TRUE(output.back() == '}');
|
||||
}
|
||||
|
||||
TEST_F(PrintCoordinateTransformTest, PrintMerge)
|
||||
{
|
||||
// Test printing merge transform
|
||||
auto merge_transform = make_merge_transform(make_tuple(number<4>{}, number<8>{}));
|
||||
|
||||
std::string output = CapturePrintOutput(merge_transform);
|
||||
|
||||
// Verify it contains merge identifier and key fields
|
||||
EXPECT_TRUE(output.find("merge") ==
|
||||
0); // Could be merge_v2_magic_division or merge_v3_division_mod
|
||||
EXPECT_TRUE(output.find("low_lengths_") != std::string::npos ||
|
||||
output.find("up_lengths_") != std::string::npos);
|
||||
EXPECT_TRUE(output.back() == '}');
|
||||
}
|
||||
|
||||
TEST_F(PrintCoordinateTransformTest, PrintUnmerge)
|
||||
{
|
||||
// Test printing unmerge transform
|
||||
auto unmerge_transform = make_unmerge_transform(make_tuple(number<4>{}, number<8>{}));
|
||||
|
||||
std::string output = CapturePrintOutput(unmerge_transform);
|
||||
|
||||
// Verify it contains the unmerge identifier and key fields
|
||||
EXPECT_TRUE(output.find("unmerge{") == 0);
|
||||
EXPECT_TRUE(output.find("up_lengths_") != std::string::npos);
|
||||
EXPECT_TRUE(output.back() == '}');
|
||||
}
|
||||
|
||||
TEST_F(PrintCoordinateTransformTest, PrintFreeze)
|
||||
{
|
||||
// Test printing freeze transform
|
||||
auto freeze_transform = make_freeze_transform(number<5>{});
|
||||
|
||||
std::string output = CapturePrintOutput(freeze_transform);
|
||||
|
||||
// Verify it contains the freeze identifier and key fields
|
||||
EXPECT_TRUE(output.find("freeze{") == 0);
|
||||
EXPECT_TRUE(output.find("low_idx_") != std::string::npos);
|
||||
EXPECT_TRUE(output.back() == '}');
|
||||
}
|
||||
|
||||
} // namespace ck_tile
|
||||
45
test/ck_tile/utility/print/test_print_sequence.cpp
Normal file
45
test/ck_tile/utility/print/test_print_sequence.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include "test_print_common.hpp"
|
||||
#include "ck_tile/core/utility/print.hpp"
|
||||
#include "ck_tile/core/container/sequence.hpp"
|
||||
|
||||
namespace ck_tile {
|
||||
|
||||
class PrintSequenceTest : public PrintTest
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(PrintSequenceTest, PrintSimpleSequence)
|
||||
{
|
||||
// Test printing sequence<1, 5, 8>
|
||||
constexpr auto seq = sequence<1, 5, 8>{};
|
||||
|
||||
std::string output = CapturePrintOutput(seq);
|
||||
|
||||
// Verify the output format
|
||||
EXPECT_EQ(output, "sequence<1, 5, 8>");
|
||||
}
|
||||
|
||||
TEST_F(PrintSequenceTest, PrintSingleElementSequence)
|
||||
{
|
||||
// Test printing sequence<42>
|
||||
constexpr auto seq = sequence<42>{};
|
||||
|
||||
std::string output = CapturePrintOutput(seq);
|
||||
|
||||
EXPECT_EQ(output, "sequence<42>");
|
||||
}
|
||||
|
||||
TEST_F(PrintSequenceTest, PrintEmptySequence)
|
||||
{
|
||||
// Test printing sequence<> (empty sequence)
|
||||
constexpr auto seq = sequence<>{};
|
||||
|
||||
std::string output = CapturePrintOutput(seq);
|
||||
|
||||
EXPECT_EQ(output, "sequence<>");
|
||||
}
|
||||
|
||||
} // namespace ck_tile
|
||||
@@ -0,0 +1,89 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include "test_print_common.hpp"
|
||||
#include "ck_tile/core/algorithm/static_encoding_pattern.hpp"
|
||||
#include "ck_tile/core/utility/print.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace ck_tile {
|
||||
|
||||
class PrintStaticEncodingPatternTest : public PrintTest
|
||||
{
|
||||
protected:
|
||||
void TestY0Y1Y2(const std::string& output, auto Y0, auto Y1, auto Y2)
|
||||
{
|
||||
std::stringstream expected;
|
||||
expected << "<Y0, Y1, Y2>: <" << Y0 << ", " << Y1 << ", " << Y2 << ">";
|
||||
EXPECT_TRUE(output.find(expected.str()) != std::string::npos);
|
||||
}
|
||||
void TestX0X1(const std::string& output, auto X0, auto X1)
|
||||
{
|
||||
std::stringstream expected;
|
||||
expected << "<X0, X1>: <" << X0 << ", " << X1 << ">";
|
||||
EXPECT_TRUE(output.find(expected.str()) != std::string::npos);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(PrintStaticEncodingPatternTest, PrintThreadRakedPattern)
|
||||
{
|
||||
// Test printing thread raked pattern
|
||||
using PatternType =
|
||||
TileDistributionEncodingPattern2D<64, 8, 16, 4, tile_distribution_pattern::thread_raked>;
|
||||
PatternType pattern;
|
||||
|
||||
std::string output = CapturePrintOutput(pattern);
|
||||
|
||||
// Verify the output contains expected information
|
||||
EXPECT_TRUE(output.find("TileDistributionEncodingPattern2D") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("BlockSize:64") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("YPerTile:8") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("XPerTile:16") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("VecSize:4") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("thread_raked") != std::string::npos);
|
||||
TestY0Y1Y2(output, PatternType::Y0, PatternType::Y1, PatternType::Y2);
|
||||
TestX0X1(output, PatternType::X0, PatternType::X1);
|
||||
}
|
||||
|
||||
TEST_F(PrintStaticEncodingPatternTest, PrintWarpRakedPattern)
|
||||
{
|
||||
// Test printing warp raked pattern
|
||||
using PatternType =
|
||||
TileDistributionEncodingPattern2D<128, 16, 32, 8, tile_distribution_pattern::warp_raked>;
|
||||
PatternType pattern;
|
||||
|
||||
std::string output = CapturePrintOutput(pattern);
|
||||
|
||||
// Verify the output contains expected information
|
||||
EXPECT_TRUE(output.find("TileDistributionEncodingPattern2D") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("BlockSize:128") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("YPerTile:16") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("XPerTile:32") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("VecSize:8") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("warp_raked") != std::string::npos);
|
||||
TestY0Y1Y2(output, PatternType::Y0, PatternType::Y1, PatternType::Y2);
|
||||
TestX0X1(output, PatternType::X0, PatternType::X1);
|
||||
}
|
||||
|
||||
TEST_F(PrintStaticEncodingPatternTest, PrintBlockRakedPattern)
|
||||
{
|
||||
// Test printing block raked pattern
|
||||
using PatternType =
|
||||
TileDistributionEncodingPattern2D<256, 32, 64, 16, tile_distribution_pattern::block_raked>;
|
||||
PatternType pattern;
|
||||
|
||||
std::string output = CapturePrintOutput(pattern);
|
||||
|
||||
// Verify the output contains expected information
|
||||
EXPECT_TRUE(output.find("TileDistributionEncodingPattern2D") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("BlockSize:256") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("YPerTile:32") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("XPerTile:64") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("VecSize:16") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("block_raked") != std::string::npos);
|
||||
TestY0Y1Y2(output, PatternType::Y0, PatternType::Y1, PatternType::Y2);
|
||||
TestX0X1(output, PatternType::X0, PatternType::X1);
|
||||
}
|
||||
|
||||
} // namespace ck_tile
|
||||
66
test/ck_tile/utility/print/test_print_tuple.cpp
Normal file
66
test/ck_tile/utility/print/test_print_tuple.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#include "test_print_common.hpp"
|
||||
#include "ck_tile/core/container/tuple.hpp"
|
||||
#include "ck_tile/core/numeric/integral_constant.hpp"
|
||||
#include "ck_tile/core/utility/print.hpp"
|
||||
|
||||
namespace ck_tile {
|
||||
|
||||
class PrintTupleTest : public PrintTest
|
||||
{
|
||||
};
|
||||
|
||||
TEST_F(PrintTupleTest, PrintSimpleTuple)
|
||||
{
|
||||
// Test printing tuple with numbers
|
||||
auto tup = make_tuple(number<1>{}, number<5>{}, number<8>{});
|
||||
|
||||
std::string output = CapturePrintOutput(tup);
|
||||
|
||||
// Verify the output format matches tuple print implementation
|
||||
EXPECT_TRUE(output.find("tuple<") == 0);
|
||||
EXPECT_TRUE(output.find("1") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("5") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("8") != std::string::npos);
|
||||
EXPECT_TRUE(output.back() == '>');
|
||||
}
|
||||
|
||||
TEST_F(PrintTupleTest, PrintSingleElementTuple)
|
||||
{
|
||||
// Test printing tuple with single element
|
||||
auto tup = make_tuple(number<42>{});
|
||||
|
||||
std::string output = CapturePrintOutput(tup);
|
||||
|
||||
EXPECT_TRUE(output.find("tuple<") == 0);
|
||||
EXPECT_TRUE(output.find("42") != std::string::npos);
|
||||
EXPECT_TRUE(output.back() == '>');
|
||||
}
|
||||
|
||||
TEST_F(PrintTupleTest, PrintEmptyTuple)
|
||||
{
|
||||
// Test printing empty tuple
|
||||
auto tup = make_tuple();
|
||||
|
||||
std::string output = CapturePrintOutput(tup);
|
||||
|
||||
EXPECT_EQ(output, "tuple<>");
|
||||
}
|
||||
|
||||
TEST_F(PrintTupleTest, PrintMixedTypeTuple)
|
||||
{
|
||||
// Test printing tuple with mixed types (numbers and constants)
|
||||
auto tup = make_tuple(number<10>{}, constant<20>{}, number<30>{});
|
||||
|
||||
std::string output = CapturePrintOutput(tup);
|
||||
|
||||
EXPECT_TRUE(output.find("tuple<") == 0);
|
||||
EXPECT_TRUE(output.find("10") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("20") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("30") != std::string::npos);
|
||||
EXPECT_TRUE(output.back() == '>');
|
||||
}
|
||||
|
||||
} // namespace ck_tile
|
||||
Reference in New Issue
Block a user