Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ foreach(source_file ${EXAMPLE_SOURCES})
if(WITH_MOORE)
target_link_libraries(${target_name} PRIVATE ${MUSART_LIB})
target_compile_options(${target_name} PRIVATE "-x" "musa")
if(WITH_MCCL)
target_compile_definitions(${target_name} PRIVATE INFINI_CCL_MCCL_BFLOAT16_UNSUPPORTED)
endif()
endif()

if(WITH_CAMBRICON)
Expand Down
4 changes: 0 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,6 @@ if(WITH_MCCL)
target_sources(infiniccl PRIVATE ${MCCL_SRCS})
target_include_directories(infiniccl PRIVATE ${MCCL_INC})
target_link_libraries(infiniccl PRIVATE ${MCCL_LIB})

if(WITH_MOORE)
target_compile_definitions(infiniccl PRIVATE INFINI_CCL_MCCL_BFLOAT16_UNSUPPORTED)
endif()
endif()

# =========================================================
Expand Down
3 changes: 3 additions & 0 deletions src/backends/ccl/mccl/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

namespace infini::ccl {

template <Device::Type device>
struct McclDataTypeTraits;

template <Device::Type device>
struct McclApi {
static constexpr BackendType kBackendType = BackendType::kMccl;
Expand Down
5 changes: 5 additions & 0 deletions src/backends/ccl/mccl/metax/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

namespace infini::ccl {

template <>
struct McclDataTypeTraits<Device::Type::kMetax> {
static constexpr mcclDataType_t kBFloat16 = mcclBfloat16;
};

template <>
struct CclApi<BackendType::kMccl, Device::Type::kMetax>
: McclApi<Device::Type::kMetax> {};
Expand Down
9 changes: 9 additions & 0 deletions src/backends/ccl/mccl/moore/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

namespace infini::ccl {

template <>
struct McclDataTypeTraits<Device::Type::kMoore> {
#if defined(MARCH_TYPE) && MARCH_TYPE >= 220
static constexpr mcclDataType_t kBFloat16 = mcclBfloat16;
#else
static constexpr mcclDataType_t kBFloat16 = mcclNumTypes;
#endif
};

template <>
struct CclApi<BackendType::kMccl, Device::Type::kMoore>
: McclApi<Device::Type::kMoore> {};
Expand Down
43 changes: 21 additions & 22 deletions src/backends/ccl/mccl/type_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,30 @@
#include <string>

#include "backends/ccl/common/api.h"
#include "backends/ccl/mccl/api.h"
#include "comm_impl.h"
#include "data_type_impl.h"
#include "logging.h"

namespace infini::ccl {

#if defined(INFINI_CCL_MCCL_BFLOAT16_UNSUPPORTED)
constexpr mcclDataType_t kMcclBFloat16Val = mcclNumTypes;
#else
constexpr mcclDataType_t kMcclBFloat16Val = mcclBfloat16;
#endif

static const ConstexprMap<DataType, mcclDataType_t, 12> kMcclTypeMap{{{
{DataType::kInt8, mcclInt8},
{DataType::kInt16, mcclNumTypes},
{DataType::kInt32, mcclInt32},
{DataType::kInt64, mcclInt64},
{DataType::kUInt8, mcclUint8},
{DataType::kUInt16, mcclNumTypes},
{DataType::kUInt32, mcclUint32},
{DataType::kUInt64, mcclUint64},
{DataType::kFloat32, mcclFloat32},
{DataType::kFloat64, mcclFloat64},
{DataType::kFloat16, mcclFloat16},
{DataType::kBFloat16, kMcclBFloat16Val},
}}};
template <Device::Type device>
struct McclDataTypeMap {
static constexpr ConstexprMap<DataType, mcclDataType_t, 12> kMap{{{
{DataType::kInt8, mcclInt8},
{DataType::kInt16, mcclNumTypes},
{DataType::kInt32, mcclInt32},
{DataType::kInt64, mcclInt64},
{DataType::kUInt8, mcclUint8},
{DataType::kUInt16, mcclNumTypes},
{DataType::kUInt32, mcclUint32},
{DataType::kUInt64, mcclUint64},
{DataType::kFloat32, mcclFloat32},
{DataType::kFloat64, mcclFloat64},
{DataType::kFloat16, mcclFloat16},
{DataType::kBFloat16, McclDataTypeTraits<device>::kBFloat16},
}}};
};

static const ConstexprMap<ReductionOpType, mcclRedOp_t, 5> kMcclOpMap{{{
{ReductionOpType::kSum, mcclSum},
Expand All @@ -41,8 +39,9 @@ static const ConstexprMap<ReductionOpType, mcclRedOp_t, 5> kMcclOpMap{{{
{ReductionOpType::kAvg, mcclAvg},
}}};

template <Device::Type device>
inline mcclDataType_t DataTypeToMcclType(DataType dtype) {
auto mccl_dtype = kMcclTypeMap.at(dtype);
auto mccl_dtype = McclDataTypeMap<device>::kMap.at(dtype);

if (mccl_dtype == mcclNumTypes) {
LOG(("DataType '" + std::string(kDataTypeToDesc.at(dtype)) +
Expand All @@ -63,7 +62,7 @@ struct CclTypeMap<BackendType::kMccl, device> {

static bool ToBackendDataType(DataType dtype,
typename Api::DataType *backend_dtype) {
auto mccl_dtype = DataTypeToMcclType(dtype);
auto mccl_dtype = DataTypeToMcclType<device>(dtype);
if (mccl_dtype == mcclNumTypes) {
return false;
}
Expand Down
Loading