Skip to content

Commit

Permalink
[Feature](mlu-ops): Support mtp_613 (#1176)
Browse files Browse the repository at this point in the history
  • Loading branch information
duzekunKTH authored Dec 12, 2024
1 parent 6413b15 commit 639cc78
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
47 changes: 24 additions & 23 deletions core/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#include "core/tool.h"
#include "kernels/kernel.h"

#define DEP_CHECK_LOG(level) \
#define DEP_CHECK_LOG(level) \
mluop::logging::LogMessage(__FILE__, __LINE__, 4, level, "MLU-OPS", true, \
true, true, true) \
true, true, true) \
.stream()

namespace mluop {
Expand All @@ -46,27 +46,23 @@ static struct deviceName name_list_table[] = {
// case.
};

// once cnrtGetDeviceProperties() update and not use
// device_ordinal, update this funciton.
mluOpDevType_t convertDeviceName(char *name) {
struct deviceName *pName = NULL;
int num = sizeof(name_list_table) / sizeof(struct deviceName);
if (CONTEXT_DEVICENAME_LEAST_SIZE > strlen(name)) {
LOG(ERROR)
<< "get device name failed. device name too short. device name = "
<< name << "\n";
return MLUOP_UNKNOWN_DEVICE;
}
for (int i = 0; i < num; i++) {
pName = &name_list_table[i];
if (0 == strncmp(pName->name, name, strlen(pName->name)) ||
(i == num - 1 &&
0 >= strncmp(pName->name, name, CONTEXT_DEVICENAME_LEAST_SIZE))) {
return pName->type;
mluOpDevType_t convertDeviceNameFromInt(int device_code) {
switch (device_code) {
case 372: {
return MLUOP_MLU370;
break;
}
case 592: {
return MLUOP_MLU590;
break;
}
case 613: {
return MLUOP_MTP613;
break;
}
default:
break;
}
LOG(ERROR) << "get device name failed. return unknown device. device name = "
<< name << "\n";
return MLUOP_UNKNOWN_DEVICE;
}
} // namespace mluop
Expand Down Expand Up @@ -179,6 +175,7 @@ mluOpStatus_t MLUOP_WIN_API mluOpCreate(mluOpHandle_t *handle) {
int32_t persisting_l2cache_maxsize = 0;
double memory_band_width = 0;
char device_name[CONTEXT_DEVICENAME_BUFFER_SIZE] = "";
int device_code = 0;
mluOpContext *ctx = new (std::nothrow) mluOpContext();
CNcontext drv_ctx;
CNctxConfigParam ctx_conf_param;
Expand Down Expand Up @@ -246,6 +243,11 @@ mluOpStatus_t MLUOP_WIN_API mluOpCreate(mluOpHandle_t *handle) {
cnDeviceGetAttribute(&persisting_l2cache_maxsize,
CN_DEVICE_ATTRIBUTE_MAX_PERSISTING_L2_CACHE_SIZE,
mlu_dev));
INTERNAL_CHECK(
"[mluOpCreate]",
CN_SUCCESS == cnDeviceGetAttribute(&device_code,
CN_DEVICE_ATTRIBUTE_MLU_ISA_VERSION,
mlu_dev));
INTERNAL_CHECK(
"[mluOpCreate]",
CN_SUCCESS == cnDeviceGetName(device_name, CONTEXT_DEVICENAME_BUFFER_SIZE,
Expand All @@ -266,8 +268,7 @@ mluOpStatus_t MLUOP_WIN_API mluOpCreate(mluOpHandle_t *handle) {
}

ctx->capability_job_limit = (int32_t)ctx_conf_param.unionLimit;
ctx->arch = mluop::convertDeviceName(
device_name); // warning: possible return unknown.
ctx->arch = mluop::convertDeviceNameFromInt(device_code);
ctx->sram_size = sram_size - REM_FOR_STACK;

strncpy(ctx->device_name, device_name, sizeof(device_name));
Expand Down
1 change: 1 addition & 0 deletions core/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ typedef enum {
MLUOP_MLU270 = 270,
MLUOP_MLU370 = 372,
MLUOP_MLU590 = 592,
MLUOP_MTP613 = 613,
MLUOP_MLU290 = 290,
} mluOpDevType_t;

Expand Down
4 changes: 4 additions & 0 deletions independent_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ long_args=(
help
mlu370 # mlu arch
mlu590
mtp613
no_prepare
perf
prepare
Expand All @@ -68,6 +69,9 @@ add_mlu_arch_support () {
--mlu590)
bang_arch="mtp_592;"
;;
--mtp613)
bang_arch="mtp_613;"
;;
*)
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion test/mlu_op_gtest/pb_gtest/mlu_op_test_proto

0 comments on commit 639cc78

Please sign in to comment.