Browse Source

!234 ge executor support windows and remove thirdparty register folder

From: @taoxiangdong
Reviewed-by: 
Signed-off-by:
tags/v1.1.0
mindspore-ci-bot Gitee 4 years ago
parent
commit
dd6bb2e5e2
78 changed files with 1082 additions and 1224 deletions
  1. +5
    -5
      CMakeLists.txt
  2. +4
    -3
      ge/CMakeLists.txt
  3. +1
    -1
      ge/client/ge_api.cc
  4. +1
    -1
      ge/common/CMakeLists.txt
  5. +5
    -7
      ge/common/auth/file_saver.cc
  6. +7
    -10
      ge/common/debug/memory_dumper.cc
  7. +8
    -8
      ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc
  8. +17
    -10
      ge/common/ge/op_tiling_manager.cc
  9. +39
    -28
      ge/common/ge/plugin_manager.cc
  10. +6
    -6
      ge/common/ge/plugin_manager.h
  11. +43
    -39
      ge/common/ge/tbe_plugin_manager.cc
  12. +0
    -1
      ge/common/ge/tbe_plugin_manager.h
  13. +4
    -2
      ge/common/ge_common.mk
  14. +2
    -4
      ge/common/helper/model_cache_helper.cc
  15. +1
    -1
      ge/common/helper/model_helper.cc
  16. +0
    -1
      ge/common/model_parser/base.cc
  17. +6
    -8
      ge/common/model_saver.cc
  18. +6
    -2
      ge/common/profiling/profiling_manager.cc
  19. +5
    -4
      ge/common/properties_manager.h
  20. +56
    -29
      ge/common/util.cc
  21. +1
    -1
      ge/engine_manager/dnnengine_manager.cc
  22. +2
    -2
      ge/ge_inference.mk
  23. +1
    -1
      ge/ge_runner.mk
  24. +4
    -4
      ge/graph/build/memory/block_mem_assigner.cc
  25. +1
    -1
      ge/graph/build/memory/graph_mem_assigner.cc
  26. +1
    -1
      ge/graph/load/new_model_manager/cpu_queue_schedule.cc
  27. +35
    -30
      ge/graph/load/new_model_manager/davinci_model.cc
  28. +5
    -5
      ge/graph/load/new_model_manager/model_manager.cc
  29. +0
    -1
      ge/graph/load/new_model_manager/model_manager.h
  30. +3
    -3
      ge/graph/load/new_model_manager/model_utils.cc
  31. +2
    -2
      ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc
  32. +28
    -18
      ge/graph/load/new_model_manager/task_info/kernel_task_info.cc
  33. +1
    -1
      ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc
  34. +8
    -6
      ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc
  35. +4
    -2
      ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h
  36. +2
    -2
      ge/graph/load/new_model_manager/zero_copy_offset.cc
  37. +2
    -1
      ge/graph/load/new_model_manager/zero_copy_task.cc
  38. +6
    -6
      ge/graph/manager/graph_var_manager.cc
  39. +3
    -3
      ge/graph/manager/trans_var_data_utils.cc
  40. +3
    -3
      ge/graph/manager/util/debug.cc
  41. +0
    -2
      ge/graph/manager/util/debug.h
  42. +2
    -2
      ge/hybrid/executor/hybrid_execution_context.h
  43. +5
    -5
      ge/init/gelib.cc
  44. +1
    -1
      ge/offline/CMakeLists.txt
  45. +9
    -7
      ge/omm/csa_interact.cc
  46. +1
    -1
      ge/opskernel_manager/ops_kernel_manager.cc
  47. +14
    -14
      ge/session/session_manager.cc
  48. +3
    -3
      ge/single_op/single_op.cc
  49. +56
    -20
      inc/framework/common/debug/ge_log.h
  50. +32
    -0
      inc/framework/common/ge_compiler_options.h
  51. +1
    -0
      inc/framework/common/string_util.h
  52. +1
    -2
      inc/framework/common/types.h
  53. +1
    -1
      metadef
  54. +1
    -1
      parser
  55. +4
    -2
      third_party/fwkacllib/inc/hccl/base.h
  56. +13
    -0
      third_party/fwkacllib/inc/mmpa/mmpa_api.h
  57. +187
    -165
      third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h
  58. +192
    -174
      third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h
  59. +0
    -39
      third_party/fwkacllib/inc/register/host_cpu_context.h
  60. +0
    -49
      third_party/fwkacllib/inc/register/op_kernel_registry.h
  61. +0
    -90
      third_party/fwkacllib/inc/register/op_registry.h
  62. +0
    -135
      third_party/fwkacllib/inc/register/op_tiling.h
  63. +0
    -62
      third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h
  64. +0
    -54
      third_party/fwkacllib/inc/register/register.h
  65. +0
    -79
      third_party/fwkacllib/inc/register/register_format_transfer.h
  66. +14
    -2
      third_party/fwkacllib/inc/runtime/base.h
  67. +1
    -1
      third_party/fwkacllib/inc/runtime/context.h
  68. +2
    -2
      third_party/fwkacllib/inc/runtime/dev.h
  69. +19
    -9
      third_party/fwkacllib/inc/runtime/event.h
  70. +43
    -14
      third_party/fwkacllib/inc/runtime/kernel.h
  71. +3
    -3
      third_party/fwkacllib/inc/runtime/mem.h
  72. +2
    -1
      third_party/fwkacllib/inc/runtime/rt_model.h
  73. +8
    -8
      third_party/fwkacllib/inc/runtime/stream.h
  74. +29
    -0
      third_party/fwkacllib/inc/tdt/index_transform.h
  75. +3
    -0
      third_party/fwkacllib/inc/tdt/status.h
  76. +20
    -2
      third_party/fwkacllib/inc/tdt/tsd_client.h
  77. +15
    -11
      third_party/fwkacllib/inc/toolchain/slog.h
  78. +72
    -0
      third_party/fwkacllib/inc/toolchain/tuning_tool/tune_api.h

+ 5
- 5
CMakeLists.txt View File

@@ -56,7 +56,7 @@ if (ENABLE_OPEN_SRC)
set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH})
set(STATIC_ACL_LIB ${GE_LIB_PATH}) set(STATIC_ACL_LIB ${GE_LIB_PATH})
find_module(slog libslog.so ${GE_LIB_PATH}) find_module(slog libslog.so ${GE_LIB_PATH})
find_module(mmpa libmmpa.so ${GE_LIB_PATH})
find_module(static_mmpa libmmpa.a ${GE_LIB_PATH})
find_module(msprof libmsprof.so ${GE_LIB_PATH}) find_module(msprof libmsprof.so ${GE_LIB_PATH})
find_module(hccl libhccl.so ${GE_LIB_PATH}) find_module(hccl libhccl.so ${GE_LIB_PATH})
find_module(adump_server libadump_server.a ${GE_LIB_PATH}) find_module(adump_server libadump_server.a ${GE_LIB_PATH})
@@ -67,10 +67,10 @@ if (ENABLE_OPEN_SRC)
find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH})
find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH}) find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH})
find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH}) find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH})
#find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH})
#find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH})
else() else()
find_module(slog libslog.so ${ASCEND_ATC_DIR}) find_module(slog libslog.so ${ASCEND_ATC_DIR})
find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR})
find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR})
if(PLATFORM STREQUAL "train") if(PLATFORM STREQUAL "train")
find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR})
find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR})
@@ -91,7 +91,7 @@ if (ENABLE_OPEN_SRC)
find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR})
find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR})
find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR})
#find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR})
#find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR})
if(PRODUCT STREQUAL "flr3") if(PRODUCT STREQUAL "flr3")
find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR})
elseif(PRODUCT STREQUAL "flr1") elseif(PRODUCT STREQUAL "flr1")
@@ -114,7 +114,7 @@ if (ENABLE_OPEN_SRC)
find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR})
find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR})
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver)
#find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR})
#find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR})
else() else()
message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated") message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated")
endif() endif()


+ 4
- 3
ge/CMakeLists.txt View File

@@ -648,6 +648,7 @@ target_link_libraries(ge_runner
ge_memory ge_memory
adump_server adump_server
msprofiler msprofiler
static_mmpa
-Wl,--no-as-needed -Wl,--no-as-needed
graph graph
ge_common ge_common
@@ -655,7 +656,6 @@ target_link_libraries(ge_runner
register register
c_sec c_sec
slog slog
mmpa
msprof msprof
runtime runtime
resource resource
@@ -712,6 +712,7 @@ target_include_directories(ge_compiler PRIVATE
target_link_libraries(ge_compiler target_link_libraries(ge_compiler
$<BUILD_INTERFACE:intf_pub> $<BUILD_INTERFACE:intf_pub>
ge_memory ge_memory
static_mmpa
-Wl,--no-as-needed -Wl,--no-as-needed
graph graph
ge_common ge_common
@@ -720,7 +721,6 @@ target_link_libraries(ge_compiler
c_sec c_sec
error_manager error_manager
slog slog
mmpa
runtime_compile runtime_compile
resource resource
-Wl,--as-needed -Wl,--as-needed
@@ -770,6 +770,7 @@ target_link_libraries(opensrc_ascendcl PRIVATE
ge_executor ge_executor
ge_common_static ge_common_static
graph_static graph_static
static_mmpa
ascend_protobuf_static ascend_protobuf_static
register_static register_static
error_manager_static error_manager_static
@@ -779,11 +780,11 @@ target_link_libraries(opensrc_ascendcl PRIVATE
-Wl,--no-as-needed -Wl,--no-as-needed
c_sec c_sec
runtime runtime
mmpa
slog slog
msprof msprof
ascend_hal_stub ascend_hal_stub
-Wl,--as-needed -Wl,--as-needed
-lrt
-ldl -ldl
json json
) )


+ 1
- 1
ge/client/ge_api.cc View File

@@ -177,7 +177,7 @@ Session::Session(const std::map<string, string> &options) {
// check init status // check init status
sessionId_ = 0; sessionId_ = 0;
if (!g_ge_initialized) { if (!g_ge_initialized) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED);
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized.");
return; return;
} }
// call Initialize // call Initialize


+ 1
- 1
ge/common/CMakeLists.txt View File

@@ -105,6 +105,7 @@ target_include_directories(ge_common PRIVATE


target_link_libraries(ge_common PRIVATE target_link_libraries(ge_common PRIVATE
$<BUILD_INTERFACE:intf_pub> $<BUILD_INTERFACE:intf_pub>
static_mmpa
-Wl,--no-as-needed -Wl,--no-as-needed
graph graph
ascend_protobuf ascend_protobuf
@@ -112,7 +113,6 @@ target_link_libraries(ge_common PRIVATE
c_sec c_sec
error_manager error_manager
slog slog
mmpa
-Wl,--as-needed -Wl,--as-needed
json json
-lrt -lrt


+ 5
- 7
ge/common/auth/file_saver.cc View File

@@ -16,9 +16,7 @@


#include "common/auth/file_saver.h" #include "common/auth/file_saver.h"


#include <fcntl.h>
#include <securec.h> #include <securec.h>
#include <unistd.h>
#include <cstdlib> #include <cstdlib>
#include <fstream> #include <fstream>
#include <vector> #include <vector>
@@ -39,12 +37,12 @@ Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) {
return FAILED; return FAILED;
} }


char real_path[PATH_MAX] = {0};
GE_IF_BOOL_EXEC(realpath(file_path.c_str(), real_path) == nullptr,
char real_path[MMPA_MAX_PATH] = {0};
GE_IF_BOOL_EXEC(mmRealPath(file_path.c_str(), real_path, MMPA_MAX_PATH) != EN_OK,
GELOGI("File %s is not exist, it will be created.", file_path.c_str())); GELOGI("File %s is not exist, it will be created.", file_path.c_str()));
// Open file // Open file
mode_t mode = S_IRUSR | S_IWUSR;
fd = mmOpen2(real_path, O_RDWR | O_CREAT | O_TRUNC, mode);
mmMode_t mode = M_IRUSR | M_IWUSR;
fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode);
if (fd == EN_INVALID_PARAM || fd == EN_ERROR) { if (fd == EN_INVALID_PARAM || fd == EN_ERROR) {
// -1: Failed to open file; - 2: Illegal parameter // -1: Failed to open file; - 2: Illegal parameter
GELOGE(FAILED, "Open file failed. mmpa_errno = %d, %s", fd, strerror(errno)); GELOGE(FAILED, "Open file failed. mmpa_errno = %d, %s", fd, strerror(errno));
@@ -194,7 +192,7 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header,


FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(const std::string &file_path) { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(const std::string &file_path) {
// Determine file path length // Determine file path length
if (file_path.size() >= PATH_MAX) {
if (file_path.size() >= MMPA_MAX_PATH) {
GELOGE(FAILED, "Path is too long:%zu", file_path.size()); GELOGE(FAILED, "Path is too long:%zu", file_path.size());
return FAILED; return FAILED;
} }


+ 7
- 10
ge/common/debug/memory_dumper.cc View File

@@ -16,9 +16,6 @@


#include "common/debug/memory_dumper.h" #include "common/debug/memory_dumper.h"


#include <fcntl.h>

#include <unistd.h>
#include <string> #include <string>


#include "framework/common/debug/log.h" #include "framework/common/debug/log.h"
@@ -138,26 +135,26 @@ int MemoryDumper::OpenFile(const char *filename) {
} }
// Get the absolute path // Get the absolute path
string real_path; string real_path;
char tmp_path[PATH_MAX] = {0};
char tmp_path[MMPA_MAX_PATH] = {0};
GE_IF_BOOL_EXEC( GE_IF_BOOL_EXEC(
-1 != path_split_pos, string prefix_path = std::string(filename).substr(0, path_split_pos); -1 != path_split_pos, string prefix_path = std::string(filename).substr(0, path_split_pos);
string last_path = std::string(filename).substr(path_split_pos, strlen(filename) - 1); string last_path = std::string(filename).substr(path_split_pos, strlen(filename) - 1);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(prefix_path.length() >= PATH_MAX, return kInvalidFd, "Prefix path is too long!");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(realpath(prefix_path.c_str(), tmp_path) == nullptr, return kInvalidFd,
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(prefix_path.length() >= MMPA_MAX_PATH, return kInvalidFd, "Prefix path is too long!");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(mmRealPath(prefix_path.c_str(), tmp_path, MMPA_MAX_PATH) != EN_OK, return kInvalidFd,
"Dir %s does not exit.", prefix_path.c_str()); "Dir %s does not exit.", prefix_path.c_str());
real_path = std::string(tmp_path) + last_path;) real_path = std::string(tmp_path) + last_path;)
GE_IF_BOOL_EXEC( GE_IF_BOOL_EXEC(
path_split_pos == -1 || path_split_pos == 0, path_split_pos == -1 || path_split_pos == 0,
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(filename) >= PATH_MAX, return kInvalidFd, "Prefix path is too long!");
GE_IF_BOOL_EXEC(realpath(filename, tmp_path) == nullptr,
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(filename) >= MMPA_MAX_PATH, return kInvalidFd, "Prefix path is too long!");
GE_IF_BOOL_EXEC(mmRealPath(filename, tmp_path, MMPA_MAX_PATH) != EN_OK,
GELOGI("File %s does not exit, it will be created.", filename)); GELOGI("File %s does not exit, it will be created.", filename));
real_path = std::string(tmp_path);) real_path = std::string(tmp_path);)


// Open file, only the current user can read and write, to avoid malicious application access // Open file, only the current user can read and write, to avoid malicious application access
// Using the O_EXCL, if the file already exists,return failed to avoid privilege escalation vulnerability. // Using the O_EXCL, if the file already exists,return failed to avoid privilege escalation vulnerability.
mode_t mode = S_IRUSR | S_IWUSR;
mmMode_t mode = M_IRUSR | M_IWUSR;


int32_t fd = mmOpen2(real_path.c_str(), O_RDWR | O_CREAT | O_APPEND, mode);
int32_t fd = mmOpen2(real_path.c_str(), M_RDWR | M_CREAT | O_TRUNC, mode);
if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { if (fd == EN_ERROR || fd == EN_INVALID_PARAM) {
GELOGE(kInvalidFd, "open file failed. errno = %d, %s", fd, strerror(errno)); GELOGE(kInvalidFd, "open file failed. errno = %d, %s", fd, strerror(errno));
return kInvalidFd; return kInvalidFd;


+ 8
- 8
ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc View File

@@ -118,19 +118,19 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) {


// data overflow check totally // data overflow check totally
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o), GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o),
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", h_o, w_o);
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", h_o, w_o);
return INTERNAL_ERROR); return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o), GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o),
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", n_o, c_o);
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", n_o, c_o);
return INTERNAL_ERROR); return INTERNAL_ERROR);
auto t1 = h_o * w_o; auto t1 = h_o * w_o;
auto t2 = n_o * c_o; auto t2 = n_o * c_o;
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", t1, t2);
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2);
return INTERNAL_ERROR); return INTERNAL_ERROR);


int64_t total_ele_cnt = n_o * c_o * h_o * w_o; int64_t total_ele_cnt = n_o * c_o * h_o * w_o;
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size), GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size),
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", total_ele_cnt, size);
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size);
return INTERNAL_ERROR); return INTERNAL_ERROR);
int64_t dst_size = total_ele_cnt * size; int64_t dst_size = total_ele_cnt * size;
if (dst_size == 0) { if (dst_size == 0) {
@@ -205,20 +205,20 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr<uin


// data overflow check // data overflow check
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o), GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o),
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", h_o, w_o);
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", h_o, w_o);
return INTERNAL_ERROR); return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o), GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o),
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", n_o, c_o);
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", n_o, c_o);
return INTERNAL_ERROR); return INTERNAL_ERROR);
auto t1 = h_o * w_o; auto t1 = h_o * w_o;
auto t2 = n_o * c_o; auto t2 = n_o * c_o;
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", t1, t2);
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2);
return INTERNAL_ERROR); return INTERNAL_ERROR);


int64_t total_ele_cnt = n_o * c_o * h_o * w_o; int64_t total_ele_cnt = n_o * c_o * h_o * w_o;
int size = GetSizeByDataType(args.src_data_type); int size = GetSizeByDataType(args.src_data_type);
GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size), GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size),
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", total_ele_cnt, size);
GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size);
return INTERNAL_ERROR); return INTERNAL_ERROR);


int64_t dst_size = total_ele_cnt * size; int64_t dst_size = total_ele_cnt * size;


+ 17
- 10
ge/common/ge/op_tiling_manager.cc View File

