[CK_BUILDER] Put global CK functions in an the CK namespace (#3232)

* Wrap ck host utitlies in CK namespace.

The CK and CK-Tile source code bases are incompatible because CK is not properly using namespaces everywhere. In particular, we need to put hip_check_error in the ck namespace.

Move all functions in include/ck_/host_utility that were in global namespace into the ck namespace.

There may be additional namespace problems like this, and it's possible we'll have namespace clashes. But it is good design to properly guard our to code bases (CK and CKTile) so that they can both coexist. Moreover, estabilishing this compatiblity is essential if we are going to allow the builder to instantiate  kernels from either template library.

* Add using declarations to test code.

After moving some of the untils into the ck namespace, most examples and a few tests had to be updated to recognize the new namespace declarations. We add using declarations to individual compute units for functions that were previously in the global namespace.

* Add using declarations to client examples.
This commit is contained in:
John Shumway
2025-11-19 02:23:02 -08:00
committed by GitHub
parent d7b3197869
commit ad57f6ef0b
235 changed files with 964 additions and 22 deletions

View File

@@ -19,6 +19,8 @@
#include <gtest/gtest.h>
using ::ck::HostTensorDescriptor;
using DataType = float;
using ImLayout = ck::tensor_layout::convolution::GNWC;

View File

@@ -8,6 +8,8 @@
#include "ck/utility/scaled_type_convert.hpp"
#include "ck/library/utility/device_memory.hpp"
using ::ck::DeviceMem;
using ck::bf6_convert_rne;
using ck::bf6_convert_sr;
using ck::bf6_t;

View File

@@ -6,6 +6,8 @@
#include "ck/utility/data_type.hpp"
#include "ck/utility/type_convert.hpp"
using ::ck::DeviceMem;
using ck::bf8_ocp_t;
using ck::bf8x2_ocp_t;
using ck::bhalf2_t;

View File

@@ -9,6 +9,8 @@
#include "ck/utility/type_convert.hpp"
#include "ck/host_utility/hip_check_error.hpp"
using ::ck::hip_check_error;
using ck::bhalf_t;
using ck::type_convert;

View File

@@ -8,6 +8,8 @@
#include "ck/utility/scaled_type_convert.hpp"
#include "ck/library/utility/device_memory.hpp"
using ::ck::DeviceMem;
using ck::e8m0_bexp_t;
using ck::f6_convert_rne;
using ck::f6_convert_sr;

View File

@@ -6,6 +6,8 @@
#include "ck/utility/data_type.hpp"
#include "ck/utility/type_convert.hpp"
using ::ck::DeviceMem;
using ck::bhalf2_t;
using ck::bhalf_t;
using ck::f8_convert_rne;

View File

@@ -14,6 +14,8 @@
#include "ck/utility/get_id.hpp"
#include "ck/library/utility/device_memory.hpp"
using ::ck::DeviceMem;
using ck::int4_t;
TEST(Int4, BaseArithmetic)

View File

@@ -5,6 +5,8 @@
#include "ck/library/utility/device_memory.hpp"
#include "ck/utility/scaled_type_convert.hpp"
using ::ck::DeviceMem;
using ck::bf8_ocp_t;
using ck::bf8x16_ocp_t;
using ck::bf8x2_ocp_t;

View File

@@ -5,6 +5,8 @@
#include "ck/library/utility/device_memory.hpp"
#include "ck/utility/scaled_type_convert.hpp"
using ::ck::DeviceMem;
using ck::e8m0_bexp_t;
using ck::float16_t;
using ck::float2_t;

View File

@@ -19,6 +19,8 @@ using ck::scaled_type_convert;
using ck::type_convert;
using ck::fp8_impl::fp8x2_storage_t;
using ::ck::DeviceMem;
constexpr uint64_t test_size = 256 * 256 + 2 + 4 + 6;
/**

View File

@@ -16,6 +16,8 @@
#include "ck/tensor_operation/gpu/element/unary_element_wise_operation.hpp"
using ::ck::DeviceMem;
using ck::bhalf2_t;
using ck::bhalf_t;
using ck::float2_t;

View File

@@ -23,6 +23,9 @@
#include "ck/library/utility/convolution_host_tensor_descriptor_helper.hpp"
#include "ck/library/reference_tensor_operation/cpu/reference_conv_bwd_weight.hpp"
using ::ck::DeviceMem;
using ::ck::Tensor;
static ck::index_t param_mask = 0xffff;
static ck::index_t instance_index = -1;
template <typename Tuple>

View File

@@ -13,6 +13,8 @@
#include "ck/library/utility/host_tensor.hpp"
#include "ck/library/utility/host_tensor_generator.hpp"
using ::ck::DeviceMem;
__global__ void gpu_magic_number_division(uint32_t magic_multiplier,
uint32_t magic_shift,
const int32_t* p_dividend,

View File

@@ -22,6 +22,8 @@
namespace {
using ::ck::Tensor;
using InElementOp = ck::tensor_operation::element_wise::PassThrough;
using WeiElementOp = ck::tensor_operation::element_wise::PassThrough;
using OutElementOp = ck::tensor_operation::element_wise::PassThrough;

View File

@@ -16,6 +16,8 @@
#include "ck/wrapper/tensor.hpp"
#include "ck/wrapper/operations/copy.hpp"
using ::ck::DeviceMem;
// Test copy from Global to Global through LDS and VGPR
template <typename InputTensor,
typename OutputTensor,

View File

@@ -25,6 +25,10 @@
#include "ck/wrapper/operations/gemm.hpp"
#include "ck/wrapper/utils/kernel_utils.hpp"
using ::ck::DeviceMem;
using ::ck::HostTensorDescriptor;
using ::ck::Tensor;
template <typename DataType>
void CheckResult(const std::vector<DataType>& a_data,
const std::vector<DataType>& b_data,

View File

@@ -16,6 +16,9 @@
#include "ck/wrapper/layout.hpp"
#include "ck/wrapper/tensor.hpp"
using ::ck::DeviceMem;
using ::ck::launch_and_time_kernel;
// Compare data in tensor with offset from layout.
// Data and offset should match if physical memory has been initialized with
// sequentially increasing values from 0.