@@ -30,8 +30,10 @@ const uint8_t kPrefixIndex = 9;
namespace ge { namespace ge {
void OpTilingManager::ClearHandles() noexcept { void OpTilingManager::ClearHandles() noexcept {
for (const auto &handle : handles_) { for (const auto &handle : handles_) {
if (dlclose(handle.second) != 0) {
GELOGE(FAILED, "Failed to close handle of %s: %s", handle.first.c_str(), dlerror());
if (mmDlclose(handle.second) != 0) {
const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGE(FAILED, "Failed to close handle of %s: %s", handle.first.c_str(), error);
} }
} }
handles_.clear(); handles_.clear();
@@ -40,11 +42,12 @@ void OpTilingManager::ClearHandles() noexcept {
OpTilingManager::~OpTilingManager() { ClearHandles(); } OpTilingManager::~OpTilingManager() { ClearHandles(); }


std::string OpTilingManager::GetPath() { std::string OpTilingManager::GetPath() {
const char *opp_path_env = std::getenv(kEnvName);
char opp_path_env[MMPA_MAX_PATH] = { 0x00 };
INT32 res = mmGetEnv(kEnvName, opp_path_env, MMPA_MAX_PATH);
std::string opp_path = kDefaultPath; std::string opp_path = kDefaultPath;
if (opp_path_env != nullptr) {
char resolved_path[PATH_MAX];
if (realpath(opp_path_env, resolved_path) == NULL) {
if (res == EN_OK) {
char resolved_path[MMPA_MAX_PATH];
if (mmRealPath(opp_path_env, resolved_path, MMPA_MAX_PATH) != EN_OK) {
ErrorManager::GetInstance().ATCReportErrMessage( ErrorManager::GetInstance().ATCReportErrMessage(
"E19024", {"env", "value", "situation"}, {"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"}); "E19024", {"env", "value", "situation"}, {"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"});
GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'[%s] is invalid path.", opp_path_env); GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'[%s] is invalid path.", opp_path_env);
@@ -66,16 +69,20 @@ void OpTilingManager::LoadSo() {
std::string built_in_name = kDefaultBuiltInTilingPath.substr(kPrefixIndex); std::string built_in_name = kDefaultBuiltInTilingPath.substr(kPrefixIndex);
std::string custom_name = kDefaultCustomTilingPath.substr(kPrefixIndex); std::string custom_name = kDefaultCustomTilingPath.substr(kPrefixIndex);


void *handle_bi = dlopen(built_in_tiling_lib.c_str(), RTLD_NOW | RTLD_GLOBAL);
void *handle_bi = mmDlopen(built_in_tiling_lib.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL);
if (handle_bi == nullptr) { if (handle_bi == nullptr) {
GELOGW("Failed to dlopen %s!", dlerror());
const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGW("Failed to dlopen %s!", error);
} else { } else {
handles_[built_in_name] = handle_bi; handles_[built_in_name] = handle_bi;
} }


void *handle_ct = dlopen(custom_tiling_lib.c_str(), RTLD_NOW | RTLD_GLOBAL);
void *handle_ct = mmDlopen(custom_tiling_lib.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL);
if (handle_ct == nullptr) { if (handle_ct == nullptr) {
GELOGW("Failed to dlopen %s!", dlerror());
const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGW("Failed to dlopen %s!", error);
} else { } else {
handles_[custom_name] = handle_ct; handles_[custom_name] = handle_ct;
} }


+ 39
- 28
ge/common/ge/plugin_manager.cc View File

@@ -16,9 +16,7 @@


#include "common/ge/plugin_manager.h" #include "common/ge/plugin_manager.h"


#include <dirent.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
@@ -38,8 +36,10 @@ const char *const kExt = ".so"; // supported extension of shared obje
namespace ge { namespace ge {
void PluginManager::ClearHandles_() noexcept { void PluginManager::ClearHandles_() noexcept {
for (const auto &handle : handles_) { for (const auto &handle : handles_) {
if (dlclose(handle.second) != 0) {
GELOGW("Failed to close handle of %s: %s", handle.first.c_str(), dlerror());
if (mmDlclose(handle.second) != 0) {
const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGW("Failed to close handle of %s: %s", handle.first.c_str(), error);
} }
} }
handles_.clear(); handles_.clear();
@@ -48,18 +48,18 @@ void PluginManager::ClearHandles_() noexcept {
PluginManager::~PluginManager() { ClearHandles_(); } PluginManager::~PluginManager() { ClearHandles_(); }


string PluginManager::GetPath() { string PluginManager::GetPath() {
Dl_info dl_info;
if (dladdr(reinterpret_cast<void *>(&PluginManager::GetPath), &dl_info) == 0) {
mmDlInfo dl_info;
if (mmDladdr(reinterpret_cast<void *>(&PluginManager::GetPath), &dl_info) != EN_OK) {
GELOGW("Failed to read the shared library file path!"); GELOGW("Failed to read the shared library file path!");
return string(); return string();
} else { } else {
std::string so_path = dl_info.dli_fname; std::string so_path = dl_info.dli_fname;
char path[PATH_MAX] = {0};
if (so_path.length() >= PATH_MAX) {
char path[MMPA_MAX_PATH] = {0};
if (so_path.length() >= MMPA_MAX_PATH) {
GELOGW("The shared library file path is too long!"); GELOGW("The shared library file path is too long!");
return string(); return string();
} }
if (realpath(so_path.c_str(), path) == nullptr) {
if (mmRealPath(so_path.c_str(), path, MMPA_MAX_PATH) != EN_OK) {
GELOGW("Failed to get realpath of %s", so_path.c_str()); GELOGW("Failed to get realpath of %s", so_path.c_str());
return string(); return string();
} }
@@ -93,7 +93,7 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec
std::vector<std::string> path_vec; std::vector<std::string> path_vec;
SplitPath(path, path_vec); SplitPath(path, path_vec);
for (const auto &single_path : path_vec) { for (const auto &single_path : path_vec) {
GE_IF_BOOL_EXEC(single_path.length() >= PATH_MAX, GELOGE(GE_PLGMGR_PATH_INVALID,
GE_IF_BOOL_EXEC(single_path.length() >= MMPA_MAX_PATH, GELOGE(GE_PLGMGR_PATH_INVALID,
"The shared library file path is too long!"); "The shared library file path is too long!");
continue); continue);
// load break when number of loaded so reach maximum // load break when number of loaded so reach maximum
@@ -119,16 +119,18 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec
GELOGI("dlopen the shared library path name: %s.", file_path_dlopen.c_str()); GELOGI("dlopen the shared library path name: %s.", file_path_dlopen.c_str());


// load continue when dlopen is failed // load continue when dlopen is failed
auto handle = dlopen(file_path_dlopen.c_str(), RTLD_NOW | RTLD_GLOBAL);
auto handle = mmDlopen(file_path_dlopen.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL);
if (handle == nullptr) { if (handle == nullptr) {
GELOGE(GE_PLGMGR_PATH_INVALID, "Failed to dlopen %s!", dlerror());
const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGE(GE_PLGMGR_PATH_INVALID, "Failed to dlopen %s!", error);
continue; continue;
} }


// load continue when so is invalid // load continue when so is invalid
bool is_valid = true; bool is_valid = true;
for (const auto &func_name : func_check_list) { for (const auto &func_name : func_check_list) {
auto real_fn = (void (*)())dlsym(handle, func_name.c_str());
auto real_fn = (void (*)())mmDlsym(handle, const_cast<char *>(func_name.c_str()));
if (real_fn == nullptr) { if (real_fn == nullptr) {
GELOGE(GE_PLGMGR_PATH_INVALID, "%s is skipped since function %s is not existed!", func_name.c_str(), GELOGE(GE_PLGMGR_PATH_INVALID, "%s is skipped since function %s is not existed!", func_name.c_str(),
func_name.c_str()); func_name.c_str());
@@ -137,7 +139,7 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec
} }
} }
if (!is_valid) { if (!is_valid) {
GE_LOGE_IF(dlclose(handle), "Failed to dlclose.");
GE_LOGE_IF(mmDlclose(handle), "Failed to dlclose.");
continue; continue;
} }


@@ -197,22 +199,29 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_
so_list_.clear(); so_list_.clear();
ClearHandles_(); ClearHandles_();


char canonical_path[PATH_MAX] = {0};
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path.length() >= PATH_MAX, GELOGW("File path is too long!");
char canonical_path[MMPA_MAX_PATH] = {0};
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path.length() >= MMPA_MAX_PATH, GELOGW("File path is too long!");
return FAILED, "File path is too long!"); return FAILED, "File path is too long!");
if (realpath(path.c_str(), canonical_path) == nullptr) {
if (mmRealPath(path.c_str(), canonical_path, MMPA_MAX_PATH) != EN_OK) {
GELOGW("Failed to get realpath of %s", path.c_str()); GELOGW("Failed to get realpath of %s", path.c_str());
return SUCCESS; return SUCCESS;
} }


DIR *dir = opendir(canonical_path);
if (dir == nullptr) {
GELOGW("Invalid path for load: %s", path.c_str());
return SUCCESS;
INT32 is_dir = mmIsDir(canonical_path);
// Lib plugin path not exist
if (is_dir != EN_OK) {
GELOGW("Invalid path for load: %s", path.c_str());
return SUCCESS;
} }


struct dirent *entry = nullptr;
while ((entry = readdir(dir)) != nullptr) {
mmDirent **entries = nullptr;
auto ret = mmScandir(canonical_path, &entries, nullptr, nullptr);
if (ret < EN_OK) {
GELOGW("scan dir failed. path = %s, ret = %d", canonical_path, ret);
return FAILED;
}
for (int i = 0; i < ret; ++i) {
mmDirent *entry = entries[i];
// read fileName and fileType // read fileName and fileType
std::string file_name = entry->d_name; std::string file_name = entry->d_name;
unsigned char file_type = entry->d_type; unsigned char file_type = entry->d_type;
@@ -250,9 +259,11 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_
GELOGI("Dlopen so path name: %s. ", file_path_dlopen.c_str()); GELOGI("Dlopen so path name: %s. ", file_path_dlopen.c_str());


// load continue when dlopen is failed // load continue when dlopen is failed
auto handle = dlopen(file_path_dlopen.c_str(), RTLD_NOW | RTLD_GLOBAL);
auto handle = mmDlopen(file_path_dlopen.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL);
if (handle == nullptr) { if (handle == nullptr) {
GELOGW("Failed in dlopen %s!", dlerror());
const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGW("Failed in dlopen %s!", error);
continue; continue;
} }


@@ -261,7 +272,7 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_
// load continue when so is invalid // load continue when so is invalid
bool is_valid = true; bool is_valid = true;
for (const auto &func_name : func_check_list) { for (const auto &func_name : func_check_list) {
auto real_fn = (void (*)())dlsym(handle, func_name.c_str());
auto real_fn = (void (*)())mmDlsym(handle, const_cast<char *>(func_name.c_str()));
if (real_fn == nullptr) { if (real_fn == nullptr) {
GELOGW("The %s is skipped since function %s is not existed!", file_name.c_str(), func_name.c_str()); GELOGW("The %s is skipped since function %s is not existed!", file_name.c_str(), func_name.c_str());
is_valid = false; is_valid = false;
@@ -269,7 +280,7 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_
} }
} }
if (!is_valid) { if (!is_valid) {
GE_LOGE_IF(dlclose(handle), "Failed to dlclose.");
GE_LOGE_IF(mmDlclose(handle), "Failed to dlclose.");
continue; continue;
} }


@@ -279,7 +290,7 @@ Status PluginManager::Load(const string &path, const vector<string> &func_check_
handles_[string(file_name)] = handle; handles_[string(file_name)] = handle;
num_of_loaded_so++; num_of_loaded_so++;
} }
closedir(dir);
mmScandirFree(entries, ret);
if (num_of_loaded_so == 0) { if (num_of_loaded_so == 0) {
GELOGW("No loadable shared library found in the path: %s", path.c_str()); GELOGW("No loadable shared library found in the path: %s", path.c_str());
return SUCCESS; return SUCCESS;


+ 6
- 6
ge/common/ge/plugin_manager.h View File

@@ -17,7 +17,6 @@
#ifndef GE_COMMON_GE_PLUGIN_MANAGER_H_ #ifndef GE_COMMON_GE_PLUGIN_MANAGER_H_
#define GE_COMMON_GE_PLUGIN_MANAGER_H_ #define GE_COMMON_GE_PLUGIN_MANAGER_H_


#include <dlfcn.h>
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <map> #include <map>
@@ -30,6 +29,7 @@
#include "common/ge_inner_error_codes.h" #include "common/ge_inner_error_codes.h"
#include "engine/dnnengine.h" #include "engine/dnnengine.h"
#include "framework/common/debug/ge_log.h" #include "framework/common/debug/ge_log.h"
#include "mmpa/mmpa_api.h"


namespace ge { namespace ge {
using SoToHandleMap = std::map<std::string, void *>; using SoToHandleMap = std::map<std::string, void *>;
@@ -57,7 +57,7 @@ class PluginManager {
template <typename R, typename... Types> template <typename R, typename... Types>
Status GetAllFunctions(const string &func_name, map<string, function<R(Types... args)>> &funcs) { Status GetAllFunctions(const string &func_name, map<string, function<R(Types... args)>> &funcs) {
for (const auto &handle : handles_) { for (const auto &handle : handles_) {
auto real_fn = (R(*)(Types...))dlsym(handle.second, func_name.c_str());
auto real_fn = (R(*)(Types...))mmDlsym(handle.second, const_cast<char *>(func_name.c_str()));
if (real_fn == nullptr) { if (real_fn == nullptr) {
GELOGW("Failed to get function %s in %s!", func_name.c_str(), handle.first.c_str()); GELOGW("Failed to get function %s in %s!", func_name.c_str(), handle.first.c_str());
return GE_PLGMGR_FUNC_NOT_EXIST; return GE_PLGMGR_FUNC_NOT_EXIST;
@@ -72,7 +72,7 @@ class PluginManager {
Status InvokeAll(const string &func_name, Types... args) { Status InvokeAll(const string &func_name, Types... args) {
for (const auto &handle : handles_) { for (const auto &handle : handles_) {
// If the funcName is existed, signature of realFn can be casted to any type // If the funcName is existed, signature of realFn can be casted to any type
auto real_fn = (void (*)(Types...))dlsym(handle.second, func_name.c_str());
auto real_fn = (void (*)(Types...))mmDlsym(handle.second, const_cast<char *>(func_name.c_str()));
if (real_fn == nullptr) { if (real_fn == nullptr) {
GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str());
return GE_PLGMGR_INVOKE_FAILED; return GE_PLGMGR_INVOKE_FAILED;
@@ -87,7 +87,7 @@ class PluginManager {
Status InvokeAll(const string &func_name, T arg) { Status InvokeAll(const string &func_name, T arg) {
for (const auto &handle : handles_) { for (const auto &handle : handles_) {
// If the funcName is existed, signature of realFn can be casted to any type // If the funcName is existed, signature of realFn can be casted to any type
auto real_fn = (void (*)(T))dlsym(handle.second, func_name.c_str());
auto real_fn = (void (*)(T))mmDlsym(handle.second, const_cast<char *>(func_name.c_str()));
if (real_fn == nullptr) { if (real_fn == nullptr) {
GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str());
return GE_PLGMGR_INVOKE_FAILED; return GE_PLGMGR_INVOKE_FAILED;
@@ -112,7 +112,7 @@ class PluginManager {
Status InvokeAll(const string &func_name, T1 arg) { Status InvokeAll(const string &func_name, T1 arg) {
for (const auto &handle : handles_) { for (const auto &handle : handles_) {
// If the funcName is existed, signature of realFn can be casted to any type // If the funcName is existed, signature of realFn can be casted to any type
auto real_fn = (T2(*)(T1))dlsym(handle.second, func_name.c_str());
auto real_fn = (T2(*)(T1))mmDlsym(handle.second, const_cast<char *>(func_name.c_str()));
if (real_fn == nullptr) { if (real_fn == nullptr) {
GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str());
return GE_PLGMGR_INVOKE_FAILED; return GE_PLGMGR_INVOKE_FAILED;
@@ -130,7 +130,7 @@ class PluginManager {
Status InvokeAll(const string &func_name) { Status InvokeAll(const string &func_name) {
for (const auto &handle : handles_) { for (const auto &handle : handles_) {
// If the funcName is existed, signature of realFn can be casted to any type // If the funcName is existed, signature of realFn can be casted to any type
auto real_fn = (T(*)())dlsym(handle.second, func_name.c_str());
auto real_fn = (T(*)())mmDlsym(handle.second, const_cast<char *>(func_name.c_str()));
if (real_fn == nullptr) { if (real_fn == nullptr) {
GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str());
return GE_PLGMGR_INVOKE_FAILED; return GE_PLGMGR_INVOKE_FAILED;


+ 43
- 39
ge/common/ge/tbe_plugin_manager.cc View File

@@ -16,8 +16,6 @@


#include "common/ge/tbe_plugin_manager.h" #include "common/ge/tbe_plugin_manager.h"


#include <dirent.h>
#include <unistd.h>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
@@ -50,9 +48,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY TBEPluginManager &TBEPluginMana
Status TBEPluginManager::ClearHandles_() { Status TBEPluginManager::ClearHandles_() {
Status ret = SUCCESS; Status ret = SUCCESS;
for (const auto &handle : handles_vec_) { for (const auto &handle : handles_vec_) {
if (dlclose(handle) != 0) {
if (mmDlclose(handle) != 0) {
ret = FAILED; ret = FAILED;
GELOGW("Failed to close handle: %s", dlerror());
const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGW("Failed to close handle: %s", error);
} }
} }
handles_vec_.clear(); handles_vec_.clear();
@@ -65,18 +65,18 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status TBEPluginManager::Finali
} }


string TBEPluginManager::GetPath() { string TBEPluginManager::GetPath() {
Dl_info dl_info;
if (dladdr(reinterpret_cast<void *>(&TBEPluginManager::GetPath), &dl_info) == 0) {
mmDlInfo dl_info;
if (mmDladdr(reinterpret_cast<void *>(&TBEPluginManager::GetPath), &dl_info) != EN_OK) {
GELOGW("Failed to read so path!"); GELOGW("Failed to read so path!");
return string(); return string();
} else { } else {
string so_path = dl_info.dli_fname; string so_path = dl_info.dli_fname;
char path[PATH_MAX] = {0};
if (so_path.length() >= PATH_MAX) {
char path[MMPA_MAX_PATH] = {0};
if (so_path.length() >= MMPA_MAX_PATH) {
GELOGW("File path is too long!"); GELOGW("File path is too long!");
return string(); return string();
} }
if (realpath(so_path.c_str(), path) == nullptr) {
if (mmRealPath(so_path.c_str(), path, MMPA_MAX_PATH) != EN_OK) {
GELOGW("Failed to get realpath of %s", so_path.c_str()); GELOGW("Failed to get realpath of %s", so_path.c_str());
return string(); return string();
} }
@@ -108,35 +108,36 @@ void TBEPluginManager::FindParserSo(const string &path, vector<string> &file_lis
GELOGW("RealPath is empty."); GELOGW("RealPath is empty.");
return; return;
} }
struct stat stat_buf;
if ((stat(real_path.c_str(), &stat_buf) != 0) || (!S_ISDIR(stat_buf.st_mode))) {
GELOGW("%s is not a dir.", real_path.c_str());
return;
}
struct dirent *dent(0);
DIR *dir = opendir(real_path.c_str());
// Plugin path does not exist
if (dir == nullptr) {
GELOGW("Open directory %s failed.", real_path.c_str());
return;
INT32 is_dir = mmIsDir(real_path.c_str());
// Lib plugin path not exist
if (is_dir != EN_OK) {
GELOGW("%s is not a dir.", real_path.c_str());
return;
} }


while ((dent = readdir(dir)) != nullptr) {
if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue;
string name = dent->d_name;
string full_name = real_path + "/" + name;
const string so_suff = ".so";
const string caffe_parser_so_suff = "lib_caffe_parser.so";
const string aicpu_so_suff = "_aicpu.so";
const string aicpu_host_so_suff = "_online.so";
if (name.size() >= so_suff.size() && name.compare(name.size() - so_suff.size(), so_suff.size(), so_suff) == 0) {
ProcessSoFullName(file_list, caffe_parser_path, full_name, caffe_parser_so_suff, aicpu_so_suff,
aicpu_host_so_suff);
} else {
FindParserSo(full_name, file_list, caffe_parser_path);
}
mmDirent **entries = nullptr;
auto ret = mmScandir(real_path.c_str(), &entries, nullptr, nullptr);
if (ret < EN_OK) {
GELOGW("scan dir failed. path = %s, ret = %d", real_path.c_str(), ret);
return;
}
for (int i = 0; i < ret; ++i) {
mmDirent *dent = entries[i];
if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue;
string name = dent->d_name;
string full_name = real_path + "/" + name;
const string so_suff = ".so";
const string caffe_parser_so_suff = "lib_caffe_parser.so";
const string aicpu_so_suff = "_aicpu.so";
const string aicpu_host_so_suff = "_online.so";
if (name.size() >= so_suff.size() && name.compare(name.size() - so_suff.size(), so_suff.size(), so_suff) == 0) {
ProcessSoFullName(file_list, caffe_parser_path, full_name, caffe_parser_so_suff, aicpu_so_suff,
aicpu_host_so_suff);
} else {
FindParserSo(full_name, file_list, caffe_parser_path);
}
} }
closedir(dir);
mmScandirFree(entries, ret);
} }


void TBEPluginManager::GetPluginSoFileList(const string &path, vector<string> &file_list, string &caffe_parser_path) { void TBEPluginManager::GetPluginSoFileList(const string &path, vector<string> &file_list, string &caffe_parser_path) {
@@ -159,8 +160,9 @@ void TBEPluginManager::GetCustomOpPath(std::string &customop_path) {
fmk_type = ge::TypeUtils::FmkTypeToSerialString(type); fmk_type = ge::TypeUtils::FmkTypeToSerialString(type);
GELOGI("Framework type is %s.", fmk_type.c_str()); GELOGI("Framework type is %s.", fmk_type.c_str());


const char *path_env = std::getenv("ASCEND_OPP_PATH");
if (path_env != nullptr) {
char path_env[MMPA_MAX_PATH] = { 0x00 };
INT32 res = mmGetEnv("ASCEND_OPP_PATH", path_env, MMPA_MAX_PATH);
if (res == EN_OK) {
std::string path = path_env; std::string path = path_env;
customop_path = (path + "/framework/custom" + "/:") + (path + "/framework/built-in/" + fmk_type); customop_path = (path + "/framework/custom" + "/:") + (path + "/framework/built-in/" + fmk_type);
GELOGI("Get custom so path from env : %s", path_env); GELOGI("Get custom so path from env : %s", path_env);
@@ -210,9 +212,11 @@ void TBEPluginManager::LoadPluginSo(const std::map<string, string> &options) {
for (auto elem : file_list) { for (auto elem : file_list) {
StringUtils::Trim(elem); StringUtils::Trim(elem);


void *handle = dlopen(elem.c_str(), RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
void *handle = mmDlopen(elem.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL | MMPA_RTLD_NODELETE);
if (handle == nullptr) { if (handle == nullptr) {
GELOGW("dlopen failed, plugin name:%s. Message(%s).", elem.c_str(), dlerror());
const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGW("dlopen failed, plugin name:%s. Message(%s).", elem.c_str(), error);
} else if (find(handles_vec_.begin(), handles_vec_.end(), handle) == handles_vec_.end()) { } else if (find(handles_vec_.begin(), handles_vec_.end(), handle) == handles_vec_.end()) {
// Close dl when the program exist, not close here // Close dl when the program exist, not close here
GELOGI("Plugin load %s success.", elem.c_str()); GELOGI("Plugin load %s success.", elem.c_str());


+ 0
- 1
ge/common/ge/tbe_plugin_manager.h View File

@@ -17,7 +17,6 @@
#ifndef GE_COMMON_GE_TBE_PLUGIN_MANAGER_H_ #ifndef GE_COMMON_GE_TBE_PLUGIN_MANAGER_H_
#define GE_COMMON_GE_TBE_PLUGIN_MANAGER_H_ #define GE_COMMON_GE_TBE_PLUGIN_MANAGER_H_


#include <dlfcn.h>
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <map> #include <map>


+ 4
- 2
ge/common/ge_common.mk View File

@@ -110,11 +110,12 @@ LOCAL_SHARED_LIBRARIES := \
libascend_protobuf \ libascend_protobuf \
libc_sec \ libc_sec \
libslog \ libslog \
libmmpa \
libgraph \ libgraph \
libregister \ libregister \
liberror_manager \ liberror_manager \


LOCAL_STATIC_LIBRARIES += libmmpa

LOCAL_LDFLAGS := -lrt -ldl LOCAL_LDFLAGS := -lrt -ldl


include $(BUILD_HOST_SHARED_LIBRARY) include $(BUILD_HOST_SHARED_LIBRARY)
@@ -152,11 +153,12 @@ LOCAL_SHARED_LIBRARIES := \
libascend_protobuf \ libascend_protobuf \
libc_sec \ libc_sec \
libslog \ libslog \
libmmpa \
libgraph \ libgraph \
libregister \ libregister \
liberror_manager \ liberror_manager \


LOCAL_STATIC_LIBRARIES += libmmpa

ifeq ($(device_os),android) ifeq ($(device_os),android)
LOCAL_LDFLAGS += -ldl LOCAL_LDFLAGS += -ldl
LOCAL_LDLIBS += -L$(PWD)/prebuilts/clang/linux-x86/aarch64/android-ndk-r21/sysroot/usr/lib/aarch64-linux-android/29 -llog LOCAL_LDLIBS += -L$(PWD)/prebuilts/clang/linux-x86/aarch64/android-ndk-r21/sysroot/usr/lib/aarch64-linux-android/29 -llog


+ 2
- 4
ge/common/helper/model_cache_helper.cc View File

@@ -14,8 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */


#include <fcntl.h>
#include <unistd.h>
#include <climits> #include <climits>
#include <cstdio> #include <cstdio>
#include <fstream> #include <fstream>
@@ -448,12 +446,12 @@ Status ModelCacheHelper::SaveJsonToFile(const string &file_name, const Json &jso
} }
const string path = cache_path_ + file_name; const string path = cache_path_ + file_name;
const int FILE_AUTHORITY = 0600; const int FILE_AUTHORITY = 0600;
int fd = open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, FILE_AUTHORITY);
int fd = mmOpen2(path.c_str(), M_WRONLY | M_CREAT | O_TRUNC, FILE_AUTHORITY);
if (fd < 0) { if (fd < 0) {
GELOGW("Fail to open the file: %s.", path.c_str()); GELOGW("Fail to open the file: %s.", path.c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (close(fd) != 0) {
if (mmClose(fd) != 0) {
GELOGW("Fail to close the file: %s.", path.c_str()); GELOGW("Fail to close the file: %s.", path.c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


+ 1
- 1
ge/common/helper/model_helper.cc View File

@@ -393,7 +393,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadTask(Om
GELOGE(INTERNAL_ERROR, "ReadProtoFromArray failed."); GELOGE(INTERNAL_ERROR, "ReadProtoFromArray failed.");
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GELOGI("TASK_INFO op_size:%zu, stream_num:%u", task->op().size(), task->stream_num());
GELOGI("TASK_INFO op_size:%d, stream_num:%u", task->op().size(), task->stream_num());
} }
model_->SetModelTaskDef(task); model_->SetModelTaskDef(task);
return SUCCESS; return SUCCESS;


+ 0
- 1
ge/common/model_parser/base.cc View File

@@ -17,7 +17,6 @@
#include "common/model_parser/base.h" #include "common/model_parser/base.h"
#include "common/helper/model_helper.h" #include "common/helper/model_helper.h"
#include <securec.h> #include <securec.h>
#include <sys/sysinfo.h>
#include <fstream> #include <fstream>
#include <memory> #include <memory>
#include <string> #include <string>


+ 6
- 8
ge/common/model_saver.cc View File

@@ -16,9 +16,7 @@


#include "common/model_saver.h" #include "common/model_saver.h"


#include <fcntl.h>
#include <securec.h> #include <securec.h>
#include <unistd.h>
#include <cstdlib> #include <cstdlib>
#include <fstream> #include <fstream>
#include <string> #include <string>
@@ -51,14 +49,14 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
return FAILED; return FAILED;
} }


char real_path[PATH_MAX] = {0};
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path) >= PATH_MAX, return FAILED, "file path is too long!");
GE_IF_BOOL_EXEC(realpath(file_path, real_path) == nullptr,
char real_path[MMPA_MAX_PATH] = {0};
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path) >= MMPA_MAX_PATH, return FAILED, "file path is too long!");
GE_IF_BOOL_EXEC(mmRealPath(file_path, real_path, MMPA_MAX_PATH) != EN_OK,
GELOGI("File %s does not exit, it will be created.", file_path)); GELOGI("File %s does not exit, it will be created.", file_path));


// Open file // Open file
mode_t mode = S_IRUSR | S_IWUSR;
int32_t fd = mmOpen2(real_path, O_RDWR | O_CREAT | O_TRUNC, mode);
mmMode_t mode = M_IRUSR | M_IWUSR;
int32_t fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode);
if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { if (fd == EN_ERROR || fd == EN_INVALID_PARAM) {
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file_path, strerror(errno)}); ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file_path, strerror(errno)});
GELOGE(FAILED, "Open file[%s] failed. %s", file_path, strerror(errno)); GELOGE(FAILED, "Open file[%s] failed. %s", file_path, strerror(errno));
@@ -72,7 +70,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
ErrorManager::GetInstance().ATCReportErrMessage( ErrorManager::GetInstance().ATCReportErrMessage(
"E19004", {"file", "errmsg"}, {file_path, strerror(errno)}); "E19004", {"file", "errmsg"}, {file_path, strerror(errno)});
// Need to both print the error info of mmWrite and mmClose, so return ret after mmClose // Need to both print the error info of mmWrite and mmClose, so return ret after mmClose
GELOGE(FAILED, "Write to file failed. errno = %d, %s", mmpa_ret, strerror(errno));
GELOGE(FAILED, "Write to file failed. errno = %ld, %s", mmpa_ret, strerror(errno));
ret = FAILED; ret = FAILED;
} }
// Close file // Close file


+ 6
- 2
ge/common/profiling/profiling_manager.cc View File

@@ -214,8 +214,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Pa
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::InitFromOptions(const Options &options) { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::InitFromOptions(const Options &options) {
#ifdef DAVINCI_SUPPORT_PROFILING #ifdef DAVINCI_SUPPORT_PROFILING
// enable profiling support two ways: env and front end // enable profiling support two ways: env and front end
const char *profiling_mode = std::getenv("PROFILING_MODE");
const char *prof_options = std::getenv("PROFILING_OPTIONS");
char profiling_mode_temp[MMPA_MAX_PATH] = { 0x00 };
char prof_options_temp[MMPA_MAX_PATH] = { 0x00 };
(void)mmGetEnv("PROFILING_MODE", profiling_mode_temp, MMPA_MAX_PATH);
(void)mmGetEnv("PROFILING_OPTIONS", prof_options_temp, MMPA_MAX_PATH );
const char *profiling_mode = profiling_mode_temp;
const char *prof_options = prof_options_temp;
if ((profiling_mode == nullptr) || (strcmp("true", profiling_mode) != 0) || (prof_options == nullptr)) { if ((profiling_mode == nullptr) || (strcmp("true", profiling_mode) != 0) || (prof_options == nullptr)) {
is_load_profiling_ = false; is_load_profiling_ = false;
is_execute_profiling_ = false; is_execute_profiling_ = false;


+ 5
- 4
ge/common/properties_manager.h View File

@@ -25,13 +25,14 @@


#include "common/dump/dump_properties.h" #include "common/dump/dump_properties.h"
#include "graph/op_desc.h" #include "graph/op_desc.h"
#include "common/ge_compiler_options.h"


namespace ge { namespace ge {
// Configuration property management // Configuration property management
static const char *SYSMODE __attribute__((unused)) = "FMK_SYSMODE";
static const char *USE_FUSION __attribute__((unused)) = "FMK_USE_FUSION";
static const char *TIMESTAT_ENABLE __attribute__((unused)) = "DAVINCI_TIMESTAT_ENABLE";
static const char *ANNDROID_DEBUG __attribute__((unused)) = "ANNDROID_DEBUG";
static const char *SYSMODE GE_ATTRIBUTE_UNUSED = "FMK_SYSMODE";
static const char *USE_FUSION GE_ATTRIBUTE_UNUSED = "FMK_USE_FUSION";
static const char *TIMESTAT_ENABLE GE_ATTRIBUTE_UNUSED = "DAVINCI_TIMESTAT_ENABLE";
static const char *ANNDROID_DEBUG GE_ATTRIBUTE_UNUSED = "ANNDROID_DEBUG";


class PropertiesManager { class PropertiesManager {
public: public:


+ 56
- 29
ge/common/util.cc View File

@@ -16,11 +16,12 @@


#include "framework/common/util.h" #include "framework/common/util.h"


#include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef __GNUC__
#include <regex.h> #include <regex.h>
#include <unistd.h>
#else
#include <regex>
#endif
#include <algorithm> #include <algorithm>
#include <climits> #include <climits>
#include <cstdlib> #include <cstdlib>
@@ -208,29 +209,30 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std::string &directory_path) { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std::string &directory_path) {
GE_CHK_BOOL_EXEC(!directory_path.empty(), return -1, "directory path is empty."); GE_CHK_BOOL_EXEC(!directory_path.empty(), return -1, "directory path is empty.");
auto dir_path_len = directory_path.length(); auto dir_path_len = directory_path.length();
if (dir_path_len >= PATH_MAX) {
ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"},
{directory_path, std::to_string(PATH_MAX)});
GELOGW("Path[%s] len is too long, it must be less than %d", directory_path.c_str(), PATH_MAX);
if (dir_path_len >= MMPA_MAX_PATH) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E19002", {"filepath", "size"}, {directory_path, std::to_string(MMPA_MAX_PATH)});
GELOGW("Path[%s] len is too long, it must be less than %d", directory_path.c_str(), MMPA_MAX_PATH);
return -1; return -1;
} }
char tmp_dir_path[PATH_MAX] = {0};
char tmp_dir_path[MMPA_MAX_PATH] = {0};
for (size_t i = 0; i < dir_path_len; i++) { for (size_t i = 0; i < dir_path_len; i++) {
tmp_dir_path[i] = directory_path[i]; tmp_dir_path[i] = directory_path[i];
if ((tmp_dir_path[i] == '\\') || (tmp_dir_path[i] == '/')) { if ((tmp_dir_path[i] == '\\') || (tmp_dir_path[i] == '/')) {
if (access(tmp_dir_path, F_OK) != 0) {
int32_t ret = mmMkdir(tmp_dir_path, S_IRUSR | S_IWUSR | S_IXUSR); // 700
if (mmAccess2(tmp_dir_path, M_F_OK) != EN_OK) {
int32_t ret = mmMkdir(tmp_dir_path, M_IRUSR | M_IWUSR | M_IXUSR); // 700
if (ret != 0) { if (ret != 0) {
if (errno != EEXIST) { if (errno != EEXIST) {
ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path}); ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path});
GELOGW("Can not create directory %s. Make sure the directory exists and writable.", directory_path.c_str());
GELOGW("Can not create directory %s. Make sure the directory exists and writable.",
directory_path.c_str());
return ret; return ret;
} }
} }
} }
} }
} }
int32_t ret = mmMkdir(const_cast<char *>(directory_path.c_str()), S_IRUSR | S_IWUSR | S_IXUSR); // 700
int32_t ret = mmMkdir(const_cast<char *>(directory_path.c_str()), M_IRUSR | M_IWUSR | M_IXUSR); // 700
if (ret != 0) { if (ret != 0) {
if (errno != EEXIST) { if (errno != EEXIST) {
ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path}); ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path});
@@ -305,9 +307,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromMem(const cha
} }


FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() {
struct timeval tv {};
int ret = gettimeofday(&tv, nullptr);
GE_LOGE_IF(ret != 0, "Func gettimeofday may failed: ret=%d", ret);
mmTimeval tv {};
int ret = mmGetTimeOfDay(&tv, nullptr);
GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed: ret=%d", ret);
auto total_use_time = tv.tv_usec + tv.tv_sec * 1000000; // 1000000: seconds to microseconds auto total_use_time = tv.tv_usec + tv.tv_sec * 1000000; // 1000000: seconds to microseconds
return static_cast<uint64_t>(total_use_time); return static_cast<uint64_t>(total_use_time);
} }
@@ -347,16 +349,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInt64MulOverflow(int6


FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char *path) { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char *path) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL."); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL.");
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
strlen(path) >= PATH_MAX,
ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(PATH_MAX)});
return "", "Path[%s] len is too long, it must be less than %d", path, PATH_MAX);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(path) >= MMPA_MAX_PATH,
ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(MMPA_MAX_PATH)});
return "", "Path[%s] len is too long, it must be less than %d", path, MMPA_MAX_PATH);


// Nullptr is returned when the path does not exist or there is no permission // Nullptr is returned when the path does not exist or there is no permission
// Return absolute path when path is accessible // Return absolute path when path is accessible
std::string res; std::string res;
char resolved_path[PATH_MAX] = {0};
if (realpath(path, resolved_path) != nullptr) {
char resolved_path[MMPA_MAX_PATH] = {0};
if (mmRealPath(path, resolved_path, MMPA_MAX_PATH) == EN_OK) {
res = resolved_path; res = resolved_path;
} }


@@ -383,7 +384,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const
// A regular matching expression to verify the validity of the input file path // A regular matching expression to verify the validity of the input file path
// Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores // Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores
// File name section: Support upper and lower case letters, numbers, underscores chinese and dots(.) // File name section: Support upper and lower case letters, numbers, underscores chinese and dots(.)
std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$";
#ifdef __GNUC__
std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$";
#else
std::string mode = "^[a-zA-Z]:([\\\\/][^\\s\\\\/:*?<>\"|][^\\\\/:*?<>\"|]*)*([/\\\\][^\\s\\\\/:*?<>\"|])?$";
#endif


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
!ValidateStr(real_path, mode), !ValidateStr(real_path, mode),
@@ -392,7 +397,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const
return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason); return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason);


// The absolute path points to a file that is not readable // The absolute path points to a file that is not readable
if (access(real_path.c_str(), R_OK) != 0) {
if (mmAccess2(real_path.c_str(), M_R_OK) != EN_OK) {
ErrorManager::GetInstance().ATCReportErrMessage("E19003", {"file", "errmsg"}, {file_path.c_str(), strerror(errno)}); ErrorManager::GetInstance().ATCReportErrMessage("E19003", {"file", "errmsg"}, {file_path.c_str(), strerror(errno)});
GELOGW("Read file[%s] failed, errmsg[%s]", file_path.c_str(), strerror(errno)); GELOGW("Read file[%s] failed, errmsg[%s]", file_path.c_str(), strerror(errno));
return false; return false;
@@ -410,15 +415,19 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const
return false; return false;
} }


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
strlen(file_path.c_str()) >= PATH_MAX, ErrorManager::GetInstance().ATCReportErrMessage(
"E19002", {"filepath", "size"}, {file_path, std::to_string(PATH_MAX)});
return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), PATH_MAX);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path.c_str()) >= MMPA_MAX_PATH,
ErrorManager::GetInstance().ATCReportErrMessage(
"E19002", {"filepath", "size"}, {file_path, std::to_string(MMPA_MAX_PATH)});
return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), MMPA_MAX_PATH);


// A regular matching expression to verify the validity of the input file path // A regular matching expression to verify the validity of the input file path
// Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores // Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores
// File name section: Support upper and lower case letters, numbers, underscores chinese and dots(.) // File name section: Support upper and lower case letters, numbers, underscores chinese and dots(.)
std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$";
#ifdef __GNUC__
std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$";
#else
std::string mode = "^[a-zA-Z]:([\\\\/][^\\s\\\\/:*?<>\"|][^\\\\/:*?<>\"|]*)*([/\\\\][^\\s\\\\/:*?<>\"|])?$";
#endif


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
!ValidateStr(file_path, mode), !ValidateStr(file_path, mode),
@@ -430,7 +439,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const
// Can get absolute path (file exists) // Can get absolute path (file exists)
if (!real_path.empty()) { if (!real_path.empty()) {
// File is not readable or writable // File is not readable or writable
if (access(real_path.c_str(), W_OK | F_OK) != 0) {
if (mmAccess2(real_path.c_str(), M_W_OK | M_F_OK) != EN_OK) {
ErrorManager::GetInstance().ATCReportErrMessage("E19004", {"file", "errmsg"}, {real_path, strerror(errno)}); ErrorManager::GetInstance().ATCReportErrMessage("E19004", {"file", "errmsg"}, {real_path, strerror(errno)});
GELOGW("Write file[%s] failed, errmsg[%s]", real_path.c_str(), strerror(errno)); GELOGW("Write file[%s] failed, errmsg[%s]", real_path.c_str(), strerror(errno));
return false; return false;
@@ -461,6 +470,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const
} }


FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::string &mode) { FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::string &mode) {
#ifdef __GNUC__
char ebuff[kMaxBuffSize]; char ebuff[kMaxBuffSize];
regex_t reg; regex_t reg;
int cflags = REG_EXTENDED | REG_NOSUB; int cflags = REG_EXTENDED | REG_NOSUB;
@@ -482,6 +492,23 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str


regfree(&reg); regfree(&reg);
return true; return true;
#else
std::wstring wstr(str.begin(), str.end());
std::wstring wmode(mode.begin(), mode.end());
std::wsmatch match;
bool res = false;

try {
std::wregex reg(wmode, std::regex::icase);
// Matching string part
res = regex_match(wstr, match, reg);
res = regex_search(str, std::regex("[`!@#$%^&*()|{}';',<>?]"));
} catch (std::exception &ex) {
GELOGW("The directory %s is invalid, error: %s.", str.c_str(), ex.what());
return false;
}
return !(res) && (str.size() == match.str().size());
#endif
} }


FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) {


+ 1
- 1
ge/engine_manager/dnnengine_manager.cc View File

@@ -433,7 +433,7 @@ Status DNNEngineManager::ReadJsonFile(const std::string &file_path, JsonHandle h
return FAILED; return FAILED;
} }
const char *file = file_path.data(); const char *file = file_path.data();
if ((access(file, F_OK)) == -1) {
if ((mmAccess2(file, M_F_OK)) != EN_OK) {
if (engines_map_.size() != 0) { if (engines_map_.size() != 0) {
GELOGE(FAILED, "The json file %s is not exist, %s", file_path.c_str(), strerror(errno)); GELOGE(FAILED, "The json file %s is not exist, %s", file_path.c_str(), strerror(errno));
return FAILED; return FAILED;


+ 2
- 2
ge/ge_inference.mk View File

@@ -387,12 +387,12 @@ LOCAL_SRC_FILES += $(BUILER_SRC_FILES)
LOCAL_SRC_FILES += $(ANALYZER_SRC_FILES) LOCAL_SRC_FILES += $(ANALYZER_SRC_FILES)


LOCAL_STATIC_LIBRARIES := libge_memory \ LOCAL_STATIC_LIBRARIES := libge_memory \
libmmpa \


LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libc_sec \ libc_sec \
libascend_protobuf \ libascend_protobuf \
libslog \ libslog \
libmmpa \
libgraph \ libgraph \
libregister \ libregister \
libge_common \ libge_common \
@@ -451,12 +451,12 @@ LOCAL_C_INCLUDES := $(DEVICE_LOCAL_C_INCLUDES)
LOCAL_C_INCLUDES += $(ANALYZER_LOCAL_INCLUDES) LOCAL_C_INCLUDES += $(ANALYZER_LOCAL_INCLUDES)


LOCAL_STATIC_LIBRARIES := libge_memory \ LOCAL_STATIC_LIBRARIES := libge_memory \
libmmpa \


LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libc_sec \ libc_sec \
libascend_protobuf \ libascend_protobuf \
libslog \ libslog \
libmmpa \
libgraph \ libgraph \
libregister \ libregister \
libresource \ libresource \


+ 1
- 1
ge/ge_runner.mk View File

@@ -372,12 +372,12 @@ LOCAL_SRC_FILES += $(LIBCLIENT_LOCAL_SRC_FILES)
LOCAL_STATIC_LIBRARIES := libge_memory \ LOCAL_STATIC_LIBRARIES := libge_memory \
libadump_server \ libadump_server \
libmsprofiler \ libmsprofiler \
libmmpa \


LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libc_sec \ libc_sec \
libascend_protobuf \ libascend_protobuf \
libslog \ libslog \
libmmpa \
libgraph \ libgraph \
libregister \ libregister \
libge_common \ libge_common \


+ 4
- 4
ge/graph/build/memory/block_mem_assigner.cc View File

@@ -1102,7 +1102,7 @@ bool IsAtomicOutputMemory(const ge::NodePtr &node, uint32_t output_index, bool i
if (static_cast<uint32_t>(index) == output_index) { if (static_cast<uint32_t>(index) == output_index) {
if (node->GetOwnerComputeGraph() != nullptr) { if (node->GetOwnerComputeGraph() != nullptr) {
string graph_name = node->GetOwnerComputeGraph()->GetName(); string graph_name = node->GetOwnerComputeGraph()->GetName();
GELOGD("[IMAS]Atomic no assign %s name[%s] output[%d] streamid[%ld].", graph_name.c_str(),
GELOGD("[IMAS]Atomic no assign %s name[%s] output[%ld] streamid[%ld].", graph_name.c_str(),
op_desc->GetName().c_str(), index, op_desc->GetStreamId()); op_desc->GetName().c_str(), index, op_desc->GetStreamId());
} }
return true; return true;
@@ -1219,7 +1219,7 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector
int64_t stream_id = op_desc->GetStreamId(); int64_t stream_id = op_desc->GetStreamId();
vector<int64_t> memorys_type; vector<int64_t> memorys_type;
bool has_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, memorys_type); bool has_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, memorys_type);
GELOGI("Assign memory node[%s], output size[%d], output memory type size[%d]", op_desc->GetName().c_str(),
GELOGI("Assign memory node[%s], output size[%zu], output memory type size[%zu]", op_desc->GetName().c_str(),
op_desc->GetOutputsSize(), memorys_type.size()); op_desc->GetOutputsSize(), memorys_type.size());
if (has_mem_type_attr && (memorys_type.size() != op_desc->GetOutputsSize())) { if (has_mem_type_attr && (memorys_type.size() != op_desc->GetOutputsSize())) {
GELOGE(INTERNAL_ERROR, "fusion: node[%s], output memory size err[outputsize:%zu, memorysize:%zu]", GELOGE(INTERNAL_ERROR, "fusion: node[%s], output memory size err[outputsize:%zu, memorysize:%zu]",
@@ -1257,7 +1257,7 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector
// fusion: other type's size not means malloc HBM memory // fusion: other type's size not means malloc HBM memory
bool l1_flag = has_mem_type_attr && memorys_type[i] == RT_MEMORY_L1; bool l1_flag = has_mem_type_attr && memorys_type[i] == RT_MEMORY_L1;
if (l1_flag) { if (l1_flag) {
GELOGI("fusion: node[%s], output[%s], output memory type [%d]",
GELOGI("fusion: node[%s], output[%s], output memory type [%ld]",
op_desc->GetName().c_str(), op_desc->GetOutputNameByIndex(i).c_str(), memorys_type[i]); op_desc->GetName().c_str(), op_desc->GetOutputNameByIndex(i).c_str(), memorys_type[i]);
size = 0; size = 0;
} }
@@ -1350,7 +1350,7 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector<int64_t> &ranges) {
bool workspace_skip_flag = false; bool workspace_skip_flag = false;
if (has_tvm_workspace_mem_type_attr && tvm_workspace_memory_type[i] == RT_MEMORY_L1) { if (has_tvm_workspace_mem_type_attr && tvm_workspace_memory_type[i] == RT_MEMORY_L1) {
GELOGI( GELOGI(
"fusion: node[%s]workspace index[%d] is not hbm type, add to zero_memory_list, workspace memory type [%ld]",
"fusion: node[%s]workspace index[%zu] is not hbm type, add to zero_memory_list, workspace memory type [%ld]",
node_op_desc->GetName().c_str(), i, tvm_workspace_memory_type[i]); node_op_desc->GetName().c_str(), i, tvm_workspace_memory_type[i]);
workspace_skip_flag = true; workspace_skip_flag = true;
} }


+ 1
- 1
ge/graph/build/memory/graph_mem_assigner.cc View File

@@ -456,7 +456,7 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node,
output_list.at(peer_out_data_anchor->GetIdx()) - continuous_mem_start + tensor_desc_size + MEM_ALIGN_SIZE; output_list.at(peer_out_data_anchor->GetIdx()) - continuous_mem_start + tensor_desc_size + MEM_ALIGN_SIZE;
} }
GELOGI( GELOGI(
"[IMAS]Check Continuous input : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%zu] "
"[IMAS]Check Continuous input : Set %s name[%s] output[%d] offset to [%ld] stream_id[%ld] size[%u] "
"real_size[%u].", "real_size[%u].",
node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(),
peer_out_data_anchor->GetIdx(), output_list.at(peer_out_data_anchor->GetIdx()), peer_op_desc->GetStreamId(), peer_out_data_anchor->GetIdx(), output_list.at(peer_out_data_anchor->GetIdx()), peer_op_desc->GetStreamId(),


+ 1
- 1
ge/graph/load/new_model_manager/cpu_queue_schedule.cc View File

@@ -131,7 +131,7 @@ Status CpuTaskZeroCopy::Init(std::vector<uintptr_t> &mbuf_list, std::map<const v
for (const auto &virtual_args_addr : virtual_args_addrs) { for (const auto &virtual_args_addr : virtual_args_addrs) {
for (size_t i = 0; i < virtual_args_addr.second.size(); ++i) { for (size_t i = 0; i < virtual_args_addr.second.size(); ++i) {
src_addrs.push_back(mbuf_list.at(index)); src_addrs.push_back(mbuf_list.at(index));
dst_addrs.push_back(reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(virtual_args_addr.second.at(i))));
dst_addrs.push_back(static_cast<uint64_t>(reinterpret_cast<uintptr_t>(virtual_args_addr.second.at(i))));
} }
} }
index++; index++;


+ 35
- 30
ge/graph/load/new_model_manager/davinci_model.cc View File

@@ -17,11 +17,7 @@
#include "graph/load/new_model_manager/davinci_model.h" #include "graph/load/new_model_manager/davinci_model.h"


#include <cce/dnn.h> #include <cce/dnn.h>
#include <dlfcn.h>
#include <graph/utils/node_utils.h> #include <graph/utils/node_utils.h>
#include <pthread.h>
#include <sched.h>
#include <sys/prctl.h>
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <utility> #include <utility>
@@ -1459,7 +1455,7 @@ Status DavinciModel::InitLabelSet(const OpDescPtr &op_desc) {
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (label_index >= LabelNum()) { if (label_index >= LabelNum()) {
GELOGE(INTERNAL_ERROR, "InitLabelSet: label index: %u >= label size: %zu.", label_index, LabelNum());
GELOGE(INTERNAL_ERROR, "InitLabelSet: label index: %u >= label size: %u.", label_index, LabelNum());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (label_id_indication_.count(label_index) > 0) { if (label_id_indication_.count(label_index) > 0) {
@@ -2187,7 +2183,7 @@ Status DavinciModel::CopyInputData(const InputData &input_data, bool device_data
void *mem_addr = data.second.GetBasicAddr(); void *mem_addr = data.second.GetBasicAddr();
void *data_buf_addr = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(data_buf.data)); void *data_buf_addr = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(data_buf.data));
uint64_t data_buf_length = data_buf.length; uint64_t data_buf_length = data_buf.length;
GELOGI("[IMAS]CopyPlainData memcpy graph_%lu type[F] input[%lu] dst[%p] src[%p] mem_size[%lu] datasize[%lu]",
GELOGI("[IMAS]CopyPlainData memcpy graph_%u type[F] input[%u] dst[%p] src[%p] mem_size[%lu] datasize[%lu]",
runtime_param_.graph_id, data.first, mem_addr, data_buf_addr, data_size, data_buf_length); runtime_param_.graph_id, data.first, mem_addr, data_buf_addr, data_size, data_buf_length);
GE_CHK_RT_RET(rtMemcpy(mem_addr, data_size, data_buf_addr, data_buf_length, kind)); GE_CHK_RT_RET(rtMemcpy(mem_addr, data_size, data_buf_addr, data_buf_length, kind));
} }
@@ -2552,10 +2548,10 @@ Status DavinciModel::CopyOutputData(uint32_t data_id, OutputData &output_data, r
if (is_dynamic_) { if (is_dynamic_) {
GELOGI("No need to check output data size."); GELOGI("No need to check output data size.");
} else if (buffer.length < mem_size) { } else if (buffer.length < mem_size) {
GELOGE(FAILED, "Tensor data size=%lu, buffer size=%u", mem_size, buffer.length);
GELOGE(FAILED, "Tensor data size=%lu, buffer size=%lu", mem_size, buffer.length);
return FAILED; return FAILED;
} else if (buffer.length > mem_size) { } else if (buffer.length > mem_size) {
GELOGW("Tensor data size=%lu, buffer size=%u", mem_size, buffer.length);
GELOGW("Tensor data size=%lu, buffer size=%lu", mem_size, buffer.length);
} }
int64_t data_size = output.second.GetDataSize(); int64_t data_size = output.second.GetDataSize();


@@ -2566,7 +2562,7 @@ Status DavinciModel::CopyOutputData(uint32_t data_id, OutputData &output_data, r
uint64_t buffer_length = buffer.length; uint64_t buffer_length = buffer.length;
void *buffer_addr = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(buffer.data)); void *buffer_addr = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(buffer.data));


GELOGI("[IMAS]CopyPlainData memcpy graph_%u type[F] output[%u] memaddr[%p] mem_size[%ld] datasize[%u]",
GELOGI("[IMAS]CopyPlainData memcpy graph_%u type[F] output[%u] memaddr[%p] mem_size[%lu] datasize[%lu]",
runtime_param_.graph_id, output.first, output.second.GetBasicAddr(), data_size, buffer_length); runtime_param_.graph_id, output.first, output.second.GetBasicAddr(), data_size, buffer_length);
GE_CHK_RT_RET(rtMemcpy(buffer_addr, buffer_length, output.second.GetBasicAddr(), data_size, kind)); GE_CHK_RT_RET(rtMemcpy(buffer_addr, buffer_length, output.second.GetBasicAddr(), data_size, kind));
idx++; idx++;
@@ -2982,7 +2978,7 @@ void DavinciModel::UnbindTaskSinkStream() {
Status DavinciModel::CreateKnownZeroCopyMap(const vector<void *> &inputs, const vector<void *> &outputs) { Status DavinciModel::CreateKnownZeroCopyMap(const vector<void *> &inputs, const vector<void *> &outputs) {
GELOGI("DavinciModel::CreateKnownZeroCopyMap in."); GELOGI("DavinciModel::CreateKnownZeroCopyMap in.");
if (inputs.size() > data_op_list_.size()) { if (inputs.size() > data_op_list_.size()) {
GELOGE(FAILED, "input data addr %u should less than input op number %u.", inputs.size(), data_op_list_.size());
GELOGE(FAILED, "input data addr %zu should less than input op number %zu.", inputs.size(), data_op_list_.size());
return FAILED; return FAILED;
} }
// remove zero copy addr in last iteration // remove zero copy addr in last iteration
@@ -2991,16 +2987,16 @@ Status DavinciModel::CreateKnownZeroCopyMap(const vector<void *> &inputs, const
for (size_t i = 0; i < inputs.size(); ++i) { for (size_t i = 0; i < inputs.size(); ++i) {
const vector<void *> addr_list = ModelUtils::GetOutputDataAddrs(runtime_param_, data_op_list_[i]); const vector<void *> addr_list = ModelUtils::GetOutputDataAddrs(runtime_param_, data_op_list_[i]);
knonw_input_data_info_[addr_list[kDataIndex]] = inputs[i]; knonw_input_data_info_[addr_list[kDataIndex]] = inputs[i];
GELOGI("DavinciModel::CreateKnownZeroCopyMap input %d,v addr %p,p addr %p .", i, addr_list[kDataIndex], inputs[i]);
GELOGI("DavinciModel::CreateKnownZeroCopyMap input %zu,v addr %p,p addr %p .", i, addr_list[kDataIndex], inputs[i]);
} }
if (output_op_list_.size() < kOutputNum) { if (output_op_list_.size() < kOutputNum) {
GELOGW("output op num in graph is %u.", output_op_list_.size());
GELOGW("output op num in graph is %zu.", output_op_list_.size());
return SUCCESS; return SUCCESS;
} }
const vector<void *> addr_list = ModelUtils::GetInputDataAddrs(runtime_param_, output_op_list_[kDataIndex]); const vector<void *> addr_list = ModelUtils::GetInputDataAddrs(runtime_param_, output_op_list_[kDataIndex]);
for (size_t i = 0; i < addr_list.size() && i < outputs.size(); ++i) { for (size_t i = 0; i < addr_list.size() && i < outputs.size(); ++i) {
knonw_output_data_info_[addr_list[i]] = outputs[i]; knonw_output_data_info_[addr_list[i]] = outputs[i];
GELOGI("DavinciModel::CreateKnownZeroCopyMap output %d,v addr %p,p addr %p .", i, addr_list[i], outputs[i]);
GELOGI("DavinciModel::CreateKnownZeroCopyMap output %zu,v addr %p,p addr %p .", i, addr_list[i], outputs[i]);
} }
GELOGI("DavinciModel::CreateKnownZeroCopyMap success."); GELOGI("DavinciModel::CreateKnownZeroCopyMap success.");
return SUCCESS; return SUCCESS;
@@ -3010,13 +3006,13 @@ Status DavinciModel::UpdateKnownZeroCopyAddr() {
for (size_t i = 0; i < total_io_addrs_.size(); ++i) { for (size_t i = 0; i < total_io_addrs_.size(); ++i) {
auto it_in = knonw_input_data_info_.find(total_io_addrs_[i]); auto it_in = knonw_input_data_info_.find(total_io_addrs_[i]);
if (it_in != knonw_input_data_info_.end()) { if (it_in != knonw_input_data_info_.end()) {
GELOGI("DavinciModel::UpdateKnownZeroCopyAddr input %d,v addr %p,p addr %p .", i, total_io_addrs_[i],
GELOGI("DavinciModel::UpdateKnownZeroCopyAddr input %zu,v addr %p,p addr %p .", i, total_io_addrs_[i],
knonw_input_data_info_.at(total_io_addrs_[i])); knonw_input_data_info_.at(total_io_addrs_[i]));
total_io_addrs_[i] = knonw_input_data_info_.at(total_io_addrs_[i]); total_io_addrs_[i] = knonw_input_data_info_.at(total_io_addrs_[i]);
} }
auto it_out = knonw_output_data_info_.find(total_io_addrs_[i]); auto it_out = knonw_output_data_info_.find(total_io_addrs_[i]);
if (it_out != knonw_output_data_info_.end()) { if (it_out != knonw_output_data_info_.end()) {
GELOGI("DavinciModel::UpdateKnownZeroCopyAddr output %d,v addr %p,p addr %p .", i, total_io_addrs_[i],
GELOGI("DavinciModel::UpdateKnownZeroCopyAddr output %zu,v addr %p,p addr %p .", i, total_io_addrs_[i],
knonw_output_data_info_.at(total_io_addrs_[i])); knonw_output_data_info_.at(total_io_addrs_[i]));
total_io_addrs_[i] = knonw_output_data_info_.at(total_io_addrs_[i]); total_io_addrs_[i] = knonw_output_data_info_.at(total_io_addrs_[i]);
} }
@@ -3037,7 +3033,7 @@ Status DavinciModel::UpdateKnownNodeArgs(const vector<void *> &inputs, const vec
if (task != nullptr) { if (task != nullptr) {
Status ret = task->UpdateArgs(); Status ret = task->UpdateArgs();
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "task %d created by davinci model is nullptr.", task_index);
GELOGE(FAILED, "task %zu created by davinci model is nullptr.", task_index);
return FAILED; return FAILED;
} }
} }
@@ -3066,7 +3062,7 @@ Status DavinciModel::UpdateKnownNodeArgs(const vector<void *> &inputs, const vec
} }


Status DavinciModel::InitTaskInfo(domi::ModelTaskDef &model_task_def) { Status DavinciModel::InitTaskInfo(domi::ModelTaskDef &model_task_def) {
GELOGI("InitTaskInfo in, task size %zu", model_task_def.task().size());
GELOGI("InitTaskInfo in, task size %d", model_task_def.task().size());
task_list_.resize(model_task_def.task_size()); task_list_.resize(model_task_def.task_size());
for (int i = 0; i < model_task_def.task_size(); ++i) { for (int i = 0; i < model_task_def.task_size(); ++i) {
// dynamic shape will create task_list_ before // dynamic shape will create task_list_ before
@@ -3142,8 +3138,9 @@ Status DavinciModel::DistributeTask() {


task_desc_info_.clear(); task_desc_info_.clear();
bool flag = GetL1FusionEnableOption(); bool flag = GetL1FusionEnableOption();
char *skt_enable_env = std::getenv("SKT_ENABLE");
int64_t env_flag = (skt_enable_env != nullptr) ? std::strtol(skt_enable_env, nullptr, kDecimal) : 0;
char skt_enable_env[MMPA_MAX_PATH] = { 0x00 };
INT32 res = mmGetEnv("SKT_ENABLE", skt_enable_env, MMPA_MAX_PATH);
int64_t env_flag = (res == EN_OK) ? std::strtol(skt_enable_env, nullptr, kDecimal) : 0;
if (env_flag != 0) { if (env_flag != 0) {
flag = true; flag = true;
} }
@@ -3331,7 +3328,7 @@ bool DavinciModel::CheckInputAndModelSize(const int64_t &input_size, const int64


if (input_size > op_size) { if (input_size > op_size) {
GELOGW( GELOGW(
"Input size [%u] is bigger than om size need [%u], "
"Input size [%ld] is bigger than om size need [%ld], "
"MAY cause inference result ERROR, please check model input", "MAY cause inference result ERROR, please check model input",
input_size, op_size); input_size, op_size);
} }
@@ -3413,7 +3410,7 @@ Status DavinciModel::UpdateIoTaskArgs(const std::map<uint32_t, ZeroCopyOffset> &


for (const auto &data : data_info) { for (const auto &data : data_info) {
if (data.first >= blobs.size()) { // check data index. if (data.first >= blobs.size()) { // check data index.
GELOGE(FAILED, "Verify %s data num failed: can not find No.%zu data, because user only feeds %zu",
GELOGE(FAILED, "Verify %s data num failed: can not find No.%u data, because user only feeds %zu",
input_or_output.c_str(), data.first, blobs.size()); input_or_output.c_str(), data.first, blobs.size());
return FAILED; return FAILED;
} }
@@ -3522,7 +3519,7 @@ Status DavinciModel::InitConstant(const OpDescPtr &op_desc) {


GeTensor *tensor = const_cast<GeTensor *>(v_weights[0].get()); GeTensor *tensor = const_cast<GeTensor *>(v_weights[0].get());
GE_IF_BOOL_EXEC(static_cast<size_t>(v_output_size[0]) < tensor->GetData().size(), GE_IF_BOOL_EXEC(static_cast<size_t>(v_output_size[0]) < tensor->GetData().size(),
GELOGE(PARAM_INVALID, "output size:%u less than weight data size:%zu", v_output_size[0],
GELOGE(PARAM_INVALID, "output size:%ld less than weight data size:%zu", v_output_size[0],
tensor->GetData().size()); tensor->GetData().size());
return PARAM_INVALID;); return PARAM_INVALID;);


@@ -3546,12 +3543,12 @@ Status DavinciModel::InitConstant(const OpDescPtr &op_desc) {
uint64_t offset = static_cast<uint64_t>(elem_num * kBytes); uint64_t offset = static_cast<uint64_t>(elem_num * kBytes);


uint64_t hbm_raw_data_base_addr = uint64_t hbm_raw_data_base_addr =
reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(v_output_addr[0])) + offset;
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(v_output_addr[0])) + offset;
for (int64_t i = elem_num - 1; i >= 0; --i) { for (int64_t i = elem_num - 1; i >= 0; --i) {
buff[i] = hbm_raw_data_base_addr + (buff[i] - buff[0]); buff[i] = hbm_raw_data_base_addr + (buff[i] - buff[0]);
} }
} }
GELOGI("[IMAS]InitConstant memcpy graph_%u type[V] name[%s] output[%d] memaddr[%p] mem_size[%u] datasize[%zu]",
GELOGI("[IMAS]InitConstant memcpy graph_%u type[V] name[%s] output[%d] memaddr[%p] mem_size[%lu] datasize[%zu]",
runtime_param_.graph_id, op_desc->GetName().c_str(), 0, v_output_addr[0], v_output_size[0], runtime_param_.graph_id, op_desc->GetName().c_str(), 0, v_output_addr[0], v_output_size[0],
tensor->GetData().size()); tensor->GetData().size());
GE_CHK_RT_RET(rtMemcpy(v_output_addr[0], v_output_size[0], tensor->GetData().data(), tensor->GetData().size(), GE_CHK_RT_RET(rtMemcpy(v_output_addr[0], v_output_size[0], tensor->GetData().data(), tensor->GetData().size(),
@@ -3906,7 +3903,9 @@ Status DavinciModel::InitEntryTask() {
uint8_t *DavinciModel::MallocFeatureMapMem(size_t data_size) { uint8_t *DavinciModel::MallocFeatureMapMem(size_t data_size) {
uint8_t *mem_base = nullptr; uint8_t *mem_base = nullptr;
const string purpose("feature map,used for op input and output."); const string purpose("feature map,used for op input and output.");
if (std::getenv(kEnvGeuseStaticMemory) != nullptr) {
char ge_static_mem_env[MMPA_MAX_PATH] = { 0x00 };
INT32 res = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH);
if (res == EN_OK) {
data_size = static_cast<size_t>(VarManager::Instance(session_id_)->GetGraphMemoryMaxSize()); data_size = static_cast<size_t>(VarManager::Instance(session_id_)->GetGraphMemoryMaxSize());
string memory_key = std::to_string(0) + "_f"; string memory_key = std::to_string(0) + "_f";
mem_base = MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, memory_key, data_size, GetDeviceId()); mem_base = MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, memory_key, data_size, GetDeviceId());
@@ -3936,7 +3935,9 @@ uint8_t *DavinciModel::MallocP2PMem(size_t p2p_data_size) {
uint8_t *DavinciModel::MallocWeightsMem(size_t weights_size) { uint8_t *DavinciModel::MallocWeightsMem(size_t weights_size) {
uint8_t *weights_mem_base = nullptr; uint8_t *weights_mem_base = nullptr;
const string purpose("weights memory in inference network."); const string purpose("weights memory in inference network.");
if (std::getenv(kEnvGeuseStaticMemory) != nullptr) {
char ge_static_mem_env[MMPA_MAX_PATH] = { 0x00 };
INT32 res = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH);
if (res == EN_OK) {
string weight_memory_key = std::to_string(0) + "_w"; string weight_memory_key = std::to_string(0) + "_w";
weights_mem_base = weights_mem_base =
MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, weight_memory_key, weights_size, GetDeviceId()); MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, weight_memory_key, weights_size, GetDeviceId());
@@ -3947,7 +3948,9 @@ uint8_t *DavinciModel::MallocWeightsMem(size_t weights_size) {
} }


void DavinciModel::FreeFeatureMapMem() { void DavinciModel::FreeFeatureMapMem() {
if (std::getenv(kEnvGeuseStaticMemory) != nullptr && is_inner_mem_base_) {
char ge_static_mem_env[MMPA_MAX_PATH] = { 0x00 };
INT32 res = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH);
if (res == EN_OK && is_inner_mem_base_) {
string weight_memory_key = std::to_string(0) + "_f"; string weight_memory_key = std::to_string(0) + "_f";
if (MemManager::Instance(RT_MEMORY_HBM)->GetMemoryAddr(weight_memory_key) != nullptr) { if (MemManager::Instance(RT_MEMORY_HBM)->GetMemoryAddr(weight_memory_key) != nullptr) {
GE_CHK_STATUS(MemManager::Instance(RT_MEMORY_HBM)->FreeMemory(weight_memory_key, GetDeviceId()), GE_CHK_STATUS(MemManager::Instance(RT_MEMORY_HBM)->FreeMemory(weight_memory_key, GetDeviceId()),
@@ -3979,7 +3982,9 @@ void DavinciModel::FreeP2PMem() {
} }


void DavinciModel::FreeWeightsMem() { void DavinciModel::FreeWeightsMem() {
if (std::getenv(kEnvGeuseStaticMemory) != nullptr) {
char ge_static_mem_env[MMPA_MAX_PATH] = { 0x00 };
INT32 res = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH);
if (res == EN_OK) {
string memory_key = std::to_string(0) + "_w"; string memory_key = std::to_string(0) + "_w";
if (MemManager::Instance(RT_MEMORY_HBM)->GetMemoryAddr(memory_key) != nullptr) { if (MemManager::Instance(RT_MEMORY_HBM)->GetMemoryAddr(memory_key) != nullptr) {
GE_CHK_STATUS(MemManager::Instance(RT_MEMORY_HBM)->FreeMemory(memory_key, GetDeviceId()), GE_CHK_STATUS(MemManager::Instance(RT_MEMORY_HBM)->FreeMemory(memory_key, GetDeviceId()),
@@ -4160,7 +4165,7 @@ Status DavinciModel::GetAllAippInputOutputDims(uint32_t index, std::vector<Input


vector<std::string> inputs; vector<std::string> inputs;
if (AttrUtils::GetListStr(data_op, ATTR_NAME_AIPP_INPUTS, inputs) && !inputs.empty()) { if (AttrUtils::GetListStr(data_op, ATTR_NAME_AIPP_INPUTS, inputs) && !inputs.empty()) {
GELOGI("GetAllAippInputOutputDims: Data: %s has %u related aippInfo.", data_op->GetName().c_str(), inputs.size());
GELOGI("GetAllAippInputOutputDims: Data: %s has %zu related aippInfo.", data_op->GetName().c_str(), inputs.size());
for (auto it : inputs) { for (auto it : inputs) {
InputOutputDims input_info; InputOutputDims input_info;
ParseAIPPInfo(it, input_info); ParseAIPPInfo(it, input_info);
@@ -4171,7 +4176,7 @@ Status DavinciModel::GetAllAippInputOutputDims(uint32_t index, std::vector<Input
int64_t data_input_size; int64_t data_input_size;
(void)TensorUtils::GetSize(*(data_op->GetInputDescPtr(kDataIndex)), data_input_size); (void)TensorUtils::GetSize(*(data_op->GetInputDescPtr(kDataIndex)), data_input_size);
GELOGD( GELOGD(
"GetAllAippInputOutputDims related Data[%d]: tensor_name is %s, dim_num is %u, tensor_size: %zu, format: "
"GetAllAippInputOutputDims related Data[%d]: tensor_name is %s, dim_num is %zu, tensor_size: %zu, format: "
"%s, data_type: %s, shape: %s .", "%s, data_type: %s, shape: %s .",
index, data_op->GetName().c_str(), data_input_desc->GetShape().GetDimNum(), data_input_size, index, data_op->GetName().c_str(), data_input_desc->GetShape().GetDimNum(), data_input_size,
TypeUtils::FormatToSerialString(data_input_desc->GetFormat()).c_str(), TypeUtils::FormatToSerialString(data_input_desc->GetFormat()).c_str(),


+ 5
- 5
ge/graph/load/new_model_manager/model_manager.cc View File

@@ -1019,8 +1019,8 @@ Status ModelManager::GetAippType(uint32_t model_id, uint32_t index, InputAippTyp
Status ModelManager::GenSessionId(uint64_t &session_id) { Status ModelManager::GenSessionId(uint64_t &session_id) {
std::lock_guard<std::mutex> lock(session_id_create_mutex_); std::lock_guard<std::mutex> lock(session_id_create_mutex_);


struct timeval tv;
if (gettimeofday(&tv, nullptr) != 0) {
mmTimeval tv;
if (mmGetTimeOfDay(&tv, nullptr) != 0) {
GELOGE(INTERNAL_ERROR, "Failed to get current time."); GELOGE(INTERNAL_ERROR, "Failed to get current time.");
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -1037,8 +1037,8 @@ Status ModelManager::GenSessionId(uint64_t &session_id) {


Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model, shared_ptr<ModelListener> listener, Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model, shared_ptr<ModelListener> listener,
void *dev_ptr, size_t mem_size, void *weight_ptr, size_t weight_size) { void *dev_ptr, size_t mem_size, void *weight_ptr, size_t weight_size) {
GE_CHK_BOOL_RET_STATUS(model.key.empty() || access(model.key.c_str(), F_OK) == 0,
ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID,
GE_CHK_BOOL_RET_STATUS(model.key.empty() || mmAccess2(model.key.c_str(), M_F_OK) == EN_OK,
ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID,
"input key file path %s is invalid, %s", model.key.c_str(), strerror(errno)); "input key file path %s is invalid, %s", model.key.c_str(), strerror(errno));
GenModelId(&model_id); GenModelId(&model_id);


@@ -1123,7 +1123,7 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model
Status ModelManager::LoadModelWithQ(uint32_t &model_id, const ModelData &model_data, Status ModelManager::LoadModelWithQ(uint32_t &model_id, const ModelData &model_data,
const std::vector<uint32_t> &input_queue_ids, const std::vector<uint32_t> &input_queue_ids,
const std::vector<uint32_t> &output_queue_ids) { const std::vector<uint32_t> &output_queue_ids) {
GE_CHK_BOOL_RET_STATUS(model_data.key.empty() || access(model_data.key.c_str(), F_OK) == 0,
GE_CHK_BOOL_RET_STATUS(model_data.key.empty() || mmAccess2(model_data.key.c_str(), M_F_OK) == EN_OK,
ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, "input key file path %s is not valid, %s", ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, "input key file path %s is not valid, %s",
model_data.key.c_str(), strerror(errno)); model_data.key.c_str(), strerror(errno));




+ 0
- 1
ge/graph/load/new_model_manager/model_manager.h View File

@@ -18,7 +18,6 @@
#define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_MODEL_MANAGER_H_ #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_MODEL_MANAGER_H_


#include <model/ge_root_model.h> #include <model/ge_root_model.h>
#include <pthread.h>
#include <stdint.h> #include <stdint.h>
#include <algorithm> #include <algorithm>
#include <map> #include <map>


+ 3
- 3
ge/graph/load/new_model_manager/model_utils.cc View File

@@ -356,7 +356,7 @@ vector<void *> ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co
// feature maps // feature maps
void *mem_addr = nullptr; void *mem_addr = nullptr;
if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion
mem_addr = reinterpret_cast<uint8_t *>(reinterpret_cast<intptr_t>(input_offset));
mem_addr = reinterpret_cast<uint8_t *>(static_cast<intptr_t>(input_offset));
v_input_data_addr.push_back(mem_addr); v_input_data_addr.push_back(mem_addr);
} else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) { } else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) {
int64_t tensor_size = 0; int64_t tensor_size = 0;
@@ -424,7 +424,7 @@ vector<void *> ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C
// feature maps // feature maps
void *mem_addr = nullptr; void *mem_addr = nullptr;
if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion
mem_addr = reinterpret_cast<uint8_t *>(reinterpret_cast<intptr_t>(v_output_offset[i]));
mem_addr = reinterpret_cast<uint8_t *>(static_cast<intptr_t>(v_output_offset[i]));
v_output_data_addr.push_back(mem_addr); v_output_data_addr.push_back(mem_addr);
} else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) { } else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) {
const GeTensorDescPtr tensor_desc = op_desc->MutableOutputDesc(i); const GeTensorDescPtr tensor_desc = op_desc->MutableOutputDesc(i);
@@ -500,7 +500,7 @@ vector<void *> ModelUtils::GetWorkspaceDataAddrs(const RuntimeParam &model_param
continue; continue;
} }
if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) {
v_workspace_data_addr.push_back(reinterpret_cast<uint8_t *>(reinterpret_cast<intptr_t>(v_workspace_offset[i])));
v_workspace_data_addr.push_back(reinterpret_cast<uint8_t *>(static_cast<intptr_t>(v_workspace_offset[i])));
GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[L1] name[%s], mem_addr[workspace index %zu]:0x%lx", GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[L1] name[%s], mem_addr[workspace index %zu]:0x%lx",
model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i]); model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i]);
} else if (v_workspace_bytes[i] == 0) { } else if (v_workspace_bytes[i] == 0) {


+ 2
- 2
ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc View File

@@ -149,7 +149,7 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin
return FAILED; return FAILED;
} }


uint64_t workspace_base_addr = reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(workspace_data_addrs[0]));
uint64_t workspace_base_addr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(workspace_data_addrs[0]));
const vector<void *> input_addrs = ModelUtils::GetInputDataAddrs(rts_param, op_desc); const vector<void *> input_addrs = ModelUtils::GetInputDataAddrs(rts_param, op_desc);
const vector<void *> output_addrs = ModelUtils::GetOutputDataAddrs(rts_param, op_desc); const vector<void *> output_addrs = ModelUtils::GetOutputDataAddrs(rts_param, op_desc);
vector<void *> io_addrs; vector<void *> io_addrs;
@@ -287,7 +287,7 @@ Status KernelExTaskInfo::CopyTaskInfo(const domi::KernelExDef &kernel_def, const
} }


if (workspace_data_sizes[0] < static_cast<int64_t>(kernel_def.task_info_size())) { if (workspace_data_sizes[0] < static_cast<int64_t>(kernel_def.task_info_size())) {
GELOGE(FAILED, "Node:%s workspace size is %zu, task info size is %zu.", op_desc->GetName().c_str(),
GELOGE(FAILED, "Node:%s workspace size is %ld, task info size is %d.", op_desc->GetName().c_str(),
workspace_data_sizes[0], kernel_def.task_info_size()); workspace_data_sizes[0], kernel_def.task_info_size());
return FAILED; return FAILED;
} }


+ 28
- 18
ge/graph/load/new_model_manager/task_info/kernel_task_info.cc View File

@@ -73,7 +73,8 @@ Status KernelTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci
GELOGD("node[%s] is_n_batch_spilt %d", op_desc_->GetName().c_str(), is_n_batch_spilt_); GELOGD("node[%s] is_n_batch_spilt %d", op_desc_->GetName().c_str(), is_n_batch_spilt_);
(void)AttrUtils::GetInt(*op_desc_, ATTR_NAME_FUSION_GROUP_KEY, group_key_); (void)AttrUtils::GetInt(*op_desc_, ATTR_NAME_FUSION_GROUP_KEY, group_key_);
has_group_key_ = (group_key_ != kInvalidGroupKey); has_group_key_ = (group_key_ != kInvalidGroupKey);
GELOGD("node[%s] has_group_key_ %ld, group key is [%ld]", op_desc_->GetName().c_str(), has_group_key_, group_key_);
GELOGD("node[%s] has_group_key_ %d, group key is [%ld]", op_desc_->GetName().c_str(), has_group_key_, group_key_);

// fusion_op_info // fusion_op_info
vector<std::string> original_op_names; vector<std::string> original_op_names;
bool result = AttrUtils::GetListStr(op_desc_, ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, original_op_names); bool result = AttrUtils::GetListStr(op_desc_, ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, original_op_names);
@@ -216,7 +217,7 @@ Status KernelTaskInfo::SuperKernelLaunch() {
rtError_t rt_ret; rtError_t rt_ret;
auto &skt_kernel_list = skt_info_.kernel_list; auto &skt_kernel_list = skt_info_.kernel_list;
auto &skt_arg_list = skt_info_.arg_list; auto &skt_arg_list = skt_info_.arg_list;
GELOGI("SuperKernelLaunch: Skt_kernel_list size[%d] skt_arg_list[%d]", skt_kernel_list.size(), skt_arg_list.size());
GELOGI("SuperKernelLaunch: Skt_kernel_list size[%zu] skt_arg_list[%zu]", skt_kernel_list.size(), skt_arg_list.size());
if (skt_kernel_list.size() == kSKTSingleSize && skt_arg_list.size() == kSKTSingleSize) { if (skt_kernel_list.size() == kSKTSingleSize && skt_arg_list.size() == kSKTSingleSize) {
rt_ret = rtKernelLaunchWithFlag(skt_info_.kernel_list[0], static_cast<uint32_t>(skt_info_.last_block_dim), rt_ret = rtKernelLaunchWithFlag(skt_info_.kernel_list[0], static_cast<uint32_t>(skt_info_.last_block_dim),
skt_info_.arg_list[0], skt_info_.last_args_size, skt_info_.arg_list[0], skt_info_.last_args_size,
@@ -367,8 +368,9 @@ Status KernelTaskInfo::Distribute() {
GELOGI("Known node %s args addr %p, offset %u.", op_desc_->GetName().c_str(), args_, args_offset_); GELOGI("Known node %s args addr %p, offset %u.", op_desc_->GetName().c_str(), args_, args_offset_);
} }
rtError_t rt_ret = RT_ERROR_NONE; rtError_t rt_ret = RT_ERROR_NONE;
char *skt_enable_env = getenv("SKT_ENABLE");
int64_t env_flag = (skt_enable_env != nullptr) ? strtol(skt_enable_env, nullptr, 10) : 0;
char skt_enable_env[MMPA_MAX_PATH] = { 0x00 };
INT32 res = mmGetEnv("SKT_ENABLE", skt_enable_env, MMPA_MAX_PATH);
int64_t env_flag = (res == EN_OK) ? strtol(skt_enable_env, nullptr, 10) : 0;
bool call_skt = ((env_flag != 0) || is_l1_fusion_enable_); bool call_skt = ((env_flag != 0) || is_l1_fusion_enable_);
if (kernel_type_ == cce::ccKernelType::AI_CPU || kernel_type_ == cce::ccKernelType::CUST_AI_CPU) { if (kernel_type_ == cce::ccKernelType::AI_CPU || kernel_type_ == cce::ccKernelType::CUST_AI_CPU) {
GELOGI("distribute task info kernel_type %d, flag %d", kernel_type_, dump_flag_); GELOGI("distribute task info kernel_type %d, flag %d", kernel_type_, dump_flag_);
@@ -747,15 +749,15 @@ Status KernelTaskInfo::InitAICPUCustomTask(uint32_t op_index, const domi::Kernel
} }
} }
*(reinterpret_cast<uint64_t *>(args + ctx_.argsOffset[0])) = *(reinterpret_cast<uint64_t *>(args + ctx_.argsOffset[0])) =
reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(custom_info_.input_descs)); // arg 0
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(custom_info_.input_descs)); // arg 0
*(reinterpret_cast<uint64_t *>(args + ctx_.argsOffset[1])) = *(reinterpret_cast<uint64_t *>(args + ctx_.argsOffset[1])) =
reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(custom_info_.input_addrs)); // arg 1
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(custom_info_.input_addrs)); // arg 1
*(reinterpret_cast<uint64_t *>(args + ctx_.argsOffset[2])) = *(reinterpret_cast<uint64_t *>(args + ctx_.argsOffset[2])) =
reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(custom_info_.output_descs)); // arg 2
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(custom_info_.output_descs)); // arg 2
*(reinterpret_cast<uint64_t *>(args + ctx_.argsOffset[3])) = *(reinterpret_cast<uint64_t *>(args + ctx_.argsOffset[3])) =
reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(custom_info_.output_addrs)); // arg 3
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(custom_info_.output_addrs)); // arg 3
*(reinterpret_cast<uint64_t *>(args + ctx_.argsOffset[4])) = *(reinterpret_cast<uint64_t *>(args + ctx_.argsOffset[4])) =
reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(custom_info_.attr_handle)); // arg 4
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(custom_info_.attr_handle)); // arg 4


rt_ret = rtMalloc(&args_, args_size_, RT_MEMORY_HBM); rt_ret = rtMalloc(&args_, args_size_, RT_MEMORY_HBM);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
@@ -913,7 +915,7 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k
op_desc_->GetType().c_str(), ext_info.size(), aicpu_ext_info_addr_); op_desc_->GetType().c_str(), ext_info.size(), aicpu_ext_info_addr_);


aicpu_param_head->extInfoAddr = reinterpret_cast<uintptr_t>(aicpu_ext_info_addr_); aicpu_param_head->extInfoAddr = reinterpret_cast<uintptr_t>(aicpu_ext_info_addr_);
aicpu_param_head->extInfoLength = reinterpret_cast<uintptr_t>(ext_info.size());
aicpu_param_head->extInfoLength = static_cast<uintptr_t>(ext_info.size());


// malloc device memory for args // malloc device memory for args
rtError_t rt_ret = rtMalloc(static_cast<void **>(&args_), args_size_, RT_MEMORY_HBM); rtError_t rt_ret = rtMalloc(static_cast<void **>(&args_), args_size_, RT_MEMORY_HBM);
@@ -1122,18 +1124,24 @@ Status KernelTaskInfo::CceUpdateKernelArgs(const domi::KernelContext &context, u
} }


GELOGI("FileName:%s, Path:%s.", file_name.c_str(), canonicalPath.c_str()); GELOGI("FileName:%s, Path:%s.", file_name.c_str(), canonicalPath.c_str());
auto handle = dlopen(canonicalPath.c_str(), RTLD_NOW | RTLD_GLOBAL);
auto handle = mmDlopen(canonicalPath.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL);
const char *error = "";
if (handle == nullptr) { if (handle == nullptr) {
GELOGE(GE_PLGMGR_SO_NOT_EXIST, "Failed in dlopen %s! ", dlerror());
error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGE(GE_PLGMGR_SO_NOT_EXIST, "Failed in dlopen %s! ", error);
return FAILED; return FAILED;
} }
cce::ccStatus_t cc_ret; cce::ccStatus_t cc_ret;
std::string update_kernel_args = "ccUpdateKernelArgs";
auto cceUpdateKernelArgs = (cce::ccStatus_t(*)(cce::ccOpContext &, uint64_t, uint64_t, uint64_t, void *, uint64_t, auto cceUpdateKernelArgs = (cce::ccStatus_t(*)(cce::ccOpContext &, uint64_t, uint64_t, uint64_t, void *, uint64_t,
void *))dlsym(handle, "ccUpdateKernelArgs");
void *))mmDlsym(handle, const_cast<char *>(update_kernel_args.c_str()));
if (cceUpdateKernelArgs == nullptr) { if (cceUpdateKernelArgs == nullptr) {
GELOGE(FAILED, "Failed to invoke function ccUpdateKernelArgs"); GELOGE(FAILED, "Failed to invoke function ccUpdateKernelArgs");
if (dlclose(handle) != 0) {
GELOGW("Failed to close handle %s", dlerror());
if (mmDlclose(handle) != 0) {
error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGW("Failed to close handle %s", error);
} }
return FAILED; return FAILED;
} else { } else {
@@ -1146,8 +1154,10 @@ Status KernelTaskInfo::CceUpdateKernelArgs(const domi::KernelContext &context, u
const_cast<char *>(kernel_def.args().data()), args_size_, sm_contrl); const_cast<char *>(kernel_def.args().data()), args_size_, sm_contrl);
} }
} }
if (dlclose(handle) != 0) {
GELOGW("Failed to close handle %s", dlerror());
if (mmDlclose(handle) != 0) {
error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGW("Failed to close handle %s", error);
return FAILED; return FAILED;
} }
if (cc_ret != cce::CC_STATUS_SUCCESS) { if (cc_ret != cce::CC_STATUS_SUCCESS) {
@@ -1188,7 +1198,7 @@ Status KernelTaskInfo::SetFlowtable(std::string &flowtable, const domi::KernelDe


*(reinterpret_cast<uint64_t *>( *(reinterpret_cast<uint64_t *>(
args + (reinterpret_cast<uint16_t *>(const_cast<char *>(context.args_offset().data())))[0])) = args + (reinterpret_cast<uint16_t *>(const_cast<char *>(context.args_offset().data())))[0])) =
reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(flowtable_));
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(flowtable_));
} }
return SUCCESS; return SUCCESS;
} }


+ 1
- 1
ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc View File

@@ -23,7 +23,7 @@ Status SuperKernel::Launch(rtStream_t stream, uint32_t dump_flag) {
const void *func_stub_ = this->GetFuncStub(); const void *func_stub_ = this->GetFuncStub();


const void *args[] = {this->GetNavTablePtr(), const void *args[] = {this->GetNavTablePtr(),
reinterpret_cast<const void *>(reinterpret_cast<uintptr_t>(this->GetNavTableSize()))};
reinterpret_cast<const void *>(static_cast<uintptr_t>(this->GetNavTableSize()))};


rtError_t rt_ret = rtMalloc((void **)&(device_args_addr_), sizeof(args), RT_MEMORY_HBM); rtError_t rt_ret = rtMalloc((void **)&(device_args_addr_), sizeof(args), RT_MEMORY_HBM);
GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc failied. error: 0x%X", rt_ret); return GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc failied. error: 0x%X", rt_ret); return


+ 8
- 6
ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc View File

@@ -27,7 +27,7 @@ SuperKernelFactory &SuperKernelFactory::GetInstance() {
Status SuperKernelFactory::Init() { Status SuperKernelFactory::Init() {
if (!is_init_) { if (!is_init_) {
std::string skt_bin = "libcce_aicore.so"; std::string skt_bin = "libcce_aicore.so";
handle_ = dlopen(skt_bin.c_str(), RTLD_NOW | RTLD_GLOBAL);
handle_ = mmDlopen(skt_bin.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL);
if (handle_ == nullptr) { if (handle_ == nullptr) {
GELOGE(FAILED, "SKT: open skt lib failed, please check LD_LIBRARY_PATH."); GELOGE(FAILED, "SKT: open skt lib failed, please check LD_LIBRARY_PATH.");
} }
@@ -85,8 +85,10 @@ Status SuperKernelFactory::FuseKernels(const std::vector<void *> &stub_func_list
"equal to 2"); "equal to 2");
return FAILED; return FAILED;
} }
GELOGI("SKT: superkernel start fuse, superkernel size %d.", stub_func_list.size());
uint64_t nav_table[2 * stub_func_list.size()];
GELOGI("SKT: superkernel start fuse, superkernel size %zu.", stub_func_list.size());
const size_t nav_table_len = 2 * stub_func_list.size();
std::unique_ptr<uint64_t[]> nav_table(new(std::nothrow) uint64_t[nav_table_len]);
GE_CHECK_NOTNULL(nav_table);
uint64_t nav_table_size = 2 * stub_func_list.size() * sizeof(int64_t); uint64_t nav_table_size = 2 * stub_func_list.size() * sizeof(int64_t);


rtError_t rt_ret; rtError_t rt_ret;
@@ -99,16 +101,16 @@ Status SuperKernelFactory::FuseKernels(const std::vector<void *> &stub_func_list
GELOGD("SKT: fuseKernels subFunc %p, device func address %p", stub_func_list[i], sub_device_func); GELOGD("SKT: fuseKernels subFunc %p, device func address %p", stub_func_list[i], sub_device_func);
// store two uint64_t address // store two uint64_t address
// address divided by 4 because of 32bits encoding, call offset will *4 when calculating // address divided by 4 because of 32bits encoding, call offset will *4 when calculating
nav_table[i * 2] = reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(sub_device_func)) / 4;
nav_table[i * 2] = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(sub_device_func)) / 4;
GELOGD("SKT: CALL offet %lu", nav_table[i * 2]); GELOGD("SKT: CALL offet %lu", nav_table[i * 2]);
nav_table[i * 2 + 1] = reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(args_addr_list[i]));
nav_table[i * 2 + 1] = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(args_addr_list[i]));
GELOGD("SKT: fuseKernels args base address %lu", nav_table[i * 2 + 1]); GELOGD("SKT: fuseKernels args base address %lu", nav_table[i * 2 + 1]);
} }
rt_ret = rtMalloc((void **)&hbm_nav_table_addr, nav_table_size, RT_MEMORY_HBM); rt_ret = rtMalloc((void **)&hbm_nav_table_addr, nav_table_size, RT_MEMORY_HBM);
GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc failed. error: 0x%X", rt_ret); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc failed. error: 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);) return RT_ERROR_TO_GE_STATUS(rt_ret);)
rt_ret = rt_ret =
rtMemcpy((void *)hbm_nav_table_addr, nav_table_size, (void *)nav_table, nav_table_size, RT_MEMCPY_HOST_TO_DEVICE);
rtMemcpy((void *)hbm_nav_table_addr, nav_table_size, (void *)nav_table.get(), nav_table_size, RT_MEMCPY_HOST_TO_DEVICE);
GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMemcpy failed. error: 0x%X", rt_ret); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMemcpy failed. error: 0x%X", rt_ret);
GE_CHK_RT(rtFree(hbm_nav_table_addr)); return RT_ERROR_TO_GE_STATUS(rt_ret);) GE_CHK_RT(rtFree(hbm_nav_table_addr)); return RT_ERROR_TO_GE_STATUS(rt_ret);)
// Create the necessary metadata for the super kernel // Create the necessary metadata for the super kernel


+ 4
- 2
ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h View File

@@ -34,8 +34,10 @@ class SuperKernelFactory {
~SuperKernelFactory() { ~SuperKernelFactory() {
if (handle_ != nullptr) { if (handle_ != nullptr) {
GELOGI("SKT: SKT LIB PATH release."); GELOGI("SKT: SKT LIB PATH release.");
if (dlclose(handle_) != 0) {
GELOGW("failed to close handle, message: %s", dlerror());
if (mmDlclose(handle_) != 0) {
const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGW("failed to close handle, message: %s", error);
} }
} }
}; };


+ 2
- 2
ge/graph/load/new_model_manager/zero_copy_offset.cc View File

@@ -69,7 +69,7 @@ Status ZeroCopyOffset::InitInputDataInfo(const vector<int64_t> &output_size_list
uint64_t out_offset = uint64_t out_offset =
reinterpret_cast<uint64_t>(virtual_addr_list[kDataIndex]) + zero_copy_relative_offset_.at(index); reinterpret_cast<uint64_t>(virtual_addr_list[kDataIndex]) + zero_copy_relative_offset_.at(index);
int64_t real_data_size = ModelUtils::GetOutputSize(op_desc).at(kDataIndex); int64_t real_data_size = ModelUtils::GetOutputSize(op_desc).at(kDataIndex);
data_info_.emplace_back(real_data_size, reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(out_offset)));
data_info_.emplace_back(real_data_size, reinterpret_cast<void *>(static_cast<uintptr_t>(out_offset)));
relative_offset_.emplace_back(zero_copy_relative_offset_.at(index)); relative_offset_.emplace_back(zero_copy_relative_offset_.at(index));
GELOGI("[ZCPY] virtual_addr: %p has been l2-fusion to %lu, need copy data_size is %ld.", basic_addr_, GELOGI("[ZCPY] virtual_addr: %p has been l2-fusion to %lu, need copy data_size is %ld.", basic_addr_,
out_offset, real_data_size); out_offset, real_data_size);
@@ -119,7 +119,7 @@ Status ZeroCopyOffset::InitOutputDataInfo(const vector<int64_t> &input_size_list
in_count++; in_count++;
uint64_t in_offset = reinterpret_cast<uint64_t>(virtual_addr_list[idx]) + zero_copy_relative_offset_.at(index); uint64_t in_offset = reinterpret_cast<uint64_t>(virtual_addr_list[idx]) + zero_copy_relative_offset_.at(index);
int64_t real_data_size = ModelUtils::GetInputSize(op_desc).at(idx); int64_t real_data_size = ModelUtils::GetInputSize(op_desc).at(idx);
data_info_.emplace_back(real_data_size, reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(in_offset)));
data_info_.emplace_back(real_data_size, reinterpret_cast<void *>(static_cast<uintptr_t>(in_offset)));
relative_offset_.emplace_back(zero_copy_relative_offset_.at(index)); relative_offset_.emplace_back(zero_copy_relative_offset_.at(index));
GELOGI("[ZCPY] virtual_addr: %p has been l2-fusion from %lu, need copy data_size is %ld.", basic_addr_, GELOGI("[ZCPY] virtual_addr: %p has been l2-fusion from %lu, need copy data_size is %ld.", basic_addr_,
in_offset, real_data_size); in_offset, real_data_size);


+ 2
- 1
ge/graph/load/new_model_manager/zero_copy_task.cc View File

@@ -19,6 +19,7 @@
#include "framework/common/debug/ge_log.h" #include "framework/common/debug/ge_log.h"
#include "framework/common/util.h" #include "framework/common/util.h"
#include "graph/load/new_model_manager/model_utils.h" #include "graph/load/new_model_manager/model_utils.h"
#include "common/ge_compiler_options.h"


namespace ge { namespace ge {
const char *const kDefaultBatchLable = "Batch_default"; const char *const kDefaultBatchLable = "Batch_default";
@@ -157,7 +158,7 @@ Status ZeroCopyTask::DistributeParam(bool async_mode, rtStream_t stream) {
rt_err = rtMemcpyAsync(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE_EX, rt_err = rtMemcpyAsync(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE_EX,
stream); stream);
} else { } else {
__builtin_prefetch(args_addr_);
GE_BUILTIN_PREFETCH(args_addr_);
rt_err = rtMemcpy(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE); rt_err = rtMemcpy(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE);
} }




+ 6
- 6
ge/graph/manager/graph_var_manager.cc View File

@@ -92,13 +92,13 @@ ge::Status VarResource::SaveVarAddr(const std::string &var_name, const ge::GeTen
GELOGD("VarResource::SaveVarAddr, var_key = %s", var_key.c_str()); GELOGD("VarResource::SaveVarAddr, var_key = %s", var_key.c_str());
if (var_addr_mgr_map_.count(var_key) == 0) { if (var_addr_mgr_map_.count(var_key) == 0) {
uint64_t logic_address = VarManager::Instance(session_id_)->GetVarMemLogicBase() + uint64_t logic_address = VarManager::Instance(session_id_)->GetVarMemLogicBase() +
reinterpret_cast<uint64_t>(reinterpret_cast<std::uintptr_t>(address));
static_cast<uint64_t>(reinterpret_cast<std::uintptr_t>(address));
GELOGI("SaveVarAddr node_name %s, tensor_desc format %s, type %s.", var_name.c_str(), GELOGI("SaveVarAddr node_name %s, tensor_desc format %s, type %s.", var_name.c_str(),
TypeUtils::FormatToSerialString(tensor_desc.GetFormat()).c_str(), TypeUtils::FormatToSerialString(tensor_desc.GetFormat()).c_str(),
TypeUtils::DataTypeToSerialString(tensor_desc.GetDataType()).c_str()); TypeUtils::DataTypeToSerialString(tensor_desc.GetDataType()).c_str());
VarAddrMgr var_addr_mgr; VarAddrMgr var_addr_mgr;
var_addr_mgr.address = reinterpret_cast<uint8_t *>(reinterpret_cast<std::uintptr_t>(logic_address));
var_addr_mgr.offset = reinterpret_cast<uint64_t>(reinterpret_cast<std::uintptr_t>(address));
var_addr_mgr.address = reinterpret_cast<uint8_t *>(static_cast<std::uintptr_t>(logic_address));
var_addr_mgr.offset = static_cast<uint64_t>(reinterpret_cast<std::uintptr_t>(address));
var_addr_mgr.tensor_desc = tensor_desc; var_addr_mgr.tensor_desc = tensor_desc;
var_addr_mgr.memory_type = memory_type; var_addr_mgr.memory_type = memory_type;
var_addr_mgr_map_[var_key] = var_addr_mgr; var_addr_mgr_map_[var_key] = var_addr_mgr;
@@ -510,7 +510,7 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen
} }


result = var_resource_->SaveVarAddr( result = var_resource_->SaveVarAddr(
var_name, tensor_desc, reinterpret_cast<uint8_t *>(reinterpret_cast<uintptr_t>(mem_offset)), memory_type);
var_name, tensor_desc, reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(mem_offset)), memory_type);
if (result != SUCCESS) { if (result != SUCCESS) {
GELOGE(ge::INTERNAL_ERROR, "AssignVarMem by offset failed."); GELOGE(ge::INTERNAL_ERROR, "AssignVarMem by offset failed.");
return ge::INTERNAL_ERROR; return ge::INTERNAL_ERROR;
@@ -527,7 +527,7 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen
result = var_resource_->GetCurVarDesc(var_name, cur_tensor_desc); result = var_resource_->GetCurVarDesc(var_name, cur_tensor_desc);
if (result != SUCCESS) { if (result != SUCCESS) {
var_resource_->SetVarAddr(var_name, tensor_desc, var_resource_->SetVarAddr(var_name, tensor_desc,
reinterpret_cast<uint8_t *>(reinterpret_cast<uintptr_t>(mem_offset)), memory_type);
reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(mem_offset)), memory_type);
return SUCCESS; return SUCCESS;
} }


@@ -542,7 +542,7 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen
ge::TypeUtils::FormatToSerialString(cur_tensor_desc.GetFormat()).c_str(), ge::TypeUtils::FormatToSerialString(cur_tensor_desc.GetFormat()).c_str(),
cur_tensor_desc.GetShape().GetDims().size()); cur_tensor_desc.GetShape().GetDims().size());
var_resource_->SetVarAddr(var_name, tensor_desc, var_resource_->SetVarAddr(var_name, tensor_desc,
reinterpret_cast<uint8_t *>(reinterpret_cast<uintptr_t>(mem_offset)), memory_type);
reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(mem_offset)), memory_type);
} }


return SUCCESS; return SUCCESS;


+ 3
- 3
ge/graph/manager/trans_var_data_utils.cc View File

@@ -374,7 +374,7 @@ Status TransVarDataUtils::SyncVarData2BroadCast(const string &var_name, const ge
GE_MAKE_GUARD_RTMEM(src_host_addr); GE_MAKE_GUARD_RTMEM(src_host_addr);
GE_CHK_STATUS_RET(SyncTensorToHost(var_name, src_tensor_desc, &src_host_addr, src_addr_size, session_id)); GE_CHK_STATUS_RET(SyncTensorToHost(var_name, src_tensor_desc, &src_host_addr, src_addr_size, session_id));


GELOGI("src_addr_size: %u, dst_addr_size: %u", src_addr_size, dst_addr_size);
GELOGI("src_addr_size: %ld, dst_addr_size: %ld", src_addr_size, dst_addr_size);
GE_CHK_BOOL_RET_STATUS(src_addr_size == dst_addr_size, FAILED, "var data size is not equal broadcast "); GE_CHK_BOOL_RET_STATUS(src_addr_size == dst_addr_size, FAILED, "var data size is not equal broadcast ");


GE_CHK_RT_RET(rtMemcpy(dst_addr, dst_addr_size, src_host_addr, src_addr_size, RT_MEMCPY_HOST_TO_DEVICE)); GE_CHK_RT_RET(rtMemcpy(dst_addr, dst_addr_size, src_host_addr, src_addr_size, RT_MEMCPY_HOST_TO_DEVICE));
@@ -403,7 +403,7 @@ Status TransVarDataUtils::SyncTensorToHost(const string &var_name, const ge::GeT
GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, src_tensor_desc, &src_addr)); GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, src_tensor_desc, &src_addr));
uint8_t *mem_addr = uint8_t *mem_addr =
src_addr - src_addr -
static_cast<int64_t>(reinterpret_cast<uintptr_t>(VarManager::Instance(session_id)->GetVarMemLogicBase())) +
static_cast<int64_t>(static_cast<uintptr_t>(VarManager::Instance(session_id)->GetVarMemLogicBase())) +
static_cast<int64_t>( static_cast<int64_t>(
reinterpret_cast<uintptr_t>(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); reinterpret_cast<uintptr_t>(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM)));
GE_CHK_RT_RET(rtMallocHost(reinterpret_cast<void **>(host_addr), src_tensor_size)); GE_CHK_RT_RET(rtMallocHost(reinterpret_cast<void **>(host_addr), src_tensor_size));
@@ -420,7 +420,7 @@ Status TransVarDataUtils::SyncTensorToDevice(const string &var_name, const uint8
GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, dst_tensor_desc, &dst_addr)); GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, dst_tensor_desc, &dst_addr));
uint8_t *mem_addr = uint8_t *mem_addr =
dst_addr - dst_addr -
static_cast<int64_t>(reinterpret_cast<uintptr_t>(VarManager::Instance(session_id)->GetVarMemLogicBase())) +
static_cast<int64_t>(static_cast<uintptr_t>(VarManager::Instance(session_id)->GetVarMemLogicBase())) +
static_cast<int64_t>( static_cast<int64_t>(
reinterpret_cast<uintptr_t>(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); reinterpret_cast<uintptr_t>(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM)));
GE_CHK_RT_RET(rtMemcpy(mem_addr, addr_size, host_addr, addr_size, RT_MEMCPY_HOST_TO_DEVICE)); GE_CHK_RT_RET(rtMemcpy(mem_addr, addr_size, host_addr, addr_size, RT_MEMCPY_HOST_TO_DEVICE));


+ 3
- 3
ge/graph/manager/util/debug.cc View File

@@ -32,7 +32,7 @@ Debug::~Debug() = default;


void Debug::DumpProto(const Message &proto, const char *file) { void Debug::DumpProto(const Message &proto, const char *file) {
std::string file_path = RealPath(file); std::string file_path = RealPath(file);
int fd = open(file_path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
int fd = mmOpen2(file_path.c_str(), M_WRONLY | M_CREAT | O_TRUNC, M_IRUSR | M_IWUSR | M_UMASK_GRPREAD | M_UMASK_OTHREAD);
if (fd == -1) { if (fd == -1) {
GELOGW("Write %s failed", file_path.c_str()); GELOGW("Write %s failed", file_path.c_str());
return; return;
@@ -40,7 +40,7 @@ void Debug::DumpProto(const Message &proto, const char *file) {
auto output = ge::MakeShared<FileOutputStream>(fd); auto output = ge::MakeShared<FileOutputStream>(fd);
if (output == nullptr) { if (output == nullptr) {
GELOGW("create output failed."); GELOGW("create output failed.");
if (close(fd) != 0) {
if (mmClose(fd) != 0) {
GELOGW("close fd failed."); GELOGW("close fd failed.");
} }
return; return;
@@ -49,7 +49,7 @@ void Debug::DumpProto(const Message &proto, const char *file) {
if (!ret) { if (!ret) {
GELOGW("dump proto failed."); GELOGW("dump proto failed.");
} }
if (close(fd) != 0) {
if (mmClose(fd) != 0) {
GELOGW("close fd failed."); GELOGW("close fd failed.");
} }
} }


+ 0
- 2
ge/graph/manager/util/debug.h View File

@@ -17,7 +17,6 @@
#ifndef GE_GRAPH_MANAGER_UTIL_DEBUG_H_ #ifndef GE_GRAPH_MANAGER_UTIL_DEBUG_H_
#define GE_GRAPH_MANAGER_UTIL_DEBUG_H_ #define GE_GRAPH_MANAGER_UTIL_DEBUG_H_


#include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <time.h> #include <time.h>
@@ -25,7 +24,6 @@
#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/text_format.h> #include <google/protobuf/text_format.h>
#include <unistd.h>
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include <iosfwd> #include <iosfwd>


+ 2
- 2
ge/hybrid/executor/hybrid_execution_context.h View File

@@ -57,9 +57,9 @@ struct GraphExecutionContext {
do { \ do { \
if ((context != nullptr) && (context)->profiler != nullptr) { \ if ((context != nullptr) && (context)->profiler != nullptr) { \
if (node_name != nullptr) { \ if (node_name != nullptr) { \
context->profiler->RecordEvent(evt_type, "tid:%lu [%s] [%s] " fmt, GetTid(), node_name, category, ##__VA_ARGS__);\
context->profiler->RecordEvent(evt_type, "tid:%lu [%s] [%s] " fmt, GeLog::GetTid(), node_name, category, ##__VA_ARGS__);\
} else { \ } else { \
context->profiler->RecordEvent(evt_type, "tid:%lu [%s] " fmt, GetTid(), category, ##__VA_ARGS__); \
context->profiler->RecordEvent(evt_type, "tid:%lu [%s] " fmt, GeLog::GetTid(), category, ##__VA_ARGS__); \
}\ }\
} \ } \
} while (0) } while (0)


+ 5
- 5
ge/init/gelib.cc View File

@@ -110,7 +110,7 @@ Status GELib::InnerInitialize(const map<string, string> &options) {
Status initSystemStatus = SystemInitialize(options); Status initSystemStatus = SystemInitialize(options);
GE_TIMESTAMP_END(SystemInitialize, "InnerInitialize::SystemInitialize"); GE_TIMESTAMP_END(SystemInitialize, "InnerInitialize::SystemInitialize");
if (initSystemStatus != SUCCESS) { if (initSystemStatus != SUCCESS) {
GELOGE(initSystemStatus);
GELOGE(initSystemStatus, "GE system initial failed.");
RollbackInit(); RollbackInit();
return initSystemStatus; return initSystemStatus;
} }
@@ -120,7 +120,7 @@ Status GELib::InnerInitialize(const map<string, string> &options) {
Status initEmStatus = engineManager_.Initialize(options); Status initEmStatus = engineManager_.Initialize(options);
GE_TIMESTAMP_END(EngineInitialize, "InnerInitialize::EngineInitialize"); GE_TIMESTAMP_END(EngineInitialize, "InnerInitialize::EngineInitialize");
if (initEmStatus != SUCCESS) { if (initEmStatus != SUCCESS) {
GELOGE(initEmStatus);
GELOGE(initEmStatus, "GE engine manager initial failed.");
RollbackInit(); RollbackInit();
return initEmStatus; return initEmStatus;
} }
@@ -130,7 +130,7 @@ Status GELib::InnerInitialize(const map<string, string> &options) {
Status initOpsStatus = opsManager_.Initialize(options); Status initOpsStatus = opsManager_.Initialize(options);
GE_TIMESTAMP_END(OpsManagerInitialize, "InnerInitialize::OpsManagerInitialize"); GE_TIMESTAMP_END(OpsManagerInitialize, "InnerInitialize::OpsManagerInitialize");
if (initOpsStatus != SUCCESS) { if (initOpsStatus != SUCCESS) {
GELOGE(initOpsStatus);
GELOGE(initOpsStatus, "GE ops manager initial failed.");
RollbackInit(); RollbackInit();
return initOpsStatus; return initOpsStatus;
} }
@@ -140,7 +140,7 @@ Status GELib::InnerInitialize(const map<string, string> &options) {
Status initOpsBuilderStatus = OpsKernelBuilderManager::Instance().Initialize(options); Status initOpsBuilderStatus = OpsKernelBuilderManager::Instance().Initialize(options);
GE_TIMESTAMP_END(OpsKernelBuilderManagerInitialize, "InnerInitialize::OpsKernelBuilderManager"); GE_TIMESTAMP_END(OpsKernelBuilderManagerInitialize, "InnerInitialize::OpsKernelBuilderManager");
if (initOpsBuilderStatus != SUCCESS) { if (initOpsBuilderStatus != SUCCESS) {
GELOGE(initOpsBuilderStatus);
GELOGE(initOpsBuilderStatus, "GE ops builder manager initial failed.");
RollbackInit(); RollbackInit();
return initOpsBuilderStatus; return initOpsBuilderStatus;
} }
@@ -150,7 +150,7 @@ Status GELib::InnerInitialize(const map<string, string> &options) {
Status initSmStatus = sessionManager_.Initialize(options); Status initSmStatus = sessionManager_.Initialize(options);
GE_TIMESTAMP_END(SessionManagerInitialize, "InnerInitialize::SessionManagerInitialize"); GE_TIMESTAMP_END(SessionManagerInitialize, "InnerInitialize::SessionManagerInitialize");
if (initSmStatus != SUCCESS) { if (initSmStatus != SUCCESS) {
GELOGE(initSmStatus);
GELOGE(initSmStatus, "GE session manager initial failed.");
RollbackInit(); RollbackInit();
return initSmStatus; return initSmStatus;
} }


+ 1
- 1
ge/offline/CMakeLists.txt View File

@@ -69,7 +69,7 @@ target_link_libraries(atc PRIVATE
json json
runtime_compile runtime_compile
slog slog
mmpa
static_mmpa
-lrt -lrt
-ldl -ldl
) )


+ 9
- 7
ge/omm/csa_interact.cc View File

@@ -52,9 +52,11 @@ void CsaInteract::Init(int32_t dev_index, int64_t job_id) {
if (!is_init_) { if (!is_init_) {
dev_index_ = dev_index; dev_index_ = dev_index;
job_id_ = job_id; job_id_ = job_id;
char *file_dir_env = std::getenv(FMK_STATUS_FILE_DIR_ENV);

char file_dir_env[MMPA_MAX_PATH] = { 0x00 };
INT32 res = mmGetEnv(FMK_STATUS_FILE_DIR_ENV, file_dir_env, MMPA_MAX_PATH);
string csa_path_prefix; string csa_path_prefix;
if (file_dir_env != nullptr) {
if (res == EN_OK) {
csa_path_prefix = file_dir_env; csa_path_prefix = file_dir_env;
} }
if (!csa_path_prefix.empty()) { if (!csa_path_prefix.empty()) {
@@ -186,21 +188,21 @@ Status CsaInteract::WriteHcomDetection(const std::string &content) {
/// ///
Status CsaInteract::WriteFile(const std::string &file_name, const std::string &content) { Status CsaInteract::WriteFile(const std::string &file_name, const std::string &content) {
// if file path is not exist, then make path // if file path is not exist, then make path
INT32 flags = O_WRONLY | O_TRUNC | O_CREAT;
int32_t fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | S_IRGRP);
INT32 flags = M_WRONLY | O_TRUNC | M_CREAT;
int32_t fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | M_UMASK_GRPREAD);
if (fd == EN_ERROR) { if (fd == EN_ERROR) {
if (MakePath(file_name) != SUCCESS) { if (MakePath(file_name) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "csainteract create file path fail, errno is %d", errno); GELOGE(INTERNAL_ERROR, "csainteract create file path fail, errno is %d", errno);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | S_IRGRP);
fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | M_UMASK_GRPREAD);
if (fd == EN_ERROR) { if (fd == EN_ERROR) {
GELOGE(INTERNAL_ERROR, "open file fail, errno is %d", errno); GELOGE(INTERNAL_ERROR, "open file fail, errno is %d", errno);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }


ssize_t ret = write(fd, content.c_str(), content.length());
mmSsize_t ret = mmWrite(fd, (void *)content.c_str(), content.length());
if (ret == EN_ERROR) { if (ret == EN_ERROR) {
GELOGE(INTERNAL_ERROR, "write file fail, errno is %d", errno); GELOGE(INTERNAL_ERROR, "write file fail, errno is %d", errno);
ret = mmClose(fd); ret = mmClose(fd);
@@ -239,7 +241,7 @@ Status CsaInteract::MakePath(const std::string &file_name) {
while (found != std::string::npos) { while (found != std::string::npos) {
std::string pre_path = file_path.substr(0, found + 1); std::string pre_path = file_path.substr(0, found + 1);
if (mmAccess(pre_path.c_str()) != EN_OK) { if (mmAccess(pre_path.c_str()) != EN_OK) {
if (mmMkdir(pre_path.c_str(), S_IRWXU) != EN_OK) {
if (mmMkdir(pre_path.c_str(), M_IRWXU) != EN_OK) {
GELOGE(INTERNAL_ERROR, "csainteract mkdir fail, errno is %d", errno); GELOGE(INTERNAL_ERROR, "csainteract mkdir fail, errno is %d", errno);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


+ 1
- 1
ge/opskernel_manager/ops_kernel_manager.cc View File

@@ -85,7 +85,7 @@ Status OpsKernelManager::Initialize(const map<string, string> &options_const) {
initialize_ = options; initialize_ = options;
Status rst0 = plugin_manager_.InvokeAll<map<string, string> &, Status>(kInitialize, initialize_); Status rst0 = plugin_manager_.InvokeAll<map<string, string> &, Status>(kInitialize, initialize_);
if (rst0 == FAILED) { if (rst0 == FAILED) {
GELOGE(GE_OPS_GET_NO_VALID_SO);
GELOGE(GE_OPS_GET_NO_VALID_SO, "There is invalid so about OpsKernelInfoStore.");
return GE_OPS_GET_NO_VALID_SO; return GE_OPS_GET_NO_VALID_SO;
} }
Status rst1 = Status rst1 =


+ 14
- 14
ge/session/session_manager.cc View File

@@ -61,7 +61,7 @@ Status SessionManager::SetRtContext(SessionId session_id, rtContext_t rt_context


Status SessionManager::CreateSession(const std::map<std::string, std::string> &options, SessionId &session_id) { Status SessionManager::CreateSession(const std::map<std::string, std::string> &options, SessionId &session_id) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
SessionId next_session_id = 0; SessionId next_session_id = 0;
@@ -92,7 +92,7 @@ Status SessionManager::CreateSession(const std::map<std::string, std::string> &o


Status SessionManager::DestroySession(SessionId session_id) { Status SessionManager::DestroySession(SessionId session_id) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
std::lock_guard<std::mutex> lock(mutex_); std::lock_guard<std::mutex> lock(mutex_);
@@ -119,7 +119,7 @@ Status SessionManager::DestroySession(SessionId session_id) {


Status SessionManager::GetVariable(SessionId session_id, const std::string &name, Tensor &val) { Status SessionManager::GetVariable(SessionId session_id, const std::string &name, Tensor &val) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
SessionPtr innerSession = nullptr; SessionPtr innerSession = nullptr;
@@ -143,7 +143,7 @@ Status SessionManager::AddGraph(SessionId session_id, uint32_t graph_id, const G
Status SessionManager::AddGraph(SessionId session_id, uint32_t graph_id, const Graph &graph, Status SessionManager::AddGraph(SessionId session_id, uint32_t graph_id, const Graph &graph,
const std::map<std::string, std::string> &options) { const std::map<std::string, std::string> &options) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
SessionPtr innerSession = nullptr; SessionPtr innerSession = nullptr;
@@ -173,7 +173,7 @@ Status SessionManager::AddGraph(SessionId session_id, uint32_t graph_id, const G
Status SessionManager::AddGraphWithCopy(SessionId session_id, uint32_t graph_id, const Graph &graph, Status SessionManager::AddGraphWithCopy(SessionId session_id, uint32_t graph_id, const Graph &graph,
const std::map<std::string, std::string> &options) { const std::map<std::string, std::string> &options) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
SessionPtr innerSession = nullptr; SessionPtr innerSession = nullptr;
@@ -203,7 +203,7 @@ Status SessionManager::AddGraphWithCopy(SessionId session_id, uint32_t graph_id,
Status SessionManager::RunGraph(SessionId session_id, uint32_t graph_id, const std::vector<Tensor> &inputs, Status SessionManager::RunGraph(SessionId session_id, uint32_t graph_id, const std::vector<Tensor> &inputs,
std::vector<Tensor> &outputs) { std::vector<Tensor> &outputs) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
SessionPtr innerSession = nullptr; SessionPtr innerSession = nullptr;
@@ -221,7 +221,7 @@ Status SessionManager::RunGraph(SessionId session_id, uint32_t graph_id, const s


Status SessionManager::RemoveGraph(SessionId session_id, uint32_t graph_id) { Status SessionManager::RemoveGraph(SessionId session_id, uint32_t graph_id) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
SessionPtr innerSession = nullptr; SessionPtr innerSession = nullptr;
@@ -239,7 +239,7 @@ Status SessionManager::RemoveGraph(SessionId session_id, uint32_t graph_id) {


bool SessionManager::HasSession(SessionId session_id) { bool SessionManager::HasSession(SessionId session_id) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return false; return false;
} }
return session_manager_map_.find(session_id) != session_manager_map_.end(); return session_manager_map_.find(session_id) != session_manager_map_.end();
@@ -247,7 +247,7 @@ bool SessionManager::HasSession(SessionId session_id) {


Status SessionManager::GetNextSessionId(SessionId &next_session_id) { Status SessionManager::GetNextSessionId(SessionId &next_session_id) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
static SessionId session_id = 0; static SessionId session_id = 0;
@@ -260,7 +260,7 @@ Status SessionManager::RegisterCallBackFunc(
SessionId session_id, const std::string &key, SessionId session_id, const std::string &key,
const std::function<Status(uint32_t, const std::map<std::string, ge::Tensor> &)> &callback) { const std::function<Status(uint32_t, const std::map<std::string, ge::Tensor> &)> &callback) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
SessionPtr innerSession = nullptr; SessionPtr innerSession = nullptr;
@@ -278,7 +278,7 @@ Status SessionManager::RegisterCallBackFunc(


Status SessionManager::BuildGraph(SessionId session_id, uint32_t graph_id, const std::vector<InputTensorInfo> &inputs) { Status SessionManager::BuildGraph(SessionId session_id, uint32_t graph_id, const std::vector<InputTensorInfo> &inputs) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
SessionPtr innerSession = nullptr; SessionPtr innerSession = nullptr;
@@ -297,7 +297,7 @@ Status SessionManager::BuildGraph(SessionId session_id, uint32_t graph_id, const
Status SessionManager::RunGraphAsync(SessionId session_id, uint32_t graph_id, Status SessionManager::RunGraphAsync(SessionId session_id, uint32_t graph_id,
const std::vector<InputTensorInfo> &inputs, RunAsyncCallback callback) { const std::vector<InputTensorInfo> &inputs, RunAsyncCallback callback) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
SessionPtr innerSession = nullptr; SessionPtr innerSession = nullptr;
@@ -317,7 +317,7 @@ Status SessionManager::GetVariables(SessionId session_id, const std::vector<std:
std::vector<Tensor> &var_values) { std::vector<Tensor> &var_values) {
// step 0: init session manager // step 0: init session manager
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return GE_SESSION_MANAGER_NOT_INIT; return GE_SESSION_MANAGER_NOT_INIT;
} }
SessionPtr innerSession = nullptr; SessionPtr innerSession = nullptr;
@@ -383,7 +383,7 @@ Status SessionManager::GetVariables(SessionId session_id, const std::vector<std:


bool SessionManager::IsGraphNeedRebuild(SessionId session_id, uint32_t graph_id) { bool SessionManager::IsGraphNeedRebuild(SessionId session_id, uint32_t graph_id) {
if (!init_flag_) { if (!init_flag_) {
GELOGE(GE_SESSION_MANAGER_NOT_INIT);
GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized.");
return true; return true;
} }
SessionPtr innerSession = nullptr; SessionPtr innerSession = nullptr;


+ 3
- 3
ge/single_op/single_op.cc View File

@@ -59,7 +59,7 @@ Status SingleOp::ValidateArgs(const std::vector<DataBuffer> &inputs, const std::
for (size_t i = 0; i < num_inputs; ++i) { for (size_t i = 0; i < num_inputs; ++i) {
// preventing from read out of bound // preventing from read out of bound
size_t aligned_size = GetAlignedSize(inputs[i].length); size_t aligned_size = GetAlignedSize(inputs[i].length);
GELOGI("Input [%zu], aligned_size:%zu, inputs.length:%lu, input_sizes_:%lu",
GELOGI("Input [%zu], aligned_size:%zu, inputs.length:%lu, input_sizes_:%zu",
i, aligned_size, inputs[i].length, input_sizes_[i]); i, aligned_size, inputs[i].length, input_sizes_[i]);
if (aligned_size < input_sizes_[i]) { if (aligned_size < input_sizes_[i]) {
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Input size mismatch. index = %zu, model expect %zu," GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Input size mismatch. index = %zu, model expect %zu,"
@@ -77,7 +77,7 @@ Status SingleOp::ValidateArgs(const std::vector<DataBuffer> &inputs, const std::
for (size_t i = 0; i < num_outputs; ++i) { for (size_t i = 0; i < num_outputs; ++i) {
// preventing from write out of bound // preventing from write out of bound
size_t aligned_size = GetAlignedSize(outputs[i].length); size_t aligned_size = GetAlignedSize(outputs[i].length);
GELOGI("Output [%zu], aligned_size:%zu, outputs.length:%lu, output_sizes_:%lu",
GELOGI("Output [%zu], aligned_size:%zu, outputs.length:%lu, output_sizes_:%zu",
i, aligned_size, outputs[i].length, output_sizes_[i]); i, aligned_size, outputs[i].length, output_sizes_[i]);
if (aligned_size < output_sizes_[i]) { if (aligned_size < output_sizes_[i]) {
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Output size mismatch. index = %zu, model expect %zu," GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Output size mismatch. index = %zu, model expect %zu,"
@@ -143,7 +143,7 @@ Status SingleOp::UpdateArgs(const std::vector<DataBuffer> &inputs, const std::ve
GE_CHECK_NOTNULL(task_io_addr); GE_CHECK_NOTNULL(task_io_addr);
auto io_addr = reinterpret_cast<uint64_t *>(const_cast<uintptr_t *>(task_io_addr)); auto io_addr = reinterpret_cast<uint64_t *>(const_cast<uintptr_t *>(task_io_addr));
for (size_t i = 0; i < io_addr_num; ++i) { for (size_t i = 0; i < io_addr_num; ++i) {
io_addr[i] = reinterpret_cast<uintptr_t>(args_[i]);
io_addr[i] = static_cast<uintptr_t>(args_[i]);
} }
} else { } else {
GELOGW("Only TF_kernel aicpu and aicpu_CC are supported, but got %u", task->GetOpTaskType()); GELOGW("Only TF_kernel aicpu and aicpu_CC are supported, but got %u", task->GetOpTaskType());


+ 56
- 20
inc/framework/common/debug/ge_log.h View File

@@ -18,24 +18,39 @@
#define INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_ #define INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_


#include <cstdint> #include <cstdint>
#include <unistd.h>
#include <sys/syscall.h>


#include "framework/common/ge_inner_error_codes.h" #include "framework/common/ge_inner_error_codes.h"
#include "toolchain/slog.h" #include "toolchain/slog.h"
#ifdef __GNUC__
#include <unistd.h>
#include <sys/syscall.h>
#else
#include "mmpa/mmpa_api.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif


#define GE_MODULE_NAME static_cast<int>(GE) #define GE_MODULE_NAME static_cast<int>(GE)


// trace status of log // trace status of log
enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP }; enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP };


#define GELOGE(ERROR_CODE, ...) GE_LOG_ERROR(GE_MODULE_NAME, ERROR_CODE, __VA_ARGS__)
#define GELOGW(...) GE_LOG_WARN(GE_MODULE_NAME, __VA_ARGS__)
#define GELOGI(...) GE_LOG_INFO(GE_MODULE_NAME, __VA_ARGS__)
#define GELOGD(...) GE_LOG_DEBUG(GE_MODULE_NAME, __VA_ARGS__)
#define GEEVENT(...) GE_LOG_EVENT(GE_MODULE_NAME, __VA_ARGS__)
#define GELOGO(...) GE_LOG_OPLOG(GE_MODULE_NAME, __VA_ARGS__)
#define GELOGT(VALUE, ...) GE_LOG_TRACE(GE_MODULE_NAME, VALUE, __VA_ARGS__)
class GeLog {
public:
#ifdef __GNUC__
static pid_t GetTid() {
thread_local static pid_t tid = syscall(__NR_gettid);
return tid;
}
#else
static int GetTid() {
thread_local static int tid = static_cast<int>(GetCurrentThreadId());
return tid;
}
#endif
};


inline bool IsLogEnable(int module_name, int log_level) { inline bool IsLogEnable(int module_name, int log_level) {
int32_t enable = CheckLogLevel(module_name, log_level); int32_t enable = CheckLogLevel(module_name, log_level);
@@ -46,23 +61,41 @@ inline bool IsLogEnable(int module_name, int log_level) {
return false; return false;
} }


inline pid_t GetTid() {
thread_local static pid_t tid = syscall(__NR_gettid);
return tid;
}
#define GELOGE(ERROR_CODE, fmt, ...) \
dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__)
#define GELOGW(fmt, ...) \
if (IsLogEnable(GE_MODULE_NAME, DLOG_WARN)) dlog_warn(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GELOGI(fmt, ...) \
if (IsLogEnable(GE_MODULE_NAME, DLOG_INFO)) dlog_info(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GELOGD(fmt, ...) \
if (IsLogEnable(GE_MODULE_NAME, DLOG_DEBUG)) dlog_debug(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GEEVENT(fmt, ...) dlog_event(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GELOGO(fmt, ...) \
Dlog(GE_MODULE_NAME, DLOG_OPLOG, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GELOGT(VALUE, fmt, ...) \
do { \
TraceStatus stat = VALUE; \
const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \
int idx = static_cast<int>(stat); \
char *k = const_cast<char *>("status"); \
char *v = const_cast<char *>(TraceStatStr[idx]); \
KeyValue kv = {k, v}; \
DlogWithKV(static_cast<int>(GE_MODULE_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__); \
} while (0)


#define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \ #define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \
dlog_error(MOD_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GetTid(), __FUNCTION__, ERROR_CODE, \
dlog_error(MOD_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \
((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__) ((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__)
#define GE_LOG_WARN(MOD_NAME, fmt, ...) \ #define GE_LOG_WARN(MOD_NAME, fmt, ...) \
if (IsLogEnable(MOD_NAME, DLOG_WARN)) dlog_warn(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__)
if (IsLogEnable(MOD_NAME, DLOG_WARN)) dlog_warn(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_INFO(MOD_NAME, fmt, ...) \ #define GE_LOG_INFO(MOD_NAME, fmt, ...) \
if (IsLogEnable(MOD_NAME, DLOG_INFO)) dlog_info(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__)
if (IsLogEnable(MOD_NAME, DLOG_INFO)) dlog_info(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_DEBUG(MOD_NAME, fmt, ...) \ #define GE_LOG_DEBUG(MOD_NAME, fmt, ...) \
if (IsLogEnable(MOD_NAME, DLOG_DEBUG)) dlog_debug(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_EVENT(MOD_NAME, fmt, ...) dlog_event(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__)
if (IsLogEnable(MOD_NAME, DLOG_DEBUG)) dlog_debug(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_EVENT(MOD_NAME, fmt, ...) dlog_event(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)
#define GE_LOG_OPLOG(MOD_NAME, fmt, ...) \ #define GE_LOG_OPLOG(MOD_NAME, fmt, ...) \
Dlog(MOD_NAME, DLOG_OPLOG, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__)
Dlog(MOD_NAME, DLOG_OPLOG, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__)


#define GE_LOG_TRACE(MOD_NAME, value, fmt, ...) \ #define GE_LOG_TRACE(MOD_NAME, value, fmt, ...) \
do { \ do { \
@@ -72,7 +105,7 @@ inline pid_t GetTid() {
char *k = const_cast<char *>("status"); \ char *k = const_cast<char *>("status"); \
char *v = const_cast<char *>(TraceStatStr[idx]); \ char *v = const_cast<char *>(TraceStatStr[idx]); \
KeyValue kv = {k, v}; \ KeyValue kv = {k, v}; \
DlogWithKV(static_cast<int>(MOD_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__); \
DlogWithKV(static_cast<int>(MOD_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__); \
} while (0) } while (0)


// print memory when it is greater than 1KB. // print memory when it is greater than 1KB.
@@ -82,4 +115,7 @@ inline pid_t GetTid() {
GELOGI("MallocMemory, func=%s, size=%zu, purpose=%s", (#FUNC), static_cast<size_t>(SIZE), (PURPOSE)); \ GELOGI("MallocMemory, func=%s, size=%zu, purpose=%s", (#FUNC), static_cast<size_t>(SIZE), (PURPOSE)); \
} \ } \
} while (0); } while (0);
#ifdef __cplusplus
}
#endif
#endif // INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_ #endif // INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_

+ 32
- 0
inc/framework/common/ge_compiler_options.h View File

@@ -0,0 +1,32 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_
#define INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_

namespace ge {
#ifdef __GNUC__
#define GE_ATTRIBUTE_UNUSED __attribute__((unused))
#define GE_FUNCTION_IDENTIFIER __PRETTY_FUNCTION__
#define GE_BUILTIN_PREFETCH(args_addr) __builtin_prefetch(args_addr)
#else
#define GE_ATTRIBUTE_UNUSED
#define GE_FUNCTION_IDENTIFIER __FUNCSIG__
#define GE_BUILTIN_PREFETCH(args_addr)
#endif
} // namespace ge

#endif // INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_

+ 1
- 0
inc/framework/common/string_util.h View File

@@ -17,6 +17,7 @@
#ifndef INC_FRAMEWORK_COMMON_STRING_UTIL_H_ #ifndef INC_FRAMEWORK_COMMON_STRING_UTIL_H_
#define INC_FRAMEWORK_COMMON_STRING_UTIL_H_ #define INC_FRAMEWORK_COMMON_STRING_UTIL_H_


#include <cctype>
#include <securec.h> #include <securec.h>


#include <algorithm> #include <algorithm>


+ 1
- 2
inc/framework/common/types.h View File

@@ -18,7 +18,6 @@
#define INC_FRAMEWORK_COMMON_TYPES_H_ #define INC_FRAMEWORK_COMMON_TYPES_H_


#include <limits.h> #include <limits.h>
#include <linux/limits.h>
#include <stdint.h> #include <stdint.h>
#include <algorithm> #include <algorithm>
#include <map> #include <map>
@@ -529,7 +528,7 @@ REGISTER_OPTYPE_DECLARE(HVDWAIT, "HorovodWait");
// aicpu op for online_infer dynamic_dims // aicpu op for online_infer dynamic_dims
REGISTER_OPTYPE_DECLARE(GETDYNAMICDIMS, "GetDynamicDims"); REGISTER_OPTYPE_DECLARE(GETDYNAMICDIMS, "GetDynamicDims");


enum InputMode { INPUT = 0, CONST };
enum InputMode { INPUT = 0, CONST_INPUT};


// Definition of the processing status enum of the process module // Definition of the processing status enum of the process module
enum ModelProcessState { enum ModelProcessState {


+ 1
- 1
metadef

@@ -1 +1 @@
Subproject commit 1b09ed04b6dd22d1aed1bee92fd42736c0fafc65
Subproject commit 6bdf2e3011150b200fdcd2acd18b7186902534b6

+ 1
- 1
parser

@@ -1 +1 @@
Subproject commit 3d49906d119b1cc01f4256d7992759ce9f3dcfcd
Subproject commit af06fc022551f154574efd5b68f96d13bce9193f

+ 4
- 2
third_party/fwkacllib/inc/hccl/base.h View File

@@ -68,8 +68,10 @@ struct MemRegisterAddr {
u64 addr; u64 addr;
u64 length; u64 length;
}; };

const u32 HCCL_MAX_MEM_REGISTER_NUM = 8; // The max number of memory register address.
/*
* @brief The max number of memory register address for remote access.
*/
const u32 HCCL_MAX_MEM_REGISTER_NUM = 32;


enum GradSplitForceMode { enum GradSplitForceMode {
FORCE_NONE, /**< no force */ FORCE_NONE, /**< no force */


+ 13
- 0
third_party/fwkacllib/inc/mmpa/mmpa_api.h View File

@@ -26,6 +26,12 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#endif #endif


#ifdef FUNC_VISIBILITY
#define MMPA_FUNC_VISIBILITY __attribute__((visibility("default")))
#else
#define MMPA_FUNC_VISIBILITY
#endif

#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
@@ -86,6 +92,13 @@




#if(OS_TYPE == WIN) //lint !e553 #if(OS_TYPE == WIN) //lint !e553

#ifdef FUNC_VISIBILITY
#define MMPA_FUNC_VISIBILITY _declspec(dllexport)
#else
#define MMPA_FUNC_VISIBILITY
#endif

#include <winsock2.h> #include <winsock2.h>
#include <winsock.h> #include <winsock.h>
#include "Windows.h" #include "Windows.h"


+ 187
- 165
third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h View File

@@ -44,12 +44,16 @@ typedef VOID *mmExitCode;
typedef key_t mmKey_t; typedef key_t mmKey_t;
typedef int mmMsgid; typedef int mmMsgid;
typedef struct dirent mmDirent; typedef struct dirent mmDirent;
typedef struct dirent mmDirent2;
typedef struct shmid_ds mmshmId_ds; typedef struct shmid_ds mmshmId_ds;
typedef int (*mmFilter)(const mmDirent *entry); typedef int (*mmFilter)(const mmDirent *entry);
typedef int (*mmFilter2)(const mmDirent2 *entry);
typedef int (*mmSort)(const mmDirent **a, const mmDirent **b); typedef int (*mmSort)(const mmDirent **a, const mmDirent **b);
typedef int (*mmSort2)(const mmDirent2 **a, const mmDirent2 **b);
typedef size_t mmSize_t; typedef size_t mmSize_t;
typedef off_t mmOfft_t; typedef off_t mmOfft_t;
typedef pid_t mmPid_t; typedef pid_t mmPid_t;
typedef long MM_LONG;


typedef VOID *(*userProcFunc)(VOID *pulArg); typedef VOID *(*userProcFunc)(VOID *pulArg);


@@ -113,6 +117,7 @@ typedef struct {
} mmIoctlBuf; } mmIoctlBuf;


typedef int mmAtomicType; typedef int mmAtomicType;
typedef int mmAtomicType64;


typedef enum { typedef enum {
pollTypeRead = 1, // pipe read pollTypeRead = 1, // pipe read
@@ -151,8 +156,8 @@ typedef struct {
} mmTimeval; } mmTimeval;


typedef struct { typedef struct {
LONG tv_sec;
LONG tv_nsec;
MM_LONG tv_sec;
MM_LONG tv_nsec;
} mmTimespec; } mmTimespec;


typedef struct { typedef struct {
@@ -272,6 +277,9 @@ typedef struct {
#define M_R_OK R_OK #define M_R_OK R_OK
#define M_W_OK W_OK #define M_W_OK W_OK


#define MM_DT_DIR DT_DIR
#define MM_DT_REG DT_REG

#define MMPA_STDIN STDIN_FILENO #define MMPA_STDIN STDIN_FILENO
#define MMPA_STDOUT STDOUT_FILENO #define MMPA_STDOUT STDOUT_FILENO
#define MMPA_STDERR STDERR_FILENO #define MMPA_STDERR STDERR_FILENO
@@ -283,182 +291,195 @@ typedef struct {


#define MMPA_DL_EXT_NAME ".so" #define MMPA_DL_EXT_NAME ".so"


extern INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock);
extern INT32 mmJoinTask(mmThread *threadHandle);
extern INT32 mmMutexInit(mmMutex_t *mutex);
extern INT32 mmMutexLock(mmMutex_t *mutex);
extern INT32 mmMutexTryLock(mmMutex_t *mutex);
extern INT32 mmMutexUnLock(mmMutex_t *mutex);
extern INT32 mmMutexDestroy(mmMutex_t *mutex);
extern INT32 mmCondInit(mmCond *cond);
extern INT32 mmCondLockInit(mmMutexFC *mutex);
extern INT32 mmCondLock(mmMutexFC *mutex);
extern INT32 mmCondUnLock(mmMutexFC *mutex);
extern INT32 mmCondLockDestroy(mmMutexFC *mutex);
extern INT32 mmRWLockInit(mmRWLock_t *rwLock);
extern INT32 mmRWLockRDLock(mmRWLock_t *rwLock);
extern INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock);
extern INT32 mmRWLockWRLock(mmRWLock_t *rwLock);
extern INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock);
extern INT32 mmRDLockUnLock(mmRWLock_t *rwLock);
extern INT32 mmWRLockUnLock(mmRWLock_t *rwLock);
extern INT32 mmRWLockDestroy(mmRWLock_t *rwLock);
extern INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex);
extern INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond);
extern INT32 mmCondNotify(mmCond *cond);
extern INT32 mmCondNotifyAll(mmCond *cond);
extern INT32 mmCondDestroy(mmCond *cond);
extern INT32 mmGetPid();
extern INT32 mmGetTid();
extern INT32 mmGetPidHandle(mmProcess *processHandle);
extern INT32 mmGetLocalTime(mmSystemTime_t *sysTime);
extern INT32 mmGetSystemTime(mmSystemTime_t *sysTime);
extern INT32 mmSemInit(mmSem_t *sem, UINT32 value);
extern INT32 mmSemWait(mmSem_t *sem);
extern INT32 mmSemPost(mmSem_t *sem);
extern INT32 mmSemDestroy(mmSem_t *sem);
extern INT32 mmOpen(const CHAR *pathName, INT32 flags);
extern INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode);
extern FILE *mmPopen(CHAR *command, CHAR *type);
extern INT32 mmClose(INT32 fd);
extern INT32 mmPclose(FILE *stream);
extern mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen);
extern mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen);
extern mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol);
extern INT32 mmBind(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
extern INT32 mmListen(mmSockHandle sockFd, INT32 backLog);
extern mmSockHandle mmAccept(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t *addrLen);
extern INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
extern INT32 mmCloseSocket(mmSockHandle sockFd);
extern mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag);
extern mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag);
extern INT32 mmSocketSendTo(mmSockHandle sockFd,
MMPA_FUNC_VISIBILITY INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock);
MMPA_FUNC_VISIBILITY INT32 mmJoinTask(mmThread *threadHandle);
MMPA_FUNC_VISIBILITY INT32 mmMutexInit(mmMutex_t *mutex);
MMPA_FUNC_VISIBILITY INT32 mmMutexLock(mmMutex_t *mutex);
MMPA_FUNC_VISIBILITY INT32 mmMutexTryLock(mmMutex_t *mutex);
MMPA_FUNC_VISIBILITY INT32 mmMutexUnLock(mmMutex_t *mutex);
MMPA_FUNC_VISIBILITY INT32 mmMutexDestroy(mmMutex_t *mutex);
MMPA_FUNC_VISIBILITY INT32 mmCondInit(mmCond *cond);
MMPA_FUNC_VISIBILITY INT32 mmCondLockInit(mmMutexFC *mutex);
MMPA_FUNC_VISIBILITY INT32 mmCondLock(mmMutexFC *mutex);
MMPA_FUNC_VISIBILITY INT32 mmCondUnLock(mmMutexFC *mutex);
MMPA_FUNC_VISIBILITY INT32 mmCondLockDestroy(mmMutexFC *mutex);
MMPA_FUNC_VISIBILITY INT32 mmRWLockInit(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRWLockRDLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRWLockWRLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRDLockUnLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmWRLockUnLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRWLockDestroy(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex);
MMPA_FUNC_VISIBILITY INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond);
MMPA_FUNC_VISIBILITY INT32 mmCondNotify(mmCond *cond);
MMPA_FUNC_VISIBILITY INT32 mmCondNotifyAll(mmCond *cond);
MMPA_FUNC_VISIBILITY INT32 mmCondDestroy(mmCond *cond);
MMPA_FUNC_VISIBILITY INT32 mmGetPid();
MMPA_FUNC_VISIBILITY INT32 mmGetTid();
MMPA_FUNC_VISIBILITY INT32 mmGetPidHandle(mmProcess *processHandle);
MMPA_FUNC_VISIBILITY INT32 mmGetLocalTime(mmSystemTime_t *sysTime);
MMPA_FUNC_VISIBILITY INT32 mmGetSystemTime(mmSystemTime_t *sysTime);
MMPA_FUNC_VISIBILITY INT32 mmSemInit(mmSem_t *sem, UINT32 value);
MMPA_FUNC_VISIBILITY INT32 mmSemWait(mmSem_t *sem);
MMPA_FUNC_VISIBILITY INT32 mmSemPost(mmSem_t *sem);
MMPA_FUNC_VISIBILITY INT32 mmSemDestroy(mmSem_t *sem);
MMPA_FUNC_VISIBILITY INT32 mmOpen(const CHAR *pathName, INT32 flags);
MMPA_FUNC_VISIBILITY INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode);
MMPA_FUNC_VISIBILITY FILE *mmPopen(CHAR *command, CHAR *type);
MMPA_FUNC_VISIBILITY INT32 mmClose(INT32 fd);
MMPA_FUNC_VISIBILITY INT32 mmPclose(FILE *stream);
MMPA_FUNC_VISIBILITY mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen);
MMPA_FUNC_VISIBILITY mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen);
MMPA_FUNC_VISIBILITY mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol);
MMPA_FUNC_VISIBILITY INT32 mmBind(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
MMPA_FUNC_VISIBILITY INT32 mmListen(mmSockHandle sockFd, INT32 backLog);
MMPA_FUNC_VISIBILITY mmSockHandle mmAccept(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t *addrLen);
MMPA_FUNC_VISIBILITY INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
MMPA_FUNC_VISIBILITY INT32 mmCloseSocket(mmSockHandle sockFd);
MMPA_FUNC_VISIBILITY mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag);
MMPA_FUNC_VISIBILITY mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag);
MMPA_FUNC_VISIBILITY INT32 mmSocketSendTo(mmSockHandle sockFd,
VOID *sendMsg, VOID *sendMsg,
INT32 sendLen, INT32 sendLen,
UINT32 sendFlag, UINT32 sendFlag,
const mmSockAddr* addr, const mmSockAddr* addr,
INT32 tolen); INT32 tolen);
extern mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd,
MMPA_FUNC_VISIBILITY mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd,
VOID *recvBuf, VOID *recvBuf,
mmSize recvLen, mmSize recvLen,
UINT32 recvFlag, UINT32 recvFlag,
mmSockAddr* addr, mmSockAddr* addr,
mmSocklen_t *FromLen); mmSocklen_t *FromLen);
extern INT32 mmSAStartup();
extern INT32 mmSACleanup();
extern VOID *mmDlopen(const CHAR *fileName, INT32 mode);
extern INT32 mmDladdr(VOID *addr, mmDlInfo *info);
extern VOID *mmDlsym(VOID *handle, CHAR *funcName);
extern INT32 mmDlclose(VOID *handle);
extern CHAR *mmDlerror();
extern INT32 mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock, UINT milliSecond, UINT period);
extern INT32 mmDeleteTimer(mmTimer timerHandle);
extern INT32 mmStatGet(const CHAR *path, mmStat_t *buffer);
extern INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer);
extern INT32 mmFStatGet(INT32 fd, mmStat_t *buffer);
extern INT32 mmMkdir(const CHAR *pathName, mmMode_t mode);
extern INT32 mmSleep(UINT32 milliSecond);

extern INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock);
extern INT32 mmGetProcessPrio(mmProcess pid);
extern INT32 mmSetProcessPrio(mmProcess pid, INT32 processPrio);
extern INT32 mmGetThreadPrio(mmThread *threadHandle);
extern INT32 mmSetThreadPrio(mmThread *threadHandle, INT32 threadPrio);
extern INT32 mmAccess(const CHAR *pathName);
extern INT32 mmAccess2(const CHAR *pathName, INT32 mode);
extern INT32 mmRmdir(const CHAR *pathName);

extern INT32 mmIoctl(mmProcess fd, INT32 ioctlCode, mmIoctlBuf *bufPtr);
extern INT32 mmSemTimedWait(mmSem_t *sem, INT32 timeout);
extern mmSsize_t mmWritev(mmProcess fd, mmIovSegment *iov, INT32 iovcnt);
extern VOID mmMb();
extern INT32 mmInetAton(const CHAR *addrStr, mmInAddr *addr);

extern mmProcess mmOpenFile(const CHAR *fileName, UINT32 access, mmCreateFlag fileFlag);
extern mmSsize_t mmReadFile(mmProcess fileId, VOID *buffer, INT32 len);
extern mmSsize_t mmWriteFile(mmProcess fileId, VOID *buffer, INT32 len);
extern INT32 mmCloseFile(mmProcess fileId);

extern mmAtomicType mmSetData(mmAtomicType *ptr, mmAtomicType value);
extern mmAtomicType mmValueInc(mmAtomicType *ptr, mmAtomicType value);
extern mmAtomicType mmValueSub(mmAtomicType *ptr, mmAtomicType value);
extern INT32 mmCreateTaskWithDetach(mmThread *threadHandle, mmUserBlock_t *funcBlock);
MMPA_FUNC_VISIBILITY INT32 mmSAStartup();
MMPA_FUNC_VISIBILITY INT32 mmSACleanup();
MMPA_FUNC_VISIBILITY VOID *mmDlopen(const CHAR *fileName, INT32 mode);
MMPA_FUNC_VISIBILITY INT32 mmDladdr(VOID *addr, mmDlInfo *info);
MMPA_FUNC_VISIBILITY VOID *mmDlsym(VOID *handle, const CHAR *funcName);
MMPA_FUNC_VISIBILITY INT32 mmDlclose(VOID *handle);
MMPA_FUNC_VISIBILITY CHAR *mmDlerror();
MMPA_FUNC_VISIBILITY INT32 mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock, UINT milliSecond, UINT period);
MMPA_FUNC_VISIBILITY INT32 mmDeleteTimer(mmTimer timerHandle);
MMPA_FUNC_VISIBILITY INT32 mmStatGet(const CHAR *path, mmStat_t *buffer);
MMPA_FUNC_VISIBILITY INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer);
MMPA_FUNC_VISIBILITY INT32 mmFStatGet(INT32 fd, mmStat_t *buffer);
MMPA_FUNC_VISIBILITY INT32 mmMkdir(const CHAR *pathName, mmMode_t mode);
MMPA_FUNC_VISIBILITY INT32 mmSleep(UINT32 milliSecond);

MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock);
MMPA_FUNC_VISIBILITY INT32 mmGetProcessPrio(mmProcess pid);
MMPA_FUNC_VISIBILITY INT32 mmSetProcessPrio(mmProcess pid, INT32 processPrio);
MMPA_FUNC_VISIBILITY INT32 mmGetThreadPrio(mmThread *threadHandle);
MMPA_FUNC_VISIBILITY INT32 mmSetThreadPrio(mmThread *threadHandle, INT32 threadPrio);
MMPA_FUNC_VISIBILITY INT32 mmAccess(const CHAR *pathName);
MMPA_FUNC_VISIBILITY INT32 mmAccess2(const CHAR *pathName, INT32 mode);
MMPA_FUNC_VISIBILITY INT32 mmRmdir(const CHAR *pathName);

MMPA_FUNC_VISIBILITY INT32 mmIoctl(mmProcess fd, INT32 ioctlCode, mmIoctlBuf *bufPtr);
MMPA_FUNC_VISIBILITY INT32 mmSemTimedWait(mmSem_t *sem, INT32 timeout);
MMPA_FUNC_VISIBILITY mmSsize_t mmWritev(mmProcess fd, mmIovSegment *iov, INT32 iovcnt);
MMPA_FUNC_VISIBILITY VOID mmMb();
MMPA_FUNC_VISIBILITY INT32 mmInetAton(const CHAR *addrStr, mmInAddr *addr);

MMPA_FUNC_VISIBILITY mmProcess mmOpenFile(const CHAR *fileName, UINT32 access, mmCreateFlag fileFlag);
MMPA_FUNC_VISIBILITY mmSsize_t mmReadFile(mmProcess fileId, VOID *buffer, INT32 len);
MMPA_FUNC_VISIBILITY mmSsize_t mmWriteFile(mmProcess fileId, VOID *buffer, INT32 len);
MMPA_FUNC_VISIBILITY INT32 mmCloseFile(mmProcess fileId);

MMPA_FUNC_VISIBILITY mmAtomicType mmSetData(mmAtomicType *ptr, mmAtomicType value);
MMPA_FUNC_VISIBILITY mmAtomicType mmValueInc(mmAtomicType *ptr, mmAtomicType value);
MMPA_FUNC_VISIBILITY mmAtomicType mmValueSub(mmAtomicType *ptr, mmAtomicType value);
MMPA_FUNC_VISIBILITY mmAtomicType64 mmSetData64(mmAtomicType64 *ptr, mmAtomicType64 value);
MMPA_FUNC_VISIBILITY mmAtomicType64 mmValueInc64(mmAtomicType64 *ptr, mmAtomicType64 value);
MMPA_FUNC_VISIBILITY mmAtomicType64 mmValueSub64(mmAtomicType64 *ptr, mmAtomicType64 value);
MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithDetach(mmThread *threadHandle, mmUserBlock_t *funcBlock);


// The following 3 interfaces are to be deleted // The following 3 interfaces are to be deleted
extern INT32 mmCreateNamedPipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
extern INT32 mmOpenNamePipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
extern VOID mmCloseNamedPipe(mmPipeHandle namedPipe[]);
MMPA_FUNC_VISIBILITY INT32 mmCreateNamedPipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
MMPA_FUNC_VISIBILITY INT32 mmOpenNamePipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
MMPA_FUNC_VISIBILITY VOID mmCloseNamedPipe(mmPipeHandle namedPipe[]);


extern INT32 mmCreatePipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
extern INT32 mmOpenPipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
extern VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount);
MMPA_FUNC_VISIBILITY INT32 mmCreatePipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
MMPA_FUNC_VISIBILITY INT32 mmOpenPipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
MMPA_FUNC_VISIBILITY VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount);


// Poll related interface // Poll related interface
extern mmCompletionHandle mmCreateCompletionPort();
extern VOID mmCloseCompletionPort(mmCompletionHandle handle);
extern INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP, pmmPollData polledData,
mmPollBack pollBack);
extern INT32 mmGetErrorCode();
extern CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size);
extern INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone);
extern mmTimespec mmGetTickCount();
extern INT32 mmGetRealPath(CHAR *path, CHAR *realPath);
extern INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen);
MMPA_FUNC_VISIBILITY mmCompletionHandle mmCreateCompletionPort();
MMPA_FUNC_VISIBILITY VOID mmCloseCompletionPort(mmCompletionHandle handle);
MMPA_FUNC_VISIBILITY INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP,
pmmPollData polledData, mmPollBack pollBack);
MMPA_FUNC_VISIBILITY INT32 mmGetErrorCode();
MMPA_FUNC_VISIBILITY CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size);
MMPA_FUNC_VISIBILITY INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone);
MMPA_FUNC_VISIBILITY mmTimespec mmGetTickCount();
MMPA_FUNC_VISIBILITY INT32 mmGetRealPath(CHAR *path, CHAR *realPath);
MMPA_FUNC_VISIBILITY INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen);


extern INT32 mmDup2(INT32 oldFd, INT32 newFd);
MMPA_FUNC_VISIBILITY INT32 mmDup2(INT32 oldFd, INT32 newFd);


extern INT32 mmDup(INT32 fd);
MMPA_FUNC_VISIBILITY INT32 mmDup(INT32 fd);


extern INT32 mmUnlink(const CHAR *filename);
MMPA_FUNC_VISIBILITY INT32 mmUnlink(const CHAR *filename);


extern INT32 mmChmod(const CHAR *filename, INT32 mode);
MMPA_FUNC_VISIBILITY INT32 mmChmod(const CHAR *filename, INT32 mode);


extern INT32 mmFileno(FILE *stream);
MMPA_FUNC_VISIBILITY INT32 mmFileno(FILE *stream);


extern INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort);
MMPA_FUNC_VISIBILITY INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort);
MMPA_FUNC_VISIBILITY INT32 mmScandir2(const CHAR *path, mmDirent2 ***entryList, mmFilter2 filterFunc, mmSort2 sort);


extern VOID mmScandirFree(mmDirent **entryList, INT32 count);
MMPA_FUNC_VISIBILITY VOID mmScandirFree(mmDirent **entryList, INT32 count);
MMPA_FUNC_VISIBILITY VOID mmScandirFree2(mmDirent2 **entryList, INT32 count);


extern mmMsgid mmMsgCreate(mmKey_t key, INT32 msgFlag);
MMPA_FUNC_VISIBILITY mmMsgid mmMsgCreate(mmKey_t key, INT32 msgFlag);


extern mmMsgid mmMsgOpen(mmKey_t key, INT32 msgFlag);
MMPA_FUNC_VISIBILITY mmMsgid mmMsgOpen(mmKey_t key, INT32 msgFlag);


extern INT32 mmMsgSnd(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);
MMPA_FUNC_VISIBILITY INT32 mmMsgSnd(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);


extern INT32 mmMsgRcv(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);
MMPA_FUNC_VISIBILITY INT32 mmMsgRcv(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);


extern INT32 mmMsgClose(mmMsgid msqid);
MMPA_FUNC_VISIBILITY INT32 mmMsgClose(mmMsgid msqid);


extern INT32 mmLocalTimeR(const time_t *timep, struct tm *result);
MMPA_FUNC_VISIBILITY INT32 mmLocalTimeR(const time_t *timep, struct tm *result);


extern INT32 mmGetOpt(INT32 argc, char *const *argv, const char *opts);
extern INT32 mmGetOptLong(INT32 argc, char *const *argv, const char *opts, const mmStructOption *longOpts,
INT32 *longIndex);
MMPA_FUNC_VISIBILITY INT32 mmGetOptErr();
MMPA_FUNC_VISIBILITY VOID mmSetOptErr(INT32 mmOptErr);
MMPA_FUNC_VISIBILITY INT32 mmGetOptInd();
MMPA_FUNC_VISIBILITY VOID mmSetOptInd(INT32 mmOptInd);
MMPA_FUNC_VISIBILITY INT32 mmGetOptOpt();
MMPA_FUNC_VISIBILITY VOID mmSetOpOpt(INT32 mmOptOpt);
MMPA_FUNC_VISIBILITY CHAR *mmGetOptArg();
MMPA_FUNC_VISIBILITY VOID mmSetOptArg(CHAR *mmOptArg);
MMPA_FUNC_VISIBILITY INT32 mmGetOpt(INT32 argc, char *const *argv, const char *opts);
MMPA_FUNC_VISIBILITY INT32 mmGetOptLong(INT32 argc, char *const *argv, const char *opts, const mmStructOption *longOpts,
INT32 *longIndex);


extern LONG mmLseek(INT32 fd, INT64 offset, INT32 seekFlag);
extern INT32 mmFtruncate(mmProcess fd, UINT32 length);
MMPA_FUNC_VISIBILITY LONG mmLseek(INT32 fd, INT64 offset, INT32 seekFlag);
MMPA_FUNC_VISIBILITY INT32 mmFtruncate(mmProcess fd, UINT32 length);


extern INT32 mmTlsCreate(mmThreadKey *key, VOID (*destructor)(VOID *));
extern INT32 mmTlsSet(mmThreadKey key, const VOID *value);
extern VOID *mmTlsGet(mmThreadKey key);
extern INT32 mmTlsDelete(mmThreadKey key);
extern INT32 mmGetOsType();
MMPA_FUNC_VISIBILITY INT32 mmTlsCreate(mmThreadKey *key, VOID (*destructor)(VOID *));
MMPA_FUNC_VISIBILITY INT32 mmTlsSet(mmThreadKey key, const VOID *value);
MMPA_FUNC_VISIBILITY VOID *mmTlsGet(mmThreadKey key);
MMPA_FUNC_VISIBILITY INT32 mmTlsDelete(mmThreadKey key);
MMPA_FUNC_VISIBILITY INT32 mmGetOsType();


extern INT32 mmFsync(mmProcess fd);
extern INT32 mmFsync2(INT32 fd);
extern INT32 mmChdir(const CHAR *path);
extern INT32 mmUmask(INT32 pmode);
extern INT32 mmThreadKill(mmThread id);
extern INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options);
MMPA_FUNC_VISIBILITY INT32 mmFsync(mmProcess fd);
MMPA_FUNC_VISIBILITY INT32 mmFsync2(INT32 fd);
MMPA_FUNC_VISIBILITY INT32 mmChdir(const CHAR *path);
MMPA_FUNC_VISIBILITY INT32 mmUmask(INT32 pmode);
MMPA_FUNC_VISIBILITY INT32 mmThreadKill(mmThread id);
MMPA_FUNC_VISIBILITY INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options);


extern INT32 mmGetCwd(CHAR *buffer, INT32 maxLen);
extern INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len);
extern INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite);
extern CHAR *mmStrTokR(CHAR *str, const CHAR *delim, CHAR **saveptr);
extern CHAR *mmDirName(CHAR *path);
extern CHAR *mmBaseName(CHAR *path);
extern INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize);
MMPA_FUNC_VISIBILITY INT32 mmGetCwd(CHAR *buffer, INT32 maxLen);
MMPA_FUNC_VISIBILITY INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len);
MMPA_FUNC_VISIBILITY INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite);
MMPA_FUNC_VISIBILITY CHAR *mmStrTokR(CHAR *str, const CHAR *delim, CHAR **saveptr);
MMPA_FUNC_VISIBILITY CHAR *mmDirName(CHAR *path);
MMPA_FUNC_VISIBILITY CHAR *mmBaseName(CHAR *path);
MMPA_FUNC_VISIBILITY INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize);


/* /*
* Function: set the thread name created by mmcreatetask * Function: set the thread name created by mmcreatetask
@@ -467,7 +488,7 @@ extern INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize);
* The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the
* execution failure returns EN_ERROR * execution failure returns EN_ERROR
*/ */
extern INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name);
MMPA_FUNC_VISIBILITY INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name);


/* /*
* Function: get thread name * Function: get thread name
@@ -477,37 +498,38 @@ extern INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name);
* The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the
* execution failure returns EN_ERROR * execution failure returns EN_ERROR
*/ */
extern INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, INT32 size);
MMPA_FUNC_VISIBILITY INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, INT32 size);
/* /*
* Function:Set the thread name of the currently executing thread - call inside the thread body * Function:Set the thread name of the currently executing thread - call inside the thread body
* Input:name:Thread name to be set * Input:name:Thread name to be set
* The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the
* execution failure returns EN_ERROR * execution failure returns EN_ERROR
*/ */
extern INT32 mmSetCurrentThreadName(const CHAR *name);
MMPA_FUNC_VISIBILITY INT32 mmSetCurrentThreadName(const CHAR *name);
/* /*
* Function:Get the thread name of the currently executing thread - in body call * Function:Get the thread name of the currently executing thread - in body call
* Input:name:The name of the thread to get, and the cache is allocated by the user,size>=MMPA_THREADNAME_SIZE * Input:name:The name of the thread to get, and the cache is allocated by the user,size>=MMPA_THREADNAME_SIZE
* The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the
* execution failure returns EN_ERROR * execution failure returns EN_ERROR
*/ */
extern INT32 mmGetCurrentThreadName(CHAR *name, INT32 size);
extern INT32 mmGetFileSize(const CHAR *fileName, ULONGLONG *length);
extern INT32 mmIsDir(const CHAR *fileName);
extern INT32 mmGetOsName(CHAR *name, INT32 nameSize);
extern INT32 mmGetOsVersion(CHAR *versionInfo, INT32 versionLength);
extern INT32 mmGetMac(mmMacInfo **list, INT32 *count);
extern INT32 mmGetMacFree(mmMacInfo *list, INT32 count);
extern INT32 mmGetCpuInfo(mmCpuDesc **cpuInfo, INT32 *count);
extern INT32 mmCpuInfoFree(mmCpuDesc *cpuInfo, INT32 count);
extern INT32 mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const char *stdoutRedirectFile, mmProcess *id);

extern INT32 mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock,
const mmThreadAttr *threadAttr);
extern mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode);
extern INT32 mmShmUnlink(const CHAR *name);
extern VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags);
extern INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra);
MMPA_FUNC_VISIBILITY INT32 mmGetCurrentThreadName(CHAR *name, INT32 size);
MMPA_FUNC_VISIBILITY INT32 mmGetFileSize(const CHAR *fileName, ULONGLONG *length);
MMPA_FUNC_VISIBILITY INT32 mmIsDir(const CHAR *fileName);
MMPA_FUNC_VISIBILITY INT32 mmGetOsName(CHAR *name, INT32 nameSize);
MMPA_FUNC_VISIBILITY INT32 mmGetOsVersion(CHAR *versionInfo, INT32 versionLength);
MMPA_FUNC_VISIBILITY INT32 mmGetMac(mmMacInfo **list, INT32 *count);
MMPA_FUNC_VISIBILITY INT32 mmGetMacFree(mmMacInfo *list, INT32 count);
MMPA_FUNC_VISIBILITY INT32 mmGetCpuInfo(mmCpuDesc **cpuInfo, INT32 *count);
MMPA_FUNC_VISIBILITY INT32 mmCpuInfoFree(mmCpuDesc *cpuInfo, INT32 count);
MMPA_FUNC_VISIBILITY INT32 mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const char *stdoutRedirectFile,
mmProcess *id);

MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock,
const mmThreadAttr *threadAttr);
MMPA_FUNC_VISIBILITY mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode);
MMPA_FUNC_VISIBILITY INT32 mmShmUnlink(const CHAR *name);
MMPA_FUNC_VISIBILITY VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags);
MMPA_FUNC_VISIBILITY INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra);
#define MMPA_DLL_API #define MMPA_DLL_API


#ifdef __cplusplus #ifdef __cplusplus


+ 192
- 174
third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h View File

@@ -30,11 +30,6 @@ extern "C" {
#define MMPA_MACINFO_DEFAULT_SIZE 18 #define MMPA_MACINFO_DEFAULT_SIZE 18
#define MMPA_CPUDESC_DEFAULT_SIZE 64 #define MMPA_CPUDESC_DEFAULT_SIZE 64


MMPA_DLL_API extern char *optarg;
MMPA_DLL_API extern int opterr;
MMPA_DLL_API extern int optind;
MMPA_DLL_API extern int optopt;

#pragma section(".CRT$XCU", long, read) #pragma section(".CRT$XCU", long, read)
#pragma section(".CRT$XPU", long, read) #pragma section(".CRT$XPU", long, read)


@@ -65,6 +60,7 @@ typedef struct sockaddr mmSockAddr;
typedef int mmSocklen_t; typedef int mmSocklen_t;
typedef int mmSemTimeout_t; typedef int mmSemTimeout_t;
typedef long mmAtomicType; typedef long mmAtomicType;
typedef long long mmAtomicType64;
typedef DWORD mmExitCode; typedef DWORD mmExitCode;
typedef DWORD mmErrorMsg; typedef DWORD mmErrorMsg;
typedef int mmKey_t; typedef int mmKey_t;
@@ -76,6 +72,7 @@ typedef INT32 mmSsize_t;
typedef int mmSize; // size typedef int mmSize; // size
typedef size_t mmSize_t; typedef size_t mmSize_t;
typedef VOID mmshmId_ds; typedef VOID mmshmId_ds;
typedef long long MM_LONG;


typedef enum { typedef enum {
DT_DIR = FILE_ATTRIBUTE_DIRECTORY, DT_DIR = FILE_ATTRIBUTE_DIRECTORY,
@@ -86,8 +83,15 @@ typedef struct {
char d_name[MAX_PATH]; // file name char d_name[MAX_PATH]; // file name
} mmDirent; } mmDirent;


typedef struct {
unsigned long d_type;
char d_name[MAX_PATH]; // file name
} mmDirent2;

typedef int (*mmFilter)(const mmDirent *entry); typedef int (*mmFilter)(const mmDirent *entry);
typedef int (*mmFilter2)(const mmDirent2 *entry);
typedef int (*mmSort)(const mmDirent **a, const mmDirent **b); typedef int (*mmSort)(const mmDirent **a, const mmDirent **b);
typedef int (*mmSort2)(const mmDirent2 **a, const mmDirent2 **b);


typedef struct { typedef struct {
VOID *sendBuf; VOID *sendBuf;
@@ -162,8 +166,8 @@ typedef struct {
} mmTimezone; } mmTimezone;


typedef struct { typedef struct {
LONG tv_sec;
LONG tv_nsec;
MM_LONG tv_sec;
MM_LONG tv_nsec;
} mmTimespec; } mmTimespec;


typedef mmTimerHandle mmTimer; typedef mmTimerHandle mmTimer;
@@ -283,12 +287,13 @@ typedef VOID (*mmPf)(VOID);
#define DT_UNKNOWN 0 #define DT_UNKNOWN 0
#define DT_FIFO 1 #define DT_FIFO 1
#define DT_CHR 2 #define DT_CHR 2
#define DT_DIR 4
#define DT_BLK 6 #define DT_BLK 6
#define DT_REG 8 #define DT_REG 8
#define DT_LNK 10 #define DT_LNK 10
#define DT_SOCK 12 #define DT_SOCK 12
#define DT_WHT 14 #define DT_WHT 14
#define MM_DT_DIR 16
#define MM_DT_REG 32


#define mmConstructor(x) __declspec(allocate(".CRT$XCU")) mmPf con = x #define mmConstructor(x) __declspec(allocate(".CRT$XCU")) mmPf con = x
#define mmDestructor(x) __declspec(allocate(".CRT$XPU")) mmPf de = x #define mmDestructor(x) __declspec(allocate(".CRT$XPU")) mmPf de = x
@@ -327,175 +332,188 @@ typedef VOID (*mmPf)(VOID);


#define __attribute__(v) #define __attribute__(v)


_declspec(dllexport) INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock);
_declspec(dllexport) INT32 mmJoinTask(mmThread *threadHandle);
_declspec(dllexport) INT32 mmMutexInit(mmMutex_t *mutex);
_declspec(dllexport) INT32 mmMutexLock(mmMutex_t *mutex);
_declspec(dllexport) INT32 mmMutexTryLock(mmMutex_t *mutex);
_declspec(dllexport) INT32 mmMutexUnLock(mmMutex_t *mutex);
_declspec(dllexport) INT32 mmMutexDestroy(mmMutex_t *mutex);
_declspec(dllexport) INT32 mmCondInit(mmCond *cond);
_declspec(dllexport) INT32 mmCondLockInit(mmMutexFC *mutex);
_declspec(dllexport) INT32 mmCondLock(mmMutexFC *mutex);
_declspec(dllexport) INT32 mmCondUnLock(mmMutexFC *mutex);
_declspec(dllexport) INT32 mmCondLockDestroy(mmMutexFC *mutex);
_declspec(dllexport) INT32 mmRWLockInit(mmRWLock_t *rwLock);
_declspec(dllexport) INT32 mmRWLockRDLock(mmRWLock_t *rwLock);
_declspec(dllexport) INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock);
_declspec(dllexport) INT32 mmRWLockWRLock(mmRWLock_t *rwLock);
_declspec(dllexport) INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock);
_declspec(dllexport) INT32 mmRDLockUnLock(mmRWLock_t *rwLock);
_declspec(dllexport) INT32 mmWRLockUnLock(mmRWLock_t *rwLock);
_declspec(dllexport) INT32 mmRWLockDestroy(mmRWLock_t *rwLock);
_declspec(dllexport) INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex);
_declspec(dllexport) INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond);
_declspec(dllexport) INT32 mmCondNotify(mmCond *cond);
_declspec(dllexport) INT32 mmCondNotifyAll(mmCond *cond);
_declspec(dllexport) INT32 mmCondDestroy(mmCond *cond);
_declspec(dllexport) INT32 mmGetPid(VOID);
_declspec(dllexport) INT32 mmGetTid(VOID);
_declspec(dllexport) INT32 mmGetPidHandle(mmProcess *processHandle);
_declspec(dllexport) INT32 mmGetLocalTime(mmSystemTime_t *sysTime);
_declspec(dllexport) INT32 mmGetSystemTime(mmSystemTime_t *sysTime);
_declspec(dllexport) INT32 mmSemInit(mmSem_t *sem, UINT32 value);
_declspec(dllexport) INT32 mmSemWait(mmSem_t *sem);
_declspec(dllexport) INT32 mmSemPost(mmSem_t *sem);
_declspec(dllexport) INT32 mmSemDestroy(mmSem_t *sem);
_declspec(dllexport) INT32 mmOpen(const CHAR *pathName, INT32 flags);
_declspec(dllexport) INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode);
_declspec(dllexport) FILE *mmPopen(CHAR *command, CHAR *type);
_declspec(dllexport) INT32 mmClose(INT32 fd);
_declspec(dllexport) INT32 mmPclose(FILE *stream);
_declspec(dllexport) mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen);
_declspec(dllexport) mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen);
_declspec(dllexport) mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol);
_declspec(dllexport) INT32 mmBind(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
_declspec(dllexport) INT32 mmListen(mmSockHandle sockFd, INT32 backLog);
_declspec(dllexport) mmSockHandle mmAccept(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t *addrLen);
_declspec(dllexport) INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
_declspec(dllexport) INT32 mmCloseSocket(mmSockHandle sockFd);
_declspec(dllexport) mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag);
_declspec(dllexport) mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag);
_declspec(dllexport) INT32 mmSocketSendTo(mmSockHandle sockFd,
MMPA_FUNC_VISIBILITY INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock);
MMPA_FUNC_VISIBILITY INT32 mmJoinTask(mmThread *threadHandle);
MMPA_FUNC_VISIBILITY INT32 mmMutexInit(mmMutex_t *mutex);
MMPA_FUNC_VISIBILITY INT32 mmMutexLock(mmMutex_t *mutex);
MMPA_FUNC_VISIBILITY INT32 mmMutexTryLock(mmMutex_t *mutex);
MMPA_FUNC_VISIBILITY INT32 mmMutexUnLock(mmMutex_t *mutex);
MMPA_FUNC_VISIBILITY INT32 mmMutexDestroy(mmMutex_t *mutex);
MMPA_FUNC_VISIBILITY INT32 mmCondInit(mmCond *cond);
MMPA_FUNC_VISIBILITY INT32 mmCondLockInit(mmMutexFC *mutex);
MMPA_FUNC_VISIBILITY INT32 mmCondLock(mmMutexFC *mutex);
MMPA_FUNC_VISIBILITY INT32 mmCondUnLock(mmMutexFC *mutex);
MMPA_FUNC_VISIBILITY INT32 mmCondLockDestroy(mmMutexFC *mutex);
MMPA_FUNC_VISIBILITY INT32 mmRWLockInit(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRWLockRDLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRWLockWRLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRDLockUnLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmWRLockUnLock(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmRWLockDestroy(mmRWLock_t *rwLock);
MMPA_FUNC_VISIBILITY INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex);
MMPA_FUNC_VISIBILITY INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond);
MMPA_FUNC_VISIBILITY INT32 mmCondNotify(mmCond *cond);
MMPA_FUNC_VISIBILITY INT32 mmCondNotifyAll(mmCond *cond);
MMPA_FUNC_VISIBILITY INT32 mmCondDestroy(mmCond *cond);
MMPA_FUNC_VISIBILITY INT32 mmGetPid(VOID);
MMPA_FUNC_VISIBILITY INT32 mmGetTid(VOID);
MMPA_FUNC_VISIBILITY INT32 mmGetPidHandle(mmProcess *processHandle);
MMPA_FUNC_VISIBILITY INT32 mmGetLocalTime(mmSystemTime_t *sysTime);
MMPA_FUNC_VISIBILITY INT32 mmGetSystemTime(mmSystemTime_t *sysTime);
MMPA_FUNC_VISIBILITY INT32 mmSemInit(mmSem_t *sem, UINT32 value);
MMPA_FUNC_VISIBILITY INT32 mmSemWait(mmSem_t *sem);
MMPA_FUNC_VISIBILITY INT32 mmSemPost(mmSem_t *sem);
MMPA_FUNC_VISIBILITY INT32 mmSemDestroy(mmSem_t *sem);
MMPA_FUNC_VISIBILITY INT32 mmOpen(const CHAR *pathName, INT32 flags);
MMPA_FUNC_VISIBILITY INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode);
MMPA_FUNC_VISIBILITY FILE *mmPopen(CHAR *command, CHAR *type);
MMPA_FUNC_VISIBILITY INT32 mmClose(INT32 fd);
MMPA_FUNC_VISIBILITY INT32 mmPclose(FILE *stream);
MMPA_FUNC_VISIBILITY mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen);
MMPA_FUNC_VISIBILITY mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen);
MMPA_FUNC_VISIBILITY mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol);
MMPA_FUNC_VISIBILITY INT32 mmBind(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
MMPA_FUNC_VISIBILITY INT32 mmListen(mmSockHandle sockFd, INT32 backLog);
MMPA_FUNC_VISIBILITY mmSockHandle mmAccept(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t *addrLen);
MMPA_FUNC_VISIBILITY INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen);
MMPA_FUNC_VISIBILITY INT32 mmCloseSocket(mmSockHandle sockFd);
MMPA_FUNC_VISIBILITY mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag);
MMPA_FUNC_VISIBILITY mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag);
MMPA_FUNC_VISIBILITY INT32 mmSocketSendTo(mmSockHandle sockFd,
VOID *sendMsg, VOID *sendMsg,
INT32 sendLen, INT32 sendLen,
UINT32 sendFlag, UINT32 sendFlag,
const mmSockAddr* addr, const mmSockAddr* addr,
INT32 tolen); INT32 tolen);
_declspec(dllexport) mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd,
MMPA_FUNC_VISIBILITY mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd,
VOID *recvBuf, VOID *recvBuf,
mmSize recvLen, mmSize recvLen,
UINT32 recvFlag, UINT32 recvFlag,
mmSockAddr* addr, mmSockAddr* addr,
mmSocklen_t *FromLen); mmSocklen_t *FromLen);
_declspec(dllexport) INT32 mmSAStartup(VOID);
_declspec(dllexport) INT32 mmSACleanup(VOID);
_declspec(dllexport) VOID *mmDlopen(const CHAR *fileName, INT mode);
_declspec(dllexport) INT32 mmDladdr(VOID *addr, mmDlInfo *info);
_declspec(dllexport) VOID *mmDlsym(VOID *handle, CHAR *fileName);
_declspec(dllexport) INT32 mmDlclose(VOID *handle);
_declspec(dllexport) CHAR *mmDlerror(VOID);
_declspec(dllexport) INT32
MMPA_FUNC_VISIBILITY INT32 mmSAStartup(VOID);
MMPA_FUNC_VISIBILITY INT32 mmSACleanup(VOID);
MMPA_FUNC_VISIBILITY VOID *mmDlopen(const CHAR *fileName, INT mode);
MMPA_FUNC_VISIBILITY INT32 mmDladdr(VOID *addr, mmDlInfo *info);
MMPA_FUNC_VISIBILITY VOID *mmDlsym(VOID *handle, const CHAR *fileName);
MMPA_FUNC_VISIBILITY INT32 mmDlclose(VOID *handle);
MMPA_FUNC_VISIBILITY CHAR *mmDlerror(VOID);
MMPA_FUNC_VISIBILITY INT32
mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock, UINT milliSecond, UINT period); mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock, UINT milliSecond, UINT period);
_declspec(dllexport) INT32 mmDeleteTimer(mmTimer timerHandle);
_declspec(dllexport) INT32 mmStatGet(const CHAR *path, mmStat_t *buffer);
_declspec(dllexport) INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer);
_declspec(dllexport) INT32 mmFStatGet(INT32 fd, mmStat_t *buffer);
_declspec(dllexport) INT32 mmMkdir(const CHAR *pathName, mmMode_t mode);
_declspec(dllexport) INT32 mmSleep(UINT32 milliSecond);
_declspec(dllexport) INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock);
_declspec(dllexport) INT32 mmGetProcessPrio(mmProcess pid);
_declspec(dllexport) INT32 mmSetProcessPrio(mmProcess pid, INT32 processPrio);
_declspec(dllexport) INT32 mmGetThreadPrio(mmThread *threadHandle);
_declspec(dllexport) INT32 mmSetThreadPrio(mmThread *threadHandle, INT32 threadPrio);
_declspec(dllexport) INT32 mmAccess(const CHAR *pathName);
_declspec(dllexport) INT32 mmAccess2(const CHAR *pathName, INT32 mode);
_declspec(dllexport) INT32 mmRmdir(const CHAR *pathName);

_declspec(dllexport) INT32 mmIoctl(mmProcess fd, INT32 ioctlCode, mmIoctlBuf *bufPtr);
_declspec(dllexport) INT32 mmSemTimedWait(mmSem_t *sem, INT32 timeout);
_declspec(dllexport) mmSsize_t mmWritev(mmSockHandle fd, mmIovSegment *iov, INT32 iovcnt);
_declspec(dllexport) VOID mmMb();
_declspec(dllexport) INT32 mmInetAton(const CHAR *addrStr, mmInAddr *addr);

_declspec(dllexport) mmProcess mmOpenFile(const CHAR *fileName, UINT32 access, mmCreateFlag fileFlag);
_declspec(dllexport) mmSsize_t mmReadFile(mmProcess fileId, VOID *buffer, INT32 len);
_declspec(dllexport) mmSsize_t mmWriteFile(mmProcess fileId, VOID *buffer, INT32 len);
_declspec(dllexport) INT32 mmCloseFile(mmProcess fileId);

_declspec(dllexport) mmAtomicType mmSetData(mmAtomicType *ptr, mmAtomicType value);
_declspec(dllexport) mmAtomicType mmValueInc(mmAtomicType *ptr, mmAtomicType value);
_declspec(dllexport) mmAtomicType mmValueSub(mmAtomicType *ptr, mmAtomicType value);
_declspec(dllexport) INT32 mmCreateTaskWithDetach(mmThread *threadHandle, mmUserBlock_t *funcBlock);

_declspec(dllexport) INT32 mmCreateNamedPipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
_declspec(dllexport) INT32 mmOpenNamePipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
_declspec(dllexport) VOID mmCloseNamedPipe(mmPipeHandle namedPipe[]);

_declspec(dllexport) INT32 mmCreatePipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
_declspec(dllexport) INT32 mmOpenPipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
_declspec(dllexport) VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount);

_declspec(dllexport) mmCompletionHandle mmCreateCompletionPort();
_declspec(dllexport) VOID mmCloseCompletionPort(mmCompletionHandle handle);
_declspec(dllexport) INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP,
MMPA_FUNC_VISIBILITY INT32 mmDeleteTimer(mmTimer timerHandle);
MMPA_FUNC_VISIBILITY INT32 mmStatGet(const CHAR *path, mmStat_t *buffer);
MMPA_FUNC_VISIBILITY INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer);
MMPA_FUNC_VISIBILITY INT32 mmFStatGet(INT32 fd, mmStat_t *buffer);
MMPA_FUNC_VISIBILITY INT32 mmMkdir(const CHAR *pathName, mmMode_t mode);
MMPA_FUNC_VISIBILITY INT32 mmSleep(UINT32 milliSecond);
MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock);
MMPA_FUNC_VISIBILITY INT32 mmGetProcessPrio(mmProcess pid);
MMPA_FUNC_VISIBILITY INT32 mmSetProcessPrio(mmProcess pid, INT32 processPrio);
MMPA_FUNC_VISIBILITY INT32 mmGetThreadPrio(mmThread *threadHandle);
MMPA_FUNC_VISIBILITY INT32 mmSetThreadPrio(mmThread *threadHandle, INT32 threadPrio);
MMPA_FUNC_VISIBILITY INT32 mmAccess(const CHAR *pathName);
MMPA_FUNC_VISIBILITY INT32 mmAccess2(const CHAR *pathName, INT32 mode);
MMPA_FUNC_VISIBILITY INT32 mmRmdir(const CHAR *pathName);

MMPA_FUNC_VISIBILITY INT32 mmIoctl(mmProcess fd, INT32 ioctlCode, mmIoctlBuf *bufPtr);
MMPA_FUNC_VISIBILITY INT32 mmSemTimedWait(mmSem_t *sem, INT32 timeout);
MMPA_FUNC_VISIBILITY mmSsize_t mmWritev(mmSockHandle fd, mmIovSegment *iov, INT32 iovcnt);
MMPA_FUNC_VISIBILITY VOID mmMb();
MMPA_FUNC_VISIBILITY INT32 mmInetAton(const CHAR *addrStr, mmInAddr *addr);

MMPA_FUNC_VISIBILITY mmProcess mmOpenFile(const CHAR *fileName, UINT32 access, mmCreateFlag fileFlag);
MMPA_FUNC_VISIBILITY mmSsize_t mmReadFile(mmProcess fileId, VOID *buffer, INT32 len);
MMPA_FUNC_VISIBILITY mmSsize_t mmWriteFile(mmProcess fileId, VOID *buffer, INT32 len);
MMPA_FUNC_VISIBILITY INT32 mmCloseFile(mmProcess fileId);

MMPA_FUNC_VISIBILITY mmAtomicType mmSetData(mmAtomicType *ptr, mmAtomicType value);
MMPA_FUNC_VISIBILITY mmAtomicType mmValueInc(mmAtomicType *ptr, mmAtomicType value);
MMPA_FUNC_VISIBILITY mmAtomicType mmValueSub(mmAtomicType *ptr, mmAtomicType value);
MMPA_FUNC_VISIBILITY mmAtomicType64 mmSetData64(mmAtomicType64 *ptr, mmAtomicType64 value);
MMPA_FUNC_VISIBILITY mmAtomicType64 mmValueInc64(mmAtomicType64 *ptr, mmAtomicType64 value);
MMPA_FUNC_VISIBILITY mmAtomicType64 mmValueSub64(mmAtomicType64 *ptr, mmAtomicType64 value);
MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithDetach(mmThread *threadHandle, mmUserBlock_t *funcBlock);

MMPA_FUNC_VISIBILITY INT32 mmCreateNamedPipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
MMPA_FUNC_VISIBILITY INT32 mmOpenNamePipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode);
MMPA_FUNC_VISIBILITY VOID mmCloseNamedPipe(mmPipeHandle namedPipe[]);

MMPA_FUNC_VISIBILITY INT32 mmCreatePipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
MMPA_FUNC_VISIBILITY INT32 mmOpenPipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode);
MMPA_FUNC_VISIBILITY VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount);

MMPA_FUNC_VISIBILITY mmCompletionHandle mmCreateCompletionPort();
MMPA_FUNC_VISIBILITY VOID mmCloseCompletionPort(mmCompletionHandle handle);
MMPA_FUNC_VISIBILITY INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP,
pmmPollData polledData, mmPollBack pollBack); pmmPollData polledData, mmPollBack pollBack);


_declspec(dllexport) INT32 mmGetErrorCode();
_declspec(dllexport) CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size);
_declspec(dllexport) INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone);
_declspec(dllexport) mmTimespec mmGetTickCount();
_declspec(dllexport) INT32 mmGetRealPath(CHAR *path, CHAR *realPath);

_declspec(dllexport) INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen);

_declspec(dllexport) INT32 mmDup2(INT32 oldFd, INT32 newFd);
_declspec(dllexport) INT32 mmDup(INT32 fd);
_declspec(dllexport) INT32 mmUnlink(const CHAR *filename);
_declspec(dllexport) INT32 mmChmod(const CHAR *filename, INT32 mode);
_declspec(dllexport) INT32 mmFileno(FILE *stream);
_declspec(dllexport) INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort);
_declspec(dllexport) VOID mmScandirFree(mmDirent **entryList, INT32 count);

_declspec(dllexport) mmMsgid mmMsgCreate(mmKey_t key, INT32 msgFlag);
_declspec(dllexport) mmMsgid mmMsgOpen(mmKey_t key, INT32 msgFlag);
_declspec(dllexport) INT32 mmMsgRcv(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);
_declspec(dllexport) INT32 mmMsgSnd(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);

_declspec(dllexport) INT32 mmMsgClose(mmMsgid msqid);

_declspec(dllexport) INT32 mmLocalTimeR(const time_t *timep, struct tm *result);
_declspec(dllexport) INT32 mmGetOpt(INT32 argc, char *const *argv, const char *opts);
_declspec(dllexport) INT32
MMPA_FUNC_VISIBILITY INT32 mmGetErrorCode();
MMPA_FUNC_VISIBILITY CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size);
MMPA_FUNC_VISIBILITY INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone);
MMPA_FUNC_VISIBILITY mmTimespec mmGetTickCount();
MMPA_FUNC_VISIBILITY INT32 mmGetRealPath(CHAR *path, CHAR *realPath);

MMPA_FUNC_VISIBILITY INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen);

MMPA_FUNC_VISIBILITY INT32 mmDup2(INT32 oldFd, INT32 newFd);
MMPA_FUNC_VISIBILITY INT32 mmDup(INT32 fd);
MMPA_FUNC_VISIBILITY INT32 mmUnlink(const CHAR *filename);
MMPA_FUNC_VISIBILITY INT32 mmChmod(const CHAR *filename, INT32 mode);
MMPA_FUNC_VISIBILITY INT32 mmFileno(FILE *stream);
MMPA_FUNC_VISIBILITY INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort);
MMPA_FUNC_VISIBILITY INT32 mmScandir2(const CHAR *path, mmDirent2 ***entryList, mmFilter2 filterFunc, mmSort2 sort);
MMPA_FUNC_VISIBILITY VOID mmScandirFree(mmDirent **entryList, INT32 count);
MMPA_FUNC_VISIBILITY VOID mmScandirFree2(mmDirent2 **entryList, INT32 count);

MMPA_FUNC_VISIBILITY mmMsgid mmMsgCreate(mmKey_t key, INT32 msgFlag);
MMPA_FUNC_VISIBILITY mmMsgid mmMsgOpen(mmKey_t key, INT32 msgFlag);
MMPA_FUNC_VISIBILITY INT32 mmMsgRcv(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);
MMPA_FUNC_VISIBILITY INT32 mmMsgSnd(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag);

MMPA_FUNC_VISIBILITY INT32 mmMsgClose(mmMsgid msqid);

MMPA_FUNC_VISIBILITY INT32 mmLocalTimeR(const time_t *timep, struct tm *result);
MMPA_FUNC_VISIBILITY INT32 mmGetOptErr();
MMPA_FUNC_VISIBILITY VOID mmSetOptErr(INT32 mmOptErr);
MMPA_FUNC_VISIBILITY INT32 mmGetOptInd();
MMPA_FUNC_VISIBILITY VOID mmSetOptInd(INT32 mmOptInd);
MMPA_FUNC_VISIBILITY INT32 mmGetOptOpt();
MMPA_FUNC_VISIBILITY VOID mmSetOpOpt(INT32 mmOptOpt);
MMPA_FUNC_VISIBILITY CHAR *mmGetOptArg();
MMPA_FUNC_VISIBILITY VOID mmSetOptArg(CHAR *mmOptArg);
MMPA_FUNC_VISIBILITY INT32 mmGetOpt(INT32 argc, char *const *argv, const char *opts);
MMPA_FUNC_VISIBILITY INT32
mmGetOptLong(INT32 argc, CHAR *const *argv, const CHAR *opts, const mmStructOption *longopts, INT32 *longindex); mmGetOptLong(INT32 argc, CHAR *const *argv, const CHAR *opts, const mmStructOption *longopts, INT32 *longindex);


_declspec(dllexport) LONG mmLseek(INT32 fd, INT64 offset, INT32 seekFlag);
_declspec(dllexport) INT32 mmFtruncate(mmProcess fd, UINT32 length);
MMPA_FUNC_VISIBILITY LONG mmLseek(INT32 fd, INT64 offset, INT32 seekFlag);
MMPA_FUNC_VISIBILITY INT32 mmFtruncate(mmProcess fd, UINT32 length);


_declspec(dllexport) INT32 mmTlsCreate(mmThreadKey *key, VOID (*destructor)(VOID *));
_declspec(dllexport) INT32 mmTlsSet(mmThreadKey key, const VOID *value);
_declspec(dllexport) VOID *mmTlsGet(mmThreadKey key);
_declspec(dllexport) INT32 mmTlsDelete(mmThreadKey key);
_declspec(dllexport) INT32 mmGetOsType();
MMPA_FUNC_VISIBILITY INT32 mmTlsCreate(mmThreadKey *key, VOID (*destructor)(VOID *));
MMPA_FUNC_VISIBILITY INT32 mmTlsSet(mmThreadKey key, const VOID *value);
MMPA_FUNC_VISIBILITY VOID *mmTlsGet(mmThreadKey key);
MMPA_FUNC_VISIBILITY INT32 mmTlsDelete(mmThreadKey key);
MMPA_FUNC_VISIBILITY INT32 mmGetOsType();


_declspec(dllexport) INT32 mmFsync(mmProcess fd);
_declspec(dllexport) INT32 mmFsync2(INT32 fd);
_declspec(dllexport) INT32 mmChdir(const CHAR *path);
_declspec(dllexport) INT32 mmUmask(INT32 pmode);
_declspec(dllexport) INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options);
MMPA_FUNC_VISIBILITY INT32 mmFsync(mmProcess fd);
MMPA_FUNC_VISIBILITY INT32 mmFsync2(INT32 fd);
MMPA_FUNC_VISIBILITY INT32 mmChdir(const CHAR *path);
MMPA_FUNC_VISIBILITY INT32 mmUmask(INT32 pmode);
MMPA_FUNC_VISIBILITY INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options);


_declspec(dllexport) INT32 mmGetCwd(CHAR *buffer, INT32 maxLen);
_declspec(dllexport) CHAR *mmStrTokR(CHAR *str, const CHAR *delim, CHAR **saveptr);
MMPA_FUNC_VISIBILITY INT32 mmGetCwd(CHAR *buffer, INT32 maxLen);
MMPA_FUNC_VISIBILITY CHAR *mmStrTokR(CHAR *str, const CHAR *delim, CHAR **saveptr);


_declspec(dllexport) INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len);
_declspec(dllexport) INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite);
_declspec(dllexport) CHAR *mmDirName(CHAR *path);
_declspec(dllexport) CHAR *mmBaseName(CHAR *path);
_declspec(dllexport) INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize);
MMPA_FUNC_VISIBILITY INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len);
MMPA_FUNC_VISIBILITY INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite);
MMPA_FUNC_VISIBILITY CHAR *mmDirName(CHAR *path);
MMPA_FUNC_VISIBILITY CHAR *mmBaseName(CHAR *path);
MMPA_FUNC_VISIBILITY INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize);


_declspec(dllexport) INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name);
_declspec(dllexport) INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, INT32 size);
MMPA_FUNC_VISIBILITY INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name);
MMPA_FUNC_VISIBILITY INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, INT32 size);


/* /*
* Function: set the thread name of the currently executing thread - internal call of thread, which is not supported * Function: set the thread name of the currently executing thread - internal call of thread, which is not supported
@@ -504,7 +522,7 @@ _declspec(dllexport) INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, I
* The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the
* execution failure returns EN_ERROR * execution failure returns EN_ERROR
*/ */
_declspec(dllexport) INT32 mmSetCurrentThreadName(const CHAR *name);
MMPA_FUNC_VISIBILITY INT32 mmSetCurrentThreadName(const CHAR *name);


/* /*
* Function: Get the thread name of the currently executing thread - thread body call, not supported under windows, null * Function: Get the thread name of the currently executing thread - thread body call, not supported under windows, null
@@ -513,25 +531,25 @@ _declspec(dllexport) INT32 mmSetCurrentThreadName(const CHAR *name);
* The input parameter error returns EN_INVALID_PARAM, the execution success returns * The input parameter error returns EN_INVALID_PARAM, the execution success returns
* EN_OK, and the execution failure returns EN_ERROR * EN_OK, and the execution failure returns EN_ERROR
*/ */
_declspec(dllexport) INT32 mmGetCurrentThreadName(CHAR *name, INT32 size);
_declspec(dllexport) INT32 mmGetFileSize(const CHAR *fileName, ULONGLONG *length);
_declspec(dllexport) INT32 mmIsDir(const CHAR *fileName);
_declspec(dllexport) INT32 mmGetOsName(CHAR *name, INT32 nameSize);
_declspec(dllexport) INT32 mmGetOsVersion(CHAR *versionInfo, INT32 versionLength);
_declspec(dllexport) INT32 mmGetMac(mmMacInfo **list, INT32 *count);
_declspec(dllexport) INT32 mmGetMacFree(mmMacInfo *list, INT32 count);
_declspec(dllexport) INT32 mmGetCpuInfo(mmCpuDesc **cpuInfo, INT32 *count);
_declspec(dllexport) INT32 mmCpuInfoFree(mmCpuDesc *cpuInfo, INT32 count);
_declspec(dllexport) INT32
MMPA_FUNC_VISIBILITY INT32 mmGetCurrentThreadName(CHAR *name, INT32 size);
MMPA_FUNC_VISIBILITY INT32 mmGetFileSize(const CHAR *fileName, ULONGLONG *length);
MMPA_FUNC_VISIBILITY INT32 mmIsDir(const CHAR *fileName);
MMPA_FUNC_VISIBILITY INT32 mmGetOsName(CHAR *name, INT32 nameSize);
MMPA_FUNC_VISIBILITY INT32 mmGetOsVersion(CHAR *versionInfo, INT32 versionLength);
MMPA_FUNC_VISIBILITY INT32 mmGetMac(mmMacInfo **list, INT32 *count);
MMPA_FUNC_VISIBILITY INT32 mmGetMacFree(mmMacInfo *list, INT32 count);
MMPA_FUNC_VISIBILITY INT32 mmGetCpuInfo(mmCpuDesc **cpuInfo, INT32 *count);
MMPA_FUNC_VISIBILITY INT32 mmCpuInfoFree(mmCpuDesc *cpuInfo, INT32 count);
MMPA_FUNC_VISIBILITY INT32
mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const char *stdoutRedirectFile, mmProcess *id); mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const char *stdoutRedirectFile, mmProcess *id);


_declspec(dllexport) INT32
MMPA_FUNC_VISIBILITY INT32
mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, const mmThreadAttr *threadAttr); mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, const mmThreadAttr *threadAttr);
_declspec(dllexport) mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode);
_declspec(dllexport) INT32 mmShmUnlink(const CHAR *name);
_declspec(dllexport) VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags);
_declspec(dllexport) INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra);
MMPA_FUNC_VISIBILITY mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode);
MMPA_FUNC_VISIBILITY INT32 mmShmUnlink(const CHAR *name);
MMPA_FUNC_VISIBILITY VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags);
MMPA_FUNC_VISIBILITY INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra);
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }


+ 0
- 39
third_party/fwkacllib/inc/register/host_cpu_context.h View File

@@ -1,39 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef INC_REGISTER_HOST_CPU_CONTEXT_H_
#define INC_REGISTER_HOST_CPU_CONTEXT_H_

#include "external/ge/ge_api_error_codes.h"
#include "register/register_types.h"

namespace ge {
class HostCpuContext {
public:
HostCpuContext() = default;
~HostCpuContext() = default;
private:
class Impl;
Impl *impl_;
};
} // namespace ge

extern "C" {
// Unified definition for registering host_cpu_kernel_wrapper when so is opened
FMK_FUNC_HOST_VISIBILITY ge::Status Initialize(const ge::HostCpuContext &ctx);
}

#endif //INC_REGISTER_HOST_CPU_CONTEXT_H_

+ 0
- 49
third_party/fwkacllib/inc/register/op_kernel_registry.h View File

@@ -1,49 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef INC_REGISTER_OP_KERNEL_REGISTRY_H_
#define INC_REGISTER_OP_KERNEL_REGISTRY_H_
#include <memory>
#include <string>
#include "register/register_types.h"
#include "register.h"

namespace ge {
class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpKernelRegistry {
public:
using CreateFn = HostCpuOp* (*)();
~OpKernelRegistry();

static OpKernelRegistry& GetInstance() {
static OpKernelRegistry instance;
return instance;
}

bool IsRegistered(const std::string &op_type);

void RegisterHostCpuOp(const std::string &op_type, CreateFn create_fn);

std::unique_ptr<HostCpuOp> CreateHostCpuOp(const std::string &op_type);

private:
OpKernelRegistry();
class OpKernelRegistryImpl;
/*lint -e148*/
std::unique_ptr<OpKernelRegistryImpl> impl_;
};
} // namespace ge

#endif // INC_REGISTER_OP_KERNEL_REGISTRY_H_

+ 0
- 90
third_party/fwkacllib/inc/register/op_registry.h View File

@@ -1,90 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef INC_REGISTER_OP_REGISTRY_H_
#define INC_REGISTER_OP_REGISTRY_H_

#include <limits.h>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

#include "register/register.h"

namespace domi {
enum RemoveInputType {
OMG_MOVE_TYPE_DTYPE = 0,
OMG_MOVE_TYPE_VALUE,
OMG_MOVE_TYPE_SHAPE,
OMG_MOVE_TYPE_FORMAT,
OMG_MOVE_TYPE_AXIS,
OMG_MOVE_TYPE_SCALAR_VALUE,
OMG_REMOVE_TYPE_WITH_COND = 1000,
OMG_REMOVE_INPUT_WITH_ORIGINAL_TYPE,
OMG_INPUT_REORDER,
};

struct RemoveInputConfigure {
int inputIdx = INT_MAX;
std::string attrName;
RemoveInputType moveType;
bool attrValue = false;
std::string originalType;
std::vector<int> input_order;
};

class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistry {
public:
static OpRegistry *Instance();

std::vector<OpRegistrationData> registrationDatas;

bool Register(const OpRegistrationData &reg_data);

domi::ImplyType GetImplyType(const std::string &op_type);

void GetOpTypeByImplyType(std::vector<std::string> &vec_op_type, const domi::ImplyType &imply_type);

domi::ParseParamFunc GetParseParamFunc(const std::string &op_type, const std::string &ori_type);

domi::ParseParamByOpFunc GetParseParamByOperatorFunc(const std::string &ori_type);

domi::FusionParseParamFunc GetFusionParseParamFunc(const std::string &op_type, const std::string &ori_type);

domi::FusionParseParamByOpFunc GetFusionParseParamByOpFunc(const std::string &op_type,
const std::string &ori_type);

domi::ParseSubgraphFunc GetParseSubgraphPostFunc(const std::string &op_type);

domi::ImplyType GetImplyTypeByOriOpType(const std::string &ori_optype);

const std::vector<RemoveInputConfigure> &GetRemoveInputConfigure(const std::string &ori_optype) const;

bool GetOmTypeByOriOpType(const std::string &ori_optype, std::string &om_type);

private:
std::unordered_map<std::string, domi::ImplyType> op_run_mode_map_;
std::unordered_map<std::string, ParseParamFunc> op_parse_params_fn_map_;
std::unordered_map<std::string, ParseParamByOpFunc> parse_params_by_op_func_map_;
std::unordered_map<std::string, FusionParseParamFunc> fusion_op_parse_params_fn_map_;
std::unordered_map<std::string, FusionParseParamByOpFunc> fusion_parse_params_by_op_fn_map_;
std::unordered_map<std::string, ParseSubgraphFunc> op_types_to_parse_subgraph_post_func_;
std::unordered_map<std::string, std::vector<RemoveInputConfigure>> remove_input_configure_map_;
std::unordered_map<std::string, std::string> origin_type_to_om_type_;
};
} // namespace domi
#endif // INC_REGISTER_OP_REGISTRY_H_

+ 0
- 135
third_party/fwkacllib/inc/register/op_tiling.h View File

@@ -1,135 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef INC_OP_TILING_H_
#define INC_OP_TILING_H_

#include "external/register/register_types.h"
#include "external/graph/tensor.h"
#include "graph/debug/ge_attr_define.h"
#include "graph/node.h"

#include <nlohmann/json.hpp>
#include <iostream>
#include <sstream>
#include <functional>
#include <vector>
#include <map>
#include <string>
#include "graph/node.h"

#define REGISTER_OP_TILING_FUNC(optype, opfunc) \
REGISTER_OP_TILING_FUNC_UNIQ_HELPER(optype, opfunc, __COUNTER__)

#define REGISTER_OP_TILING_FUNC_UNIQ_HELPER(optype, opfunc, counter) \
REGISTER_OP_TILING_FUNC_UNIQ(optype, opfunc, counter)

#define REGISTER_OP_TILING_FUNC_UNIQ(optype, opfunc, counter) \
static OpTilingInterf g_##optype##TilingInterf##counter(#optype, opfunc)

namespace optiling {

enum TensorArgType {
TA_NONE,
TA_SINGLE,
TA_LIST,
};


using ByteBuffer = std::stringstream;

struct TeOpTensor {
std::vector<int64_t> shape;
std::vector<int64_t> ori_shape;
std::string format;
std::string ori_format;
std::string dtype;
std::map<std::string, std::string> attrs;
};


struct TeOpTensorArg {
TensorArgType arg_type;
std::vector<TeOpTensor> tensor;
};

struct OpRunInfo {
uint32_t block_dim;
std::vector<int64_t> workspaces;
ByteBuffer tiling_data;
};


using TeOpAttrArgs = std::vector<std::string>;
using TeConstTensorData = std::tuple<const uint8_t*, size_t, ge::Tensor>;

struct TeOpParas {
std::vector<TeOpTensorArg> inputs;
std::vector<TeOpTensorArg> outputs;
std::map<std::string, TeConstTensorData> const_inputs;
TeOpAttrArgs attrs;
};


using OpTilingFunc = std::function<bool(const std::string&, const TeOpParas&,
const nlohmann::json& , OpRunInfo&)>;

using OpTilingFuncPtr = bool(*)(const std::string&, const TeOpParas&, const nlohmann::json& , OpRunInfo&);

class FMK_FUNC_HOST_VISIBILITY OpTilingInterf
{
public:
OpTilingInterf(std::string op_type, OpTilingFunc func);
~OpTilingInterf() = default;
static std::map<std::string, OpTilingFunc> &RegisteredOpInterf();
static std::string OpTilingUuid;
};


template <class T>
ByteBuffer& ByteBufferPut(ByteBuffer &buf, const T &value)
{
buf.write(reinterpret_cast<const char*>(&value), sizeof(value));
buf.flush();
return buf;
}

template <class T>
ByteBuffer& ByteBufferGet(ByteBuffer &buf, T &value)
{
buf.read(reinterpret_cast<char*>(&value), sizeof(value));
return buf;
}

inline size_t ByteBufferGetAll(ByteBuffer &buf, char *dest, size_t dest_len)
{
size_t nread = 0;
size_t rn = 0;
do {
rn = buf.readsome(dest + nread, dest_len - nread);
nread += rn;
} while (rn > 0 && dest_len > nread);

return nread;
}


extern "C" ge::graphStatus OpParaCalculate(const ge::Node &node, OpRunInfo &run_info);
extern "C" ge::graphStatus OpAtomicCalculate(const ge::Node &node, OpRunInfo &run_info);

}

#endif // INC_OP_TILING_H_

+ 0
- 62
third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h View File

@@ -1,62 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_
#define INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_

#include <memory>
#include "register/register_types.h"
#include "common/opskernel/ops_kernel_builder.h"

namespace ge {
using OpsKernelBuilderPtr = std::shared_ptr<OpsKernelBuilder>;

class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpsKernelBuilderRegistry {
public:
static OpsKernelBuilderRegistry &GetInstance();

void Register(const std::string &lib_name, const OpsKernelBuilderPtr &instance);

void UnregisterAll();

const std::map<std::string, OpsKernelBuilderPtr> &GetAll() const;

private:
std::map<std::string, OpsKernelBuilderPtr> kernel_builders_;
};

class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpsKernelBuilderRegistrar {
public:
using CreateFn = OpsKernelBuilder *(*)();
OpsKernelBuilderRegistrar(const std::string &kernel_lib_name, CreateFn fn);
~OpsKernelBuilderRegistrar() = default;
};

#define REGISTER_OPS_KERNEL_BUILDER(kernel_lib_name, builder) \
REGISTER_OPS_KERNEL_BUILDER_UNIQ_HELPER(__COUNTER__, kernel_lib_name, builder)

#define REGISTER_OPS_KERNEL_BUILDER_UNIQ_HELPER(ctr, kernel_lib_name, builder) \
REGISTER_OPS_KERNEL_BUILDER_UNIQ(ctr, kernel_lib_name, builder)

#define REGISTER_OPS_KERNEL_BUILDER_UNIQ(ctr, kernel_lib_name, builder) \
static ::ge::OpsKernelBuilderRegistrar register_op_kernel_builder_##ctr \
__attribute__((unused)) = \
::ge::OpsKernelBuilderRegistrar(kernel_lib_name, []()->::ge::OpsKernelBuilder* { \
return new (std::nothrow) builder(); \
})
} // namespace ge

#endif // INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_

+ 0
- 54
third_party/fwkacllib/inc/register/register.h View File

@@ -1,54 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef INC_REGISTER_REGISTRY_H_
#define INC_REGISTER_REGISTRY_H_

#include "external/register/register.h"
#include "external/ge/ge_api_error_codes.h"

namespace ge {
class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY HostCpuOp {
public:
HostCpuOp() = default;
virtual ~HostCpuOp() = default;

virtual graphStatus Compute(Operator &op,
const std::map<std::string, const Tensor> &inputs,
std::map<std::string, Tensor> &outputs) = 0;
};

class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY HostCpuOpRegistrar {
public:
HostCpuOpRegistrar(const char *op_type, HostCpuOp *(*create_fn)());
~HostCpuOpRegistrar() = default;
};

#define REGISTER_HOST_CPU_OP_BUILDER(name, op) \
REGISTER_HOST_CPU_OP_BUILDER_UNIQ_HELPER(__COUNTER__, name, op)

#define REGISTER_HOST_CPU_OP_BUILDER_UNIQ_HELPER(ctr, name, op) \
REGISTER_HOST_CPU_OP_BUILDER_UNIQ(ctr, name, op)

#define REGISTER_HOST_CPU_OP_BUILDER_UNIQ(ctr, name, op) \
static ::ge::HostCpuOpRegistrar register_host_cpu_op##ctr \
__attribute__((unused)) = \
::ge::HostCpuOpRegistrar(name, []()->::ge::HostCpuOp* { \
return new (std::nothrow) op(); \
})
} // namespace ge

#endif //INC_REGISTER_REGISTRY_H_

+ 0
- 79
third_party/fwkacllib/inc/register/register_format_transfer.h View File

@@ -1,79 +0,0 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef INC_REGISTER_REGISTER_FORMAT_TRANSFER_H_
#define INC_REGISTER_REGISTER_FORMAT_TRANSFER_H_

#include <functional>
#include <memory>
#include <vector>

#include "external/graph/types.h"
#include "ge/ge_api_error_codes.h"

namespace ge {
namespace formats {
struct TransArgs {
const uint8_t *data;
Format src_format;
Format dst_format;
// For scenes that need to supplement the shape, for example, 5D to 4D
// It is not possible to convert the format normally if you only get the src_shape,
// and must get the shape before you mend the shape.
// So the parameters here need to be passed in both src_shape and dst_shape
std::vector<int64_t> src_shape;
std::vector<int64_t> dst_shape;
DataType src_data_type;
};

struct TransResult {
std::shared_ptr<uint8_t> data;
// data length in bytes
size_t length;
};

class FormatTransfer {
public:
virtual ~FormatTransfer() = default;
virtual Status TransFormat(const TransArgs &args, TransResult &result) = 0;
virtual Status TransShape(Format src_format, const std::vector<int64_t> &src_shape, DataType data_type,
Format dst_format, std::vector<int64_t> &dst_shape) = 0;
};

using FormatTransferBuilder = std::function<std::shared_ptr<FormatTransfer>()>;

class FormatTransferRegister {
public:
FormatTransferRegister(FormatTransferBuilder builder, Format src, Format dst);
~FormatTransferRegister() = default;
};

#define REGISTER_FORMAT_TRANSFER(TransferClass, format1, format2) \
namespace { \
FormatTransferRegister format_transfer_register_##TransferClass##format1##format2( \
[]() { return std::make_shared<TransferClass>(); }, format1, format2); \
}

/// Build a formattransfer according to 'args'
/// @param args
/// @param result
/// @return
std::shared_ptr<FormatTransfer> BuildFormatTransfer(const TransArgs &args);

bool FormatTransferExists(const TransArgs &args);
} // namespace formats
} // namespace ge
#endif // INC_REGISTER_REGISTER_FORMAT_TRANSFER_H_

+ 14
- 2
third_party/fwkacllib/inc/runtime/base.h View File

@@ -391,6 +391,8 @@ typedef void (*rtErrorCallback)(rtExceptionType);


typedef void (*rtTaskFailCallback)(rtExceptionInfo *exceptionInfo); typedef void (*rtTaskFailCallback)(rtExceptionInfo *exceptionInfo);


typedef void (*rtDeviceStateCallback)(uint32_t devId, bool isOpen);

/** /**
* @ingroup dvrt_base * @ingroup dvrt_base
* @brief stream handle. * @brief stream handle.
@@ -419,7 +421,7 @@ RTS_API rtError_t rtSetProfDirEx(const char *profDir, const char *address, const
* @ingroup profiling_base * @ingroup profiling_base
* @brief init profiler object. * @brief init profiler object.
*/ */
RTS_API rtError_t rtProfilerInit(const char *profdir, const char *address, const char *job_ctx);
RTS_API rtError_t rtProfilerInit(const char *profDir, const char *address, const char *jobCtx);


/** /**
* @ingroup profiling_base * @ingroup profiling_base
@@ -473,6 +475,16 @@ RTS_API rtError_t rtSetExceptCallback(rtErrorCallback callback);
*/ */
RTS_API rtError_t rtSetTaskFailCallback(rtTaskFailCallback callback); RTS_API rtError_t rtSetTaskFailCallback(rtTaskFailCallback callback);


/**
* @ingroup dvrt_base
* @brief register callback for deviceid
* @param [in] uniName unique register name, can't be null
* @param [in] callback Device state callback function
* @param [out] NA
* @return RT_ERROR_NONE for ok
*/
RTS_API rtError_t rtRegDeviceStateCallback(const char *regName, rtDeviceStateCallback callback);

/** /**
* @ingroup dvrt_base * @ingroup dvrt_base
* @brief notify handle. * @brief notify handle.
@@ -593,7 +605,7 @@ RTS_API rtError_t rtLabelCreateEx(rtLabel_t *label, rtStream_t stream);
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for input null ptr * @return RT_ERROR_INVALID_VALUE for input null ptr
*/ */
RTS_API rtError_t rtGetTaskIdAndStreamID(uint32_t *taskid, uint32_t *streamid);
RTS_API rtError_t rtGetTaskIdAndStreamID(uint32_t *taskId, uint32_t *streamId);


#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE)
} }


+ 1
- 1
third_party/fwkacllib/inc/runtime/context.h View File

@@ -139,7 +139,7 @@ RTS_API rtError_t rtSetGroup(int32_t groupId);
* @param [in] groupid count * @param [in] groupid count
* @return RT_ERROR_NONE for ok, errno for failed * @return RT_ERROR_NONE for ok, errno for failed
*/ */
RTS_API rtError_t rtGetGroupInfo(int32_t groupId, rtGroupInfo_t* groupInfo, uint32_t count);
RTS_API rtError_t rtGetGroupInfo(int32_t groupId, rtGroupInfo_t *groupInfo, uint32_t count);


/** /**
* @ingroup * @ingroup


+ 2
- 2
third_party/fwkacllib/inc/runtime/dev.h View File

@@ -295,7 +295,7 @@ RTS_API rtError_t rtGetRunMode(rtRunMode *mode);
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_DRV_ERR for can not get aicpu deploy * @return RT_ERROR_DRV_ERR for can not get aicpu deploy
*/ */
RTS_API rtError_t rtGetAicpuDeploy(rtAicpuDeployType_t *deplyType);
RTS_API rtError_t rtGetAicpuDeploy(rtAicpuDeployType_t *deployType);


/** /**
* @ingroup dvrt_dev * @ingroup dvrt_dev
@@ -309,7 +309,7 @@ RTS_API rtError_t rtSetSocVersion(const char *version);
* @brief get chipType * @brief get chipType
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
*/ */
rtError_t rtGetSocVersion(char *version, const uint32_t maxLen);
RTS_API rtError_t rtGetSocVersion(char *version, const uint32_t maxLen);


/** /**
* @ingroup dvrt_dev * @ingroup dvrt_dev


+ 19
- 9
third_party/fwkacllib/inc/runtime/event.h View File

@@ -57,6 +57,16 @@ RTS_API rtError_t rtEventCreateWithFlag(rtEvent_t *event, uint32_t flag);
*/ */
RTS_API rtError_t rtEventDestroy(rtEvent_t event); RTS_API rtError_t rtEventDestroy(rtEvent_t event);


/**
* @ingroup dvrt_event
* @brief get event id
* @param [in] event_ event to be get
* @param [in|out] event_id event_id id
* @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
*/
RTS_API rtError_t rtGetEventID(rtEvent_t event, uint32_t *eventId);

/** /**
* @ingroup dvrt_event * @ingroup dvrt_event
* @brief event record * @brief event record
@@ -116,13 +126,13 @@ RTS_API rtError_t rtEventGetTimeStamp(uint64_t *time, rtEvent_t event);
/** /**
* @ingroup dvrt_event * @ingroup dvrt_event
* @brief name an event * @brief name an event
* @param [in] event_ event to be named
* @param [in] event event to be named
* @param [in] name identification name * @param [in] name identification name
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input of event, name * @return RT_ERROR_INVALID_VALUE for error input of event, name
* @return RT_ERROR_DRV_ERR for driver error * @return RT_ERROR_DRV_ERR for driver error
*/ */
RTS_API rtError_t rtNameEvent(rtEvent_t event_, const char *name);
RTS_API rtError_t rtNameEvent(rtEvent_t event, const char *name);


/** /**
* @ingroup dvrt_event * @ingroup dvrt_event
@@ -132,7 +142,7 @@ RTS_API rtError_t rtNameEvent(rtEvent_t event_, const char *name);
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtNotifyCreate(int32_t device_id, rtNotify_t *notify_);
RTS_API rtError_t rtNotifyCreate(int32_t deviceId, rtNotify_t *notify);


/** /**
* @ingroup dvrt_event * @ingroup dvrt_event
@@ -142,7 +152,7 @@ RTS_API rtError_t rtNotifyCreate(int32_t device_id, rtNotify_t *notify_);
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_DRV_ERR for driver error * @return RT_ERROR_DRV_ERR for driver error
*/ */
RTS_API rtError_t rtNotifyDestroy(rtNotify_t notify_);
RTS_API rtError_t rtNotifyDestroy(rtNotify_t notify);


/** /**
* @ingroup dvrt_event * @ingroup dvrt_event
@@ -153,7 +163,7 @@ RTS_API rtError_t rtNotifyDestroy(rtNotify_t notify_);
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_STREAM_CONTEXT for stream is not in current ctx * @return RT_ERROR_STREAM_CONTEXT for stream is not in current ctx
*/ */
RTS_API rtError_t rtNotifyRecord(rtNotify_t notify_, rtStream_t stream_);
RTS_API rtError_t rtNotifyRecord(rtNotify_t notify, rtStream_t stream);


/** /**
* @ingroup dvrt_event * @ingroup dvrt_event
@@ -164,7 +174,7 @@ RTS_API rtError_t rtNotifyRecord(rtNotify_t notify_, rtStream_t stream_);
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_STREAM_CONTEXT for stream is not in current ctx * @return RT_ERROR_STREAM_CONTEXT for stream is not in current ctx
*/ */
RTS_API rtError_t rtNotifyWait(rtNotify_t notify_, rtStream_t stream_);
RTS_API rtError_t rtNotifyWait(rtNotify_t notify, rtStream_t stream);


/** /**
* @ingroup dvrt_event * @ingroup dvrt_event
@@ -174,7 +184,7 @@ RTS_API rtError_t rtNotifyWait(rtNotify_t notify_, rtStream_t stream_);
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtNameNotify(rtNotify_t notify_, const char *name);
RTS_API rtError_t rtNameNotify(rtNotify_t notify, const char *name);


/** /**
* @ingroup dvrt_event * @ingroup dvrt_event
@@ -184,7 +194,7 @@ RTS_API rtError_t rtNameNotify(rtNotify_t notify_, const char *name);
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtGetNotifyID(rtNotify_t notify_, uint32_t *notify_id);
RTS_API rtError_t rtGetNotifyID(rtNotify_t notify, uint32_t *notifyId);


/** /**
* @ingroup dvrt_event * @ingroup dvrt_event
@@ -199,7 +209,7 @@ RTS_API rtError_t rtIpcSetNotifyName(rtNotify_t notify, char *name, uint32_t len
/** /**
* @ingroup dvrt_event * @ingroup dvrt_event
* @brief Open IPC notify * @brief Open IPC notify
* @param [in] notify notify to be opened
* @param [out] notify the opened notify
* @param [in] name identification name * @param [in] name identification name
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input


+ 43
- 14
third_party/fwkacllib/inc/runtime/kernel.h View File

@@ -169,6 +169,18 @@ typedef void (*rtCallback_t)(void *fnData);
*/ */
#define RT_DEV_BINARY_MAGIC_ELF_AIVEC 0x41415246 #define RT_DEV_BINARY_MAGIC_ELF_AIVEC 0x41415246


/**
* @ingroup rt_kernel
* @brief magic number of elf binary for aicube
*/
#define RT_DEV_BINARY_MAGIC_ELF_AICUBE 0x41415247

/**
* @ingroup rt_kernel
* @brief magic number of elf binary for aivector
*/
#define RT_DEV_BINARY_MAGIC_ELF_AIVECTOR 0x41415248

/** /**
* @ingroup rt_kernel_flags * @ingroup rt_kernel_flags
* @brief kernel op bit flags * @brief kernel op bit flags
@@ -285,7 +297,7 @@ RTS_API rtError_t rtQueryFunctionRegistered(const char *stubName);
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtKernelConfigDump(uint32_t kind, uint32_t dumpSizePerBlock, uint32_t blockDim, void **dumpBaseAddr, RTS_API rtError_t rtKernelConfigDump(uint32_t kind, uint32_t dumpSizePerBlock, uint32_t blockDim, void **dumpBaseAddr,
rtStream_t stream_);
rtStream_t stream);


/** /**
* @ingroup rt_kernel * @ingroup rt_kernel
@@ -297,7 +309,7 @@ RTS_API rtError_t rtKernelConfigDump(uint32_t kind, uint32_t dumpSizePerBlock, u
* @param [in] smDesc shared memory description * @param [in] smDesc shared memory description
* @param [in] stream associated stream * @param [in] stream associated stream
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtKernelLaunch(const void *stubFunc, uint32_t blockDim, void *args, uint32_t argsSize, RTS_API rtError_t rtKernelLaunch(const void *stubFunc, uint32_t blockDim, void *args, uint32_t argsSize,
rtSmDesc_t *smDesc, rtStream_t stream); rtSmDesc_t *smDesc, rtStream_t stream);
@@ -313,7 +325,7 @@ RTS_API rtError_t rtKernelLaunch(const void *stubFunc, uint32_t blockDim, void *
* @param [in] stream associated stream * @param [in] stream associated stream
* @param [in] flag dump flag * @param [in] flag dump flag
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtKernelLaunchWithFlag(const void *stubFunc, uint32_t blockDim, void *args, uint32_t argsSize, RTS_API rtError_t rtKernelLaunchWithFlag(const void *stubFunc, uint32_t blockDim, void *args, uint32_t argsSize,
rtSmDesc_t *smDesc, rtStream_t stream, uint32_t flags); rtSmDesc_t *smDesc, rtStream_t stream, uint32_t flags);
@@ -375,7 +387,7 @@ typedef void *rtModel_t;
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtDumpAddrSet(rtModel_t model, void *addr , uint32_t dumpSize, uint32_t flag);
RTS_API rtError_t rtDumpAddrSet(rtModel_t model, void *addr, uint32_t dumpSize, uint32_t flag);


/** /**
* @ingroup rt_kernel * @ingroup rt_kernel
@@ -444,7 +456,7 @@ RTS_API rtError_t rtKernelConfigTransArg(const void *ptr, uint64_t size, uint32_
* @brief start fusion kernels. * @brief start fusion kernels.
* @param [in] stream stream for fusion kernels * @param [in] stream stream for fusion kernels
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtKernelFusionStart(rtStream_t stream); RTS_API rtError_t rtKernelFusionStart(rtStream_t stream);


@@ -453,7 +465,7 @@ RTS_API rtError_t rtKernelFusionStart(rtStream_t stream);
* @brief end fusion kernels. * @brief end fusion kernels.
* @param [in] stream stream for fusion kernels * @param [in] stream stream for fusion kernels
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtKernelFusionEnd(rtStream_t stream); RTS_API rtError_t rtKernelFusionEnd(rtStream_t stream);


@@ -462,7 +474,7 @@ RTS_API rtError_t rtKernelFusionEnd(rtStream_t stream);
* @brief set kernelinfo callback * @brief set kernelinfo callback
* @param [in] callback * @param [in] callback
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtSetKernelReportCallback(rtKernelReportCallback callBack); RTS_API rtError_t rtSetKernelReportCallback(rtKernelReportCallback callBack);


@@ -472,7 +484,7 @@ RTS_API rtError_t rtSetKernelReportCallback(rtKernelReportCallback callBack);
* @param [in] threadId thread id for stream * @param [in] threadId thread id for stream
* @param [in] stream stream for subscribe * @param [in] stream stream for subscribe
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtSubscribeReport(uint64_t threadId, rtStream_t stream); RTS_API rtError_t rtSubscribeReport(uint64_t threadId, rtStream_t stream);


@@ -483,7 +495,7 @@ RTS_API rtError_t rtSubscribeReport(uint64_t threadId, rtStream_t stream);
* @param [in] fnData user data * @param [in] fnData user data
* @param [in] stream subscribed stream * @param [in] stream subscribed stream
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtCallbackLaunch(rtCallback_t callBackFunc, void *fnData, rtStream_t stream, bool isBlock); RTS_API rtError_t rtCallbackLaunch(rtCallback_t callBackFunc, void *fnData, rtStream_t stream, bool isBlock);


@@ -492,7 +504,7 @@ RTS_API rtError_t rtCallbackLaunch(rtCallback_t callBackFunc, void *fnData, rtSt
* @brief process callback report. * @brief process callback report.
* @param [in] timeout if timeout=-1, while(1); else timeout * @param [in] timeout if timeout=-1, while(1); else timeout
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtProcessReport(int32_t timeout); RTS_API rtError_t rtProcessReport(int32_t timeout);


@@ -502,7 +514,7 @@ RTS_API rtError_t rtProcessReport(int32_t timeout);
* @param [in] threadId thread id for stream * @param [in] threadId thread id for stream
* @param [in] stream stream for subscribe * @param [in] stream stream for subscribe
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtUnSubscribeReport(uint64_t threadId, rtStream_t stream); RTS_API rtError_t rtUnSubscribeReport(uint64_t threadId, rtStream_t stream);


@@ -510,7 +522,7 @@ RTS_API rtError_t rtUnSubscribeReport(uint64_t threadId, rtStream_t stream);
* @ingroup profiling_base * @ingroup profiling_base
* @brief start online prof. * @brief start online prof.
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtStartOnlineProf(rtStream_t stream, uint32_t sampleNum); RTS_API rtError_t rtStartOnlineProf(rtStream_t stream, uint32_t sampleNum);


@@ -518,7 +530,7 @@ RTS_API rtError_t rtStartOnlineProf(rtStream_t stream, uint32_t sampleNum);
* @ingroup profiling_base * @ingroup profiling_base
* @brief stop online prof. * @brief stop online prof.
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtStopOnlineProf(rtStream_t stream); RTS_API rtError_t rtStopOnlineProf(rtStream_t stream);


@@ -526,9 +538,26 @@ RTS_API rtError_t rtStopOnlineProf(rtStream_t stream);
* @ingroup profiling_base * @ingroup profiling_base
* @brief get online prof. * @brief get online prof.
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtGetOnlineProfData(rtStream_t stream, rtProfDataInfo_t *pProfData, uint32_t profDataNum); RTS_API rtError_t rtGetOnlineProfData(rtStream_t stream, rtProfDataInfo_t *pProfData, uint32_t profDataNum);

/**
* @ingroup profiling_base
* @brief start mdc profiler.
* @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
*/
RTS_API rtError_t rtStartMDCProfiler(void **addr, uint32_t length);

/**
* @ingroup profiling_base
* @brief stop mdc profiler.
* @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input
*/
RTS_API rtError_t rtStopMDCProfiler(void *addr);

#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE)
} }
#endif #endif


+ 3
- 3
third_party/fwkacllib/inc/runtime/mem.h View File

@@ -475,7 +475,7 @@ RTS_API rtError_t rtIpcSetMemoryName(const void *ptr, uint64_t byteCount, char *
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_DRV_ERR for driver error * @return RT_ERROR_DRV_ERR for driver error
*/ */
rtError_t rtIpcDestroyMemoryName(const char *name);
RTS_API rtError_t rtIpcDestroyMemoryName(const char *name);


/** /**
* @ingroup dvrt_mem * @ingroup dvrt_mem
@@ -503,13 +503,13 @@ RTS_API rtError_t rtIpcCloseMemory(const void *ptr);
* @ingroup dvrt_mem * @ingroup dvrt_mem
* @brief HCCL Async memory cpy * @brief HCCL Async memory cpy
* @param [in] index sq index * @param [in] index sq index
* @param [in] wqe_index moudle index
* @param [in] wqeIndex moudle index
* @param [in] stream asynchronized task stream * @param [in] stream asynchronized task stream
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
* @return RT_ERROR_DRV_ERR for driver error * @return RT_ERROR_DRV_ERR for driver error
*/ */
RTS_API rtError_t rtRDMASend(uint32_t index, uint32_t wqe_index, rtStream_t stream);
RTS_API rtError_t rtRDMASend(uint32_t index, uint32_t wqeIndex, rtStream_t stream);


/** /**
* @ingroup dvrt_mem * @ingroup dvrt_mem


+ 2
- 1
third_party/fwkacllib/inc/runtime/rt_model.h View File

@@ -438,7 +438,8 @@ RTS_API rtError_t rtModelGetId(rtModel_t model, uint32_t *modelId);
* @return RT_ERROR_NONE for ok * @return RT_ERROR_NONE for ok
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
*/ */
rtError_t rtDebugRegister(rtModel_t model, uint32_t flag, const void *addr, uint32_t *streamId, uint32_t *taskId);
RTS_API rtError_t rtDebugRegister(rtModel_t model, uint32_t flag, const void *addr,
uint32_t *streamId, uint32_t *taskId);


/* /*
* @ingroup rt_model * @ingroup rt_model


+ 8
- 8
third_party/fwkacllib/inc/runtime/stream.h View File

@@ -126,17 +126,17 @@ RTS_API rtError_t rtGetStreamId(rtStream_t stream, int32_t *streamId);
* @return RT_ERROR_NONE for complete * @return RT_ERROR_NONE for complete
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtGetMaxStreamAndTask(uint32_t streamType, uint32_t *MaxStrCount, uint32_t *MaxTaskCount);
RTS_API rtError_t rtGetMaxStreamAndTask(uint32_t streamType, uint32_t *maxStrCount, uint32_t *maxTaskCount);


/** /**
* @ingroup dvrt_stream * @ingroup dvrt_stream
* @brief Name a stream * @brief Name a stream
* @param [in] stream_ stream to be named
* @param [in] stream stream to be named
* @param [in] name identification name * @param [in] name identification name
* @return RT_ERROR_NONE for complete * @return RT_ERROR_NONE for complete
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtNameStream(rtStream_t stream_, const char *name);
RTS_API rtError_t rtNameStream(rtStream_t stream, const char *name);


/** /**
* @ingroup dvrt_stream * @ingroup dvrt_stream
@@ -144,12 +144,12 @@ RTS_API rtError_t rtNameStream(rtStream_t stream_, const char *name);
* @param [in] ptr Determine the address where the value of the true and false branches is located * @param [in] ptr Determine the address where the value of the true and false branches is located
* @param [in] condition switch condition * @param [in] condition switch condition
* @param [in] value switch value * @param [in] value switch value
* @param [in] true_stream Stream that needs to be activated when the value is non-zero
* @param [in] trueStream Stream that needs to be activated when the value is non-zero
* @param [in] stream input stream to init task * @param [in] stream input stream to init task
* @return RT_ERROR_NONE for complete * @return RT_ERROR_NONE for complete
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtStreamSwitch(void *ptr, rtCondition_t condition, int64_t value, rtStream_t true_stream,
RTS_API rtError_t rtStreamSwitch(void *ptr, rtCondition_t condition, int64_t value, rtStream_t trueStream,
rtStream_t stream); rtStream_t stream);


/** /**
@@ -162,18 +162,18 @@ RTS_API rtError_t rtStreamSwitch(void *ptr, rtCondition_t condition, int64_t val
* @param [in] dataType data type of target value * @param [in] dataType data type of target value
* @return RT_ERROR_NONE for complete * @return RT_ERROR_NONE for complete
*/ */
RTS_API rtError_t rtStreamSwitchEx(void *ptr, rtCondition_t condition, void *value_ptr, rtStream_t true_stream,
RTS_API rtError_t rtStreamSwitchEx(void *ptr, rtCondition_t condition, void *valuePtr, rtStream_t trueStream,
rtStream_t stream, rtSwitchDataType_t dataType); rtStream_t stream, rtSwitchDataType_t dataType);


/** /**
* @ingroup dvrt_stream * @ingroup dvrt_stream
* @brief Active a stream * @brief Active a stream
* @param [in] active_stream stream to be activated
* @param [in] activeStream stream to be activated
* @param [in] stream input stream to init task * @param [in] stream input stream to init task
* @return RT_ERROR_NONE for complete * @return RT_ERROR_NONE for complete
* @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_INVALID_VALUE for error input
*/ */
RTS_API rtError_t rtStreamActive(rtStream_t active_stream, rtStream_t stream);
RTS_API rtError_t rtStreamActive(rtStream_t activeStream, rtStream_t stream);


/** /**
* @brief execute extensible stream case switch task * @brief execute extensible stream case switch task


+ 29
- 0
third_party/fwkacllib/inc/tdt/index_transform.h View File

@@ -0,0 +1,29 @@
/**
* @file index_transform.h
*
* Copyright (C) Huawei Technologies Co., Ltd. 2018-2019. All Rights Reserved.
*
* This program is used to get logical device id by phy device id.
*/

#ifndef INC_TDT_INDEX_TRANSFORM_H
#define INC_TDT_INDEX_TRANSFORM_H

#include "stdint.h"
/**
* @ingroup IndexTransform
* @brief get logical device id by phy device id.
*
* @par Function get logical device id by phy device id.
*
* @param phyId [IN] physical device id
* @param logicalId [OUT] logical device id
* @retval 0 Success
* @retval OtherValues Fail
*
* @par Dependency
* @li libruntime.so: Library to which the interface belongs.
*/

int32_t IndexTransform(const uint32_t phyId, uint32_t &logicId);
#endif

+ 3
- 0
third_party/fwkacllib/inc/tdt/status.h View File

@@ -193,6 +193,7 @@ enum {
TDT_HDC_SRV_TYPE_ERROR_CODE, TDT_HDC_SRV_TYPE_ERROR_CODE,
TDT_TSD_CLT_OPEN_FAILED_CODE, TDT_TSD_CLT_OPEN_FAILED_CODE,
TDT_TSD_CLT_CLOSE_FAILED_CODE, TDT_TSD_CLT_CLOSE_FAILED_CODE,
TDT_TSD_CLT_UPDATE_PROFILING_FAILED_CODE,
TDT_TSD_CLT_INTERFACE_NOT_SUPPORT_CODE, TDT_TSD_CLT_INTERFACE_NOT_SUPPORT_CODE,
TDT_SUPERVISOR_ILLEGAL_HEARTBEAT_TIME_CODE, TDT_SUPERVISOR_ILLEGAL_HEARTBEAT_TIME_CODE,
TDT_SUPERVISOR_INOTIFY_READ_SIZE_ERROR_CODE, TDT_SUPERVISOR_INOTIFY_READ_SIZE_ERROR_CODE,
@@ -697,6 +698,8 @@ TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_BIND_CPUCORE_FAILED, "thread
TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_HDC_SRV_CLOSED, "hdc server has been closed"); TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_HDC_SRV_CLOSED, "hdc server has been closed");
TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_OPEN_FAILED, "tsd client open failed"); TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_OPEN_FAILED, "tsd client open failed");
TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_CLOSE_FAILED, "tsd client close failed"); TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_CLOSE_FAILED, "tsd client close failed");
TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_UPDATE_PROFILING_FAILED,
"tsd client update profiling failed");
TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_INTERFACE_NOT_SUPPORT, "tsd client func not support"); TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_INTERFACE_NOT_SUPPORT, "tsd client func not support");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FILELIST_NOT_EXIST, "tdt filelist open failed"); TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FILELIST_NOT_EXIST, "tdt filelist open failed");
TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_SAMPLE_FILE_NOT_FOUND, "tdt sample file is empty"); TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_SAMPLE_FILE_NOT_FOUND, "tdt sample file is empty");


+ 20
- 2
third_party/fwkacllib/inc/tdt/tsd_client.h View File

@@ -49,7 +49,7 @@ extern "C" {
* @li tsd_client.h: Header file where the interface declaration is located. * @li tsd_client.h: Header file where the interface declaration is located.
* @li data_common.h: Header file where 'TDT_StatusT' defined * @li data_common.h: Header file where 'TDT_StatusT' defined
*/ */
TDT_StatusT TsdOpen(const uint32_t phyDeviceId, const uint32_t rankSize);
TDT_LIB_EXPORT TDT_StatusT TsdOpen(const uint32_t phyDeviceId, const uint32_t rankSize);


/** /**
* @ingroup Close * @ingroup Close
@@ -67,7 +67,25 @@ TDT_StatusT TsdOpen(const uint32_t phyDeviceId, const uint32_t rankSize);
* @li tsd_client.h: Header file where the interface declaration is located. * @li tsd_client.h: Header file where the interface declaration is located.
* @li data_common.h: Header file where 'TDT_StatusT' defined * @li data_common.h: Header file where 'TDT_StatusT' defined
*/ */
TDT_StatusT TsdClose(const uint32_t phyDeviceId);
TDT_LIB_EXPORT TDT_StatusT TsdClose(const uint32_t phyDeviceId);

/**
* @ingroup UpdateProfilingMode
* @brief notify TSDClient update profiling mode
*
* @par Function
* notify TSDClient update profiling mode
*
* @param NA
* @retval TDT_OK Success
* @retval OtherValues Failure
*
* @par Dependency
* @li libtsdclient.so: Library to which the interface belongs.
* @li tsd_client.h: Header file where the interface declaration is located.
* @li data_common.h: Header file where 'TDT_StatusT' defined
*/
TDT_LIB_EXPORT TDT_StatusT UpdateProfilingMode(const uint32_t phyDeviceId, const uint32_t flag);


/** /**
* @ingroup CreateCmdParameterObj * @ingroup CreateCmdParameterObj


+ 15
- 11
third_party/fwkacllib/inc/toolchain/slog.h View File

@@ -25,10 +25,20 @@ extern "C" {
#define LINUX 0 #define LINUX 0
#endif // LINUX #endif // LINUX


#ifndef WIN
#define WIN 1
#endif

#ifndef OS_TYPE #ifndef OS_TYPE
#define OS_TYPE 0 #define OS_TYPE 0
#endif // OS_TYPE #endif // OS_TYPE


#if (OS_TYPE == LINUX)
#define DLL_EXPORT __attribute__((visibility("default")))
#else
#define DLL_EXPORT _declspec(dllexport)
#endif

/** /**
* @ingroup slog * @ingroup slog
* *
@@ -180,12 +190,11 @@ enum {
INVLID_MOUDLE_ID INVLID_MOUDLE_ID
}; };


#if (OS_TYPE == LINUX)
/** /**
* @ingroup slog * @ingroup slog
* @brief External log interface, which called by modules * @brief External log interface, which called by modules
*/ */
extern void dlog_init(void);
DLL_EXPORT void dlog_init(void);


/** /**
* @ingroup slog * @ingroup slog
@@ -195,7 +204,7 @@ extern void dlog_init(void);
* @param [out]enableEvent: 1: enable; 0: disable * @param [out]enableEvent: 1: enable; 0: disable
* @return: module level(0: debug, 1: info, 2: warning, 3: error, 4: null output) * @return: module level(0: debug, 1: info, 2: warning, 3: error, 4: null output)
*/ */
extern int dlog_getlevel(int moduleId, int *enableEvent);
DLL_EXPORT int dlog_getlevel(int moduleId, int *enableEvent);


/** /**
* @ingroup slog * @ingroup slog
@@ -206,7 +215,7 @@ extern int dlog_getlevel(int moduleId, int *enableEvent);
* @param [in]enableEvent: 1: enable; 0: disable, others:invalid * @param [in]enableEvent: 1: enable; 0: disable, others:invalid
* @return: 0: SUCCEED, others: FAILED * @return: 0: SUCCEED, others: FAILED
*/ */
extern int dlog_setlevel(int moduleId, int level, int enableEvent);
DLL_EXPORT int dlog_setlevel(int moduleId, int level, int enableEvent);


/** /**
* @ingroup slog * @ingroup slog
@@ -217,7 +226,7 @@ extern int dlog_setlevel(int moduleId, int level, int enableEvent);
* @param [in]logLevel: eg: DLOG_EVENT/DLOG_ERROR/DLOG_WARN/DLOG_INFO/DLOG_DEBUG * @param [in]logLevel: eg: DLOG_EVENT/DLOG_ERROR/DLOG_WARN/DLOG_INFO/DLOG_DEBUG
* @return: 1:enable, 0:disable * @return: 1:enable, 0:disable
*/ */
extern int CheckLogLevel(int moduleId, int logLevel);
DLL_EXPORT int CheckLogLevel(int moduleId, int logLevel);


/** /**
* @ingroup slog * @ingroup slog
@@ -343,7 +352,7 @@ extern int CheckLogLevel(int moduleId, int logLevel);
* @ingroup slog * @ingroup slog
* @brief DlogFlush: flush log buffer to file * @brief DlogFlush: flush log buffer to file
*/ */
void DlogFlush(void);
DLL_EXPORT void DlogFlush(void);


/** /**
* @ingroup slog * @ingroup slog
@@ -357,11 +366,6 @@ void DlogEventInner(int moduleId, const char *fmt, ...);
void DlogInner(int moduleId, int level, const char *fmt, ...); void DlogInner(int moduleId, int level, const char *fmt, ...);
void DlogWithKVInner(int moduleId, int level, KeyValue *pstKVArray, int kvNum, const char *fmt, ...); void DlogWithKVInner(int moduleId, int level, KeyValue *pstKVArray, int kvNum, const char *fmt, ...);


#else
_declspec(dllexport) void dlog_init(void);
_declspec(dllexport) int dlog_getlevel(int moduleId, int *enableEvent);
#endif // OS_TYPE

#ifdef __cplusplus #ifdef __cplusplus
} }
#endif // __cplusplus #endif // __cplusplus


+ 72
- 0
third_party/fwkacllib/inc/toolchain/tuning_tool/tune_api.h View File

@@ -0,0 +1,72 @@
/**
* @file tune_api.h
*
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.\n
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n
* 描述:mstune调优接口头文件
*/
/** @defgroup mstune mstune调优接口 */
#ifndef TUNE_API_H
#define TUNE_API_H
#include <vector>
#include <map>
#include <string>
#include "graph/graph.h"
#include "ge/ge_api.h"

/**
* @ingroup mstune
*
* mstune status
*/
enum MsTuneStatus {
MSTUNE_SUCCESS, /** tune success */
MSTUNE_FAILED, /** tune failed */
};

// Option key: for train options sets
const std::string MSTUNE_SELF_KEY = "mstune";
const std::string MSTUNE_GEINIT_KEY = "initialize";
const std::string MSTUNE_GESESS_KEY = "session";

/**
* @ingroup mstune
* @par 描述: 命令行调优
*
* @attention 无
* @param option [IN] 调优参数
* @param msg [OUT] 调优异常下返回信息
* @retval #MSTUNE_SUCCESS 执行成功
* @retval #MSTUNE_FAILED 执行失败
* @par 依赖:
* @li tune_api.cpp:该接口所属的开发包。
* @li tune_api.h:该接口声明所在的头文件。
* @see 无
* @since
*/
MsTuneStatus MsTuning(const std::map<std::string, std::string> &option, std::string &msg);

/**
* @ingroup mstune
* @par 描述: 梯度调优
*
* @attention 无
* @param tuningGraph [IN] 调优图
* @param dependGraph [IN] 调优依赖图
* @param session [IN] ge连接会话
* @param option [IN] 参数集. 包含调优参数及ge参数
* @retval #MSTUNE_SUCCESS 执行成功
* @retval #MSTUNE_FAILED 执行失败
* @par 依赖:
* @li tune_api.cpp:该接口所属的开发包。
* @li tune_api.h:该接口声明所在的头文件。
* @see 无
* @since
*/
extern "C" MsTuneStatus MsTrainTuning(ge::Graph &tuningGraph, std::vector<ge::Graph> &dependGraph,
ge::Session *session, const std::map<std::string, std::map<std::string, std::string>> &option);

#endif

Loading…
Cancel
Save