已合并
Refactor cmake structure and Framework/Kernel launch project #160
chenyiyuan创建于 1月24日
Refactor cmake structure and Framework/Kernel launch project #160
已合并
chenyiyuan创建于 1月24日
161 个文件变更+3997-3476
@@ -43,6 +43,7 @@ if(CCACHE_PROGRAM)
43endif()43endif()
44 44 
45add_subdirectory(impl)45add_subdirectory(impl)
46+add_subdirectory(cmake)
46 47 
47if(BUILD_OPEN_PROJECT)48if(BUILD_OPEN_PROJECT)
48 include(cmake/intf_pub_linux.cmake)49 include(cmake/intf_pub_linux.cmake)
@@ -0,0 +1,23 @@
1+# ----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------------------------------------
10+ 
11+set(ASC_CMAKE_MODULE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/ascendc_kernel_cmake)
12+add_custom_target(ascendc_kernel_cmake ALL
13+ COMMAND ${CMAKE_COMMAND} -E make_directory "${ASC_CMAKE_MODULE_BINARY_DIR}"
14+ COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/asc" "${ASC_CMAKE_MODULE_BINARY_DIR}"
15+)
16+if(NOT BUILD_OPEN_PROJECT)
17+ add_dependencies(ascendc_kernel_cmake ascendc_kernel_cmake_legacy)
18+endif()
19+ 
20+install(DIRECTORY ${ASC_CMAKE_MODULE_BINARY_DIR}
21+ DESTINATION ${INSTALL_LIBRARY_DIR} OPTIONAL
22+ PATTERN "test_*" EXCLUDE
23+)
@@ -0,0 +1,18 @@
1+# ----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------------------------------------
10+if(NOT DEFINED ENV{ASCEND_HOME_PATH})
11+ message(FATAL_ERROR "ERROR: ASCEND_HOME_PATH environment variable is not set! source set_env.sh in cann install directory first.")
12+else()
13+ if(NOT EXISTS "$ENV{ASCEND_HOME_PATH}")
14+ message(FATAL_ERROR "ERROR: ASCEND_HOME_PATH directory does not exist!")
15+ endif()
16+endif()
17+ 
18+list(APPEND CMAKE_MODULE_PATH "$ENV{ASCEND_HOME_PATH}/compiler/tikcpp/ascendc_kernel_cmake/aicpu_modules")
@@ -0,0 +1,15 @@
1+# ----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------------------------------------
10+ 
11+set(CMAKE_AICPU_COMPILER "@CMAKE_AICPU_COMPILER@")
12+set(CMAKE_AICPU_COMPILER_LOADED 1)
13+set(CMAKE_AICPU_SOURCE_FILE_EXTENSIONS @CMAKE_AICPU_SOURCE_FILE_EXTENSIONS@)
14+set(CMAKE_AICPU_OUTPUT_EXTENSION @CMAKE_AICPU_OUTPUT_EXTENSION@)
15+set(CMAKE_AICPU_COMPILER_ENV_VAR "@CMAKE_AICPU_COMPILER_ENV_VAR@")
Rtools/build/scripts/AICPU_CMake/CMakeAICPUInformation.cmakecmake/asc/aicpu_modules/CMakeAICPUInformation.cmake+12-3
@@ -1,8 +1,15 @@
1+# ----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------------------------------------
10+ 
1include(CMakeCommonLanguageInclude)11include(CMakeCommonLanguageInclude)
2 12 
3- 
4-set(CMAKE_INCLUDE_FLAG_AICPU "-I")
5- 
6# extension for the output of a compile for a single file13# extension for the output of a compile for a single file
7if(UNIX)14if(UNIX)
8 set(CMAKE_AICPU_OUTPUT_EXTENSION .o)15 set(CMAKE_AICPU_OUTPUT_EXTENSION .o)
@@ -10,6 +17,8 @@ else()
10 set(CMAKE_AICPU_OUTPUT_EXTENSION .obj)17 set(CMAKE_AICPU_OUTPUT_EXTENSION .obj)
11endif()18endif()
12 19 
20+set(CMAKE_INCLUDE_FLAG_AICPU "-I")
21+ 
13set(CMAKE_DEPFILE_FLAGS_AICPU "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")22set(CMAKE_DEPFILE_FLAGS_AICPU "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
14if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) AND CMAKE_GENERATOR MATCHES "Makefiles|WMake")23if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) AND CMAKE_GENERATOR MATCHES "Makefiles|WMake")
15 # dependencies are computed by the compiler itself24 # dependencies are computed by the compiler itself
Rtools/build/scripts/AICPU_CMake/CMakeDetermineAICPUCompiler.cmakecmake/asc/aicpu_modules/CMakeDetermineAICPUCompiler.cmake+9-21
@@ -1,24 +1,12 @@
1-if(NOT DEFINED ENV{ASCEND_HOME_PATH})1+# ----------------------------------------------------------------------------------------------------------
2- set(POSSIBLE_PATHS "/usr/local/Ascend/cann" "${HOME}/Ascend/cann")2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- 3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- message(FATAL_ERROR "4+# CANN Open Software License Agreement Version 2.0 (the "License").
5- ================================================================================5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6- ERROR: ASCEND_HOME_PATH environment variable is not set!6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- 7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- This variable is required to find CANN package.8+# See LICENSE in the root of the software repository for the full text of the License.
9- 9+# ----------------------------------------------------------------------------------------------------------
10- Possible solutions:
11- Source the environment setup script: source <ascend_install_path>/set_env.sh
12-
13- Common installation locations:
14- ${POSSIBLE_PATHS}
15- ================================================================================
16- ")
17-else()
18- if(NOT EXISTS "$ENV{ASCEND_HOME_PATH}")
19- message(FATAL_ERROR "ERROR: ASCEND_HOME_PATH directory does not exist!")
20- endif()
21-endif()
22 10 
23string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSTEM_LOWER_PROCESSOR)11string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSTEM_LOWER_PROCESSOR)
24if(EXISTS $ENV{ASCEND_HOME_PATH}/${SYSTEM_LOWER_PROCESSOR}-linux/ccec_compiler/bin)12if(EXISTS $ENV{ASCEND_HOME_PATH}/${SYSTEM_LOWER_PROCESSOR}-linux/ccec_compiler/bin)
Rcmake/asc/AICPUConfig.cmakecmake/asc/aicpu_modules/CMakeTestAICPUCompiler.cmake+2-1
@@ -7,4 +7,5 @@
7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8# See LICENSE in the root of the software repository for the full text of the License.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------------------------------------9# ----------------------------------------------------------------------------------------------------------
10-list(APPEND CMAKE_MODULE_PATH "$ENV{ASCEND_HOME_PATH}/compiler/tikcpp/ascendc_kernel_cmake/AICPU_CMake")10+ 
11+set(CMAKE_AICPU_COMPILER_WORKS 1 CACHE INTERNAL "")
Rcmake/asc/ASCConfig.cmakecmake/asc/asc-config.cmake+11-2
@@ -7,6 +7,15 @@
7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8# See LICENSE in the root of the software repository for the full text of the License.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------------------------------------9# ----------------------------------------------------------------------------------------------------------
10+ 
11+if(NOT DEFINED ENV{ASCEND_HOME_PATH})
12+ message(FATAL_ERROR "ERROR: ASCEND_HOME_PATH environment variable is not set! source set_env.sh in cann install directory first.")
13+else()
14+ if(NOT EXISTS "$ENV{ASCEND_HOME_PATH}")
15+ message(FATAL_ERROR "ERROR: ASCEND_HOME_PATH directory does not exist!")
16+ endif()
17+endif()
18+ 
10if(_ASC_MODULE_LOADED)19if(_ASC_MODULE_LOADED)
11 return()20 return()
12endif()21endif()
@@ -16,6 +25,6 @@ include($ENV{ASCEND_HOME_PATH}/compiler/tikcpp/ascendc_kernel_cmake/fwk_modules/
16include($ENV{ASCEND_HOME_PATH}/compiler/tikcpp/ascendc_kernel_cmake/fwk_modules/intf.cmake)25include($ENV{ASCEND_HOME_PATH}/compiler/tikcpp/ascendc_kernel_cmake/fwk_modules/intf.cmake)
17 26 
18# plugin support ASC language27# plugin support ASC language
19-list(APPEND CMAKE_MODULE_PATH "$ENV{ASCEND_HOME_PATH}/compiler/tikcpp/ascendc_kernel_cmake/ASC_CMake")28+list(APPEND CMAKE_MODULE_PATH "$ENV{ASCEND_HOME_PATH}/compiler/tikcpp/ascendc_kernel_cmake/asc_modules")
20-include($ENV{ASCEND_HOME_PATH}/compiler/tikcpp/ascendc_kernel_cmake/ASC_CMake/FindASC.cmake)29+include($ENV{ASCEND_HOME_PATH}/compiler/tikcpp/ascendc_kernel_cmake/asc_modules/FindASC.cmake)
21set(_ASC_MODULE_LOADED TRUE)30set(_ASC_MODULE_LOADED TRUE)
@@ -0,0 +1,15 @@
1+# ----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------------------------------------
10+ 
11+set(CMAKE_ASC_COMPILER "@CMAKE_ASC_COMPILER@")
12+set(CMAKE_ASC_COMPILER_LOADED 1)
13+set(CMAKE_ASC_SOURCE_FILE_EXTENSIONS @CMAKE_ASC_SOURCE_FILE_EXTENSIONS@)
14+set(CMAKE_ASC_OUTPUT_EXTENSION @CMAKE_ASC_OUTPUT_EXTENSION@)
15+set(CMAKE_ASC_COMPILER_ENV_VAR "@CMAKE_ASC_COMPILER_ENV_VAR@")
Rtools/ascc/cmake/ASC_CMake/CMakeASCInformation.cmakecmake/asc/asc_modules/CMakeASCInformation.cmake+13-12文件内容审核中,请稍后刷新重试
Rtools/ascc/cmake/ASC_CMake/CMakeDetermineASCCompiler.cmakecmake/asc/asc_modules/CMakeDetermineASCCompiler.cmake+11-25
@@ -1,30 +1,16 @@
1+# ----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------------------------------------
10+ 
1# CMakeDetermineASCCompiler.cmake is used to initialize ASC-related variables.11# CMakeDetermineASCCompiler.cmake is used to initialize ASC-related variables.
2# And this file will not be triggered again during incremental compilation.12# And this file will not be triggered again during incremental compilation.
3-# This file is used to locate the compiler.13+# 1. Find compiler for ASC extension
4-# Update SOC_VERSION, CMAKE_BUILD_TYPE, CMAKE_INSTALL_PREFIX
5-# 1. Setup env variable ASCEND_HOME_PATH
6-if(NOT DEFINED ENV{ASCEND_HOME_PATH})
7- set(POSSIBLE_PATHS "/usr/local/Ascend/cann" "${HOME}/Ascend/cann")
8- 
9- message(FATAL_ERROR "
10- ================================================================================
11- ERROR: ASCEND_HOME_PATH environment variable is not set!
12- 
13- This variable is required to find CANN package.
14- 
15- Possible solutions:
16- Source the environment setup script: source <ascend_install_path>/set_env.sh
17- 
18- Common installation locations:
19- ${POSSIBLE_PATHS}
20- ================================================================================
21- ")
22-else()
23- if(NOT EXISTS "$ENV{ASCEND_HOME_PATH}")
24- message(FATAL_ERROR "ERROR: ASCEND_HOME_PATH directory does not exist!")
25- endif()
26-endif()
27- 
28message(STATUS "System processer: ${CMAKE_SYSTEM_PROCESSOR}")14message(STATUS "System processer: ${CMAKE_SYSTEM_PROCESSOR}")
29if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")15if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
30 set(ASCEND_CANN_PACKAGE_LINUX_PATH $ENV{ASCEND_HOME_PATH}/x86_64-linux)16 set(ASCEND_CANN_PACKAGE_LINUX_PATH $ENV{ASCEND_HOME_PATH}/x86_64-linux)
@@ -0,0 +1,11 @@
1+# ----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------------------------------------
10+ 
11+set(CMAKE_ASC_COMPILER_WORKS 1 CACHE INTERNAL "")
Rtools/ascc/cmake/ASC_CMake/FindASC.cmakecmake/asc/asc_modules/FindASC.cmake+11-1
@@ -1,3 +1,13 @@
1+# ----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------------------------------------
10+ 
1set(LIB_SUPPORT_TYPES SHARED STATIC)11set(LIB_SUPPORT_TYPES SHARED STATIC)
2 12 
3function(library_interface_setup target_name)13function(library_interface_setup target_name)
@@ -18,7 +28,7 @@ function(library_interface_setup target_name)
18 error_manager28 error_manager
19 profapi29 profapi
20 ge_common_base30 ge_common_base
21- ascendalog31+ unified_dlog
22 mmpa32 mmpa
23 dl33 dl
24 ascend_dump34 ascend_dump
The file is empty
@@ -21,7 +21,9 @@ endif()
21if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)21if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
22 set(ASCENDC_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}" CACHE PATH "" FORCE)22 set(ASCENDC_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}" CACHE PATH "" FORCE)
23else()23else()
24- set(ASCENDC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "" FORCE)24+ if (NOT ASCENDC_INSTALL_PREFIX)
25+ set(ASCENDC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "" FORCE)
26+ endif()
25endif()27endif()
26if (NOT DEFINED ENABLE_SOURCE_PACKAGE)28if (NOT DEFINED ENABLE_SOURCE_PACKAGE)
27 set(ENABLE_SOURCE_PACKAGE TRUE CACHE BOOL "")29 set(ENABLE_SOURCE_PACKAGE TRUE CACHE BOOL "")
@@ -44,13 +46,15 @@ set(ASCEND_CANN_PACKAGE_PATH ${_ASCEND_CANN_PACKAGE_PATH} CACHE PATH "")
44if (NOT DEFINED ASCEND_PYTHON_EXECUTABLE)46if (NOT DEFINED ASCEND_PYTHON_EXECUTABLE)
45 set(ASCEND_PYTHON_EXECUTABLE python3 CACHE STRING "")47 set(ASCEND_PYTHON_EXECUTABLE python3 CACHE STRING "")
46endif()48endif()
49+ 
50+ 
51+set(ASCEND_CHECK_OPTYPE_DUPLICATE FALSE CACHE BOOL "")
52+ 
47if (NOT DEFINED ASCEND_COMPUTE_UNIT)53if (NOT DEFINED ASCEND_COMPUTE_UNIT)
48 set(ASCEND_COMPUTE_UNIT ascend910b CACHE STRING "")54 set(ASCEND_COMPUTE_UNIT ascend910b CACHE STRING "")
49endif()55endif()
50 56 
51-set(ASC_VALID_SOC_LIST 57+set(ASC_VALID_SOC_LIST ascend310b ascend310p ascend610 ascend910 ascend910b ascend910_93 ascend910_95 bs9sx1a bs9sx2a ascend610lite ascend910_55 mc61am21a mc62cm12a ascend910_96 kirinx90 kirin9030)
52- ascend310b ascend310p ascend610 ascend910 ascend910b ascend910_93 bs9sx1a bs9sx2a ascend610lite mc61am21a
53- kirinx90 kirin9030)
54 58 
55foreach(soc_version ${ASCEND_COMPUTE_UNIT})59foreach(soc_version ${ASCEND_COMPUTE_UNIT})
56 if(NOT soc_version IN_LIST ASC_VALID_SOC_LIST)60 if(NOT soc_version IN_LIST ASC_VALID_SOC_LIST)
@@ -518,7 +518,7 @@ function(npu_op_code_gen)
518 OUTPUT_VARIABLE EXEC_INFO518 OUTPUT_VARIABLE EXEC_INFO
519 ERROR_VARIABLE EXEC_ERROR519 ERROR_VARIABLE EXEC_ERROR
520 )520 )
521- if (${EXEC_RESULT})521+ if (NOT ${EXEC_RESULT} EQUAL 0)
522 message("compile ascend_all_ops info: ${EXEC_INFO}")522 message("compile ascend_all_ops info: ${EXEC_INFO}")
523 message("compile ascend_all_ops result: ${EXEC_RESULT}")523 message("compile ascend_all_ops result: ${EXEC_RESULT}")
524 message(FATAL_ERROR "opbuild run failed! ${EXEC_ERROR}")524 message(FATAL_ERROR "opbuild run failed! ${EXEC_ERROR}")
@@ -565,10 +565,34 @@ function(npu_op_code_gen)
565 unset(ENV{ASCEND_VENDOR_NAME})565 unset(ENV{ASCEND_VENDOR_NAME})
566 unset(ENV{OPS_PROTO_SEPARATE})566 unset(ENV{OPS_PROTO_SEPARATE})
567 567 
568- if (${EXEC_RESULT})568+ if (NOT ${EXEC_RESULT} EQUAL 0)
569 message("opbuild ops info: ${EXEC_INFO}")569 message("opbuild ops info: ${EXEC_INFO}")
570+ message("opbuild ops result: ${EXEC_RESULT}")
570 message(FATAL_ERROR "opbuild ops error: ${EXEC_ERROR}")571 message(FATAL_ERROR "opbuild ops error: ${EXEC_ERROR}")
571 endif()572 endif()
573+ 
574+ if (${ASCEND_CHECK_OPTYPE_DUPLICATE})
575+ foreach(compute_unit ${ASCEND_COMPUTE_UNIT})
576+ if (NOT EXISTS ${OPBUILD_OUT_DIR}/aic-${compute_unit}-ops-info.ini)
577+ message(FATAL_ERROR "file: ${OPBUILD_OUT_DIR}/aic-${compute_unit}-ops-info.ini not exist")
578+ endif()
579+ execute_process(COMMAND ${ASCEND_PYTHON_EXECUTABLE} ${ASCENDC_CMAKE_SCRIPTS_PATH}/util/ascendc_check_optype_duplicate.py
580+ --ini-file=${OPBUILD_OUT_DIR}/aic-${compute_unit}-ops-info.ini --soc-version=${compute_unit}
581+ RESULT_VARIABLE EXEC_RESULT
582+ OUTPUT_VARIABLE EXEC_INFO
583+ ERROR_VARIABLE EXEC_ERROR
584+ OUTPUT_STRIP_TRAILING_WHITESPACE
585+ )
586+ if (NOT ${EXEC_RESULT} EQUAL 0)
587+ if (${EXEC_RESULT} EQUAL 2)
588+ message(FATAL_ERROR "Error: Op '${EXEC_ERROR}' is DUPLICATE with built-in operators")
589+ else()
590+ message(FATAL_ERROR "Error: ${EXEC_ERROR}")
591+ endif()
592+ endif()
593+ endforeach()
594+ endif()
595+ 
572 message(STATUS "Opbuild generating sources - done")596 message(STATUS "Opbuild generating sources - done")
573endfunction()597endfunction()
574 598 
@@ -794,7 +818,6 @@ function(npu_op_package_add target_package_name)
794 set_source_files_properties(${op_registry} PROPERTIES GENERATED TRUE)818 set_source_files_properties(${op_registry} PROPERTIES GENERATED TRUE)
795 target_sources(${_ascendc_aclnn_target} PRIVATE ${op_registry})819 target_sources(${_ascendc_aclnn_target} PRIVATE ${op_registry})
796 target_compile_definitions(${_ascendc_aclnn_target} PRIVATE ACLNN_WITH_BINARY)820 target_compile_definitions(${_ascendc_aclnn_target} PRIVATE ACLNN_WITH_BINARY)
797- target_compile_options(${_ascendc_aclnn_target} PRIVATE -DLOG_CPP)
798 endif()821 endif()
799 endif()822 endif()
800 823 
@@ -7,7 +7,7 @@
7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8# See LICENSE in the root of the software repository for the full text of the License.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------------------------------------9# ----------------------------------------------------------------------------------------------------------
10-if(NOT TARGET intf_pub)10+if (NOT TARGET intf_pub)
11 add_library(intf_pub INTERFACE)11 add_library(intf_pub INTERFACE)
12 target_compile_options(intf_pub INTERFACE12 target_compile_options(intf_pub INTERFACE
13 -fPIC13 -fPIC
@@ -9,8 +9,6 @@
9# See LICENSE in the root of the software repository for the full text of the License.9# See LICENSE in the root of the software repository for the full text of the License.
10# ----------------------------------------------------------------------------------------------------------10# ----------------------------------------------------------------------------------------------------------
11 11 
12-set -e
13- 
14vendor_name=customize12vendor_name=customize
15targetdir=/usr/local/Ascend/opp13targetdir=/usr/local/Ascend/opp
16target_custom=014target_custom=0
@@ -180,7 +178,7 @@ upgrade()
180 log "[INFO] ${targetdir}/$vendordir/$1 is empty !!"178 log "[INFO] ${targetdir}/$vendordir/$1 is empty !!"
181 return 1179 return 1
182 fi180 fi
183- grep -q $file_b <<<"$(ls "${targetdir}/${vendordir}/${1}")";181+ grep -q $file_b <<<`ls ${targetdir}/$vendordir/$1`;
184 if [[ $? -eq 0 ]]; then182 if [[ $? -eq 0 ]]; then
185 echo -n "${file_b} "183 echo -n "${file_b} "
186 has_same_file=0184 has_same_file=0
@@ -9,8 +9,6 @@
9# See LICENSE in the root of the software repository for the full text of the License.9# See LICENSE in the root of the software repository for the full text of the License.
10# ----------------------------------------------------------------------------------------------------------10# ----------------------------------------------------------------------------------------------------------
11 11 
12-set -e
13- 
14vendor_name=customize12vendor_name=customize
15 13 
16curr_path=$(dirname "$0")14curr_path=$(dirname "$0")
@@ -9,8 +9,6 @@
9# See LICENSE in the root of the software repository for the full text of the License.9# See LICENSE in the root of the software repository for the full text of the License.
10# ----------------------------------------------------------------------------------------------------------10# ----------------------------------------------------------------------------------------------------------
11 11 
12-set -e
13- 
14vendor_name=customize12vendor_name=customize
15targetdir=/usr/local/Ascend/opp13targetdir=/usr/local/Ascend/opp
16target_custom=014target_custom=0
@@ -0,0 +1,83 @@
1+#!/usr/bin/env python
2+# -*- coding: UTF-8 -*-
3+# ----------------------------------------------------------------------------------------------------------
4+# Copyright (c) 2026 Huawei Technologies Co., Ltd.
5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6+# CANN Open Software License Agreement Version 2.0 (the "License").
7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10+# See LICENSE in the root of the software repository for the full text of the License.
11+# ----------------------------------------------------------------------------------------------------------
12+ 
13+import configparser
14+import argparse
15+import os
16+import glob
17+import json
18+import sys
19+from asc_op_compile_base.asc_op_compiler.op_tiling import _ASCEND_OPP_PATH_ENV, \
20+ _ASCEND_OPP_PATH_DEFAULT, op_impl_path
21+from asc_op_compile_base.common.utils.log_utils import LogUtil, AscendCLogLevel
22+ 
23+ 
24+def check_optype_duplicate(args, ini_optypes):
25+ opp_path = os.environ.get(_ASCEND_OPP_PATH_ENV, _ASCEND_OPP_PATH_DEFAULT)
26+ json_path_base = os.path.join(opp_path, op_impl_path, os.path.join("ai_core", "tbe", "config", args.soc_version))
27+ LogUtil.print_compile_log("check_optype_duplicate", f"json path base is {json_path_base}", \
28+ AscendCLogLevel.LOG_DEBUG, LogUtil.Option.NON_SOC)
29+ json_pattern = json_path_base + f"/*.json"
30+ json_files = glob.glob(json_pattern, recursive=True)
31+ 
32+ if len(json_files) == 0:
33+ LogUtil.print_compile_log("check_optype_duplicate", f"no json files found", \
34+ AscendCLogLevel.LOG_DEBUG, LogUtil.Option.NON_SOC)
35+ return 0
36+
37+ optypes = []
38+ for json_file in json_files:
39+ try:
40+ with open(json_file, 'r') as fd:
41+ ops_info = json.load(fd)
42+ optypes += ops_info.keys()
43+ except Exception as err:
44+ sys.stderr.write(f"json file {json_file} open failed, err msg {err}")
45+ return 1
46+ 
47+ intersection_ops = list(set(ini_optypes) & set(optypes))
48+ LogUtil.print_compile_log("check_optype_duplicate", f"custom optypes {ini_optypes}", \
49+ AscendCLogLevel.LOG_DEBUG, LogUtil.Option.NON_SOC)
50+ LogUtil.print_compile_log("check_optype_duplicate", \
51+ f"duplicate optypes {intersection_ops}", AscendCLogLevel.LOG_DEBUG, LogUtil.Option.NON_SOC)
52+ if len(intersection_ops) != 0:
53+ sys.stderr.write(" ".join(intersection_ops))
54+ return 2
55+ 
56+ return 0
57+ 
58+ 
59+def get_optypes(args):
60+ op_config = configparser.ConfigParser()
61+ LogUtil.print_compile_log("check_optype_duplicate", f"ini file: {args.ini_file}", \
62+ AscendCLogLevel.LOG_DEBUG, LogUtil.Option.NON_SOC)
63+
64+ op_config.read(args.ini_file)
65+ return op_config.sections()
66+ 
67+ 
68+def args_parse():
69+ parser = argparse.ArgumentParser()
70+ parser.add_argument(
71+ "-i", "--ini-file", help="op info ini."
72+ )
73+ parser.add_argument(
74+ "-v", "--soc-version", help="soc version."
75+ )
76+ return parser.parse_args()
77+ 
78+ 
79+if __name__ == "__main__":
80+ args = args_parse()
81+ ini_optypes = get_optypes(args)
82+ res = check_optype_duplicate(args, ini_optypes)
83+ sys.exit(res)
@@ -213,12 +213,6 @@ def {}({}, kernel_name="{}"{}):
213 options.append("-DDETERMINISTIC_MODE=1")213 options.append("-DDETERMINISTIC_MODE=1")
214 else:214 else:
215 options.append("-DDETERMINISTIC_MODE=0")215 options.append("-DDETERMINISTIC_MODE=0")
216- ascendc_api_version_header_path = os.path.join(asc_path, "include/adv_api/ascendc_api_version.h")
217- if os.path.exists(ascendc_api_version_header_path):
218- with open(ascendc_api_version_header_path, "r") as ascendc_api_version_file:
219- ascendc_api_version = re.findall(r"#define ASCENDC_API_VERSION (\d+)", ascendc_api_version_file.read())
220- if ascendc_api_version:
221- options.append(f"-DASCENDC_API_VERSION={{ascendc_api_version[0]}}")
222 custom_compile_options = {},216 custom_compile_options = {},
223 custom_all_compile_options = {},217 custom_all_compile_options = {},
224 soc_version = get_soc_spec("SOC_VERSION")218 soc_version = get_soc_spec("SOC_VERSION")
@@ -23,15 +23,15 @@ DATA_TPYE_DICT = {
23 'float32': 0,23 'float32': 0,
24 'float16': 1,24 'float16': 1,
25 'int8': 2,25 'int8': 2,
26+ 'int32': 3,
27+ 'uint8': 4,
26 'int16': 6,28 'int16': 6,
27 'uint16': 7,29 'uint16': 7,
28- 'uint8': 4,
29- 'int32': 3,
30- 'int64': 9,
31 'uint32': 8,30 'uint32': 8,
31+ 'int64': 9,
32 'uint64': 10,32 'uint64': 10,
33- 'bool': 12,
34 'double': 11,33 'double': 11,
34+ 'bool': 12,
35 'string': 13,35 'string': 13,
36 'dual_sub_int8': 14,36 'dual_sub_int8': 14,
37 'dual_sub_uint8': 15,37 'dual_sub_uint8': 15,
@@ -102,7 +102,16 @@ FORMAT_DICT = {
102 'ND_RNN_BIAS': 43,102 'ND_RNN_BIAS': 43,
103 'FRACTAL_ZN_RNN': 44,103 'FRACTAL_ZN_RNN': 44,
104 'NYUV': 45,104 'NYUV': 45,
105- 'NYUV_A': 46105+ 'NYUV_A': 46,
106+ 'NCL': 47,
107+ 'FRACTAL_Z_WINO': 48,
108+ 'C1HWC0': 49,
109+ 'FRACTAL_NZ_C0_16': 50,
110+ 'FRACTAL_NZ_C0_32': 51,
111+ 'FRACTAL_NZ_C0_2': 52,
112+ 'FRACTAL_NZ_C0_4': 53,
113+ 'FRACTAL_NZ_C0_8': 54,
114+ 'MAX': 55,
106}115}
107 116 
108 117 
@@ -73,6 +73,8 @@ SOC_TO_SHORT_SOC_MAP = {
73 "ascend910_957b": "ascend910_95",73 "ascend910_957b": "ascend910_95",
74 "ascend910_957c": "ascend910_95",74 "ascend910_957c": "ascend910_95",
75 "ascend910_957d": "ascend910_95",75 "ascend910_957d": "ascend910_95",
76+ "ascend910_950x": "ascend910_95",
77+ "ascend910_950y": "ascend910_95",
76 "ascend910_950z": "ascend910_95",78 "ascend910_950z": "ascend910_95",
77 "ascend910_958a": "ascend910_95",79 "ascend910_958a": "ascend910_95",
78 "ascend910_9599": "ascend910_95",80 "ascend910_9599": "ascend910_95",
@@ -29,17 +29,83 @@ target_compile_definitions(device_intf_pub INTERFACE
29target_include_directories(device_intf_pub INTERFACE29target_include_directories(device_intf_pub INTERFACE
30 ${ASCENDC_DEVKIT_PATH}/asc/impl/adv_api30 ${ASCENDC_DEVKIT_PATH}/asc/impl/adv_api
31 ${ASCENDC_DEVKIT_PATH}/asc/impl/basic_api31 ${ASCENDC_DEVKIT_PATH}/asc/impl/basic_api
32+ ${ASCENDC_DEVKIT_PATH}/asc/impl/c_api
33+ ${ASCENDC_DEVKIT_PATH}/asc/impl/micro_api
34+ ${ASCENDC_DEVKIT_PATH}/asc/impl/simt_api
32 ${ASCENDC_DEVKIT_PATH}/asc/impl/utils35 ${ASCENDC_DEVKIT_PATH}/asc/impl/utils
33 ${ASCENDC_DEVKIT_PATH}/asc/include36 ${ASCENDC_DEVKIT_PATH}/asc/include
34 ${ASCENDC_DEVKIT_PATH}/asc/include/adv_api37 ${ASCENDC_DEVKIT_PATH}/asc/include/adv_api
35 ${ASCENDC_DEVKIT_PATH}/asc/include/basic_api38 ${ASCENDC_DEVKIT_PATH}/asc/include/basic_api
36 ${ASCENDC_DEVKIT_PATH}/asc/include/aicpu_api39 ${ASCENDC_DEVKIT_PATH}/asc/include/aicpu_api
40+ ${ASCENDC_DEVKIT_PATH}/asc/include/c_api
41+ ${ASCENDC_DEVKIT_PATH}/asc/include/micro_api
42+ ${ASCENDC_DEVKIT_PATH}/asc/include/simt_api
37 ${ASCENDC_DEVKIT_PATH}/asc/include/utils 43 ${ASCENDC_DEVKIT_PATH}/asc/include/utils
38 ${ASCENDC_DEVKIT_PATH}/tikcpp/tikcfw44 ${ASCENDC_DEVKIT_PATH}/tikcpp/tikcfw
39 ${ASCENDC_DEVKIT_PATH}/tikcpp/tikcfw/interface45 ${ASCENDC_DEVKIT_PATH}/tikcpp/tikcfw/interface
40 ${ASCENDC_DEVKIT_PATH}/tikcpp/tikcfw/impl46 ${ASCENDC_DEVKIT_PATH}/tikcpp/tikcfw/impl
41)47)
42 48 
49+add_library(c310_aiv_intf_pub INTERFACE)
50+ 
51+target_compile_options(c310_aiv_intf_pub INTERFACE
52+ -D__DAV_C310__
53+ --cce-aicore-arch=dav-c310-vec
54+ --cce-aicore-only
55+ --cce-auto-sync
56+ --cce-mask-opt
57+ "SHELL:-mllvm -cce-aicore-stack-size=0x8000"
58+ "SHELL:-mllvm -cce-aicore-function-stack-size=0x8000"
59+ "SHELL:-mllvm -cce-aicore-record-overflow=true"
60+ "SHELL:-mllvm -cce-aicore-addr-transform"
61+ "SHELL:-mllvm -cce-aicore-jump-expand=true"
62+ "SHELL:-mllvm -cce-aicore-dcci-insert-for-scalar=false"
63+)
64+ 
65+target_link_libraries(c310_aiv_intf_pub INTERFACE
66+ $<BUILD_INTERFACE:device_intf_pub>
67+)
68+ 
69+add_library(c310_aic_intf_pub INTERFACE)
70+ 
71+target_compile_options(c310_aic_intf_pub INTERFACE
72+ -D__DAV_C310__
73+ --cce-aicore-arch=dav-c310-cube
74+ --cce-aicore-only
75+ --cce-auto-sync
76+ --cce-mask-opt
77+ "SHELL:-mllvm -cce-aicore-stack-size=0x8000"
78+ "SHELL:-mllvm -cce-aicore-function-stack-size=0x8000"
79+ "SHELL:-mllvm -cce-aicore-record-overflow=true"
80+ "SHELL:-mllvm -cce-aicore-addr-transform"
81+ "SHELL:-mllvm -cce-aicore-jump-expand=true"
82+ "SHELL:-mllvm -cce-aicore-dcci-insert-for-scalar=false"
83+ "SHELL:-mllvm -cce-aicore-dcci-before-kernel-end=false"
84+)
85+ 
86+target_link_libraries(c310_aic_intf_pub INTERFACE
87+ $<BUILD_INTERFACE:device_intf_pub>
88+)
89+ 
90+add_library(310r6_intf_pub INTERFACE)
91+ 
92+target_compile_options(310r6_intf_pub INTERFACE
93+ --cce-aicore-arch=dav-310r6
94+ --cce-aicore-only
95+ --cce-auto-sync
96+ --cce-mask-opt
97+ "SHELL:-mllvm -cce-aicore-stack-size=0x8000"
98+ "SHELL:-mllvm -cce-aicore-function-stack-size=0x8000"
99+ "SHELL:-mllvm -cce-aicore-record-overflow=true"
100+ "SHELL:-mllvm -cce-aicore-addr-transform"
101+ "SHELL:-mllvm -cce-aicore-dcci-insert-for-scalar=false"
102+ "SHELL:-mllvm -cce-aicore-dcci-before-kernel-end=false"
103+)
104+ 
105+target_link_libraries(310r6_intf_pub INTERFACE
106+ $<BUILD_INTERFACE:device_intf_pub>
107+)
108+ 
43add_library(m300_intf_pub INTERFACE)109add_library(m300_intf_pub INTERFACE)
44 110 
45target_compile_options(m300_intf_pub INTERFACE111target_compile_options(m300_intf_pub INTERFACE
@@ -92,6 +158,7 @@ target_compile_options(c220_aic_intf_pub INTERFACE
92target_link_libraries(c220_aic_intf_pub INTERFACE158target_link_libraries(c220_aic_intf_pub INTERFACE
93 $<BUILD_INTERFACE:device_intf_pub>159 $<BUILD_INTERFACE:device_intf_pub>
94)160)
161+ 
95add_library(l300_intf_pub INTERFACE)162add_library(l300_intf_pub INTERFACE)
96 163 
97target_compile_options(l300_intf_pub INTERFACE164target_compile_options(l300_intf_pub INTERFACE
@@ -124,8 +124,6 @@ function(ascendc_library target_name target_type)
124 )124 )
125 add_dependencies(${device_target}_preprocess ${device_target}_precompile)125 add_dependencies(${device_target}_preprocess ${device_target}_precompile)
126 126 
127- # echo
128- # MESSAGE
129 # Merge the device-side obj files to generate device.o127 # Merge the device-side obj files to generate device.o
130 if(DYNAMIC_MODE)128 if(DYNAMIC_MODE)
131 set(${device_target}_aic_device_dir ${CMAKE_CURRENT_BINARY_DIR}/${device_target}_aic_device_dir)129 set(${device_target}_aic_device_dir ${CMAKE_CURRENT_BINARY_DIR}/${device_target}_aic_device_dir)
@@ -322,6 +320,7 @@ function(ascendc_library target_name target_type)
322 -DBUILD_CFG=${${device_target}_auto_gen_dir}/host_config.cmake320 -DBUILD_CFG=${${device_target}_auto_gen_dir}/host_config.cmake
323 -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}321 -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}
324 -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}322 -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
323+ -DBUILD_MODE=${BUILD_MODE}
325 <SOURCE_DIR>324 <SOURCE_DIR>
326 LIST_SEPARATOR ::325 LIST_SEPARATOR ::
327 BUILD_ALWAYS TRUE326 BUILD_ALWAYS TRUE
@@ -399,7 +398,7 @@ function(ascendc_library target_name target_type)
399 tiling_api398 tiling_api
400 register399 register
401 platform400 platform
402- ascendalog401+ unified_dlog
403 mmpa402 mmpa
404 c_sec403 c_sec
405 dl404 dl
@@ -422,7 +421,7 @@ function(ascendc_library target_name target_type)
422 error_manager421 error_manager
423 profapi422 profapi
424 ge_common_base423 ge_common_base
425- ascendalog424+ unified_dlog
426 mmpa425 mmpa
427 dl426 dl
428 PUBLIC427 PUBLIC
@@ -11,9 +11,14 @@ set(ascend910b_list ascend910b1 ascend910b2 ascend910b2c ascend910b3 ascend910b4
11set(ascend910_list ascend910a ascend910proa ascend910b ascend910prob ascend910premiuma)11set(ascend910_list ascend910a ascend910proa ascend910b ascend910prob ascend910premiuma)
12set(ascend310p_list ascend310p1 ascend310p3 ascend310p5 ascend310p7 ascend310p3vir01 ascend310p3vir02 ascend310p3vir04 ascend310p3vir08)12set(ascend310p_list ascend310p1 ascend310p3 ascend310p5 ascend310p7 ascend310p3vir01 ascend310p3vir02 ascend310p3vir04 ascend310p3vir08)
13set(ascend310b_list ascend310b1 ascend310b2 ascend310b3 ascend310b4)13set(ascend310b_list ascend310b1 ascend310b2 ascend310b3 ascend310b4)
14+set(ascend910_95_list ascend910_9599 ascend910_9589 ascend910_9579 ascend910_958b ascend910_957b ascend910_957d ascend910_950z ascend910_958a ascend910_957c
15+ ascend910_95a1 ascend910_95a2 ascend910_9591 ascend910_9592 ascend910_9595 ascend910_9596 ascend910_9581 ascend910_9582 ascend910_9583 ascend910_9584
16+ ascend910_9585 ascend910_9586 ascend910_9587 ascend910_9588 ascend910_9571 ascend910_9572 ascend910_9573 ascend910_9574 ascend910_9575 ascend910_9576
17+ ascend910_9577 ascend910_9578 ascend910_950x ascend910_950y)
18+set(ascend910_55_list ascend910_5591)
14set(kirinx90_list kirinx90)19set(kirinx90_list kirinx90)
15set(kirin9030_list kirin9030)20set(kirin9030_list kirin9030)
16-set(all_product ${ascend910b_list} ${ascend910_list} ${ascend310p_list} ${kirinx90_list} ${kirin9030_list})21+set(all_product ${ascend910b_list} ${ascend910_list} ${ascend310p_list} ${ascend910_95_list} ${ascend910_55_list} ${kirinx90_list} ${kirin9030_list})
17 22 
18if(NOT DEFINED SOC_VERSION)23if(NOT DEFINED SOC_VERSION)
19 message(FATAL_ERROR "SOC_VERSION value not set.")24 message(FATAL_ERROR "SOC_VERSION value not set.")
@@ -21,9 +26,15 @@ endif()
21 26 
22string(TOLOWER "${SOC_VERSION}" _LOWER_SOC_VERSION)27string(TOLOWER "${SOC_VERSION}" _LOWER_SOC_VERSION)
23 28 
24-if(_LOWER_SOC_VERSION IN_LIST ascend910b_list)29+if(_LOWER_SOC_VERSION IN_LIST ascend910_95_list)
30+ set(DYNAMIC_MODE ON)
31+ set(BUILD_MODE c310)
32+elseif(_LOWER_SOC_VERSION IN_LIST ascend910b_list)
25 set(DYNAMIC_MODE ON)33 set(DYNAMIC_MODE ON)
26 set(BUILD_MODE c220)34 set(BUILD_MODE c220)
35+elseif(_LOWER_SOC_VERSION IN_LIST ascend910_55_list)
36+ set(DYNAMIC_MODE ON)
37+ set(BUILD_MODE 310r6)
27elseif(_LOWER_SOC_VERSION IN_LIST ascend910_list)38elseif(_LOWER_SOC_VERSION IN_LIST ascend910_list)
28 set(BUILD_MODE c100)39 set(BUILD_MODE c100)
29elseif(_LOWER_SOC_VERSION IN_LIST ascend310p_list)40elseif(_LOWER_SOC_VERSION IN_LIST ascend310p_list)
@@ -11,7 +11,6 @@ add_library(host_intf_pub INTERFACE)
11 11 
12target_compile_options(host_intf_pub INTERFACE12target_compile_options(host_intf_pub INTERFACE
13 -fPIC13 -fPIC
14- #-fvisibility=hidden
15 $<$<CONFIG:Release>:-O2>14 $<$<CONFIG:Release>:-O2>
16 $<$<CONFIG:Debug>:-O0>15 $<$<CONFIG:Debug>:-O0>
17 $<$<COMPILE_LANGUAGE:CXX>:-std=c++17 -fvisibility-inlines-hidden>16 $<$<COMPILE_LANGUAGE:CXX>:-std=c++17 -fvisibility-inlines-hidden>
@@ -125,7 +125,6 @@ def v310_mode_cube_ofile(little_endian, binary_32) -> int:
125 '0110101000', # MOV_OUT _TO_L1 _MULTI_DN2NZ125 '0110101000', # MOV_OUT _TO_L1 _MULTI_DN2NZ
126 '0110101100', # MOV_OUT _TO_L1 _MULTI_ND2NZ126 '0110101100', # MOV_OUT _TO_L1 _MULTI_ND2NZ
127 '0110111010', # MOV_OUT_TO_L1_V2127 '0110111010', # MOV_OUT_TO_L1_V2
128- '0111010000', # MOV_OUT_TO_L1_ALIGN_V2
129 '0111011000', # LOAD_L1_TO_L0A_MX_2Dv2和LOAD_L1_TO_L0B_MX_2Dv2128 '0111011000', # LOAD_L1_TO_L0A_MX_2Dv2和LOAD_L1_TO_L0B_MX_2Dv2
130 '0110011100', # LOAD_L1_TO_L0A_3Dv2和LOAD_L1_TO_L0B_3Dv2129 '0110011100', # LOAD_L1_TO_L0A_3Dv2和LOAD_L1_TO_L0B_3Dv2
131 '0110011101',130 '0110011101',
@@ -147,7 +146,7 @@ def v310_mode_cube_ofile(little_endian, binary_32) -> int:
147 (little_endian[0] == 'f' and little_endian[1] in '2345abcd' and binary_32[30] == '0'),146 (little_endian[0] == 'f' and little_endian[1] in '2345abcd' and binary_32[30] == '0'),
148 147 
149 # DMA148 # DMA
150- (high_9 == '011100100' and mid_36 in ('0001', '0101')),149+ (high_9 == '011100100' and mid_36 in ('0001', '0101')), # DMA move inst, include MOV L1 TO UB
151 (high_10 in cube_high_low_map and binary_32[30:] == cube_high_low_map[high_10]),150 (high_10 in cube_high_low_map and binary_32[30:] == cube_high_low_map[high_10]),
152 (high_10 in cube_high_low2_map and binary_32[31] == cube_high_low2_map[high_10]),151 (high_10 in cube_high_low2_map and binary_32[31] == cube_high_low2_map[high_10]),
153 (high_10 in cube_high_map),152 (high_10 in cube_high_map),
@@ -63,4 +63,4 @@ STR_TO_KERNEL_TYPE_L300 = {
63 63 
64STR_TO_KERNEL_TYPE_L311 = {64STR_TO_KERNEL_TYPE_L311 = {
65 "KERNEL_TYPE_AICORE" : CodeMode.AIC,65 "KERNEL_TYPE_AICORE" : CodeMode.AIC,
66-}66+}
The file is empty
The file is empty
@@ -1,11 +1,21 @@
1+# ----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------------------------------------
10+ 
1if(CUSTOM_ASCEND_CANN_PACKAGE_PATH)11if(CUSTOM_ASCEND_CANN_PACKAGE_PATH)
2- set(ASCEND_CANN_PACKAGE_PATH ${CUSTOM_ASCEND_CANN_PACKAGE_PATH})12+ set(ASCEND_CANN_PACKAGE_PATH ${CUSTOM_ASCEND_CANN_PACKAGE_PATH})
3elseif(DEFINED ENV{ASCEND_HOME_PATH})13elseif(DEFINED ENV{ASCEND_HOME_PATH})
4- set(ASCEND_CANN_PACKAGE_PATH $ENV{ASCEND_HOME_PATH})14+ set(ASCEND_CANN_PACKAGE_PATH $ENV{ASCEND_HOME_PATH})
5elseif(DEFINED ENV{ASCEND_OPP_PATH})15elseif(DEFINED ENV{ASCEND_OPP_PATH})
6 get_filename_component(ASCEND_CANN_PACKAGE_PATH "$ENV{ASCEND_OPP_PATH}/.." ABSOLUTE)16 get_filename_component(ASCEND_CANN_PACKAGE_PATH "$ENV{ASCEND_OPP_PATH}/.." ABSOLUTE)
7else()17else()
8- set(ASCEND_CANN_PACKAGE_PATH "/usr/local/Ascend/cann")18+ set(ASCEND_CANN_PACKAGE_PATH "/usr/local/Ascend/cann")
9endif()19endif()
10 20 
11if (NOT EXISTS "${ASCEND_CANN_PACKAGE_PATH}")21if (NOT EXISTS "${ASCEND_CANN_PACKAGE_PATH}")
@@ -13,26 +23,25 @@ if (NOT EXISTS "${ASCEND_CANN_PACKAGE_PATH}")
13endif()23endif()
14 24 
15if (CMAKE_INSTALL_PREFIX STREQUAL /usr/local)25if (CMAKE_INSTALL_PREFIX STREQUAL /usr/local)
16- set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/_CPack_Packages/makeself_staging" CACHE STRING "path for install()" FORCE)26+ set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/_CPack_Packages/makeself_staging" CACHE STRING "path for install()" FORCE)
17-endif ()27+endif()
18 28 
19-set(HI_PYTHON "python3" CACHE STRING "python executor")29+set(HI_PYTHON "python3" CACHE STRING "python executor")
20-set(PRODUCT_SIDE host)30+set(PRODUCT_SIDE host)
21set(COMPILE_BASE_ON_SUBGROUP OFF BOOL)31set(COMPILE_BASE_ON_SUBGROUP OFF BOOL)
22 32 
23if (ENABLE_TEST)33if (ENABLE_TEST)
24 set(CMAKE_SKIP_RPATH FALSE)34 set(CMAKE_SKIP_RPATH FALSE)
25-else ()35+else()
26 set(CMAKE_SKIP_RPATH TRUE)36 set(CMAKE_SKIP_RPATH TRUE)
27-endif ()37+endif()
28 38 
29if (CMAKE_BUILD_TYPE STREQUAL Release)39if (CMAKE_BUILD_TYPE STREQUAL Release)
30 set(DEFAULT_BUILD_TYPE "Release")40 set(DEFAULT_BUILD_TYPE "Release")
31elseif (CMAKE_BUILD_TYPE STREQUAL Debug)41elseif (CMAKE_BUILD_TYPE STREQUAL Debug)
32 set(DEFAULT_BUILD_TYPE "Debug")42 set(DEFAULT_BUILD_TYPE "Debug")
33-else ()43+else()
34 set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the build type: Release/Debug" FORCE)44 set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the build type: Release/Debug" FORCE)
35-endif ()45+endif()
36 46 
37get_filename_component(ASCENDC_API_ADV_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE)47get_filename_component(ASCENDC_API_ADV_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE)
38-# include(${ASCENDC_API_ADV_CMAKE_DIR}/intf_pub_linux.cmake)
@@ -14,10 +14,9 @@ set(CMAKE_MODULE_PATH
14 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules14 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
15 ${CMAKE_MODULE_PATH}15 ${CMAKE_MODULE_PATH}
16)16)
17-message(STATUS "CMAKE_MODULE_PATH :${CMAKE_MODULE_PATH}")17+message(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
18 18 
19- 19+find_package(unified_dlog MODULE REQUIRED)
20-find_package(alog MODULE REQUIRED)
21find_package(securec MODULE REQUIRED)20find_package(securec MODULE REQUIRED)
22find_package(mmpa MODULE REQUIRED)21find_package(mmpa MODULE REQUIRED)
23find_package(metadef MODULE REQUIRED)22find_package(metadef MODULE REQUIRED)
@@ -26,4 +25,3 @@ find_package(platform MODULE REQUIRED)
26if(ENABLE_TEST)25if(ENABLE_TEST)
27 find_package(pvmodel MODULE REQUIRED)26 find_package(pvmodel MODULE REQUIRED)
28endif()27endif()
29- 
@@ -1,3 +0,0 @@
1- --full Install full mode
2- --install-path=<path> Install product to specific dir path
3- --rollback Rollback spc cold patch
@@ -1,375 +0,0 @@
1-#!/bin/bash
2-# ----------------------------------------------------------------------------------------------------------
3-# Copyright (c) 2025 Huawei Technologies Co., Ltd.
4-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5-# CANN Open Software License Agreement Version 2.0 (the "License").
6-# Please refer to the License for details. You may not use this file except in compliance with the License.
7-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9-# See LICENSE in the root of the software repository for the full text of the License.
10-# ----------------------------------------------------------------------------------------------------------
11- 
12-set -e
13- 
14-USER_ID=$(id -u)
15-CURRENT_DIR=$(dirname $(readlink -f $0))
16-SOURCE_DIR=${CURRENT_DIR}/packages
17- 
18-if [ "${USER_ID}" != "0" ]; then
19- DEFAULT_TOOLKIT_INSTALL_DIR="${HOME}/Ascend/cann"
20- DEFAULT_INSTALL_DIR="${HOME}/Ascend/cann"
21-else
22- DEFAULT_TOOLKIT_INSTALL_DIR="/usr/local/Ascend/cann"
23- DEFAULT_INSTALL_DIR="/usr/local/Ascend/cann"
24-fi
25- 
26-function log() {
27- local current_time=$(date +"%Y-%m-%d %H:%M:%S")
28- echo "[$current_time] "$1
29-}
30- 
31-function get_version_dir() {
32- local _outvar="$1"
33- local _version_info_path="$2"
34- local _result
35- 
36- if [ ! -f "${_version_info_path}" ]; then
37- eval "${_outvar}=\"\""
38- return 1
39- fi
40- 
41- _result="$(grep "^version_dir=" "${_version_info_path}" | cut -d= -f2-)"
42- eval "${_outvar}=\"${_result}\""
43-}
44- 
45-function get_version_info() {
46- local _outvar="$1"
47- local _version_info_path="$2"
48- local _result
49- 
50- if [ ! -f "${_version_info_path}" ]; then
51- eval "${_outvar}=\"\""
52- return 1
53- fi
54- 
55- _result="$(grep "^Version=" "${_version_info_path}" | cut -d= -f2-)"
56- eval "${_outvar}=\"${_result}\""
57-}
58- 
59-function get_backup_dir() {
60- local _outvar="$1"
61- local _version_info_path="$2"
62- local _result
63- 
64- if [ ! -f "${_version_info_path}" ]; then
65- eval "${_outvar}=\"\""
66- return 1
67- fi
68- 
69- _result="$(grep "^backup_dir=" "${_version_info_path}" | cut -d= -f2-)"
70- eval "${_outvar}=\"${_result}\""
71-}
72- 
73-function get_base_package() {
74- local _outvar="$1"
75- local _version_info_path="$2"
76- local _result
77- 
78- if [ ! -f "${_version_info_path}" ]; then
79- eval "${_outvar}=\"\""
80- return 1
81- fi
82- 
83- _result="$(grep "^base_package=" "${_version_info_path}" | cut -d= -f2-)"
84- eval "${_outvar}=\"${_result}\""
85-}
86- 
87-function get_version_file() {
88- local _outvar="$1"
89- local _root_dir="$2"
90- local _package_list="$3"
91- local _result=""
92- 
93- temp_ifs=$IFS
94- IFS=";"
95- for package in $_package_list; do
96- version_file=${_root_dir}/${package}/version.info
97- if [ -f "${version_file}" ];then
98- _result=${version_file}
99- break
100- fi
101- done
102- IFS=$temp_ifs
103- 
104- if [ "${_result}" == "" ]; then
105- eval "${_outvar}=\"\""
106- return 1
107- else
108- eval "${_outvar}=\"${_result}\""
109- fi
110-}
111- 
112-function delete_backup() {
113- local manifest_file="$1"
114- local version_info_file="$2"
115- local backup_dir="$3"
116- if [ -n "${manifest_file}" ] && [ -f "${manifest_file}" ];then
117- rm -rf ${manifest_file}
118- fi
119- 
120- if [ -n "${version_info_file}" ] && [ -f "${version_info_file}" ];then
121- rm -rf ${version_info_file}
122- fi
123- 
124- if [ -n "${backup_dir}" ] && [ -d "${backup_dir}" ];then
125- rm -rf ${backup_dir}
126- fi
127- 
128-}
129- 
130-function cp_file() {
131- local src_dir="$1"
132- local dest_dir="$2"
133- local relative_file="$3"
134- local src_file="${src_dir}/${relative_file}"
135- local dest_file="${dest_dir}/${relative_file}"
136- local install_dir=$(dirname ${dest_file})
137- if [ "${IS_QUIET}" == "n" ];then
138- local _option="-v"
139- fi
140- if [ ! -f "${install_dir}" ];then
141- mkdir -p ${install_dir}
142- fi
143- cp -rf ${_option} ${src_file} ${dest_file}
144-}
145- 
146-function install_patches() {
147- local mode="$1"
148- local src_dir="$2"
149- local dest_dir="$3"
150- local install_manifest="$4"
151- local backup_dir="$5"
152- local original_perms=""
153- 
154- # 获取源目录中所有子目录
155- local src_subdirectorys=$(find ${src_dir} -mindepth 1 -type d | sort)
156- 
157- # 为目的目录添加写权限,并记录原始目录权限
158- for file in ${src_subdirectorys}; do
159- relative_directory="${file#$src_dir/}"
160- actual_directory=${dest_dir}/${relative_directory}
161- if [ -d "${actual_directory}" ];then
162- perm=$(stat -c '%a %n' $actual_directory)
163- original_perms+=" ${perm}"
164- chmod u+w ${actual_directory}
165- fi
166- done
167- 
168- if [ "${mode}" == "install" ];then
169- # install模式根据生成manifest文件
170- install_manifest_dir=$(dirname ${install_manifest})
171- if [ ! -d "${install_manifest_dir}" ];then
172- mkdir -p ${install_manifest_dir}
173- fi
174- touch ${install_manifest}
175- else
176- while read line
177- do
178- rm -f ${dest_dir}/${line}
179- done < ${install_manifest}
180- fi
181- 
182- # 获取源目录中所有文件和软连接
183- local file_list=$(find ${src_dir} -mindepth 1 \( -type f -o -type l \) | sort)
184- for file in ${file_list}; do
185- relative_file="${file#$src_dir/}"
186- actual_file=${dest_dir}/${relative_file}
187- 
188- # 记录安装文件列表
189- if [ "${mode}" == "install" ];then
190- echo "${relative_file}" >> ${install_manifest}
191- if [ -e "${actual_file}" ];then
192- if [ -d "${actual_file}" ]; then
193- chmod -R u+w "${actual_file}" 2>/dev/null
194- else
195- chmod u+w "${actual_file}" 2>/dev/null
196- fi
197- cp_file ${dest_dir} ${backup_dir} ${relative_file}
198- 
199- if [ -d "${actual_file}" ]; then
200- rm -rf "${actual_file}"
201- else
202- rm -f "${actual_file}"
203- fi
204- fi
205- fi
206- cp_file ${src_dir} ${dest_dir} ${relative_file}
207- done
208- 
209- # 恢复目的目录及其子目录的原始权限
210- original_perm_arr=($original_perms)
211- for((i=0;i<${#original_perm_arr[@]};i+=2))
212- do
213- chmod ${original_perm_arr[i]} ${original_perm_arr[i+1]}
214- done
215-}
216- 
217-function check_version_compatiable() {
218- local base_version="$1"
219- local current_version="$2"
220- _base_version=$(echo ${base_version} | cut -d'.' -f1-4)
221- _current_version=$(echo ${current_version} | cut -d'.' -f1-4)
222- 
223- _lower_base_version=$(echo "${_base_version}" | tr '[:upper:]' '[:lower:]')
224- _lower_current_version=$(echo "${_current_version}" | tr '[:upper:]' '[:lower:]')
225- 
226- if [ "$_lower_base_version" != "$_lower_current_version" ]; then
227- log "[ERROR] the version number of the incremental package is ${_lower_current_version}, and the version number of the cann package used is ${_lower_base_version}. Please install version ${_lower_current_version} of the cann package."
228- exit 1
229- fi
230-}
231- 
232-function copy_version_info() {
233- local src_file="$1"
234- local dst_file="$2"
235- 
236- dst_dir=$(dirname ${dst_file})
237- if [ ! -d ${dst_dir} ];then
238- mkdir -p ${dst_dir}
239- fi
240- cp -rf ${src_file} ${dst_file}
241-}
242- 
243-IS_QUIET="n"
244-IS_ROLLBACK="n"
245-CUSTOM_INSTALL_DIR=""
246- 
247-while true
248-do
249- case $1 in
250- --quiet)
251- IS_QUIET="y"
252- shift
253- ;;
254- --rollback)
255- IS_ROLLBACK="y"
256- shift
257- ;;
258- --install-path=*)
259- temp_install_path=$(echo $1 | cut -d"=" -f2-)
260- CUSTOM_INSTALL_DIR=${temp_install_path%*/}
261- shift
262- ;;
263- --full)
264- shift
265- ;;
266- --*)
267- shift
268- ;;
269- *)
270- break
271- ;;
272- esac
273-done
274- 
275-if [ -n "${CUSTOM_INSTALL_DIR}" ]; then
276- fstr="$(expr substr "$CUSTOM_INSTALL_DIR" 1 1)"
277- if [ "$fstr" = "~" ]; then
278- INSTALL_DIR="${HOME}$(echo "${CUSTOM_INSTALL_DIR}" | cut -d'~' -f 2-)"
279- elif [ "$fstr" != "/" ]; then
280- log "[ERROR] --install-path parameter requires an absolute path."
281- exit 1
282- else
283- INSTALL_DIR=${CUSTOM_INSTALL_DIR}/cann
284- fi
285- log "[INFO] The custom installation directory path is ${INSTALL_DIR} ."
286-elif [ -n "${ASCEND_HOME_PATH}" ];then
287- INSTALL_DIR=${ASCEND_HOME_PATH}
288- log "[INFO] Use ASCEND_HOME_PATH installation directory ${ASCEND_HOME_PATH} ."
289-elif [ -d "${DEFAULT_TOOLKIT_INSTALL_DIR}" ]; then
290- INSTALL_DIR=${DEFAULT_TOOLKIT_INSTALL_DIR}
291- log "[INFO] Use default installation directory ${INSTALL_DIR} ."
292-elif [ -d "${DEFAULT_INSTALL_DIR}" ]; then
293- INSTALL_DIR=${DEFAULT_INSTALL_DIR}
294- log "[INFO] Use default installation directory ${INSTALL_DIR} ."
295-else
296- log "[INFO] Please set the installation directory through --install-path"
297-fi
298- 
299-TARGET_LATEST_DIR=${INSTALL_DIR}
300- 
301-if [ ! -d "${TARGET_LATEST_DIR}" ]; then
302- log "[ERROR] the $TARGET_LATEST_DIR dose not exist, please install the CANN package and set environment variables."
303- exit 1
304-fi
305- 
306-TARGET_ROOT_DIR=$(dirname ${TARGET_LATEST_DIR})
307- 
308-get_base_package "base_package" "./version.info"
309-if [ "${base_package}" == "" ]; then
310- log "[ERROR] get base_package failed."
311- exit 1
312-fi
313- 
314-get_version_file "version_file" ${TARGET_LATEST_DIR} ${base_package}
315-if [ "${version_file}" == "" ]; then
316- log "[ERROR] please install the basic package ${base_package} first."
317- exit 1
318-fi
319- 
320-get_version_dir "version_dir" "${version_file}"
321-if [ "${version_dir}" == "" ]; then
322- log "[ERROR] get version_dir failed."
323- exit 1
324-fi
325- 
326-get_version_info "base_version_info" "${version_file}"
327-if [ "${base_version_info}" == "" ]; then
328- log "[ERROR] get base_version_info failed."
329- exit 1
330-fi
331- 
332-TARGET_DIR=${TARGET_ROOT_DIR}/${version_dir}
333- 
334-if [ ! -d "${TARGET_DIR}" ];then
335- log "[ERROR] ${TARGET_DIR} does not exist."
336- exit 1
337-fi
338- 
339-get_backup_dir "backup_dir" "./version.info"
340-if [ "${backup_dir}" == "" ]; then
341- log "[ERROR] get backup_dir failed."
342- exit 1
343-fi
344- 
345-get_version_info "current_version_info" "./version.info"
346-if [ "${current_version_info}" == "" ]; then
347- log "[ERROR] get current_version_info failed."
348- exit 1
349-fi
350- 
351-BACKUP_DIR=${TARGET_DIR}/backup/${backup_dir}
352-MANIFEST_FILE=${BACKUP_DIR}-manifest.ini
353-VERSION_INFO_FILE=${BACKUP_DIR}-version.info
354- 
355-if [ "${IS_ROLLBACK}" == "y" ];then
356- if [ ! -d "${BACKUP_DIR}" ]; then
357- log "[ERROR] the incremental package ${BACKUP_DIR} is not installed, rollback cannot be performed."
358- exit 1
359- fi
360- log "[INFO] the rollback path is ${TARGET_DIR}."
361- install_patches "backup" "${BACKUP_DIR}" "${TARGET_DIR}" "${MANIFEST_FILE}"
362- delete_backup "${MANIFEST_FILE}" "${VERSION_INFO_FILE}" "${BACKUP_DIR}"
363- log "[INFO] package rollback successfully!"
364-else
365- if [ ! -d "${SOURCE_DIR}" ]; then
366- log "[ERROR] the source code package ${SOURCE_DIR} does not exist, please check."
367- exit 1
368- fi
369- check_version_compatiable "${base_version_info}" "${current_version_info}"
370- log "[INFO] the installation path is ${TARGET_DIR}."
371- delete_backup "${MANIFEST_FILE}" "${VERSION_INFO_FILE}" "${BACKUP_DIR}"
372- copy_version_info "./version.info" "${VERSION_INFO_FILE}"
373- install_patches "install" "${SOURCE_DIR}" "${TARGET_DIR}" "${MANIFEST_FILE}" "${BACKUP_DIR}"
374- log "[INFO] package install successfully!"
375-fi
@@ -7,6 +7,7 @@
7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8# See LICENSE in the root of the software repository for the full text of the License.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------------------------------------9# ----------------------------------------------------------------------------------------------------------
10+ 
10if(TARGET intf_pub)11if(TARGET intf_pub)
11 message(STATUS "intf_pub has been found, no need add library")12 message(STATUS "intf_pub has been found, no need add library")
12 return()13 return()
@@ -7,6 +7,7 @@
7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8# See LICENSE in the root of the software repository for the full text of the License.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------------------------------------9# ----------------------------------------------------------------------------------------------------------
10+ 
10# makeself.cmake - 自定义 makeself 打包脚本11# makeself.cmake - 自定义 makeself 打包脚本
11message(STATUS "CPACK_CMAKE_SOURCE_DIR = ${CPACK_CMAKE_SOURCE_DIR}")12message(STATUS "CPACK_CMAKE_SOURCE_DIR = ${CPACK_CMAKE_SOURCE_DIR}")
12message(STATUS "CPACK_CMAKE_CURRENT_SOURCE_DIR = ${CPACK_CMAKE_CURRENT_SOURCE_DIR}")13message(STATUS "CPACK_CMAKE_CURRENT_SOURCE_DIR = ${CPACK_CMAKE_CURRENT_SOURCE_DIR}")
@@ -114,4 +115,3 @@ execute_process(COMMAND bash ${MAKESELF_EXE}
114if(NOT EXEC_RESULT EQUAL 0)115if(NOT EXEC_RESULT EQUAL 0)
115 message(FATAL_ERROR "makeself packaging failed: ${EXEC_ERROR}")116 message(FATAL_ERROR "makeself packaging failed: ${EXEC_ERROR}")
116endif()117endif()
117- 
@@ -16,7 +16,7 @@ endif()
16set(_cmake_targets_defined "")16set(_cmake_targets_defined "")
17set(_cmake_targets_not_defined "")17set(_cmake_targets_not_defined "")
18set(_cmake_expected_targets "")18set(_cmake_expected_targets "")
19-foreach(_cmake_expected_target IN ITEMS pvmodel_ascend910 pvmodel_ascend310p pvmodel_ascend610 pem_davinci_ascend910B1 pem_davinci_ascend310B pem_davinci_ascend610Lite)19+foreach(_cmake_expected_target IN ITEMS pvmodel_ascend910 pvmodel_ascend310p pvmodel_ascend610 pem_davinci_ascend910B1 pem_davinci_ascend310B pem_davinci_ascend910_9599 pem_davinci_ascend610Lite)
20 list(APPEND _cmake_expected_targets "${_cmake_expected_target}")20 list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
21 if(TARGET "${_cmake_expected_target}")21 if(TARGET "${_cmake_expected_target}")
22 list(APPEND _cmake_targets_defined "${_cmake_expected_target}")22 list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
@@ -74,12 +74,24 @@ find_library(ascend310B1_LIBRARY
74 NO_CMAKE_SYSTEM_PATH74 NO_CMAKE_SYSTEM_PATH
75 NO_CMAKE_FIND_ROOT_PATH)75 NO_CMAKE_FIND_ROOT_PATH)
76 76 
77+find_library(ascend910_9599_LIBRARY
78+ NAMES libpem_davinci.so
79+ PATHS ${ASCEND_DIR}/*/simulator/Ascend910_9599/lib
80+ NO_CMAKE_SYSTEM_PATH
81+ NO_CMAKE_FIND_ROOT_PATH)
82+ 
77find_library(ascend610Lite_LIBRARY83find_library(ascend610Lite_LIBRARY
78 NAMES libpem_davinci.so84 NAMES libpem_davinci.so
79 PATHS ${ASCEND_DIR}/*/simulator/Ascend610Lite/lib85 PATHS ${ASCEND_DIR}/*/simulator/Ascend610Lite/lib
80 NO_CMAKE_SYSTEM_PATH86 NO_CMAKE_SYSTEM_PATH
81 NO_CMAKE_FIND_ROOT_PATH)87 NO_CMAKE_FIND_ROOT_PATH)
82 88 
89+find_library(mc62cm12aa_LIBRARY
90+ NAMES libpem_davinci.so
91+ PATHS ${ASCEND_DIR}/*/simulator/MC62CM12AA/lib
92+ NO_CMAKE_SYSTEM_PATH
93+ NO_CMAKE_FIND_ROOT_PATH)
94+ 
83include(FindPackageHandleStandardArgs)95include(FindPackageHandleStandardArgs)
84find_package_handle_standard_args(pvmodel_ascend91096find_package_handle_standard_args(pvmodel_ascend910
85 FOUND_VAR97 FOUND_VAR
@@ -96,7 +108,9 @@ if(pvmodel_ascend910_FOUND)
96 cmake_print_variables(ascend610_LIBRARY)108 cmake_print_variables(ascend610_LIBRARY)
97 cmake_print_variables(ascend910B1_LIBRARY)109 cmake_print_variables(ascend910B1_LIBRARY)
98 cmake_print_variables(ascend310B1_LIBRARY)110 cmake_print_variables(ascend310B1_LIBRARY)
111+ cmake_print_variables(ascend910_9599_LIBRARY)
99 cmake_print_variables(ascend610Lite_LIBRARY)112 cmake_print_variables(ascend610Lite_LIBRARY)
113+ cmake_print_variables(mc62cm12aa_LIBRARY)
100 114 
101 add_library(pvmodel_ascend910 SHARED IMPORTED)115 add_library(pvmodel_ascend910 SHARED IMPORTED)
102 set_target_properties(pvmodel_ascend910 PROPERTIES116 set_target_properties(pvmodel_ascend910 PROPERTIES
@@ -123,10 +137,20 @@ if(pvmodel_ascend910_FOUND)
123 IMPORTED_LOCATION "${ascend310B1_LIBRARY}"137 IMPORTED_LOCATION "${ascend310B1_LIBRARY}"
124 )138 )
125 139 
140+ add_library(pem_davinci_ascend910_9599 SHARED IMPORTED)
141+ set_target_properties(pem_davinci_ascend910_9599 PROPERTIES
142+ IMPORTED_LOCATION "${ascend910_9599_LIBRARY}"
143+ )
144+ 
126 add_library(pem_davinci_ascend610Lite SHARED IMPORTED)145 add_library(pem_davinci_ascend610Lite SHARED IMPORTED)
127 set_target_properties(pem_davinci_ascend610Lite PROPERTIES146 set_target_properties(pem_davinci_ascend610Lite PROPERTIES
128 IMPORTED_LOCATION "${ascend610Lite_LIBRARY}"147 IMPORTED_LOCATION "${ascend610Lite_LIBRARY}"
129 )148 )
149+ 
150+ add_library(pem_davinci_mc62cm12aa SHARED IMPORTED)
151+ set_target_properties(pem_davinci_mc62cm12aa PROPERTIES
152+ IMPORTED_LOCATION "${mc62cm12aa_LIBRARY}"
153+ )
130endif()154endif()
131 155 
132# Cleanup temporary variables.156# Cleanup temporary variables.
@@ -135,4 +159,6 @@ set(ascend310p_LIBRARY)
135set(ascend610_LIBRARY)159set(ascend610_LIBRARY)
136set(ascend910B1_LIBRARY)160set(ascend910B1_LIBRARY)
137set(ascend310B1_LIBRARY)161set(ascend310B1_LIBRARY)
162+set(ascend910_9599_LIBRARY)
138set(ascend610Lite_LIBRARY)163set(ascend610Lite_LIBRARY)
164+set(mc62cm12aa_LIBRARY)
Rcmake/modules/Findalog.cmakecmake/modules/Findunified_dlog.cmake+27-45
@@ -8,15 +8,15 @@
8# See LICENSE in the root of the software repository for the full text of the License.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------------------------------------9# ----------------------------------------------------------------------------------------------------------
10 10 
11-if (alog_FOUND)11+if (unified_dlog_FOUND)
12- message(STATUS "Package alog has been found.")12+ message(STATUS "Package unified_dlog has been found.")
13 return()13 return()
14endif()14endif()
15 15 
16set(_cmake_targets_defined "")16set(_cmake_targets_defined "")
17set(_cmake_targets_not_defined "")17set(_cmake_targets_not_defined "")
18set(_cmake_expected_targets "")18set(_cmake_expected_targets "")
19-foreach(_cmake_expected_target IN ITEMS slog alog alog_headers)19+foreach(_cmake_expected_target IN ITEMS unified_dlog unified_dlog_headers)
20 list(APPEND _cmake_expected_targets "${_cmake_expected_target}")20 list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
21 if(TARGET "${_cmake_expected_target}")21 if(TARGET "${_cmake_expected_target}")
22 list(APPEND _cmake_targets_defined "${_cmake_expected_target}")22 list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
@@ -44,72 +44,54 @@ unset(_cmake_targets_defined)
44unset(_cmake_targets_not_defined)44unset(_cmake_targets_not_defined)
45unset(_cmake_expected_targets)45unset(_cmake_expected_targets)
46 46 
47-find_path(alog_INCLUDE_DIR47+find_path(unified_dlog_INCLUDE_DIR
48- NAMES base/alog_pub.h48+ NAMES base/dlog_pub.h
49 PATH_SUFFIXES pkg_inc49 PATH_SUFFIXES pkg_inc
50 NO_CMAKE_SYSTEM_PATH50 NO_CMAKE_SYSTEM_PATH
51 NO_CMAKE_FIND_ROOT_PATH)51 NO_CMAKE_FIND_ROOT_PATH)
52 52 
53-find_library(slog_a_SHARED_LIBRARY53+find_library(unified_dlog_SHARED_LIBRARY
54- NAMES libascendalog.so54+ NAMES libunified_dlog.so
55- PATH_SUFFIXES lib64
56- NO_CMAKE_SYSTEM_PATH
57- NO_CMAKE_FIND_ROOT_PATH)
58- 
59-find_library(alog_a_SHARED_LIBRARY
60- NAMES libascendalog.so
61 PATH_SUFFIXES lib6455 PATH_SUFFIXES lib64
62 NO_CMAKE_SYSTEM_PATH56 NO_CMAKE_SYSTEM_PATH
63 NO_CMAKE_FIND_ROOT_PATH)57 NO_CMAKE_FIND_ROOT_PATH)
64 58 
65include(FindPackageHandleStandardArgs)59include(FindPackageHandleStandardArgs)
66-find_package_handle_standard_args(alog60+find_package_handle_standard_args(unified_dlog
67 FOUND_VAR61 FOUND_VAR
68- alog_FOUND62+ unified_dlog_FOUND
69 REQUIRED_VARS63 REQUIRED_VARS
70- alog_INCLUDE_DIR64+ unified_dlog_INCLUDE_DIR
71- slog_a_SHARED_LIBRARY65+ unified_dlog_SHARED_LIBRARY
72- alog_a_SHARED_LIBRARY
73)66)
74 67 
75-if(alog_FOUND)68+if(unified_dlog_FOUND)
76- set(alog_a_INCLUDE_DIR "${alog_INCLUDE_DIR}")69+ set(unified_dlog_INCLUDE_DIR "${unified_dlog_INCLUDE_DIR}")
77 include(CMakePrintHelpers)70 include(CMakePrintHelpers)
78- message(STATUS "Variables in alog module:")71+ message(STATUS "Variables in unified_dlog module:")
79- cmake_print_variables(alog_a_INCLUDE_DIR)72+ cmake_print_variables(unified_dlog_INCLUDE_DIR)
80- cmake_print_variables(slog_a_SHARED_LIBRARY)73+ cmake_print_variables(unified_dlog_SHARED_LIBRARY)
81- cmake_print_variables(alog_a_SHARED_LIBRARY)
82 74 
83- add_library(slog SHARED IMPORTED)75+ add_library(unified_dlog SHARED IMPORTED)
84- set_target_properties(slog PROPERTIES76+ set_target_properties(unified_dlog PROPERTIES
85- INTERFACE_COMPILE_DEFINITIONS "LOG_CPP;PROCESS_LOG"77+ INTERFACE_COMPILE_DEFINITIONS "PROCESS_LOG"
86- INTERFACE_LINK_LIBRARIES "alog_headers"78+ INTERFACE_LINK_LIBRARIES "unified_dlog_headers"
87- IMPORTED_LOCATION "${slog_a_SHARED_LIBRARY}"79+ IMPORTED_LOCATION "${unified_dlog_SHARED_LIBRARY}"
88 )80 )
89 81 
90- add_library(alog SHARED IMPORTED)82+ add_library(unified_dlog_headers INTERFACE IMPORTED)
91- set_target_properties(alog PROPERTIES83+ set_target_properties(unified_dlog_headers PROPERTIES
92- INTERFACE_COMPILE_DEFINITIONS "LOG_CPP;PROCESS_LOG"84+ INTERFACE_INCLUDE_DIRECTORIES "${unified_dlog_INCLUDE_DIR};${unified_dlog_INCLUDE_DIR}/base"
93- INTERFACE_LINK_LIBRARIES "alog_headers"
94- IMPORTED_LOCATION "${alog_a_SHARED_LIBRARY}"
95- )
96- 
97- add_library(alog_headers INTERFACE IMPORTED)
98- set_target_properties(alog_headers PROPERTIES
99- INTERFACE_INCLUDE_DIRECTORIES "${alog_a_INCLUDE_DIR};${alog_a_INCLUDE_DIR}/base"
100 )85 )
101 86 
102 include(CMakePrintHelpers)87 include(CMakePrintHelpers)
103- cmake_print_properties(TARGETS slog88+ cmake_print_properties(TARGETS unified_dlog
104 PROPERTIES INTERFACE_COMPILE_DEFINITIONS INTERFACE_LINK_LIBRARIES IMPORTED_LOCATION89 PROPERTIES INTERFACE_COMPILE_DEFINITIONS INTERFACE_LINK_LIBRARIES IMPORTED_LOCATION
105 )90 )
106- cmake_print_properties(TARGETS alog91+ cmake_print_properties(TARGETS unified_dlog_headers
107- PROPERTIES INTERFACE_COMPILE_DEFINITIONS INTERFACE_LINK_LIBRARIES IMPORTED_LOCATION
108- )
109- cmake_print_properties(TARGETS alog_headers
110 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES92 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
111 )93 )
112endif()94endif()
113 95 
114# Cleanup temporary variables.96# Cleanup temporary variables.
115-set(alog_INCLUDE_DIR)97+set(unified_dlog_INCLUDE_DIR)
@@ -105,5 +105,3 @@ set_target_properties(gtest PROPERTIES
105set_target_properties(gtest_main PROPERTIES105set_target_properties(gtest_main PROPERTIES
106 IMPORTED_LOCATION ${GTEST_INSTALL_PATH}/lib/libgtest_main.a106 IMPORTED_LOCATION ${GTEST_INSTALL_PATH}/lib/libgtest_main.a
107 INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INSTALL_PATH}/include)107 INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INSTALL_PATH}/include)
108- 
109- 
The file is empty
@@ -1,3 +1,17 @@
1+/**
2+* Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+* CANN Open Software License Agreement Version 2.0 (the "License").
5+* Please refer to the License for details. You may not use this file except in compliance with the License.
6+* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+* See LICENSE in the root of the software repository for the full text of the License.
9+*/
10+ 
11+/*!
12+ * \file version.h.in
13+ * \brief
14+ */
1#ifndef ASC_DEVKIT_VERSION_H15#ifndef ASC_DEVKIT_VERSION_H
2#define ASC_DEVKIT_VERSION_H16#define ASC_DEVKIT_VERSION_H
3 17 
@@ -1,3 +1,13 @@
1+# ----------------------------------------------------------------------------------------------------------
2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+# CANN Open Software License Agreement Version 2.0 (the "License").
5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+# See LICENSE in the root of the software repository for the full text of the License.
9+# ----------------------------------------------------------------------------------------------------------
10+ 
1cmake_minimum_required(VERSION 3.16)11cmake_minimum_required(VERSION 3.16)
2 12 
3# 从 version.info 读取版本号13# 从 version.info 读取版本号
@@ -180,14 +180,14 @@
180 <file_info copy_type="delivery" src_path="lib/host" dst_path="$(TARGET_ENV)/ascendc_kernel_cmake" install_path="$(TARGET_ENV)/tikcpp/ascendc_kernel_cmake">180 <file_info copy_type="delivery" src_path="lib/host" dst_path="$(TARGET_ENV)/ascendc_kernel_cmake" install_path="$(TARGET_ENV)/tikcpp/ascendc_kernel_cmake">
181 <file value="fwk_modules"/>181 <file value="fwk_modules"/>
182 <file value="legacy_modules"/>182 <file value="legacy_modules"/>
183- <file value="ASC_CMake"/>183+ <file value="asc_modules"/>
184- <file value="AICPU_CMake"/>184+ <file value="aicpu_modules"/>
185 <file value="ascendc.cmake"/>185 <file value="ascendc.cmake"/>
186 </file_info>186 </file_info>
187 187 
188 <file_info copy_type="delivery" src_path="lib/host" dst_path="$(TARGET_ENV)/ascendc_kernel_cmake" install_path="$(TARGET_ENV)/lib64/cmake">188 <file_info copy_type="delivery" src_path="lib/host" dst_path="$(TARGET_ENV)/ascendc_kernel_cmake" install_path="$(TARGET_ENV)/lib64/cmake">
189- <file value="AICPUConfig.cmake" install_softlink="$(TARGET_ENV)/tikcpp/ascendc_kernel_cmake/AICPUConfig.cmake"/>189+ <file value="aicpu-config.cmake" install_softlink="$(TARGET_ENV)/tikcpp/ascendc_kernel_cmake/aicpu-config.cmake"/>
190- <file value="ASCConfig.cmake" install_softlink="$(TARGET_ENV)/tikcpp/ascendc_kernel_cmake/ASCConfig.cmake"/>190+ <file value="asc-config.cmake" install_softlink="$(TARGET_ENV)/tikcpp/ascendc_kernel_cmake/asc-config.cmake"/>
191 </file_info>191 </file_info>
192 <file_info value="acl_rt" copy_type="delivery" src_path="lib/host" dst_path="$(TARGET_ENV)/acl" install_path="$(TARGET_ENV)/include/acl" install_mod="440">192 <file_info value="acl_rt" copy_type="delivery" src_path="lib/host" dst_path="$(TARGET_ENV)/acl" install_path="$(TARGET_ENV)/include/acl" install_mod="440">
193 <file value="acl_rt_compile.h"/>193 <file value="acl_rt_compile.h"/>
@@ -53,6 +53,18 @@ int aclrtMalloc(void **devPtr, size_t size, aclrtMemMallocPolicy policy)
53}53}
54 54 
55int aclrtGetFunctionName(aclrtFuncHandle funcHandle, uint32_t maxLen, char *name)55int aclrtGetFunctionName(aclrtFuncHandle funcHandle, uint32_t maxLen, char *name)
56+{
57+ return 0;
58+}
59+ 
60+aclError aclrtBinaryGetFunction(const aclrtBinHandle binHandle, const char *kernelName, aclrtFuncHandle *funcHandle)
61+{
62+ return 0;
63+}
64+ 
65+aclError aclrtLaunchKernelWithHostArgs(aclrtFuncHandle funcHandle, uint32_t numBlocks, aclrtStream stream,
66+ aclrtLaunchKernelCfg *cfg, void *hostArgs, size_t argsSize, aclrtPlaceHolderInfo *placeHolderArray,
67+ size_t placeHolderNum)
56{68{
57 return 0;69 return 0;
58}70}
@@ -76,4 +76,10 @@ rtError_t rtKernelLaunchWithFlagV2(const void *stubFunc, uint32_t blockDim, rtAr
76 rtSmDesc_t *smDesc, rtStream_t stm, uint32_t flags, const rtTaskCfgInfo_t *cfgInfo)76 rtSmDesc_t *smDesc, rtStream_t stm, uint32_t flags, const rtTaskCfgInfo_t *cfgInfo)
77{77{
78 return 0;78 return 0;
79+}
80+ 
81+rtError_t rtFunctionGetMetaInfo(const rtFuncHandle funcHandle, const rtFunctionMetaType type, void *data,
82+ const uint32_t length)
83+{
84+ return 0;
79}85}
@@ -1,641 +1,11 @@
1{1{
2 "traceEvents": [2 "traceEvents": [
3- {
4- "optype": "AddCustomUnalign",
5- "name": "AddCustomUnalign compile op",
6- "cat": "compile_op",
7- "ph": "B",
8- "ts": 5901640914963115,
9- "pid": 309540,
10- "tid": 309540,
11- "args": {
12- "tiling_key": "['1']"
13- }
14- },
15- {
16- "optype": "AddCustomUnalign",
17- "name": "AddCustomUnalign compile op",
18- "cat": "compile_op",
19- "ph": "E",
20- "ts": 5901653364982445,
21- "pid": 309540,
22- "tid": 309540
23- },
24- {
25- "optype": "AddCustomUnalign",
26- "name": "preprocess",
27- "cat": "compile_op",
28- "ph": "B",
29- "ts": 5901640915129315,
30- "pid": 309540,
31- "tid": 309540,
32- "args": {
33- "tiling_key": "['1']"
34- }
35- },
36- {
37- "optype": "AddCustomUnalign",
38- "name": "preprocess",
39- "cat": "compile_op",
40- "ph": "E",
41- "ts": 5901642537610217,
42- "pid": 309540,
43- "tid": 309540
44- },
45- {
46- "optype": "AddCustomUnalign",
47- "name": "generate tiling",
48- "cat": "compile_op",
49- "ph": "B",
50- "ts": 5901642537776778,
51- "pid": 309540,
52- "tid": 309540,
53- "args": {
54- "tiling_key": "['1']"
55- }
56- },
57- {
58- "optype": "AddCustomUnalign",
59- "name": "generate tiling",
60- "cat": "compile_op",
61- "ph": "E",
62- "ts": 5901649310179189,
63- "pid": 309540,
64- "tid": 309540
65- },
66- {
67- "optype": "AddCustomUnalign",
68- "name": "generate kernel stub",
69- "cat": "compile_op",
70- "ph": "B",
71- "ts": 5901649310318580,
72- "pid": 309540,
73- "tid": 309540,
74- "args": {
75- "tiling_key": "['1']"
76- }
77- },
78- {
79- "optype": "AddCustomUnalign",
80- "name": "generate kernel stub",
81- "cat": "compile_op",
82- "ph": "E",
83- "ts": 5901649312873111,
84- "pid": 309540,
85- "tid": 309540
86- },
87- {
88- "optype": "AddCustomUnalign",
89- "name": "compile kernel",
90- "cat": "compile_op",
91- "ph": "B",
92- "ts": 5901649312984823,
93- "pid": 309540,
94- "tid": 309540,
95- "args": {
96- "tiling_key": "['1']"
97- }
98- },
99- {
100- "optype": "AddCustomUnalign",
101- "name": "compile kernel",
102- "cat": "compile_op",
103- "ph": "E",
104- "ts": 5901653096423741,
105- "pid": 309540,
106- "tid": 309540
107- },
108- {
109- "optype": "AddCustomUnalign",
110- "name": "link kernel",
111- "cat": "compile_op",
112- "ph": "B",
113- "ts": 5901653096675915,
114- "pid": 309540,
115- "tid": 309540,
116- "args": {
117- "tiling_key": "['1']"
118- }
119- },
120- {
121- "optype": "AddCustomUnalign",
122- "name": "link kernel",
123- "cat": "compile_op",
124- "ph": "E",
125- "ts": 5901653360432533,
126- "pid": 309540,
127- "tid": 309540
128- },
129- {
130- "optype": "AddCustomTemplate",
131- "name": "AddCustomTemplate compile op",
132- "cat": "compile_op",
133- "ph": "B",
134- "ts": 5901642485664143,
135- "pid": 309533,
136- "tid": 309533,
137- "args": {
138- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
139- }
140- },
141- {
142- "optype": "AddCustomTemplate",
143- "name": "AddCustomTemplate compile op",
144- "cat": "compile_op",
145- "ph": "E",
146- "ts": 5901654718691907,
147- "pid": 309533,
148- "tid": 309533
149- },
150- {
151- "optype": "AddCustomTemplate",
152- "name": "preprocess",
153- "cat": "compile_op",
154- "ph": "B",
155- "ts": 5901642485829100,
156- "pid": 309533,
157- "tid": 309533,
158- "args": {
159- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
160- }
161- },
162- {
163- "optype": "AddCustomTemplate",
164- "name": "preprocess",
165- "cat": "compile_op",
166- "ph": "E",
167- "ts": 5901644008636574,
168- "pid": 309533,
169- "tid": 309533
170- },
171- {
172- "optype": "AddCustomTemplate",
173- "name": "generate tiling",
174- "cat": "compile_op",
175- "ph": "B",
176- "ts": 5901644008758792,
177- "pid": 309533,
178- "tid": 309533,
179- "args": {
180- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
181- }
182- },
183- {
184- "optype": "AddCustomTemplate",
185- "name": "generate tiling",
186- "cat": "compile_op",
187- "ph": "E",
188- "ts": 5901650322726282,
189- "pid": 309533,
190- "tid": 309533
191- },
192- {
193- "optype": "AddCustomTemplate",
194- "name": "generate kernel stub",
195- "cat": "compile_op",
196- "ph": "B",
197- "ts": 5901650322946196,
198- "pid": 309533,
199- "tid": 309533,
200- "args": {
201- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
202- }
203- },
204- {
205- "optype": "AddCustomTemplate",
206- "name": "generate kernel stub",
207- "cat": "compile_op",
208- "ph": "E",
209- "ts": 5901650328631440,
210- "pid": 309533,
211- "tid": 309533
212- },
213- {
214- "optype": "AddCustomTemplate",
215- "name": "compile kernel",
216- "cat": "compile_op",
217- "ph": "B",
218- "ts": 5901650328836109,
219- "pid": 309533,
220- "tid": 309533,
221- "args": {
222- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
223- }
224- },
225- {
226- "optype": "AddCustomTemplate",
227- "name": "compile kernel",
228- "cat": "compile_op",
229- "ph": "E",
230- "ts": 5901654583513602,
231- "pid": 309533,
232- "tid": 309533
233- },
234- {
235- "optype": "AddCustomTemplate",
236- "name": "link kernel",
237- "cat": "compile_op",
238- "ph": "B",
239- "ts": 5901654583792894,
240- "pid": 309533,
241- "tid": 309533,
242- "args": {
243- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
244- }
245- },
246- {
247- "optype": "AddCustomTemplate",
248- "name": "link kernel",
249- "cat": "compile_op",
250- "ph": "E",
251- "ts": 5901654715413258,
252- "pid": 309533,
253- "tid": 309533
254- },
255- {
256- "optype": "AddCustomWithoutTpipe",
257- "name": "AddCustomWithoutTpipe compile op",
258- "cat": "compile_op",
259- "ph": "B",
260- "ts": 5901641044392058,
261- "pid": 309471,
262- "tid": 309471,
263- "args": {
264- "tiling_key": "['1', '2']"
265- }
266- },
267- {
268- "optype": "AddCustomWithoutTpipe",
269- "name": "AddCustomWithoutTpipe compile op",
270- "cat": "compile_op",
271- "ph": "E",
272- "ts": 5901654410003976,
273- "pid": 309471,
274- "tid": 309471
275- },
276- {
277- "optype": "AddCustomWithoutTpipe",
278- "name": "preprocess",
279- "cat": "compile_op",
280- "ph": "B",
281- "ts": 5901641044539021,
282- "pid": 309471,
283- "tid": 309471,
284- "args": {
285- "tiling_key": "['1', '2']"
286- }
287- },
288- {
289- "optype": "AddCustomWithoutTpipe",
290- "name": "preprocess",
291- "cat": "compile_op",
292- "ph": "E",
293- "ts": 5901643654293781,
294- "pid": 309471,
295- "tid": 309471
296- },
297- {
298- "optype": "AddCustomWithoutTpipe",
299- "name": "generate tiling",
300- "cat": "compile_op",
301- "ph": "B",
302- "ts": 5901643654477493,
303- "pid": 309471,
304- "tid": 309471,
305- "args": {
306- "tiling_key": "['1', '2']"
307- }
308- },
309- {
310- "optype": "AddCustomWithoutTpipe",
311- "name": "generate tiling",
312- "cat": "compile_op",
313- "ph": "E",
314- "ts": 5901649952289893,
315- "pid": 309471,
316- "tid": 309471
317- },
318- {
319- "optype": "AddCustomWithoutTpipe",
320- "name": "generate kernel stub",
321- "cat": "compile_op",
322- "ph": "B",
323- "ts": 5901649952512882,
324- "pid": 309471,
325- "tid": 309471,
326- "args": {
327- "tiling_key": "['1', '2']"
328- }
329- },
330- {
331- "optype": "AddCustomWithoutTpipe",
332- "name": "generate kernel stub",
333- "cat": "compile_op",
334- "ph": "E",
335- "ts": 5901649957650975,
336- "pid": 309471,
337- "tid": 309471
338- },
339- {
340- "optype": "AddCustomWithoutTpipe",
341- "name": "compile kernel",
342- "cat": "compile_op",
343- "ph": "B",
344- "ts": 5901649957841368,
345- "pid": 309471,
346- "tid": 309471,
347- "args": {
348- "tiling_key": "['1', '2']"
349- }
350- },
351- {
352- "optype": "AddCustomWithoutTpipe",
353- "name": "compile kernel",
354- "cat": "compile_op",
355- "ph": "E",
356- "ts": 5901654246041763,
357- "pid": 309471,
358- "tid": 309471
359- },
360- {
361- "optype": "AddCustomWithoutTpipe",
362- "name": "link kernel",
363- "cat": "compile_op",
364- "ph": "B",
365- "ts": 5901654246297160,
366- "pid": 309471,
367- "tid": 309471,
368- "args": {
369- "tiling_key": "['1', '2']"
370- }
371- },
372- {
373- "optype": "AddCustomWithoutTpipe",
374- "name": "link kernel",
375- "cat": "compile_op",
376- "ph": "E",
377- "ts": 5901654407939817,
378- "pid": 309471,
379- "tid": 309471
380- },
381- {
382- "optype": "AddCustomWithoutTpipe",
383- "name": "AddCustomWithoutTpipe compile op",
384- "cat": "compile_op",
385- "ph": "B",
386- "ts": 5901640648161610,
387- "pid": 309499,
388- "tid": 309499,
389- "args": {
390- "tiling_key": "['1', '2']"
391- }
392- },
393- {
394- "optype": "AddCustomWithoutTpipe",
395- "name": "AddCustomWithoutTpipe compile op",
396- "cat": "compile_op",
397- "ph": "E",
398- "ts": 5901654523236234,
399- "pid": 309499,
400- "tid": 309499
401- },
402- {
403- "optype": "AddCustomWithoutTpipe",
404- "name": "preprocess",
405- "cat": "compile_op",
406- "ph": "B",
407- "ts": 5901640648306515,
408- "pid": 309499,
409- "tid": 309499,
410- "args": {
411- "tiling_key": "['1', '2']"
412- }
413- },
414- {
415- "optype": "AddCustomWithoutTpipe",
416- "name": "preprocess",
417- "cat": "compile_op",
418- "ph": "E",
419- "ts": 5901642536370325,
420- "pid": 309499,
421- "tid": 309499
422- },
423- {
424- "optype": "AddCustomWithoutTpipe",
425- "name": "generate tiling",
426- "cat": "compile_op",
427- "ph": "B",
428- "ts": 5901642536544042,
429- "pid": 309499,
430- "tid": 309499,
431- "args": {
432- "tiling_key": "['1', '2']"
433- }
434- },
435- {
436- "optype": "AddCustomWithoutTpipe",
437- "name": "generate tiling",
438- "cat": "compile_op",
439- "ph": "E",
440- "ts": 5901649997321067,
441- "pid": 309499,
442- "tid": 309499
443- },
444- {
445- "optype": "AddCustomWithoutTpipe",
446- "name": "generate kernel stub",
447- "cat": "compile_op",
448- "ph": "B",
449- "ts": 5901649997544510,
450- "pid": 309499,
451- "tid": 309499,
452- "args": {
453- "tiling_key": "['1', '2']"
454- }
455- },
456- {
457- "optype": "AddCustomWithoutTpipe",
458- "name": "generate kernel stub",
459- "cat": "compile_op",
460- "ph": "E",
461- "ts": 5901650003497613,
462- "pid": 309499,
463- "tid": 309499
464- },
465- {
466- "optype": "AddCustomWithoutTpipe",
467- "name": "compile kernel",
468- "cat": "compile_op",
469- "ph": "B",
470- "ts": 5901650003686322,
471- "pid": 309499,
472- "tid": 309499,
473- "args": {
474- "tiling_key": "['1', '2']"
475- }
476- },
477- {
478- "optype": "AddCustomWithoutTpipe",
479- "name": "compile kernel",
480- "cat": "compile_op",
481- "ph": "E",
482- "ts": 5901654372474313,
483- "pid": 309499,
484- "tid": 309499
485- },
486- {
487- "optype": "AddCustomWithoutTpipe",
488- "name": "link kernel",
489- "cat": "compile_op",
490- "ph": "B",
491- "ts": 5901654372705756,
492- "pid": 309499,
493- "tid": 309499,
494- "args": {
495- "tiling_key": "['1', '2']"
496- }
497- },
498- {
499- "optype": "AddCustomWithoutTpipe",
500- "name": "link kernel",
501- "cat": "compile_op",
502- "ph": "E",
503- "ts": 5901654520159275,
504- "pid": 309499,
505- "tid": 309499
506- },
507- {
508- "optype": "AddCustomTemplate",
509- "name": "AddCustomTemplate compile op",
510- "cat": "compile_op",
511- "ph": "B",
512- "ts": 5901641876342931,
513- "pid": 309515,
514- "tid": 309515,
515- "args": {
516- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
517- }
518- },
519- {
520- "optype": "AddCustomTemplate",
521- "name": "AddCustomTemplate compile op",
522- "cat": "compile_op",
523- "ph": "E",
524- "ts": 5901655100164643,
525- "pid": 309515,
526- "tid": 309515
527- },
528- {
529- "optype": "AddCustomTemplate",
530- "name": "preprocess",
531- "cat": "compile_op",
532- "ph": "B",
533- "ts": 5901641876440554,
534- "pid": 309515,
535- "tid": 309515,
536- "args": {
537- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
538- }
539- },
540- {
541- "optype": "AddCustomTemplate",
542- "name": "preprocess",
543- "cat": "compile_op",
544- "ph": "E",
545- "ts": 5901643791609067,
546- "pid": 309515,
547- "tid": 309515
548- },
549- {
550- "optype": "AddCustomTemplate",
551- "name": "generate tiling",
552- "cat": "compile_op",
553- "ph": "B",
554- "ts": 5901643791772889,
555- "pid": 309515,
556- "tid": 309515,
557- "args": {
558- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
559- }
560- },
561- {
562- "optype": "AddCustomTemplate",
563- "name": "generate tiling",
564- "cat": "compile_op",
565- "ph": "E",
566- "ts": 5901650414444547,
567- "pid": 309515,
568- "tid": 309515
569- },
570- {
571- "optype": "AddCustomTemplate",
572- "name": "generate kernel stub",
573- "cat": "compile_op",
574- "ph": "B",
575- "ts": 5901650414655646,
576- "pid": 309515,
577- "tid": 309515,
578- "args": {
579- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
580- }
581- },
582- {
583- "optype": "AddCustomTemplate",
584- "name": "generate kernel stub",
585- "cat": "compile_op",
586- "ph": "E",
587- "ts": 5901650419822970,
588- "pid": 309515,
589- "tid": 309515
590- },
591- {
592- "optype": "AddCustomTemplate",
593- "name": "compile kernel",
594- "cat": "compile_op",
595- "ph": "B",
596- "ts": 5901650420019851,
597- "pid": 309515,
598- "tid": 309515,
599- "args": {
600- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
601- }
602- },
603- {
604- "optype": "AddCustomTemplate",
605- "name": "compile kernel",
606- "cat": "compile_op",
607- "ph": "E",
608- "ts": 5901654965579198,
609- "pid": 309515,
610- "tid": 309515
611- },
612- {
613- "optype": "AddCustomTemplate",
614- "name": "link kernel",
615- "cat": "compile_op",
616- "ph": "B",
617- "ts": 5901654965739612,
618- "pid": 309515,
619- "tid": 309515,
620- "args": {
621- "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
622- }
623- },
624- {
625- "optype": "AddCustomTemplate",
626- "name": "link kernel",
627- "cat": "compile_op",
628- "ph": "E",
629- "ts": 5901655097885016,
630- "pid": 309515,
631- "tid": 309515
632- },
633 {3 {
634 "optype": "AddCustomFollow",4 "optype": "AddCustomFollow",
635 "name": "AddCustomFollow compile op",5 "name": "AddCustomFollow compile op",
636 "cat": "compile_op",6 "cat": "compile_op",
637 "ph": "B",7 "ph": "B",
638- "ts": 5901640752644912,8+ "ts": 5901640752.644912,
639 "pid": 309408,9 "pid": 309408,
640 "tid": 309408,10 "tid": 309408,
641 "args": {11 "args": {
@@ -647,7 +17,7 @@
647 "name": "AddCustomFollow compile op",17 "name": "AddCustomFollow compile op",
648 "cat": "compile_op",18 "cat": "compile_op",
649 "ph": "E",19 "ph": "E",
650- "ts": 5901655589096990,20+ "ts": 5901655589.09699,
651 "pid": 309408,21 "pid": 309408,
652 "tid": 30940822 "tid": 309408
653 },23 },
@@ -656,7 +26,7 @@
656 "name": "preprocess",26 "name": "preprocess",
657 "cat": "compile_op",27 "cat": "compile_op",
658 "ph": "B",28 "ph": "B",
659- "ts": 5901640752786147,29+ "ts": 5901640752.786147,
660 "pid": 309408,30 "pid": 309408,
661 "tid": 309408,31 "tid": 309408,
662 "args": {32 "args": {
@@ -668,7 +38,7 @@
668 "name": "preprocess",38 "name": "preprocess",
669 "cat": "compile_op",39 "cat": "compile_op",
670 "ph": "E",40 "ph": "E",
671- "ts": 5901642686302885,41+ "ts": 5901642686.302885,
672 "pid": 309408,42 "pid": 309408,
673 "tid": 30940843 "tid": 309408
674 },44 },
@@ -677,7 +47,7 @@
677 "name": "generate tiling",47 "name": "generate tiling",
678 "cat": "compile_op",48 "cat": "compile_op",
679 "ph": "B",49 "ph": "B",
680- "ts": 5901642686439211,50+ "ts": 5901642686.439211,
681 "pid": 309408,51 "pid": 309408,
682 "tid": 309408,52 "tid": 309408,
683 "args": {53 "args": {
@@ -689,7 +59,7 @@
689 "name": "generate tiling",59 "name": "generate tiling",
690 "cat": "compile_op",60 "cat": "compile_op",
691 "ph": "E",61 "ph": "E",
692- "ts": 5901651389710099,62+ "ts": 5901651389.710099,
693 "pid": 309408,63 "pid": 309408,
694 "tid": 30940864 "tid": 309408
695 },65 },
@@ -698,7 +68,7 @@
698 "name": "generate kernel stub",68 "name": "generate kernel stub",
699 "cat": "compile_op",69 "cat": "compile_op",
700 "ph": "B",70 "ph": "B",
701- "ts": 5901651389943616,71+ "ts": 5901651389.943616,
702 "pid": 309408,72 "pid": 309408,
703 "tid": 309408,73 "tid": 309408,
704 "args": {74 "args": {
@@ -710,7 +80,7 @@
710 "name": "generate kernel stub",80 "name": "generate kernel stub",
711 "cat": "compile_op",81 "cat": "compile_op",
712 "ph": "E",82 "ph": "E",
713- "ts": 5901651394723206,83+ "ts": 5901651394.723206,
714 "pid": 309408,84 "pid": 309408,
715 "tid": 30940885 "tid": 309408
716 },86 },
@@ -719,7 +89,7 @@
719 "name": "compile kernel",89 "name": "compile kernel",
720 "cat": "compile_op",90 "cat": "compile_op",
721 "ph": "B",91 "ph": "B",
722- "ts": 5901651394927046,92+ "ts": 5901651394.927046,
723 "pid": 309408,93 "pid": 309408,
724 "tid": 309408,94 "tid": 309408,
725 "args": {95 "args": {
@@ -731,7 +101,7 @@
731 "name": "compile kernel",101 "name": "compile kernel",
732 "cat": "compile_op",102 "cat": "compile_op",
733 "ph": "E",103 "ph": "E",
734- "ts": 5901655372808161,104+ "ts": 5901655372.808161,
735 "pid": 309408,105 "pid": 309408,
736 "tid": 309408106 "tid": 309408
737 },107 },
@@ -740,7 +110,7 @@
740 "name": "link kernel",110 "name": "link kernel",
741 "cat": "compile_op",111 "cat": "compile_op",
742 "ph": "B",112 "ph": "B",
743- "ts": 5901655373072426,113+ "ts": 5901655373.072426,
744 "pid": 309408,114 "pid": 309408,
745 "tid": 309408,115 "tid": 309408,
746 "args": {116 "args": {
@@ -752,18 +122,522 @@
752 "name": "link kernel",122 "name": "link kernel",
753 "cat": "compile_op",123 "cat": "compile_op",
754 "ph": "E",124 "ph": "E",
755- "ts": 5901655586643167,125+ "ts": 5901655586.643167,
756 "pid": 309408,126 "pid": 309408,
757 "tid": 309408127 "tid": 309408
758 },128 },
129+ {
130+ "optype": "AddCustomWithoutTpipe",
131+ "name": "AddCustomWithoutTpipe compile op",
132+ "cat": "compile_op",
133+ "ph": "B",
134+ "ts": 5901641044.392058,
135+ "pid": 309471,
136+ "tid": 309471,
137+ "args": {
138+ "tiling_key": "['1', '2']"
139+ }
140+ },
141+ {
142+ "optype": "AddCustomWithoutTpipe",
143+ "name": "AddCustomWithoutTpipe compile op",
144+ "cat": "compile_op",
145+ "ph": "E",
146+ "ts": 5901654410.003976,
147+ "pid": 309471,
148+ "tid": 309471
149+ },
150+ {
151+ "optype": "AddCustomWithoutTpipe",
152+ "name": "preprocess",
153+ "cat": "compile_op",
154+ "ph": "B",
155+ "ts": 5901641044.539021,
156+ "pid": 309471,
157+ "tid": 309471,
158+ "args": {
159+ "tiling_key": "['1', '2']"
160+ }
161+ },
162+ {
163+ "optype": "AddCustomWithoutTpipe",
164+ "name": "preprocess",
165+ "cat": "compile_op",
166+ "ph": "E",
167+ "ts": 5901643654.293781,
168+ "pid": 309471,
169+ "tid": 309471
170+ },
171+ {
172+ "optype": "AddCustomWithoutTpipe",
173+ "name": "generate tiling",
174+ "cat": "compile_op",
175+ "ph": "B",
176+ "ts": 5901643654.477493,
177+ "pid": 309471,
178+ "tid": 309471,
179+ "args": {
180+ "tiling_key": "['1', '2']"
181+ }
182+ },
183+ {
184+ "optype": "AddCustomWithoutTpipe",
185+ "name": "generate tiling",
186+ "cat": "compile_op",
187+ "ph": "E",
188+ "ts": 5901649952.289893,
189+ "pid": 309471,
190+ "tid": 309471
191+ },
192+ {
193+ "optype": "AddCustomWithoutTpipe",
194+ "name": "generate kernel stub",
195+ "cat": "compile_op",
196+ "ph": "B",
197+ "ts": 5901649952.512882,
198+ "pid": 309471,
199+ "tid": 309471,
200+ "args": {
201+ "tiling_key": "['1', '2']"
202+ }
203+ },
204+ {
205+ "optype": "AddCustomWithoutTpipe",
206+ "name": "generate kernel stub",
207+ "cat": "compile_op",
208+ "ph": "E",
209+ "ts": 5901649957.650975,
210+ "pid": 309471,
211+ "tid": 309471
212+ },
213+ {
214+ "optype": "AddCustomWithoutTpipe",
215+ "name": "compile kernel",
216+ "cat": "compile_op",
217+ "ph": "B",
218+ "ts": 5901649957.841368,
219+ "pid": 309471,
220+ "tid": 309471,
221+ "args": {
222+ "tiling_key": "['1', '2']"
223+ }
224+ },
225+ {
226+ "optype": "AddCustomWithoutTpipe",
227+ "name": "compile kernel",
228+ "cat": "compile_op",
229+ "ph": "E",
230+ "ts": 5901654246.041763,
231+ "pid": 309471,
232+ "tid": 309471
233+ },
234+ {
235+ "optype": "AddCustomWithoutTpipe",
236+ "name": "link kernel",
237+ "cat": "compile_op",
238+ "ph": "B",
239+ "ts": 5901654246.29716,
240+ "pid": 309471,
241+ "tid": 309471,
242+ "args": {
243+ "tiling_key": "['1', '2']"
244+ }
245+ },
246+ {
247+ "optype": "AddCustomWithoutTpipe",
248+ "name": "link kernel",
249+ "cat": "compile_op",
250+ "ph": "E",
251+ "ts": 5901654407.939817,
252+ "pid": 309471,
253+ "tid": 309471
254+ },
255+ {
256+ "optype": "AddCustomWithoutTpipe",
257+ "name": "AddCustomWithoutTpipe compile op",
258+ "cat": "compile_op",
259+ "ph": "B",
260+ "ts": 5901640648.16161,
261+ "pid": 309499,
262+ "tid": 309499,
263+ "args": {
264+ "tiling_key": "['1', '2']"
265+ }
266+ },
267+ {
268+ "optype": "AddCustomWithoutTpipe",
269+ "name": "AddCustomWithoutTpipe compile op",
270+ "cat": "compile_op",
271+ "ph": "E",
272+ "ts": 5901654523.236234,
273+ "pid": 309499,
274+ "tid": 309499
275+ },
276+ {
277+ "optype": "AddCustomWithoutTpipe",
278+ "name": "preprocess",
279+ "cat": "compile_op",
280+ "ph": "B",
281+ "ts": 5901640648.306515,
282+ "pid": 309499,
283+ "tid": 309499,
284+ "args": {
285+ "tiling_key": "['1', '2']"
286+ }
287+ },
288+ {
289+ "optype": "AddCustomWithoutTpipe",
290+ "name": "preprocess",
291+ "cat": "compile_op",
292+ "ph": "E",
293+ "ts": 5901642536.370325,
294+ "pid": 309499,
295+ "tid": 309499
296+ },
297+ {
298+ "optype": "AddCustomWithoutTpipe",
299+ "name": "generate tiling",
300+ "cat": "compile_op",
301+ "ph": "B",
302+ "ts": 5901642536.544042,
303+ "pid": 309499,
304+ "tid": 309499,
305+ "args": {
306+ "tiling_key": "['1', '2']"
307+ }
308+ },
309+ {
310+ "optype": "AddCustomWithoutTpipe",
311+ "name": "generate tiling",
312+ "cat": "compile_op",
313+ "ph": "E",
314+ "ts": 5901649997.321067,
315+ "pid": 309499,
316+ "tid": 309499
317+ },
318+ {
319+ "optype": "AddCustomWithoutTpipe",
320+ "name": "generate kernel stub",
321+ "cat": "compile_op",
322+ "ph": "B",
323+ "ts": 5901649997.54451,
324+ "pid": 309499,
325+ "tid": 309499,
326+ "args": {
327+ "tiling_key": "['1', '2']"
328+ }
329+ },
330+ {
331+ "optype": "AddCustomWithoutTpipe",
332+ "name": "generate kernel stub",
333+ "cat": "compile_op",
334+ "ph": "E",
335+ "ts": 5901650003.497613,
336+ "pid": 309499,
337+ "tid": 309499
338+ },
339+ {
340+ "optype": "AddCustomWithoutTpipe",
341+ "name": "compile kernel",
342+ "cat": "compile_op",
343+ "ph": "B",
344+ "ts": 5901650003.686322,
345+ "pid": 309499,
346+ "tid": 309499,
347+ "args": {
348+ "tiling_key": "['1', '2']"
349+ }
350+ },
351+ {
352+ "optype": "AddCustomWithoutTpipe",
353+ "name": "compile kernel",
354+ "cat": "compile_op",
355+ "ph": "E",
356+ "ts": 5901654372.474313,
357+ "pid": 309499,
358+ "tid": 309499
359+ },
360+ {
361+ "optype": "AddCustomWithoutTpipe",
362+ "name": "link kernel",
363+ "cat": "compile_op",
364+ "ph": "B",
365+ "ts": 5901654372.705756,
366+ "pid": 309499,
367+ "tid": 309499,
368+ "args": {
369+ "tiling_key": "['1', '2']"
370+ }
371+ },
372+ {
373+ "optype": "AddCustomWithoutTpipe",
374+ "name": "link kernel",
375+ "cat": "compile_op",
376+ "ph": "E",
377+ "ts": 5901654520.159275,
378+ "pid": 309499,
379+ "tid": 309499
380+ },
381+ {
382+ "optype": "AddCustomTemplate",
383+ "name": "AddCustomTemplate compile op",
384+ "cat": "compile_op",
385+ "ph": "B",
386+ "ts": 5901641876.342931,
387+ "pid": 309515,
388+ "tid": 309515,
389+ "args": {
390+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
391+ }
392+ },
393+ {
394+ "optype": "AddCustomTemplate",
395+ "name": "AddCustomTemplate compile op",
396+ "cat": "compile_op",
397+ "ph": "E",
398+ "ts": 5901655100.164643,
399+ "pid": 309515,
400+ "tid": 309515
401+ },
402+ {
403+ "optype": "AddCustomTemplate",
404+ "name": "preprocess",
405+ "cat": "compile_op",
406+ "ph": "B",
407+ "ts": 5901641876.440554,
408+ "pid": 309515,
409+ "tid": 309515,
410+ "args": {
411+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
412+ }
413+ },
414+ {
415+ "optype": "AddCustomTemplate",
416+ "name": "preprocess",
417+ "cat": "compile_op",
418+ "ph": "E",
419+ "ts": 5901643791.609067,
420+ "pid": 309515,
421+ "tid": 309515
422+ },
423+ {
424+ "optype": "AddCustomTemplate",
425+ "name": "generate tiling",
426+ "cat": "compile_op",
427+ "ph": "B",
428+ "ts": 5901643791.772889,
429+ "pid": 309515,
430+ "tid": 309515,
431+ "args": {
432+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
433+ }
434+ },
435+ {
436+ "optype": "AddCustomTemplate",
437+ "name": "generate tiling",
438+ "cat": "compile_op",
439+ "ph": "E",
440+ "ts": 5901650414.444547,
441+ "pid": 309515,
442+ "tid": 309515
443+ },
444+ {
445+ "optype": "AddCustomTemplate",
446+ "name": "generate kernel stub",
447+ "cat": "compile_op",
448+ "ph": "B",
449+ "ts": 5901650414.655646,
450+ "pid": 309515,
451+ "tid": 309515,
452+ "args": {
453+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
454+ }
455+ },
456+ {
457+ "optype": "AddCustomTemplate",
458+ "name": "generate kernel stub",
459+ "cat": "compile_op",
460+ "ph": "E",
461+ "ts": 5901650419.82297,
462+ "pid": 309515,
463+ "tid": 309515
464+ },
465+ {
466+ "optype": "AddCustomTemplate",
467+ "name": "compile kernel",
468+ "cat": "compile_op",
469+ "ph": "B",
470+ "ts": 5901650420.019851,
471+ "pid": 309515,
472+ "tid": 309515,
473+ "args": {
474+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
475+ }
476+ },
477+ {
478+ "optype": "AddCustomTemplate",
479+ "name": "compile kernel",
480+ "cat": "compile_op",
481+ "ph": "E",
482+ "ts": 5901654965.579198,
483+ "pid": 309515,
484+ "tid": 309515
485+ },
486+ {
487+ "optype": "AddCustomTemplate",
488+ "name": "link kernel",
489+ "cat": "compile_op",
490+ "ph": "B",
491+ "ts": 5901654965.739612,
492+ "pid": 309515,
493+ "tid": 309515,
494+ "args": {
495+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
496+ }
497+ },
498+ {
499+ "optype": "AddCustomTemplate",
500+ "name": "link kernel",
501+ "cat": "compile_op",
502+ "ph": "E",
503+ "ts": 5901655097.885016,
504+ "pid": 309515,
505+ "tid": 309515
506+ },
507+ {
508+ "optype": "AddCustomTemplate",
509+ "name": "AddCustomTemplate compile op",
510+ "cat": "compile_op",
511+ "ph": "B",
512+ "ts": 5901642485.664143,
513+ "pid": 309533,
514+ "tid": 309533,
515+ "args": {
516+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
517+ }
518+ },
519+ {
520+ "optype": "AddCustomTemplate",
521+ "name": "AddCustomTemplate compile op",
522+ "cat": "compile_op",
523+ "ph": "E",
524+ "ts": 5901654718.691907,
525+ "pid": 309533,
526+ "tid": 309533
527+ },
528+ {
529+ "optype": "AddCustomTemplate",
530+ "name": "preprocess",
531+ "cat": "compile_op",
532+ "ph": "B",
533+ "ts": 5901642485.8291,
534+ "pid": 309533,
535+ "tid": 309533,
536+ "args": {
537+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
538+ }
539+ },
540+ {
541+ "optype": "AddCustomTemplate",
542+ "name": "preprocess",
543+ "cat": "compile_op",
544+ "ph": "E",
545+ "ts": 5901644008.636574,
546+ "pid": 309533,
547+ "tid": 309533
548+ },
549+ {
550+ "optype": "AddCustomTemplate",
551+ "name": "generate tiling",
552+ "cat": "compile_op",
553+ "ph": "B",
554+ "ts": 5901644008.758792,
555+ "pid": 309533,
556+ "tid": 309533,
557+ "args": {
558+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
559+ }
560+ },
561+ {
562+ "optype": "AddCustomTemplate",
563+ "name": "generate tiling",
564+ "cat": "compile_op",
565+ "ph": "E",
566+ "ts": 5901650322.726282,
567+ "pid": 309533,
568+ "tid": 309533
569+ },
570+ {
571+ "optype": "AddCustomTemplate",
572+ "name": "generate kernel stub",
573+ "cat": "compile_op",
574+ "ph": "B",
575+ "ts": 5901650322.946196,
576+ "pid": 309533,
577+ "tid": 309533,
578+ "args": {
579+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
580+ }
581+ },
582+ {
583+ "optype": "AddCustomTemplate",
584+ "name": "generate kernel stub",
585+ "cat": "compile_op",
586+ "ph": "E",
587+ "ts": 5901650328.63144,
588+ "pid": 309533,
589+ "tid": 309533
590+ },
591+ {
592+ "optype": "AddCustomTemplate",
593+ "name": "compile kernel",
594+ "cat": "compile_op",
595+ "ph": "B",
596+ "ts": 5901650328.836109,
597+ "pid": 309533,
598+ "tid": 309533,
599+ "args": {
600+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
601+ }
602+ },
603+ {
604+ "optype": "AddCustomTemplate",
605+ "name": "compile kernel",
606+ "cat": "compile_op",
607+ "ph": "E",
608+ "ts": 5901654583.513602,
609+ "pid": 309533,
610+ "tid": 309533
611+ },
612+ {
613+ "optype": "AddCustomTemplate",
614+ "name": "link kernel",
615+ "cat": "compile_op",
616+ "ph": "B",
617+ "ts": 5901654583.792894,
618+ "pid": 309533,
619+ "tid": 309533,
620+ "args": {
621+ "tiling_key": "['17435146', '4312402442', '168430090', '4463397386', '18093076', '4313060372', '169088020', '4464055316']"
622+ }
623+ },
624+ {
625+ "optype": "AddCustomTemplate",
626+ "name": "link kernel",
627+ "cat": "compile_op",
628+ "ph": "E",
629+ "ts": 5901654715.413258,
630+ "pid": 309533,
631+ "tid": 309533
632+ },
759 {633 {
760 "optype": "AddCustomUnalign",634 "optype": "AddCustomUnalign",
761 "name": "AddCustomUnalign compile op",635 "name": "AddCustomUnalign compile op",
762 "cat": "compile_op",636 "cat": "compile_op",
763 "ph": "B",637 "ph": "B",
764- "ts": 5901640659711706,638+ "ts": 5901640914.963115,
765- "pid": 309551,639+ "pid": 309540,
766- "tid": 309551,640+ "tid": 309540,
767 "args": {641 "args": {
768 "tiling_key": "['1']"642 "tiling_key": "['1']"
769 }643 }
@@ -773,18 +647,18 @@
773 "name": "AddCustomUnalign compile op",647 "name": "AddCustomUnalign compile op",
774 "cat": "compile_op",648 "cat": "compile_op",
775 "ph": "E",649 "ph": "E",
776- "ts": 5901655085010966,650+ "ts": 5901653364.982445,
777- "pid": 309551,651+ "pid": 309540,
778- "tid": 309551652+ "tid": 309540
779 },653 },
780 {654 {
781 "optype": "AddCustomUnalign",655 "optype": "AddCustomUnalign",
782 "name": "preprocess",656 "name": "preprocess",
783 "cat": "compile_op",657 "cat": "compile_op",
784 "ph": "B",658 "ph": "B",
785- "ts": 5901640659808002,659+ "ts": 5901640915.129315,
786- "pid": 309551,660+ "pid": 309540,
787- "tid": 309551,661+ "tid": 309540,
788 "args": {662 "args": {
789 "tiling_key": "['1']"663 "tiling_key": "['1']"
790 }664 }
@@ -794,18 +668,18 @@
794 "name": "preprocess",668 "name": "preprocess",
795 "cat": "compile_op",669 "cat": "compile_op",
796 "ph": "E",670 "ph": "E",
797- "ts": 5901643213051578,671+ "ts": 5901642537.610217,
798- "pid": 309551,672+ "pid": 309540,
799- "tid": 309551673+ "tid": 309540
800 },674 },
801 {675 {
802 "optype": "AddCustomUnalign",676 "optype": "AddCustomUnalign",
803 "name": "generate tiling",677 "name": "generate tiling",
804 "cat": "compile_op",678 "cat": "compile_op",
805 "ph": "B",679 "ph": "B",
806- "ts": 5901643213223313,680+ "ts": 5901642537.776778,
807- "pid": 309551,681+ "pid": 309540,
808- "tid": 309551,682+ "tid": 309540,
809 "args": {683 "args": {
810 "tiling_key": "['1']"684 "tiling_key": "['1']"
811 }685 }
@@ -815,18 +689,18 @@
815 "name": "generate tiling",689 "name": "generate tiling",
816 "cat": "compile_op",690 "cat": "compile_op",
817 "ph": "E",691 "ph": "E",
818- "ts": 5901650623351638,692+ "ts": 5901649310.179189,
819- "pid": 309551,693+ "pid": 309540,
820- "tid": 309551694+ "tid": 309540
821 },695 },
822 {696 {
823 "optype": "AddCustomUnalign",697 "optype": "AddCustomUnalign",
824 "name": "generate kernel stub",698 "name": "generate kernel stub",
825 "cat": "compile_op",699 "cat": "compile_op",
826 "ph": "B",700 "ph": "B",
827- "ts": 5901650623633621,701+ "ts": 5901649310.31858,
828- "pid": 309551,702+ "pid": 309540,
829- "tid": 309551,703+ "tid": 309540,
830 "args": {704 "args": {
831 "tiling_key": "['1']"705 "tiling_key": "['1']"
832 }706 }
@@ -836,18 +710,18 @@
836 "name": "generate kernel stub",710 "name": "generate kernel stub",
837 "cat": "compile_op",711 "cat": "compile_op",
838 "ph": "E",712 "ph": "E",
839- "ts": 5901650628767402,713+ "ts": 5901649312.873111,
840- "pid": 309551,714+ "pid": 309540,
841- "tid": 309551715+ "tid": 309540
842 },716 },
843 {717 {
844 "optype": "AddCustomUnalign",718 "optype": "AddCustomUnalign",
845 "name": "compile kernel",719 "name": "compile kernel",
846 "cat": "compile_op",720 "cat": "compile_op",
847 "ph": "B",721 "ph": "B",
848- "ts": 5901650628967890,722+ "ts": 5901649312.984823,
849- "pid": 309551,723+ "pid": 309540,
850- "tid": 309551,724+ "tid": 309540,
851 "args": {725 "args": {
852 "tiling_key": "['1']"726 "tiling_key": "['1']"
853 }727 }
@@ -857,18 +731,18 @@
857 "name": "compile kernel",731 "name": "compile kernel",
858 "cat": "compile_op",732 "cat": "compile_op",
859 "ph": "E",733 "ph": "E",
860- "ts": 5901654939924961,734+ "ts": 5901653096.423741,
861- "pid": 309551,735+ "pid": 309540,
862- "tid": 309551736+ "tid": 309540
863 },737 },
864 {738 {
865 "optype": "AddCustomUnalign",739 "optype": "AddCustomUnalign",
866 "name": "link kernel",740 "name": "link kernel",
867 "cat": "compile_op",741 "cat": "compile_op",
868 "ph": "B",742 "ph": "B",
869- "ts": 5901654940161743,743+ "ts": 5901653096.675915,
870- "pid": 309551,744+ "pid": 309540,
871- "tid": 309551,745+ "tid": 309540,
872 "args": {746 "args": {
873 "tiling_key": "['1']"747 "tiling_key": "['1']"
874 }748 }
@@ -878,9 +752,9 @@
878 "name": "link kernel",752 "name": "link kernel",
879 "cat": "compile_op",753 "cat": "compile_op",
880 "ph": "E",754 "ph": "E",
881- "ts": 5901655082188866,755+ "ts": 5901653360.432533,
882- "pid": 309551,756+ "pid": 309540,
883- "tid": 309551757+ "tid": 309540
884 }758 }
885 ]759 ]
886}760}
@@ -174,6 +174,7 @@ TEST_F(TEST_ACL_RT_COMPILE, aclrtc_aclrtcCreateProg)
174__global__ __aicore__ void add_custom(GM_ADDR x) {*x = 3 + MY_CONST;}174__global__ __aicore__ void add_custom(GM_ADDR x) {*x = 3 + MY_CONST;}
175// extern "C" __global__ __aicore__ void add_custom(GM_ADDR x) {*x = 3 + MY_CONST;}175// extern "C" __global__ __aicore__ void add_custom(GM_ADDR x) {*x = 3 + MY_CONST;}
176)"""";176)"""";
177+ MOCKER(LoadExtraLib).stubs().will(returnValue(ACL_SUCCESS));
177 aclError result = aclrtcCreateProg(&prog, src, "test_kernel", 0, nullptr, nullptr);178 aclError result = aclrtcCreateProg(&prog, src, "test_kernel", 0, nullptr, nullptr);
178 EXPECT_EQ(result, ACL_SUCCESS);179 EXPECT_EQ(result, ACL_SUCCESS);
179}180}
@@ -193,7 +194,7 @@ __global__ __aicore__ void add_custom(GM_ADDR x) {*x = 3 + MY_CONST;}
193// extern "C" __global__ __aicore__ void add_custom(GM_ADDR x) {*x = 3 + MY_CONST;}194// extern "C" __global__ __aicore__ void add_custom(GM_ADDR x) {*x = 3 + MY_CONST;}
194)"""";195)"""";
195 asrtcDestroyProgramPtr = mockFunc;196 asrtcDestroyProgramPtr = mockFunc;
196- 197+ MOCKER(LoadExtraLib).stubs().will(returnValue(ACL_SUCCESS));
197 aclrtcProg prog = nullptr;198 aclrtcProg prog = nullptr;
198 aclrtcCreateProg(&prog, src, "test_kernel", 0, nullptr, nullptr);199 aclrtcCreateProg(&prog, src, "test_kernel", 0, nullptr, nullptr);
199 aclError result = aclrtcDestroyProg(&prog);200 aclError result = aclrtcDestroyProg(&prog);
@@ -86,13 +86,14 @@ TEST_F(TEST_ASCENDC_RUNTIME, ascendcRuntimeDevBinaryRegisterTest) {
86 void **args = nullptr;86 void **args = nullptr;
87 uint32_t size;87 uint32_t size;
88 rtStream_t stream = nullptr;88 rtStream_t stream = nullptr;
89- ret = AscendKernelLaunchWithFlagV2(stubFunc, blockDim, args, size, stream);89+ ret = AscendKernelLaunchWithFlagV2(stubFunc, blockDim, args, size, stream, 0);
90 EXPECT_EQ(ret, 0);90 EXPECT_EQ(ret, 0);
91}91}
92 92 
93TEST_F(TEST_ASCENDC_RUNTIME, ascendcRuntimeMemoryFailedTest){93TEST_F(TEST_ASCENDC_RUNTIME, ascendcRuntimeMemoryFailedTest){
94 size_t bufsize = 16;94 size_t bufsize = 16;
95 uint32_t ret;95 uint32_t ret;
96+ MOCKER(aclrtMalloc).expects(once()).will(returnValue(1));
96 ret = AllocAscendMemDevice(nullptr, bufsize);97 ret = AllocAscendMemDevice(nullptr, bufsize);
97 EXPECT_NE(ret, 0);98 EXPECT_NE(ret, 0);
98 ret = FreeAscendMemDevice(nullptr);99 ret = FreeAscendMemDevice(nullptr);
@@ -1,2 +0,0 @@
1-# This .gitkeep file ensures the directory is tracked by Git.
2-# Remove this file when addding actual content to the directory.
@@ -7,26 +7,15 @@
7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8# See LICENSE in the root of the software repository for the full text of the License.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------------------------------------9# ----------------------------------------------------------------------------------------------------------
10+ 
11+add_compile_options(-Werror)
12+ 
10if(NOT ENABLE_TEST)13if(NOT ENABLE_TEST)
11 add_subdirectory(ascc)14 add_subdirectory(ascc)
12- add_subdirectory(build)
13 add_subdirectory(aclrtc)15 add_subdirectory(aclrtc)
14endif()16endif()
17+add_subdirectory(build)
15 18 
16install(FILES scripts/ascendc_parse_dumpinfo.py19install(FILES scripts/ascendc_parse_dumpinfo.py
17 DESTINATION ${INSTALL_LIBRARY_DIR} OPTIONAL20 DESTINATION ${INSTALL_LIBRARY_DIR} OPTIONAL
18)21)
19- 
20-add_custom_command(
21- OUTPUT ${CMAKE_BINARY_DIR}/ascendc_kernel_cmake
22- COMMAND rm -rf ${CMAKE_BINARY_DIR}/ascendc_kernel_cmake
23- COMMAND cp -rf ${ASCENDC_DIR}/cmake/asc ${CMAKE_BINARY_DIR}/ascendc_kernel_cmake
24- COMMAND cp -rf ${ASCENDC_DIR}/tools/ascc/cmake/. ${CMAKE_BINARY_DIR}/ascendc_kernel_cmake
25- COMMAND cp -rf ${ASCENDC_DIR}/tools/build/scripts/AICPU_CMake ${CMAKE_BINARY_DIR}/ascendc_kernel_cmake
26-)
27-add_custom_target(ascendc_kernel_cmake ALL DEPENDS ${CMAKE_BINARY_DIR}/ascendc_kernel_cmake)
28- 
29-install(DIRECTORY ${CMAKE_BINARY_DIR}/ascendc_kernel_cmake
30- DESTINATION ${INSTALL_LIBRARY_DIR} OPTIONAL
31- PATTERN "test_*" EXCLUDE
32-)
The file is empty
@@ -20,7 +20,6 @@
20#include <string>20#include <string>
21#include <iostream>21#include <iostream>
22#include <string_view>22#include <string_view>
23-#include <unistd.h>
24 23 
25#include "acl_base.h"24#include "acl_base.h"
26#include "securec.h"25#include "securec.h"
@@ -183,7 +182,7 @@ asrtcGetLoweredNameFuncPtr asrtcGetLoweredNamePtr = nullptr;
183asrtcGetProgramLogSizeFuncPtr asrtcGetProgramLogSizePtr = nullptr;182asrtcGetProgramLogSizeFuncPtr asrtcGetProgramLogSizePtr = nullptr;
184asrtcGetProgramLogFuncPtr asrtcGetProgramLogPtr = nullptr;183asrtcGetProgramLogFuncPtr asrtcGetProgramLogPtr = nullptr;
185 184 
186-void __attribute__((constructor)) LoadExtraLib() {185+aclError LoadExtraLib() {
187 std::string cannPath = GetCannPath();186 std::string cannPath = GetCannPath();
188 std::string libPathX86 = cannPath + "/x86_64-linux/ccec_compiler/lib/libasrtc.so";187 std::string libPathX86 = cannPath + "/x86_64-linux/ccec_compiler/lib/libasrtc.so";
189 std::string libPathArm = cannPath + "/aarch64-linux/ccec_compiler/lib/libasrtc.so";188 std::string libPathArm = cannPath + "/aarch64-linux/ccec_compiler/lib/libasrtc.so";
@@ -192,8 +191,10 @@ void __attribute__((constructor)) LoadExtraLib() {
192 handle = dlopen(libPathX86.c_str(), RTLD_GLOBAL | RTLD_NOW);191 handle = dlopen(libPathX86.c_str(), RTLD_GLOBAL | RTLD_NOW);
193 } else if (PathCheck(libPathArm.c_str())) {192 } else if (PathCheck(libPathArm.c_str())) {
194 handle = dlopen(libPathArm.c_str(), RTLD_GLOBAL | RTLD_NOW);193 handle = dlopen(libPathArm.c_str(), RTLD_GLOBAL | RTLD_NOW);
195- } else {194+ }
196- return;195+ if (!handle) {
196+ fprintf(stderr, "[ERROR] Failed to load inner rtc library, please check it!\n");
197+ return ACL_ERROR_RTC_FAILURE;
197 }198 }
198 // 4. dlsym199 // 4. dlsym
199 asrtcCreateProgramPtr = (asrtcCreateProgramFuncPtr)dlsym(handle, "asrtcCreateProgram");200 asrtcCreateProgramPtr = (asrtcCreateProgramFuncPtr)dlsym(handle, "asrtcCreateProgram");
@@ -205,6 +206,7 @@ void __attribute__((constructor)) LoadExtraLib() {
205 asrtcGetLoweredNamePtr = (asrtcGetLoweredNameFuncPtr)dlsym(handle, "asrtcGetLoweredName");206 asrtcGetLoweredNamePtr = (asrtcGetLoweredNameFuncPtr)dlsym(handle, "asrtcGetLoweredName");
206 asrtcGetProgramLogSizePtr = (asrtcGetProgramLogSizeFuncPtr)dlsym(handle, "asrtcGetProgramLogSize");207 asrtcGetProgramLogSizePtr = (asrtcGetProgramLogSizeFuncPtr)dlsym(handle, "asrtcGetProgramLogSize");
207 asrtcGetProgramLogPtr = (asrtcGetProgramLogFuncPtr)dlsym(handle, "asrtcGetProgramLog");208 asrtcGetProgramLogPtr = (asrtcGetProgramLogFuncPtr)dlsym(handle, "asrtcGetProgramLog");
209+ return ACL_SUCCESS;
208}210}
209 211 
210void __attribute__((destructor)) UnloadExtraLib() {212void __attribute__((destructor)) UnloadExtraLib() {
@@ -256,6 +258,10 @@ aclError aclrtcCreateProg(aclrtcProg *prog, const char *src, const char *name, i
256 if (prog == nullptr || src == nullptr || name == nullptr) {258 if (prog == nullptr || src == nullptr || name == nullptr) {
257 return ACL_ERROR_RTC_INVALID_INPUT;259 return ACL_ERROR_RTC_INVALID_INPUT;
258 }260 }
261+ aclError retLoad = LoadExtraLib();
262+ if (retLoad != ACL_SUCCESS) {
263+ return retLoad;
264+ }
259 AclrtcProgram* ascProg = CreatAclrtcProgram(name);265 AclrtcProgram* ascProg = CreatAclrtcProgram(name);
260 aclrtcProg program = nullptr;266 aclrtcProg program = nullptr;
261 aclError ret = ErrorCodeProcess(asrtcCreateProgramPtr(&program, src, name, numHeaders, headers, includeNames));267 aclError ret = ErrorCodeProcess(asrtcCreateProgramPtr(&program, src, name, numHeaders, headers, includeNames));
@@ -8,3 +8,16 @@
8# See LICENSE in the root of the software repository for the full text of the License.8# See LICENSE in the root of the software repository for the full text of the License.
9# ----------------------------------------------------------------------------------------------------------9# ----------------------------------------------------------------------------------------------------------
10add_subdirectory(asc_plugin)10add_subdirectory(asc_plugin)
11+ 
12+if(NOT BUILD_OPEN_PROJECT)
13+ set(ASC_CMAKE_MODULE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/ascendc_kernel_cmake)
14+ add_custom_target(ascendc_kernel_cmake_legacy ALL
15+ COMMAND ${CMAKE_COMMAND} -E make_directory "${ASC_CMAKE_MODULE_BINARY_DIR}"
16+ COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${ASC_CMAKE_MODULE_BINARY_DIR}"
17+ )
18+ 
19+ install(DIRECTORY ${ASC_CMAKE_MODULE_BINARY_DIR}
20+ DESTINATION ${INSTALL_LIBRARY_DIR} OPTIONAL
21+ PATTERN "test_*" EXCLUDE
22+ )
23+endif()
The file is empty
@@ -18,15 +18,42 @@
18 18 
19#include <string>19#include <string>
20#include <vector>20#include <vector>
21+#include <unordered_map>
22+#include <functional>
21 23 
22#include "asc_struct.h"24#include "asc_struct.h"
23#include "asc_utils.h"25#include "asc_utils.h"
24 26 
25namespace AscPlugin {27namespace AscPlugin {
26- 
27KernelTypeResult CheckHasMixKernelFunc();28KernelTypeResult CheckHasMixKernelFunc();
28-std::vector<std::string> GetHostCompileOptions();29+class CompileOptionManager {
29-std::vector<std::string> GetDeviceCommonCompileOptions(const KernelTypeResult& kernelTypeRes);30+public:
31+ CompileOptionManager();
32+ std::vector<std::string> GetHostCompileOptions() const;
33+ std::vector<std::string> GetDeviceCompileOptions(CoreType type) const;
30 34 
35+private:
36+ template<ShortSocVersion soc>
37+ std::vector<std::string> GetDeviceCompileOptionsWithSoc(CoreType coreType) const;
38+ void SetOldPrintOptions(std::vector<std::string>& devSocOpts) const;
39+ void InitDispatchTable();
40+ template<ShortSocVersion soc>
41+ void RegisterOptHandler();
42+ 
43+private:
44+ using SocOptHandler = std::function<std::vector<std::string>(CoreType)>;
45+ 
46+ ShortSocVersion socVersion_ = ShortSocVersion::ASCEND910B;
47+ bool isAutoSyncOn_ = true;
48+ bool userDumpStatus_ = true;
49+ bool isDumpOn_ = true;
50+ bool l2CacheOn_ = true;
51+ uint32_t oneCoreDumpSize_ = 0;
52+ 
53+ std::string optiLevel_;
54+ std::string cannVersionHeader_;
55+ std::vector<std::string> deviceCompileOpt_;
56+ std::unordered_map<ShortSocVersion, SocOptHandler> dispatchTable_;
57+};
31} // namespace AscPlugin58} // namespace AscPlugin
32#endif // __INCLUDE_INTERNAL_ASC_COMPILE_OPTIONS_H__59#endif // __INCLUDE_INTERNAL_ASC_COMPILE_OPTIONS_H__
Rtools/ascc/asc_plugin/include/internal/asc_dev_funcRegistry_generate.htools/ascc/asc_plugin/include/internal/asc_dev_func_registry_generate.h+2-2
@@ -9,14 +9,14 @@
9*/9*/
10 10 
11/*!11/*!
12- * \file asc_dev_funcRegistry_generate.h12+ * \file asc_dev_func_registry_generate.h
13 * \brief13 * \brief
14 */14 */
15 15 
16#ifndef __INCLUDE_INTERNAL_ASC_DEV_FUNCREGISTRY_GENERATE_H__16#ifndef __INCLUDE_INTERNAL_ASC_DEV_FUNCREGISTRY_GENERATE_H__
17#define __INCLUDE_INTERNAL_ASC_DEV_FUNCREGISTRY_GENERATE_H__17#define __INCLUDE_INTERNAL_ASC_DEV_FUNCREGISTRY_GENERATE_H__
18 18 
19-#include "asc_utils.h"19+#include <string>
20 20 
21namespace AscPlugin {21namespace AscPlugin {
22 22 
@@ -33,12 +33,16 @@ public:
33 std::string GenCode();33 std::string GenCode();
34 34 
35private:35private:
36- std::string GenStubFuncDecl(bool hasNameSpace, bool hasAnonymousSpace) const;36+ std::string GenStubFuncDecl() const;
37 std::string ManglingNameJudgeCode();37 std::string ManglingNameJudgeCode();
38 void GenStubFuncImpl();38 void GenStubFuncImpl();
39+ void ParseKernelName();
39 40 
40private:41private:
41 KernelInfo kernelInfo_;42 KernelInfo kernelInfo_;
43+ bool hasAnonymousSpace_ = false;
44+ bool hasNameSpace_ = true;
45+ std::string kernelNameWithNameSpace_ = "";
42 std::ostringstream typeJudgePreCode_;46 std::ostringstream typeJudgePreCode_;
43 std::ostringstream kernelCallStub_;47 std::ostringstream kernelCallStub_;
44 std::unordered_set<KernelMetaType> kernelType_ = {KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2};48 std::unordered_set<KernelMetaType> kernelType_ = {KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2};
@@ -59,6 +59,9 @@ struct PathInfo {
59 59 
60 cannPath + "/asc/impl/adv_api",60 cannPath + "/asc/impl/adv_api",
61 cannPath + "/asc/impl/basic_api",61 cannPath + "/asc/impl/basic_api",
62+ cannPath + "/asc/impl/c_api",
63+ cannPath + "/asc/impl/micro_api",
64+ cannPath + "/asc/impl/simt_api",
62 cannPath + "/asc/impl/utils",65 cannPath + "/asc/impl/utils",
63 66 
64 cannPath + "/asc/include",67 cannPath + "/asc/include",
@@ -66,7 +69,10 @@ struct PathInfo {
66 cannPath + "/asc/include/adv_api/matmul",69 cannPath + "/asc/include/adv_api/matmul",
67 cannPath + "/asc/include/aicpu_api",70 cannPath + "/asc/include/aicpu_api",
68 cannPath + "/asc/include/basic_api",71 cannPath + "/asc/include/basic_api",
72+ cannPath + "/asc/include/c_api",
69 cannPath + "/asc/include/interface",73 cannPath + "/asc/include/interface",
74+ cannPath + "/asc/include/micro_api",
75+ cannPath + "/asc/include/simt_api",
70 cannPath + "/asc/include/tiling",76 cannPath + "/asc/include/tiling",
71 cannPath + "/asc/include/utils"77 cannPath + "/asc/include/utils"
72 };78 };
@@ -109,6 +115,7 @@ public:
109 void SetSaveTempRequested(const bool saveTemp);115 void SetSaveTempRequested(const bool saveTemp);
110 void SetUserDumpStatus(const bool dumpStatus);116 void SetUserDumpStatus(const bool dumpStatus);
111 void SetHasPrintf(const bool hasPrintf);117 void SetHasPrintf(const bool hasPrintf);
118+ void SetHasSimtPrintf(const bool hasSimtPrintf);
112 void SetHasAssert(const bool hasAssert);119 void SetHasAssert(const bool hasAssert);
113 void SetOpSystemCfg(const bool hasOpSystemCfg);120 void SetOpSystemCfg(const bool hasOpSystemCfg);
114 void AddGlobalSymbolInfo(const std::string &mangling, const KernelMetaType &type, const std::string &fileName,121 void AddGlobalSymbolInfo(const std::string &mangling, const KernelMetaType &type, const std::string &fileName,
@@ -134,7 +141,9 @@ public:
134 bool UserDumpRequested() const;141 bool UserDumpRequested() const;
135 bool HasTimeStamp() const;142 bool HasTimeStamp() const;
136 bool HasPrintf() const;143 bool HasPrintf() const;
144+ bool HasSimtPrintf() const;
137 bool HasAssert() const;145 bool HasAssert() const;
146+ bool HasUbufDynamicSize() const; // simt: <<<blockDim, nullptr, stream, ubufDynamicSize>>>
138 bool IsDumpOn() const; // when user not pass -DASCENDC_DUMP=0, and uses printf/ assert147 bool IsDumpOn() const; // when user not pass -DASCENDC_DUMP=0, and uses printf/ assert
139 uint32_t GetOneCoreDumpSize() const; // for -DONE_CORE_DUMP_SIZE=xxx148 uint32_t GetOneCoreDumpSize() const; // for -DONE_CORE_DUMP_SIZE=xxx
140 bool IsL2CacheEnabled() const;149 bool IsL2CacheEnabled() const;
@@ -166,7 +175,9 @@ private:
166 bool userDumpStatus_ = true; // if user passed -DASCENDC_DUMP, then update. True means = 1175 bool userDumpStatus_ = true; // if user passed -DASCENDC_DUMP, then update. True means = 1
167 bool hasTimeStamp_ = false; // for -DASCENDC_TIME_STAMP_ON176 bool hasTimeStamp_ = false; // for -DASCENDC_TIME_STAMP_ON
168 bool hasPrintf_ = false;177 bool hasPrintf_ = false;
178+ bool hasSimtPrintf_ = false; // only for 910_95 simt
169 bool hasAssert_ = false;179 bool hasAssert_ = false;
180+ bool hasUbufDynamicSize_ = true;
170 bool enableL2Cache_ = true; // default enable181 bool enableL2Cache_ = true; // default enable
171 bool hasOpSystemCfg_ =false;182 bool hasOpSystemCfg_ =false;
172 uint32_t oneCoreDumpSize_ = 1048576; // 1024 K183 uint32_t oneCoreDumpSize_ = 1048576; // 1024 K
@@ -80,15 +80,14 @@ enum class ShortSocVersion : uint32_t {
80 ASCEND910 = 2,80 ASCEND910 = 2,
81 ASCEND310B = 3,81 ASCEND310B = 3,
82 ASCEND910_95 = 4,82 ASCEND910_95 = 4,
83- KIRINX90 = 5,
84- KIRIN9030 = 6,
85 INVALID_TYPE = 0xffffffff83 INVALID_TYPE = 0xffffffff
86};84};
87 85 
88// for split architecture, cube / vec; otherwise means aicore(use cube) + vec86// for split architecture, cube / vec; otherwise means aicore(use cube) + vec
89enum class CoreType: uint32_t {87enum class CoreType: uint32_t {
90 CUBE = 0,88 CUBE = 0,
91- VEC89+ VEC,
90+ NO_SPLIT
92};91};
93 92 
94enum class FeatureFlag: uint32_t {93enum class FeatureFlag: uint32_t {
@@ -154,6 +153,8 @@ const std::unordered_map<std::string, AscPlugin::ShortSocVersion> SOC_VERSION_MA
154 {"Ascend310B4", AscPlugin::ShortSocVersion::ASCEND310B},153 {"Ascend310B4", AscPlugin::ShortSocVersion::ASCEND310B},
155 154 
156 {"Ascend910_957b", AscPlugin::ShortSocVersion::ASCEND910_95}, // ascend910_95_list155 {"Ascend910_957b", AscPlugin::ShortSocVersion::ASCEND910_95}, // ascend910_95_list
156+ {"Ascend910_950x", AscPlugin::ShortSocVersion::ASCEND910_95},
157+ {"Ascend910_950y", AscPlugin::ShortSocVersion::ASCEND910_95},
157 {"Ascend910_950z", AscPlugin::ShortSocVersion::ASCEND910_95},158 {"Ascend910_950z", AscPlugin::ShortSocVersion::ASCEND910_95},
158 {"Ascend910_958b", AscPlugin::ShortSocVersion::ASCEND910_95},159 {"Ascend910_958b", AscPlugin::ShortSocVersion::ASCEND910_95},
159 {"Ascend910_958a", AscPlugin::ShortSocVersion::ASCEND910_95},160 {"Ascend910_958a", AscPlugin::ShortSocVersion::ASCEND910_95},
@@ -184,8 +185,6 @@ const std::unordered_map<std::string, AscPlugin::ShortSocVersion> SOC_VERSION_MA
184 {"Ascend910_9576", AscPlugin::ShortSocVersion::ASCEND910_95},185 {"Ascend910_9576", AscPlugin::ShortSocVersion::ASCEND910_95},
185 {"Ascend910_9577", AscPlugin::ShortSocVersion::ASCEND910_95},186 {"Ascend910_9577", AscPlugin::ShortSocVersion::ASCEND910_95},
186 {"Ascend910_9578", AscPlugin::ShortSocVersion::ASCEND910_95},187 {"Ascend910_9578", AscPlugin::ShortSocVersion::ASCEND910_95},
187- {"KirinX90", AscPlugin::ShortSocVersion::KIRINX90},
188- {"Kirin9030", AscPlugin::ShortSocVersion::KIRIN9030},
189};188};
190 189 
191const std::map<std::pair<AscPlugin::ShortSocVersion, AscPlugin::CoreType>, std::string> CCE_AICORE_MAP = {190const std::map<std::pair<AscPlugin::ShortSocVersion, AscPlugin::CoreType>, std::string> CCE_AICORE_MAP = {
@@ -199,10 +198,6 @@ const std::map<std::pair<AscPlugin::ShortSocVersion, AscPlugin::CoreType>, std::
199 {{AscPlugin::ShortSocVersion::ASCEND310B, AscPlugin::CoreType::VEC}, "dav-m300"},198 {{AscPlugin::ShortSocVersion::ASCEND310B, AscPlugin::CoreType::VEC}, "dav-m300"},
200 {{AscPlugin::ShortSocVersion::ASCEND910_95, AscPlugin::CoreType::CUBE}, "dav-c310-cube"},199 {{AscPlugin::ShortSocVersion::ASCEND910_95, AscPlugin::CoreType::CUBE}, "dav-c310-cube"},
201 {{AscPlugin::ShortSocVersion::ASCEND910_95, AscPlugin::CoreType::VEC}, "dav-c310-vec"},200 {{AscPlugin::ShortSocVersion::ASCEND910_95, AscPlugin::CoreType::VEC}, "dav-c310-vec"},
202- {{AscPlugin::ShortSocVersion::KIRINX90, AscPlugin::CoreType::CUBE}, "dav-l300"},
203- {{AscPlugin::ShortSocVersion::KIRINX90, AscPlugin::CoreType::VEC}, "dav-l300"},
204- {{AscPlugin::ShortSocVersion::KIRIN9030, AscPlugin::CoreType::CUBE}, "dav-l311"},
205- {{AscPlugin::ShortSocVersion::KIRIN9030, AscPlugin::CoreType::VEC}, "dav-l311"},
206};201};
207 202 
208const std::unordered_map<std::string, AscPlugin::ShortSocVersion> CCE_AICORE_ARCH_MAP = {203const std::unordered_map<std::string, AscPlugin::ShortSocVersion> CCE_AICORE_ARCH_MAP = {
@@ -214,8 +209,6 @@ const std::unordered_map<std::string, AscPlugin::ShortSocVersion> CCE_AICORE_ARC
214 {"dav-c310-cube", AscPlugin::ShortSocVersion::ASCEND910_95}, // ascend910_95_list209 {"dav-c310-cube", AscPlugin::ShortSocVersion::ASCEND910_95}, // ascend910_95_list
215 {"dav-c310-vec", AscPlugin::ShortSocVersion::ASCEND910_95},210 {"dav-c310-vec", AscPlugin::ShortSocVersion::ASCEND910_95},
216 {"dav-c310", AscPlugin::ShortSocVersion::ASCEND910_95},211 {"dav-c310", AscPlugin::ShortSocVersion::ASCEND910_95},
217- {"dav-l300", AscPlugin::ShortSocVersion::KIRINX90},
218- {"dav-l311", AscPlugin::ShortSocVersion::KIRIN9030},
219};212};
220 213 
221const std::unordered_map<AscPlugin::KernelMetaType, std::string> KERNEL_TYPE_STR_MAP = {214const std::unordered_map<AscPlugin::KernelMetaType, std::string> KERNEL_TYPE_STR_MAP = {
@@ -235,8 +228,6 @@ const std::unordered_map<AscPlugin::ShortSocVersion, AscPlugin::KernelMetaType>
235 {AscPlugin::ShortSocVersion::ASCEND310P, AscPlugin::KernelMetaType::KERNEL_TYPE_AICORE},228 {AscPlugin::ShortSocVersion::ASCEND310P, AscPlugin::KernelMetaType::KERNEL_TYPE_AICORE},
236 {AscPlugin::ShortSocVersion::ASCEND910B, AscPlugin::KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2},229 {AscPlugin::ShortSocVersion::ASCEND910B, AscPlugin::KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2},
237 {AscPlugin::ShortSocVersion::ASCEND910_95, AscPlugin::KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2},230 {AscPlugin::ShortSocVersion::ASCEND910_95, AscPlugin::KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2},
238- {AscPlugin::ShortSocVersion::KIRINX90, AscPlugin::KernelMetaType::KERNEL_TYPE_MIX_AICORE},
239- {AscPlugin::ShortSocVersion::KIRIN9030, AscPlugin::KernelMetaType::KERNEL_TYPE_MIX_AICORE},
240};231};
241 232 
242const std::unordered_map<std::string, AscPlugin::KernelMetaType> KERNEL_TYPE_MAP_V220 = {233const std::unordered_map<std::string, AscPlugin::KernelMetaType> KERNEL_TYPE_MAP_V220 = {
@@ -67,15 +67,13 @@ int32_t AscAstDeviceAnalyzer::Process()
67 67 
68void AscAstDeviceAnalyzer::InitCompileDeviceArgs(const std::string &source)68void AscAstDeviceAnalyzer::InitCompileDeviceArgs(const std::string &source)
69{69{
70- auto npuArch = InfoManager::GetInstance().GetShortSocVersion();70+ auto shortSoc = InfoManager::GetInstance().GetShortSocVersion();
71 static const std::unordered_map<ShortSocVersion, std::vector<const char*>> DAV_VERSION_MAP = {71 static const std::unordered_map<ShortSocVersion, std::vector<const char*>> DAV_VERSION_MAP = {
72- {ShortSocVersion::ASCEND910B, {"-D__DAV_C220_CUBE__", "-D__CCE_AICORE__=220", "-D__NPU_ARCH__=2201"}},72+ {ShortSocVersion::ASCEND910B, {"-D__DAV_C220_CUBE__", "-D__CCE_AICORE__=220", "-D__NPU_ARCH__=2201", "-D__DAV_CUBE__"}},
73 {ShortSocVersion::ASCEND310P, {"-D__DAV_M200__", "-D__CCE_AICORE__=200", "-D__NPU_ARCH__=2002"}},73 {ShortSocVersion::ASCEND310P, {"-D__DAV_M200__", "-D__CCE_AICORE__=200", "-D__NPU_ARCH__=2002"}},
74 {ShortSocVersion::ASCEND910, {"-D__DAV_C100__", "-D__CCE_AICORE__=100", "-D__NPU_ARCH__=1001"}},74 {ShortSocVersion::ASCEND910, {"-D__DAV_C100__", "-D__CCE_AICORE__=100", "-D__NPU_ARCH__=1001"}},
75 {ShortSocVersion::ASCEND310B, {"-D__DAV_M300__", "-D__CCE_AICORE__=300", "-D__NPU_ARCH__=3002"}},75 {ShortSocVersion::ASCEND310B, {"-D__DAV_M300__", "-D__CCE_AICORE__=300", "-D__NPU_ARCH__=3002"}},
76- {ShortSocVersion::ASCEND910_95, {"-D__DAV_C310__", "-D__CCE_AICORE__=310", "-D__NPU_ARCH__=3101"}},76+ {ShortSocVersion::ASCEND910_95, {"-D__DAV_C310_CUBE__", "-D__CCE_AICORE__=310", "-D__NPU_ARCH__=3101", "-D__DAV_CUBE__"}},
77- {ShortSocVersion::KIRINX90, {"-D__DAV_L300__", "-D__CCE_AICORE__=300", "-D__NPU_ARCH__=3003"}},
78- {ShortSocVersion::KIRIN9030, {"-D__DAV_L311__", "-D__CCE_AICORE__=311", "-D__NPU_ARCH__=3113"}},
79 };77 };
80 78 
81 static const std::vector<std::string> innerOpts = {79 static const std::vector<std::string> innerOpts = {
@@ -87,12 +85,21 @@ void AscAstDeviceAnalyzer::InitCompileDeviceArgs(const std::string &source)
87 "-D__CCE__",85 "-D__CCE__",
88 "-DGM_ADDR= __gm__ uint8_t*",86 "-DGM_ADDR= __gm__ uint8_t*",
89 "-D__gm__= __attribute__((annotate(\"cce_global\")))",87 "-D__gm__= __attribute__((annotate(\"cce_global\")))",
88+ "-D__forceinline__=",
90 "-D__host_aicore__=",89 "-D__host_aicore__=",
90+ "-D__kfc_workspace__=",
91+ "-D__disable_kernel_type_autoinfer__=",
91 "-DASCENDC_DUMP=1",92 "-DASCENDC_DUMP=1",
92 "-D__CHECK_FEATURE_AT_PRECOMPILE",93 "-D__CHECK_FEATURE_AT_PRECOMPILE",
93 "-Dhalf=__fp16",94 "-Dhalf=__fp16",
94 "-Dbfloat16_t=__bf16",95 "-Dbfloat16_t=__bf16",
95 "-D__NPU_DEVICE__",96 "-D__NPU_DEVICE__",
97+ // simt and simd attribute
98+ "-D__simt_callee__=",
99+ "-D__simt_vf__=",
100+ "-D__simd_callee__=",
101+ "-D__simd_vf__=",
102+ "-D__no_simd_vf_fusion__=",
96 // bisheng kernel type attribute103 // bisheng kernel type attribute
97 "-D__mix__(cube, vec)=",104 "-D__mix__(cube, vec)=",
98 "-D__cube__=",105 "-D__cube__=",
@@ -113,7 +120,7 @@ void AscAstDeviceAnalyzer::InitCompileDeviceArgs(const std::string &source)
113 std::vector<std::string> removeOpts = {"-DL2_CACHE_HINT"};120 std::vector<std::string> removeOpts = {"-DL2_CACHE_HINT"};
114 astDeviceArgs_.RemoveOptions(removeOpts);121 astDeviceArgs_.RemoveOptions(removeOpts);
115 astDeviceArgs_.definitions.insert(astDeviceArgs_.definitions.end(), innerDefinitions.begin(), innerDefinitions.end());122 astDeviceArgs_.definitions.insert(astDeviceArgs_.definitions.end(), innerDefinitions.begin(), innerDefinitions.end());
116- const auto& archOptionList = DAV_VERSION_MAP.at(npuArch);123+ const auto& archOptionList = DAV_VERSION_MAP.at(shortSoc);
117 for (const auto& option : archOptionList) {124 for (const auto& option : archOptionList) {
118 astDeviceArgs_.definitions.emplace_back(option);125 astDeviceArgs_.definitions.emplace_back(option);
119 }126 }
@@ -124,6 +124,11 @@ bool ASTDeviceVisitor::VisitCallExpr(clang::CallExpr *exprCall)
124 qualifiedName.find("AscendC::AssertPrint") != std::string::npos) {124 qualifiedName.find("AscendC::AssertPrint") != std::string::npos) {
125 manager.SetHasAssert(true);125 manager.SetHasAssert(true);
126 ASC_LOGD("Found %s call at line: %u, file: %s", qualifiedName.c_str(), pLoc.getLine(), fname);126 ASC_LOGD("Found %s call at line: %u, file: %s", qualifiedName.c_str(), pLoc.getLine(), fname);
127+ } else if (manager.GetShortSocVersion() == ShortSocVersion::ASCEND910_95 &&
128+ (qualifiedName.find("AscendC::Simt::printf") != std::string::npos ||
129+ qualifiedName == "printf")) {
130+ manager.SetHasSimtPrintf(true);
131+ ASC_LOGD("Found %s call at line: %u, file: %s", qualifiedName.c_str(), pLoc.getLine(), fname);
127 }132 }
128 } else if (ule) {133 } else if (ule) {
129 std::string funcName = ule->getName().getAsString();134 std::string funcName = ule->getName().getAsString();
@@ -169,18 +174,6 @@ void StoreFuncKernelType(const AscPlugin::KernelFuncInfo& kernelKey, const std::
169 g_kernelFuncType[kernelKey].first = {iter->second};174 g_kernelFuncType[kernelKey].first = {iter->second};
170 kernelTypeValid = true;175 kernelTypeValid = true;
171 }176 }
172- } else if (shortSoc == ShortSocVersion::KIRINX90) {
173- auto iter = KERNEL_TYPE_MAP_KIRINX90.find(kernelTypeStr);
174- if (iter != KERNEL_TYPE_MAP_KIRINX90.end() && kernelTypeStr == "KERNEL_TYPE_AICORE") {
175- g_kernelFuncType[kernelKey].first = {iter->second};
176- kernelTypeValid = true;
177- }
178- } else if (shortSoc == ShortSocVersion::KIRIN9030) {
179- auto iter = KERNEL_TYPE_MAP_KIRIN9030.find(kernelTypeStr);
180- if (iter != KERNEL_TYPE_MAP_KIRIN9030.end() && kernelTypeStr == "KERNEL_TYPE_AICORE") {
181- g_kernelFuncType[kernelKey].first = {iter->second};
182- kernelTypeValid = true;
183- }
184 }177 }
185 178 
186 if (kernelTypeValid) {179 if (kernelTypeValid) {
@@ -280,6 +273,13 @@ std::pair<std::unordered_set<KernelMetaType>, KfcScene> GetKernelFuncScene(const
280 return {{socDefaultKtype}, kfcFlag}; // Kfc using mix 1:2273 return {{socDefaultKtype}, kfcFlag}; // Kfc using mix 1:2
281 }274 }
282 if (g_kernelFuncType.size() == 1) {275 if (g_kernelFuncType.size() == 1) {
276+ // 910_95 dont support auto type deduction, use default type "mix 1:2"
277+ if (shortSoc == ShortSocVersion::ASCEND910_95) {
278+ ASC_LOGD("Can not find Kernel type, kernel func mangled name: %s at %s:%u, col:%u, using default "
279+ "KERNEL_TYPE_MIX_AIC_1_2", kernelKey.mangledName.c_str(), kernelKey.fileName.c_str(),
280+ kernelKey.lineNum, kernelKey.colNum);
281+ return {{socDefaultKtype}, KfcScene::Close};
282+ }
283 ASC_LOGD("Can not find Kernel type, kernel func mangled name: %s at %s:%u, col:%u, automatic kernel type "283 ASC_LOGD("Can not find Kernel type, kernel func mangled name: %s at %s:%u, col:%u, automatic kernel type "
284 "identification is now enabled", kernelKey.mangledName.c_str(), kernelKey.fileName.c_str(),284 "identification is now enabled", kernelKey.mangledName.c_str(), kernelKey.fileName.c_str(),
285 kernelKey.lineNum, kernelKey.colNum);285 kernelKey.lineNum, kernelKey.colNum);
@@ -48,89 +48,196 @@ KernelTypeResult CheckHasMixKernelFunc()
48 mixOneToTwoWithKfcInfo = {funcInfo.first, fileName, lineNum, colNum};48 mixOneToTwoWithKfcInfo = {funcInfo.first, fileName, lineNum, colNum};
49 }49 }
50 }50 }
51- 51+ if (InfoManager::GetInstance().GetShortSocVersion() != ShortSocVersion::ASCEND910B) {
52- if (res.hasMixOneToOneWithKfc && res.hasMixOneToTwo) {52+ if (res.hasMixOneToOneWithKfc && res.hasMixOneToTwo) {
53- ASC_LOGE("Having kernel function %s with KERNEL_TYPE_MIX_AIC_1_1 in file %s line %u col %u with "53+ ASC_LOGE("Having kernel function %s with KERNEL_TYPE_MIX_AIC_1_1 in file %s line %u col %u with "
54- "REGIST_MATMUL_OBJ and kernel function %s with KERNEL_TYPE_MIX_AIC_1_2 in file %s line %u col %u "54+ "REGIST_MATMUL_OBJ and kernel function %s with KERNEL_TYPE_MIX_AIC_1_2 in file %s line %u col %u "
55- "is not supported.", mixOneToOneWithKfcInfo.mangledName.c_str(), mixOneToOneWithKfcInfo.fileName.c_str(),55+ "is not supported.", mixOneToOneWithKfcInfo.mangledName.c_str(), mixOneToOneWithKfcInfo.fileName.c_str(),
56- mixOneToOneWithKfcInfo.lineNum, mixOneToOneWithKfcInfo.colNum, mixOneToTwoInfo.mangledName.c_str(),56+ mixOneToOneWithKfcInfo.lineNum, mixOneToOneWithKfcInfo.colNum, mixOneToTwoInfo.mangledName.c_str(),
57- mixOneToTwoInfo.fileName.c_str(), mixOneToTwoInfo.lineNum, mixOneToTwoInfo.colNum);57+ mixOneToTwoInfo.fileName.c_str(), mixOneToTwoInfo.lineNum, mixOneToTwoInfo.colNum);
58- return res;58+ return res;
59- }59+ }
60- 60+ if (res.hasMixOneToTwoWithKfc && res.hasMixOneToOne) {
61- if (res.hasMixOneToTwoWithKfc && res.hasMixOneToOne) {61+ ASC_LOGE("Having kernel function %s with KERNEL_TYPE_MIX_AIC_1_1 in file %s line %u col %u and kernel "
62- ASC_LOGE("Having kernel function %s with KERNEL_TYPE_MIX_AIC_1_1 in file %s line %u col %u and kernel "62+ "function %s with KERNEL_TYPE_MIX_AIC_1_2 in file %s line %u col %u with REGIST_MATMUL_OBJ "
63- "function %s with KERNEL_TYPE_MIX_AIC_1_2 in file %s line %u col %u with REGIST_MATMUL_OBJ "63+ "is not supported.", mixOneToOneInfo.mangledName.c_str(), mixOneToOneInfo.fileName.c_str(),
64- "is not supported.", mixOneToOneInfo.mangledName.c_str(), mixOneToOneInfo.fileName.c_str(),64+ mixOneToOneInfo.lineNum, mixOneToOneInfo.colNum, mixOneToTwoWithKfcInfo.mangledName.c_str(),
65- mixOneToOneInfo.lineNum, mixOneToOneInfo.colNum, mixOneToTwoWithKfcInfo.mangledName.c_str(),65+ mixOneToTwoWithKfcInfo.fileName.c_str(), mixOneToTwoWithKfcInfo.lineNum, mixOneToTwoWithKfcInfo.colNum);
66- mixOneToTwoWithKfcInfo.fileName.c_str(), mixOneToTwoWithKfcInfo.lineNum, mixOneToTwoWithKfcInfo.colNum);66+ return res;
67- return res;67+ }
68 }68 }
69 }69 }
70- 
71 ASC_LOGD("KernelTypeResult result: hasMixOneToOne %d, hasMixOneToTwo %d, hasMixOneToOneWithKfc %d, "70 ASC_LOGD("KernelTypeResult result: hasMixOneToOne %d, hasMixOneToTwo %d, hasMixOneToOneWithKfc %d, "
72 "hasMixOneToTwoWithKfc %d.", res.hasMixOneToOne, res.hasMixOneToTwo, res.hasMixOneToOneWithKfc,71 "hasMixOneToTwoWithKfc %d.", res.hasMixOneToOne, res.hasMixOneToTwo, res.hasMixOneToOneWithKfc,
73 res.hasMixOneToTwoWithKfc);72 res.hasMixOneToTwoWithKfc);
74 return res;73 return res;
75}74}
76 75 
77-std::vector<std::string> GetHostCompileOptions()76+inline bool IsMixKernelType(const KernelMetaType kType)
78{77{
79- return {"-std=c++17", InfoManager::GetInstance().GetOptimizeLevel(), "-D__NPU_HOST__", "-DTILING_KEY_VAR=0"};78+ return (kType == KernelMetaType::KERNEL_TYPE_MIX_AIC_1_0 || kType == KernelMetaType::KERNEL_TYPE_MIX_AIV_1_0 ||
79+ kType == KernelMetaType::KERNEL_TYPE_MIX_AIC_1_1 || kType == KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2);
80}80}
81 81 
82-std::vector<std::string> GetDeviceCommonCompileOptions(const KernelTypeResult& kernelTypeRes)82+// Assume mangling name is A. If AIC_ONLY / AIV_ONLY => do not need update
83+// If MIX_AIC_1_0, MIX_AIV_1_0, MIX_AIC_1_1, MIX_AIC_1_2,
84+// then update -D<manglingName>=<manglingName>_mix_aic, -D<manglingName>=<manglingName>_mix_aiv
85+void UpdateManglingNameSuffix(std::vector<std::string>& compileOptions, const CoreType coreType)
83{86{
84 auto& manager = InfoManager::GetInstance();87 auto& manager = InfoManager::GetInstance();
85- std::string cannPath = manager.GetCannPath();88+ ShortSocVersion shortSoc = manager.GetShortSocVersion();
86- std::string optLevel = manager.GetOptimizeLevel();89+ if (shortSoc == ShortSocVersion::ASCEND910B || shortSoc == ShortSocVersion::ASCEND910_95) {
87- ShortSocVersion socVersion = manager.GetShortSocVersion();90+ for (const auto& funcInfo : InfoManager::GetInstance().GetGlobalSymbolInfo()) {
88- std::vector<std::string> deviceCommonOptions = {"-std=c++17", optLevel, "-D__NPU_DEVICE__", "-DTILING_KEY_VAR=0"};91+ std::string manglingName = funcInfo.first;
89- 92+ KernelMetaType kType = std::get<0>(funcInfo.second);
90- if (socVersion == ShortSocVersion::ASCEND910B || socVersion == ShortSocVersion::ASCEND910_95) {93+ bool isMixKernelType = IsMixKernelType(kType);
91- // MIX_1_1 and MIX_1_2 with either one having KFC at same time is not supported94+ if (coreType == CoreType::CUBE && isMixKernelType) {
92- if ((kernelTypeRes.hasMixOneToOneWithKfc && kernelTypeRes.hasMixOneToTwo) ||95+ compileOptions.emplace_back(
93- (kernelTypeRes.hasMixOneToTwoWithKfc && kernelTypeRes.hasMixOneToOne)) {96+ "-D" + manglingName + "=" + manglingName.substr(DEVICE_STUB_PREFIX_LEN) + "_mix_aic");
94- return deviceCommonOptions;97+ } else if (coreType == CoreType::VEC && isMixKernelType) {
98+ compileOptions.emplace_back(
99+ "-D" + manglingName + "=" + manglingName.substr(DEVICE_STUB_PREFIX_LEN) + "_mix_aiv");
100+ } else {
101+ compileOptions.emplace_back("-D" + manglingName + "=" + manglingName.substr(DEVICE_STUB_PREFIX_LEN));
102+ }
95 }103 }
96- 
97- deviceCommonOptions.insert(deviceCommonOptions.end(), {"-mllvm", "-cce-aicore-stack-size=0x8000",
98- "-mllvm", "-cce-aicore-function-stack-size=0x8000", "-mllvm", "-cce-aicore-dcci-insert-for-scalar=false"});
99- 
100- if(manager.IsL2CacheEnabled()) {
101- deviceCommonOptions.emplace_back("-DL2_CACHE_HINT");
102- }
103- // needs to update -D__MIX_CORE_AIC_RATION__, -D__MIX_CORE_MACRO__ based on kernel type info
104- if (kernelTypeRes.hasMixOneToOne || kernelTypeRes.hasMixOneToTwo) {
105- // used for KFC, thus only when type is 1_1 / 1_2
106- deviceCommonOptions.emplace_back("-D__MIX_CORE_MACRO__=1");
107- }
108- if (kernelTypeRes.hasMixOneToOne) {
109- deviceCommonOptions.emplace_back("-D__MIX_CORE_AIC_RATION__=1");
110- }
111- } else if (socVersion == ShortSocVersion::ASCEND310P) {
112- deviceCommonOptions.insert(deviceCommonOptions.end(), {
113- // bisheng will add --cce-mask-opt for 310P in default
114- "-mllvm", "-cce-aicore-fp-ceiling=2",
115- "-mllvm", "-cce-aicore-record-overflow=false", "-mllvm", "-cce-aicore-mask-opt=false"});
116- }
117- 
118- if (manager.IsAutoSyncOn()){
119- deviceCommonOptions.emplace_back("--cce-auto-sync");
120- }
121- if (!manager.UserDumpRequested()) { // user passed -DASCENDC_DUMP=0 in compile args
122- deviceCommonOptions.emplace_back("-DASCENDC_DUMP=0");
123 } else {104 } else {
124- if (manager.IsDumpOn()) {105+ for (const auto& funcInfo : InfoManager::GetInstance().GetGlobalSymbolInfo()) {
125- deviceCommonOptions.emplace_back("-DASCENDC_DUMP=1");106+ std::string manglingName = funcInfo.first;
126- deviceCommonOptions.emplace_back("-DONE_CORE_DUMP_SIZE=" + std::to_string(manager.GetOneCoreDumpSize()));107+ compileOptions.emplace_back("-D" + manglingName + "=" + manglingName.substr(DEVICE_STUB_PREFIX_LEN));
127 }108 }
128 }109 }
129- if (!manager.GetPathInfo().cannVersionHeader.empty()) {110+}
130- deviceCommonOptions.emplace_back("-include");111+ 
131- deviceCommonOptions.emplace_back(manager.GetPathInfo().cannVersionHeader);112+void CompileOptionManager::SetOldPrintOptions(std::vector<std::string>& devSocOpts) const
113+{
114+ if (userDumpStatus_ && isDumpOn_) {
115+ devSocOpts.emplace_back("-DONE_CORE_DUMP_SIZE=" + std::to_string(oneCoreDumpSize_));
132 }116 }
133- return deviceCommonOptions;117+ if (!cannVersionHeader_.empty()) {
118+ devSocOpts.emplace_back("-include");
119+ devSocOpts.emplace_back(cannVersionHeader_);
120+ }
121+}
122+ 
123+template <>
124+std::vector<std::string> CompileOptionManager::GetDeviceCompileOptionsWithSoc<ShortSocVersion::ASCEND910B>(
125+ CoreType coreType) const
126+{
127+ (void)coreType;
128+ std::vector<std::string> devSocOpts = {"-mllvm", "-cce-aicore-stack-size=0x8000",
129+ "-mllvm", "-cce-aicore-function-stack-size=0x8000",
130+ "-mllvm", "-cce-aicore-dcci-insert-for-scalar=false",
131+ "-D__ENABLE_ASCENDC_PRINTF__"};
132+ if (l2CacheOn_) {
133+ devSocOpts.emplace_back("-DL2_CACHE_HINT");
134+ }
135+ return devSocOpts;
136+}
137+ 
138+template <>
139+std::vector<std::string> CompileOptionManager::GetDeviceCompileOptionsWithSoc<ShortSocVersion::ASCEND910_95>(
140+ CoreType coreType) const
141+{
142+ KernelTypeResult kernelTypeRes = CheckHasMixKernelFunc();
143+ if ((kernelTypeRes.hasMixOneToOneWithKfc && kernelTypeRes.hasMixOneToTwo) ||
144+ (kernelTypeRes.hasMixOneToTwoWithKfc && kernelTypeRes.hasMixOneToOne)) {
145+ return {};
146+ }
147+ std::vector<std::string> devSocOpts = {"-mllvm", "-cce-aicore-stack-size=0x8000",
148+ "-mllvm", "-cce-aicore-function-stack-size=0x8000",
149+ "-mllvm", "-cce-aicore-dcci-insert-for-scalar=false"};
150+ if (l2CacheOn_) {
151+ devSocOpts.emplace_back("-DL2_CACHE_HINT");
152+ }
153+ // needs to update -D__MIX_CORE_AIC_RATION__, -D__MIX_CORE_MACRO__ based on kernel type info
154+ if (kernelTypeRes.hasMixOneToOne || kernelTypeRes.hasMixOneToTwo) {
155+ // used for KFC, thus only when type is 1_1 / 1_2
156+ devSocOpts.emplace_back("-D__MIX_CORE_MACRO__=1");
157+ }
158+ if (kernelTypeRes.hasMixOneToOne) {
159+ devSocOpts.emplace_back("-D__MIX_CORE_AIC_RATION__=1");
160+ }
161+ SetOldPrintOptions(devSocOpts);
162+ UpdateManglingNameSuffix(devSocOpts, coreType);
163+ return devSocOpts;
164+}
165+ 
166+template <>
167+std::vector<std::string> CompileOptionManager::GetDeviceCompileOptionsWithSoc<ShortSocVersion::ASCEND310P>(
168+ CoreType coreType) const
169+{
170+ std::vector<std::string> devSocOpts = {// bisheng will add --cce-mask-opt for 310P in default
171+ "-mllvm", "-cce-aicore-fp-ceiling=2",
172+ "-mllvm", "-cce-aicore-record-overflow=false",
173+ "-mllvm", "-cce-aicore-mask-opt=false",
174+ "-D__ENABLE_ASCENDC_PRINTF__"};
175+ 
176+ if (coreType == CoreType::VEC) {
177+ devSocOpts.emplace_back("-D__ENABLE_VECTOR_CORE__");
178+ }
179+ UpdateManglingNameSuffix(devSocOpts, coreType);
180+ return devSocOpts;
181+}
182+ 
183+template<ShortSocVersion soc>
184+void CompileOptionManager::RegisterOptHandler()
185+{
186+ dispatchTable_[soc] = [this](CoreType type) {
187+ return this->GetDeviceCompileOptionsWithSoc<soc>(type);
188+ };
189+}
190+ 
191+void CompileOptionManager::InitDispatchTable()
192+{
193+ RegisterOptHandler<ShortSocVersion::ASCEND910B>();
194+ RegisterOptHandler<ShortSocVersion::ASCEND910_95>();
195+ RegisterOptHandler<ShortSocVersion::ASCEND310P>();
196+}
197+ 
198+CompileOptionManager::CompileOptionManager() :
199+ socVersion_(InfoManager::GetInstance().GetShortSocVersion()),
200+ isAutoSyncOn_(InfoManager::GetInstance().IsAutoSyncOn()),
201+ userDumpStatus_(InfoManager::GetInstance().UserDumpRequested()),
202+ isDumpOn_(InfoManager::GetInstance().IsDumpOn()),
203+ l2CacheOn_(InfoManager::GetInstance().IsL2CacheEnabled()),
204+ oneCoreDumpSize_(InfoManager::GetInstance().GetOneCoreDumpSize()),
205+ optiLevel_(InfoManager::GetInstance().GetOptimizeLevel()),
206+ cannVersionHeader_(InfoManager::GetInstance().GetPathInfo().cannVersionHeader)
207+{
208+ InitDispatchTable();
209+}
210+ 
211+std::vector<std::string> CompileOptionManager::GetDeviceCompileOptions(CoreType type) const
212+{
213+ std::vector<std::string> devSocOpts;
214+ auto it = dispatchTable_.find(socVersion_);
215+ if (it != dispatchTable_.end()) {
216+ devSocOpts = it->second(type); // GetDeviceCompileOptionsWithSoc<socVersion_>
217+ } else {
218+ return {};
219+ }
220+ if (devSocOpts.empty()) {
221+ return {};
222+ }
223+ 
224+ std::vector<std::string> opts = {"-std=c++17", optiLevel_, "-D__NPU_DEVICE__", "-DTILING_KEY_VAR=0"};
225+ opts.emplace_back("--cce-aicore-arch=" + CCE_AICORE_MAP.at({socVersion_, type}));
226+ if (isAutoSyncOn_){
227+ opts.emplace_back("--cce-auto-sync");
228+ }
229+ if (!userDumpStatus_) { // user passed -DASCENDC_DUMP=0 in compile args
230+ opts.emplace_back("-DASCENDC_DUMP=0");
231+ } else if (isDumpOn_) {
232+ opts.emplace_back("-DASCENDC_DUMP=1");
233+ }
234+ opts.insert(opts.end(), devSocOpts.begin(), devSocOpts.end());
235+ return opts;
236+}
237+ 
238+std::vector<std::string> CompileOptionManager::GetHostCompileOptions() const
239+{
240+ return {"-std=c++17", optiLevel_, "-D__NPU_HOST__", "-DTILING_KEY_VAR=0"};
134}241}
135 242 
136} // namespace AscPlugin243} // namespace AscPlugin
Rtools/ascc/asc_plugin/src/asc_dev_funcRegistry_generate.cpptools/ascc/asc_plugin/src/asc_dev_func_registry_generate.cpp+9-49
@@ -9,37 +9,34 @@
9*/9*/
10 10 
11/*!11/*!
12- * \file asc_dev_funcRegistry_generate.cpp12+ * \file asc_dev_func_registry_generate.cpp
13 * \brief13 * \brief
14 */14 */
15 15 
16-#include "asc_dev_funcRegistry_generate.h"16+#include "asc_dev_func_registry_generate.h"
17#include "asc_log.h"17#include "asc_log.h"
18 18 
19#include <sstream>19#include <sstream>
20 20 
21namespace AscPlugin {21namespace AscPlugin {
22constexpr size_t FUNCREG_SIZE_CODE_BUFFER_LEN = 16 * 1024;22constexpr size_t FUNCREG_SIZE_CODE_BUFFER_LEN = 16 * 1024;
23-constexpr const char *FUNC_REGISTER_CODE = R"(#include <stdio.h>23+constexpr const char* FUNC_REGISTER_CODE = R"(#include <stdio.h>
24#include <cstdint>24#include <cstdint>
25extern "C" {25extern "C" {
26uint32_t AllocAscendMemDevice(void **devMem, uint64_t size);26uint32_t AllocAscendMemDevice(void **devMem, uint64_t size);
27uint32_t FreeAscendMemDevice(void *devMem);27uint32_t FreeAscendMemDevice(void *devMem);
28-int32_t AscendFunctionRegister(void *handle, const char *stubFunc);
29-uint32_t GetAscendCoreSyncAddr(void **addr);
30}28}
31namespace Adx {29namespace Adx {
32void AdumpPrintWorkSpace(const void *workSpaceAddr, const size_t dumpWorkSpaceSize,30void AdumpPrintWorkSpace(const void *workSpaceAddr, const size_t dumpWorkSpaceSize,
33 void *stream, const char *opType);31 void *stream, const char *opType);
34} // namespace Adx32} // namespace Adx
35namespace AscPluginGenerator {33namespace AscPluginGenerator {
36-typedef void (*KernelFuncRegister)(void*);34+int32_t BindKernelRegisterFunc(void (*)(void*));
37-int32_t BindKernelRegisterFunc(KernelFuncRegister func);35+uint32_t LaunchAndProfiling(const char *kernelName, uint32_t blockDim, void *stream, void **args, uint32_t size,
38-uint32_t LaunchAndProfiling(36+ uint32_t ktype, const uint32_t ubufDynamicSize);
39- const char *stubFunc, uint32_t blockDim, void *stream, void **args, uint32_t size, uint32_t ktype);
40-void GetHandleUnregisterInst();
41uint32_t ascendc_set_exception_dump_info(uint32_t dumpSize);37uint32_t ascendc_set_exception_dump_info(uint32_t dumpSize);
42} // namespace AscPluginGenerator38} // namespace AscPluginGenerator
39+static const int32_t g_ascend_plugin_register = AscPluginGenerator::BindKernelRegisterFunc(nullptr);
43 40 
44#define ASC_PLUGIN_LAUNCH_LOGE(kernelName, stream, blockDim, fmt, ...) \41#define ASC_PLUGIN_LAUNCH_LOGE(kernelName, stream, blockDim, fmt, ...) \
45 ::printf("[ERROR] [AscPlugin] Kernel: [%s] Stream: [%p] BlockDim: [%u] " fmt "\n", \42 ::printf("[ERROR] [AscPlugin] Kernel: [%s] Stream: [%p] BlockDim: [%u] " fmt "\n", \
@@ -47,59 +44,22 @@ uint32_t ascendc_set_exception_dump_info(uint32_t dumpSize);
47 stream, \44 stream, \
48 blockDim, \45 blockDim, \
49 ##__VA_ARGS__)46 ##__VA_ARGS__)
50- 
51-namespace {
52-struct AscendCBinaryVersion {
53- uint16_t type = 0;
54- uint16_t len = 4;
55- uint32_t version = 0;
56-};
57- 
58-struct AscendCFeatureFlag {
59- uint16_t type = 4;
60- uint16_t len = 4;
61- uint32_t flag = 0;
62-};
63-}
64)";47)";
65 48 
66constexpr const char *KERNEL_BINARY_VERSION_SECTION = R"(49constexpr const char *KERNEL_BINARY_VERSION_SECTION = R"(
67-static const struct AscendCBinaryVersion __ascendc_binary_version__ __attribute__ ((used, section (".ascend.meta"))) =50+static const struct BinaryMetaVersion __ascendc_binary_version__ __attribute__ ((used, section (".ascend.meta"))) =
68 {0, 4, 1};51 {0, 4, 1};
69)";52)";
70 53 
71std::string FunctionRegistryImpl()54std::string FunctionRegistryImpl()
72{55{
73- auto& infoManager = InfoManager::GetInstance();
74 std::stringstream codeSource;56 std::stringstream codeSource;
75 std::string buffer;57 std::string buffer;
76 buffer.reserve(FUNCREG_SIZE_CODE_BUFFER_LEN);58 buffer.reserve(FUNCREG_SIZE_CODE_BUFFER_LEN);
77 codeSource.str(std::move(buffer));59 codeSource.str(std::move(buffer));
78 codeSource << FUNC_REGISTER_CODE;60 codeSource << FUNC_REGISTER_CODE;
79- codeSource << "static void AscFunctionRegister(void* g_kernel_handle)\n{\n";61+ if (InfoManager::GetInstance().HasKernelFunc()) {
80- codeSource << " int32_t retRegister = 0;\n";
81- codeSource << " const char *kernelFuncMangling = nullptr;\n";
82- for (const auto& GlobalSymbolInfo : infoManager.GetGlobalSymbolInfo()) {
83- codeSource << " kernelFuncMangling = \"";
84- codeSource << GlobalSymbolInfo.first.substr(DEVICE_STUB_PREFIX_LEN);
85- codeSource << "\";\n";
86- codeSource << " retRegister = AscendFunctionRegister(g_kernel_handle, kernelFuncMangling);\n";
87- codeSource << " if (retRegister != 0) {\n";
88- codeSource << " ::printf(\"[ERROR] [AscPlugin] Kernel [%s] : function register failure! ret %d\\n\", kernelFuncMangling, "
89- "retRegister);\n";
90- codeSource << " }\n";
91- }
92- codeSource << "}\n";
93- codeSource << "static const int32_t g_regiter_regfunc_ret = "
94- "AscPluginGenerator::BindKernelRegisterFunc(AscFunctionRegister);";
95- if (infoManager.HasKernelFunc()) {
96 codeSource << KERNEL_BINARY_VERSION_SECTION;62 codeSource << KERNEL_BINARY_VERSION_SECTION;
97- if (infoManager.IsFifoDumpOn()) {
98- codeSource << GetAscFeatureMetaSection(FeatureFlag::ASC_PRINT_MASK);
99- }
100- if (infoManager.IsL2CacheEnabled()) {
101- codeSource << GetAscFeatureMetaSection(FeatureFlag::ASC_L2CACHE_HINT_MASK);
102- }
103 }63 }
104 ASC_LOGD("call device stub registry function is: %s", codeSource.str().c_str());64 ASC_LOGD("call device stub registry function is: %s", codeSource.str().c_str());
105 return codeSource.str();65 return codeSource.str();
@@ -111,14 +111,6 @@ void AscDevMetaGenerator::GenMetaSection(const char* globalSymbol, const KernelM
111 genKtypeWithArchMacro("__DAV_C310_CUBE__", "_mix_aic");111 genKtypeWithArchMacro("__DAV_C310_CUBE__", "_mix_aic");
112 genKtypeWithArchMacro("__DAV_C310_VEC__", "_mix_aiv");112 genKtypeWithArchMacro("__DAV_C310_VEC__", "_mix_aiv");
113 }113 }
114- } else if (manager.GetShortSocVersion() == ShortSocVersion::KIRINX90) {
115- if (kernelType == KernelMetaType::KERNEL_TYPE_AICORE) {
116- genKtypeWithArchMacro("__DAV_L300__", "");
117- }
118- } else if (manager.GetShortSocVersion() == ShortSocVersion::KIRIN9030) {
119- if (kernelType == KernelMetaType::KERNEL_TYPE_AICORE) {
120- genKtypeWithArchMacro("__DAV_L311__", "");
121- }
122 }114 }
123}115}
124 116 
@@ -135,7 +127,7 @@ std::string AscDevMetaGenerator::GenCode()
135 GenMetaSection(kernelInfo_.kernelMangledName.c_str(), defaultKtype);127 GenMetaSection(kernelInfo_.kernelMangledName.c_str(), defaultKtype);
136 }128 }
137 129 
138- if (InfoManager::GetInstance().GetShortSocVersion() == ShortSocVersion::ASCEND910B && 130+ if (InfoManager::GetInstance().GetShortSocVersion() == ShortSocVersion::ASCEND910B &&
139 defaultKtype != KernelMetaType::KERNEL_TYPE_AIV_ONLY &&131 defaultKtype != KernelMetaType::KERNEL_TYPE_AIV_ONLY &&
140 defaultKtype != KernelMetaType::KERNEL_TYPE_AIC_ONLY) {132 defaultKtype != KernelMetaType::KERNEL_TYPE_AIC_ONLY) {
141 codeStream_ << GetAscFeatureMetaSection(FeatureFlag::ASC_FFTS_MASK);133 codeStream_ << GetAscFeatureMetaSection(FeatureFlag::ASC_FFTS_MASK);
@@ -25,7 +25,6 @@
25#include "asc_info_manager.h"25#include "asc_info_manager.h"
26 26 
27namespace AscPlugin {27namespace AscPlugin {
28-constexpr size_t CODE_BUFFER_LEN = 16 * 1024;
29namespace {28namespace {
30enum class ParamJoinType : uint8_t {29enum class ParamJoinType : uint8_t {
31 ONLY_NAME = 0,30 ONLY_NAME = 0,
@@ -80,7 +79,8 @@ AscDevStubGenerator::AscDevStubGenerator(const KernelInfo &kernelInfo, const std
80{79{
81 // init stringstream80 // init stringstream
82 std::string buffer;81 std::string buffer;
83- buffer.reserve(CODE_BUFFER_LEN);82+ constexpr size_t codeBuffLen = 16 * 1024;
83+ buffer.reserve(codeBuffLen);
84 codeStream_.str(std::move(buffer));84 codeStream_.str(std::move(buffer));
85 85 
86 // init dump flag86 // init dump flag
@@ -97,7 +97,7 @@ AscDevStubGenerator::AscDevStubGenerator(const KernelInfo &kernelInfo, const std
97std::string AscDevStubGenerator::GetWorkspaceArgName() const97std::string AscDevStubGenerator::GetWorkspaceArgName() const
98{98{
99 for (const auto& param : kernelInfo_.kernelParameters) {99 for (const auto& param : kernelInfo_.kernelParameters) {
100- if (param.attribute.find(std::string("kfc_workspace")) != std::string::npos) {100+ if (param.attribute.find(std::string("cce_kfc_workspace")) != std::string::npos) {
101 ASC_LOGI("Kernel [%s] : the kernel utilizes the workspace.", kernelInfo_.kernelName.c_str());101 ASC_LOGI("Kernel [%s] : the kernel utilizes the workspace.", kernelInfo_.kernelName.c_str());
102 return param.name;102 return param.name;
103 }103 }
@@ -135,6 +135,11 @@ void AscDevStubGenerator::StubFuncDumpAndHardSyncImpl(const bool& isMix, const b
135 codeStream_ << " AscendC::InitDump(false, __ascendc_dump_addr, ONE_CORE_DUMP_SIZE);\n";135 codeStream_ << " AscendC::InitDump(false, __ascendc_dump_addr, ONE_CORE_DUMP_SIZE);\n";
136 }136 }
137 }137 }
138+ const auto& infoManager = InfoManager::GetInstance();
139+ if (infoManager.IsDumpOn() && infoManager.HasSimtPrintf()) {
140+ codeStream_ << " AscendC::Simt::SetSimtDumpWorkspace(__ascendc_dump_addr + "
141+ << "(ONE_CORE_DUMP_SIZE * 108 + 72 * 2048 * 2048));\n";
142+ }
138 if (isHardSync) {143 if (isHardSync) {
139 codeStream_ << " icache_preload(1);\n";144 codeStream_ << " icache_preload(1);\n";
140 codeStream_ << " if (g_sysFftsAddr != nullptr) {\n";145 codeStream_ << " if (g_sysFftsAddr != nullptr) {\n";
@@ -171,7 +176,8 @@ void AscDevStubGenerator::StubFuncWorkSpaceImpl(const bool& isMix)
171 }176 }
172 codeStream_ << " AscendC::SetSysWorkspaceForce(ascendc_workspace_param);\n";177 codeStream_ << " AscendC::SetSysWorkspaceForce(ascendc_workspace_param);\n";
173 codeStream_ << " ascendc_workspace_usr = AscendC::GetUserWorkspace(ascendc_workspace_param);\n";178 codeStream_ << " ascendc_workspace_usr = AscendC::GetUserWorkspace(ascendc_workspace_param);\n";
174- if (isMix && kfcScene_ == KfcScene::Open) {179+ ShortSocVersion shortSoc = InfoManager::GetInstance().GetShortSocVersion();
180+ if (isMix && kfcScene_ == KfcScene::Open && shortSoc != ShortSocVersion::ASCEND910_95) {
175 codeStream_ << " if constexpr (g_coreType == AscendC::AIC) {\n";181 codeStream_ << " if constexpr (g_coreType == AscendC::AIC) {\n";
176 codeStream_ << " matmul::clearWorkspace(ascendc_workspace_param);\n";182 codeStream_ << " matmul::clearWorkspace(ascendc_workspace_param);\n";
177 codeStream_ << " }\n";183 codeStream_ << " }\n";
@@ -19,17 +19,16 @@
19#include "asc_log.h"19#include "asc_log.h"
20 20 
21namespace AscPlugin {21namespace AscPlugin {
22-static constexpr size_t BINARY_SIZE_CODE_BUFFER_LEN = 16 * 1024;
23AscHostBinaryGenerator::AscHostBinaryGenerator()22AscHostBinaryGenerator::AscHostBinaryGenerator()
24{23{
25 std::string buffer;24 std::string buffer;
26- buffer.reserve(BINARY_SIZE_CODE_BUFFER_LEN);25+ constexpr size_t codeBuffLen = 16 * 1024;
26+ buffer.reserve(codeBuffLen);
27 codeStream_.str(std::move(buffer));27 codeStream_.str(std::move(buffer));
28}28}
29 29 
30static const char *BINARY_REGISTER_CODE = R"(#include <stdio.h>30static const char *BINARY_REGISTER_CODE = R"(#include <stdio.h>
31#include <stdint.h>31#include <stdint.h>
32-#include <vector>
33 32 
34namespace AscPluginGenerator {33namespace AscPluginGenerator {
35constexpr unsigned int ascendcExceptionDumpHead = 2U;34constexpr unsigned int ascendcExceptionDumpHead = 2U;
@@ -75,127 +74,72 @@ __attribute__ ((visibility("hidden"))) uint32_t ascendc_set_exception_dump_info(
75} // namespace AscPluginGenerator74} // namespace AscPluginGenerator
76 75 
77extern "C" {76extern "C" {
78-int32_t AscendDevBinaryRegister(const void *fileBuf, size_t fileSize, void **handle);77+int32_t AscendDevBinaryLazyRegister(const char* binBuf, size_t binSize, void** handle);
79-int32_t AscendKernelLaunchWithFlagV2(const char *stubFunc, const uint32_t blockDim, void **args,78+int32_t AscendGetFuncFromBinary(void* const binHandle, const char* kernelName, void** funcHandle);
80- uint32_t size, const void *stream);79+int32_t AscendLaunchKernelWithHostArgs(void* funcHandle,
81-int UnregisterAscendBinary(void *hdl);80+ uint32_t blockDim, void* stream, void* hostArgs, size_t argsSize, uint32_t ubufDynamicSize);
82void StartAscendProf(const char *name, uint64_t *startTime);81void StartAscendProf(const char *name, uint64_t *startTime);
83void ReportAscendProf(const char *name, uint32_t blockDim, uint32_t taskType, const uint64_t startTime);82void ReportAscendProf(const char *name, uint32_t blockDim, uint32_t taskType, const uint64_t startTime);
84bool GetAscendProfStatus();83bool GetAscendProfStatus();
85void AscendProfRegister();84void AscendProfRegister();
85+using rtFuncHandle = void*;
86+uint32_t AscendCGetProfkTypeImpl(const rtFuncHandle funcHandle);
86}87}
87 88 
88namespace {89namespace {
89-char ascendcErrMsg[4096] = {0};90+class AscProfRegister {
90-void *g_kernel_handle = nullptr;
91- 
92-typedef void (*KernelFuncRegister)(void*);
93- 
94-class AscPluginRegFuncRegister {
95public:91public:
96- inline static AscPluginRegFuncRegister& GetInstance()92+static AscProfRegister& GetInstance() {
97- {93+ static AscProfRegister instance;
98- static AscPluginRegFuncRegister instance;
99- return instance;
100- }
101- 
102-public:
103- std::vector<KernelFuncRegister> regFuncCallbackList;
104-private:
105- AscPluginRegFuncRegister() = default;
106- ~AscPluginRegFuncRegister() = default;
107- AscPluginRegFuncRegister(const AscPluginRegFuncRegister&) = delete;
108- AscPluginRegFuncRegister& operator=(const AscPluginRegFuncRegister&) = delete;
109- AscPluginRegFuncRegister(AscPluginRegFuncRegister&&) = delete;
110- AscPluginRegFuncRegister& operator=(AscPluginRegFuncRegister&&) = delete;
111-};
112- 
113-void RegisterKernels(void)
114-{
115- int32_t ret;
116- ret = AscendDevBinaryRegister(fatbinDataPtr, fatbinDataLength, &g_kernel_handle);
117- if (ret != 0) {
118- ::printf("[ERROR] [AscPlugin] Kernel binary register failure! ret %d \n", ret);
119- }
120- AscendProfRegister();
121-}
122- 
123-class KernelHandleGradUnregister {
124-private:
125- KernelHandleGradUnregister() = default;
126- ~KernelHandleGradUnregister() {
127- if (g_kernel_handle) {
128- UnregisterAscendBinary(g_kernel_handle);
129- g_kernel_handle = nullptr;
130- }
131- }
132- KernelHandleGradUnregister(const KernelHandleGradUnregister&) = delete;
133- KernelHandleGradUnregister& operator=(const KernelHandleGradUnregister&) = delete;
134-public:
135- static KernelHandleGradUnregister& GetInstance() {
136- static KernelHandleGradUnregister instance;
137- return instance;
138- }
139-};
140- 
141-class AscendCOperatorRegister {
142-public:
143-static AscendCOperatorRegister& GetInstance() {
144- static AscendCOperatorRegister instance;
145 return instance;94 return instance;
146}95}
147private:96private:
148-AscendCOperatorRegister() {97+AscProfRegister() {
149- RegisterKernels();98+ AscendProfRegister();
150- const auto& inst = AscPluginRegFuncRegister::GetInstance();
151- for (auto func : inst.regFuncCallbackList) {
152- func(g_kernel_handle);
153- }
154}99}
155-~AscendCOperatorRegister() = default;100+~AscProfRegister() = default;
156-AscendCOperatorRegister(const AscendCOperatorRegister&) = delete;101+AscProfRegister(const AscProfRegister&) = delete;
157-AscendCOperatorRegister& operator=(const AscendCOperatorRegister&) = delete;102+AscProfRegister& operator=(const AscProfRegister&) = delete;
158};103};
159 104 
160} // namespace105} // namespace
161 106 
162namespace AscPluginGenerator {107namespace AscPluginGenerator {
163-__attribute__ ((visibility("hidden"))) int32_t BindKernelRegisterFunc(KernelFuncRegister func)108+__attribute__ ((visibility("hidden"))) int32_t BindKernelRegisterFunc(void (*)(void*)) { return 0; }
164-{
165- auto& inst = AscPluginRegFuncRegister::GetInstance();
166- inst.regFuncCallbackList.emplace_back(func);
167- return 0;
168-}
169 109 
170-__attribute__ ((visibility("hidden"))) void GetHandleUnregisterInst() {110+__attribute__ ((visibility("hidden"))) uint32_t LaunchAndProfiling(const char *kernelName, uint32_t blockDim,
171- auto& regMng = KernelHandleGradUnregister::GetInstance();111+ void *stream, void **args, uint32_t size, uint32_t ktype, const uint32_t ubufDynamicSize)
172-}
173- 
174-__attribute__ ((visibility("hidden"))) uint32_t LaunchAndProfiling(
175- const char *stubFunc, uint32_t blockDim, void *stream, void **args, uint32_t size, uint32_t ktype)
176{112{
177- const auto& reg = AscendCOperatorRegister::GetInstance();113+ static auto& reg = AscProfRegister::GetInstance();
178- uint64_t startTime;114+ void* binHandle = nullptr;
179- const char *name = stubFunc;115+ int32_t ret = AscendDevBinaryLazyRegister(fatbinDataPtr, fatbinDataLength, &binHandle);
180- bool profStatus = GetAscendProfStatus();116+ if (ret != 0) {
181- if (profStatus) {117+ ::printf("[ERROR] [AscPlugin] Kernel binary register failure! ret %d \n", ret);
182- StartAscendProf(name, &startTime);
183 }118 }
184- if (g_kernel_handle == nullptr) {119+ void* funcHandle = nullptr;
185- ::printf("[ERROR] [AscPlugin] %s\n", ascendcErrMsg);120+ ret = AscendGetFuncFromBinary(binHandle, kernelName, &funcHandle);
121+ if (ret != 0) {
122+ ::printf("[ERROR] [AscPlugin] Get kernel function failure! ret %d \n", ret);
186 return 1;123 return 1;
187 }124 }
188- int32_t retLaunch = AscendKernelLaunchWithFlagV2(stubFunc, blockDim, args, size, stream);125+ uint64_t startTime;
189- if (retLaunch != 0) {126+ bool profStatus = GetAscendProfStatus();
190- ::printf("[ERROR] [AscPlugin] AscendKernelLaunchWithFlagV2 ret %u\n", retLaunch);127+ if (profStatus) {
128+ ktype = AscendCGetProfkTypeImpl(funcHandle);
129+ StartAscendProf(kernelName, &startTime);
130+ }
131+ ret = AscendLaunchKernelWithHostArgs(funcHandle, blockDim, stream, (void*)args, size, ubufDynamicSize);
132+ if (ret != 0) {
133+ ::printf("[ERROR] [AscPlugin] Launch kernel failure! ret %u\n", ret);
191 }134 }
192 if (profStatus) {135 if (profStatus) {
193- ReportAscendProf(name, blockDim, ktype, startTime);136+ ReportAscendProf(kernelName, blockDim, ktype, startTime);
194 }137 }
195- return retLaunch;138+ return ret;
196}139}
197 140 
198} // namespace AscPluginGenerator141} // namespace AscPluginGenerator
142+ 
199)";143)";
200 144 
201std::string AscHostBinaryGenerator::GenCode()145std::string AscHostBinaryGenerator::GenCode()
@@ -18,6 +18,7 @@
18#include <string>18#include <string>
19#include <vector>19#include <vector>
20#include <atomic>20#include <atomic>
21+#include <cstdio>
21 22 
22#include "asc_log.h"23#include "asc_log.h"
23#include "asc_utils.h"24#include "asc_utils.h"
@@ -45,18 +46,31 @@ public:
45 }46 }
46};47};
47AscHostStubGenerator::AscHostStubGenerator(const KernelInfo& kernelInfo,48AscHostStubGenerator::AscHostStubGenerator(const KernelInfo& kernelInfo,
48- const std::unordered_set<KernelMetaType>& kernelType) : kernelInfo_(kernelInfo), kernelType_(kernelType) {}49+ const std::unordered_set<KernelMetaType>& kernelType) : kernelInfo_(kernelInfo), kernelType_(kernelType)
50+{
51+ // init stringstream
52+ std::string buffer;
53+ constexpr size_t codeBuffLen = 16 * 1024;
54+ buffer.reserve(codeBuffLen);
55+ kernelCallStub_.str(std::move(buffer));
56+}
49 57 
50-std::string AscHostStubGenerator::GenStubFuncDecl(bool hasNameSpace, bool hasAnonymousSpace) const58+std::string AscHostStubGenerator::GenStubFuncDecl() const
51{59{
52 std::string functionEntryReplace = "";60 std::string functionEntryReplace = "";
53- std::string paramsList = "(uint32_t __ascendc_blockDim, void* __ascendc_hold, void* __ascendc_stream";61+ auto &infoManager = InfoManager::GetInstance();
62+ ShortSocVersion shortSoc = infoManager.GetShortSocVersion();
63+ std::string paramsList = "";
64+ if (shortSoc == ShortSocVersion::ASCEND910_95 && infoManager.HasUbufDynamicSize()) {
65+ paramsList = "(uint32_t __ascendc_blockDim, uint32_t __ascendc_ubufDynamicSize, void* __ascendc_stream";
66+ } else {
67+ paramsList = "(uint32_t __ascendc_blockDim, void* __ascendc_hold, void* __ascendc_stream";
68+ }
54 for (auto &param : kernelInfo_.kernelParameters) {69 for (auto &param : kernelInfo_.kernelParameters) {
55 paramsList += ", " + param.type + " " + param.name;70 paramsList += ", " + param.type + " " + param.name;
56 }71 }
57 paramsList += ")";72 paramsList += ")";
58- std::string kernelNameSpace = "";73+ if (hasAnonymousSpace_) {
59- if (hasAnonymousSpace) {
60 for (const auto& spaceName : kernelInfo_.namespaces) {74 for (const auto& spaceName : kernelInfo_.namespaces) {
61 if (spaceName == std::string(ANONYMOUS_NAME)) {75 if (spaceName == std::string(ANONYMOUS_NAME)) {
62 functionEntryReplace += "namespace {\n";76 functionEntryReplace += "namespace {\n";
@@ -64,12 +78,7 @@ std::string AscHostStubGenerator::GenStubFuncDecl(bool hasNameSpace, bool hasAno
64 functionEntryReplace += "namespace " + spaceName + " {\n";78 functionEntryReplace += "namespace " + spaceName + " {\n";
65 }79 }
66 }80 }
67- } else {
68- for (auto &nameSpace : kernelInfo_.namespaces) {
69- kernelNameSpace += nameSpace + "::";
70- }
71 }81 }
72- std::string kernelName = hasNameSpace ? kernelNameSpace + kernelInfo_.kernelName : kernelInfo_.kernelName;
73 std::string tempParamDecl;82 std::string tempParamDecl;
74 if (kernelInfo_.isTemplate) {83 if (kernelInfo_.isTemplate) {
75 tempParamDecl = "template<";84 tempParamDecl = "template<";
@@ -82,9 +91,9 @@ std::string AscHostStubGenerator::GenStubFuncDecl(bool hasNameSpace, bool hasAno
82 tempParamDecl += ">";91 tempParamDecl += ">";
83 }92 }
84 if (!kernelInfo_.isTemplate) {93 if (!kernelInfo_.isTemplate) {
85- functionEntryReplace += "void " + kernelName + paramsList;94+ functionEntryReplace += "void " + kernelNameWithNameSpace_ + paramsList;
86 } else {95 } else {
87- functionEntryReplace += tempParamDecl + " void " + kernelName + paramsList;96+ functionEntryReplace += tempParamDecl + " void " + kernelNameWithNameSpace_ + paramsList;
88 }97 }
89 return functionEntryReplace;98 return functionEntryReplace;
90}99}
@@ -146,86 +155,121 @@ inline std::string MapParamTypeToVoid(std::string paramType)
146 return (paramType == "uint8_t *" || paramType == "unsigned char *") ? "void*" : paramType;155 return (paramType == "uint8_t *" || paramType == "unsigned char *") ? "void*" : paramType;
147}156}
148 157 
158+void AscHostStubGenerator::ParseKernelName()
159+{
160+ // judge the anonymous space
161+ auto it = std::find(kernelInfo_.namespaces.begin(), kernelInfo_.namespaces.end(), std::string(ANONYMOUS_NAME));
162+ if (it != kernelInfo_.namespaces.end()) {
163+ hasAnonymousSpace_ = true;
164+ }
165+ std::string kernelNameSpace = "";
166+ if (!hasAnonymousSpace_) {
167+ for (auto &nameSpace : kernelInfo_.namespaces) {
168+ kernelNameSpace += nameSpace + "::";
169+ }
170+ }
171+ kernelNameWithNameSpace_ = hasNameSpace_ ? kernelNameSpace + kernelInfo_.kernelName : kernelInfo_.kernelName;
172+}
173+ 
149void AscHostStubGenerator::GenStubFuncImpl()174void AscHostStubGenerator::GenStubFuncImpl()
150{175{
151- auto &infoManager = InfoManager::GetInstance();176+ auto& infoManager = InfoManager::GetInstance();
152 uint32_t maxCoreNum = infoManager.GetMaxCoreNum();177 uint32_t maxCoreNum = infoManager.GetMaxCoreNum();
153 bool isSupportFifoDump = infoManager.IsSupportFifoDump();178 bool isSupportFifoDump = infoManager.IsSupportFifoDump();
154 KernelMetaType defaultKtype = ExtractKernelType(kernelType_);179 KernelMetaType defaultKtype = ExtractKernelType(kernelType_);
155- std::ostringstream funcImplCode;180+ kernelCallStub_ << GenStubFuncDecl() << "\n{\n";
156- bool hasAnonymous = false;181+ kernelCallStub_ << " struct {\n";
157- auto it = std::find(kernelInfo_.namespaces.begin(), kernelInfo_.namespaces.end(), std::string(ANONYMOUS_NAME));
158- if (it != kernelInfo_.namespaces.end()) {
159- hasAnonymous = true;
160- }
161- funcImplCode << GenStubFuncDecl(/* hasNameSpace = */true, hasAnonymous) << "\n{\n";
162- funcImplCode << " struct {\n";
163 if (!isSupportFifoDump && infoManager.IsDumpOn()) {182 if (!isSupportFifoDump && infoManager.IsDumpOn()) {
164- funcImplCode << " void* __ascendc_dump;\n";183+ kernelCallStub_ << " void* __ascendc_dump;\n";
165 }184 }
166- for (auto &param : kernelInfo_.kernelParameters) {185+ for (auto& param : kernelInfo_.kernelParameters) {
167- funcImplCode << " alignas(((alignof(" << MapParamTypeToVoid(param.type) << ") + 3) >> 2) << 2) "186+ kernelCallStub_ << " alignas(((alignof(" << MapParamTypeToVoid(param.type) << ") + 3) >> 2) << 2) "
168- << MapParamTypeToVoid(param.type) << " " << param.name << ";\n";187+ << MapParamTypeToVoid(param.type) << " " << param.name << ";\n";
169 }188 }
170- funcImplCode << " } __ascendc_args {";189+ kernelCallStub_ << " } __ascendc_args {";
171 if (!isSupportFifoDump && infoManager.IsDumpOn()) {190 if (!isSupportFifoDump && infoManager.IsDumpOn()) {
172- funcImplCode << "nullptr, ";191+ kernelCallStub_ << "nullptr, ";
173 }192 }
174- for (auto &param : kernelInfo_.kernelParameters) {193+ for (auto& param : kernelInfo_.kernelParameters) {
175- funcImplCode << param.name << ", ";194+ kernelCallStub_ << param.name << ", ";
176 }195 }
177- funcImplCode << "};\n";196+ kernelCallStub_ << "};\n";
178 197 
179 // args declare code198 // args declare code
180- funcImplCode << " uint32_t __ascendc_ret;\n";199+ kernelCallStub_ << " uint32_t __ascendc_ret;\n";
181 if (!isSupportFifoDump && infoManager.IsDumpOn()) {200 if (!isSupportFifoDump && infoManager.IsDumpOn()) {
182- funcImplCode << " constexpr uint32_t __ascendc_one_core_dump_size = "201+ kernelCallStub_ << " constexpr uint32_t __ascendc_one_core_dump_size = "
183- << std::to_string(infoManager.GetOneCoreDumpSize()) << ";\n";202+ << std::to_string(infoManager.GetOneCoreDumpSize()) << ";\n";
184- funcImplCode << " AllocAscendMemDevice(&(__ascendc_args.__ascendc_dump), __ascendc_one_core_dump_size * "203+ if (infoManager.HasSimtPrintf()) {
185- << maxCoreNum << ");\n";204+ kernelCallStub_
186- }205+ << " AllocAscendMemDevice(&(__ascendc_args.__ascendc_dump), __ascendc_one_core_dump_size * "
187- funcImplCode << " const char* __ascendc_name = \"" << kernelInfo_.kernelName << "\";\n";206+ << maxCoreNum << " + 72 * 2048 * 2048);\n";
188- 207+ } else {
189- // when no template, only has 1 kernel type208+ kernelCallStub_
190- funcImplCode << " uint32_t __ascendc_kType = " << KTYPE_TO_LAUNCH_PARAMS.at(defaultKtype) << ";\n";209+ << " AllocAscendMemDevice(&(__ascendc_args.__ascendc_dump), __ascendc_one_core_dump_size * "
191- funcImplCode << ManglingNameJudgeCode();210+ << maxCoreNum << ");\n";
192- 211+ }
193- if (!isSupportFifoDump && infoManager.IsDumpOn() && infoManager.HasAssert()) {212+ }
194- funcImplCode << " __ascendc_ret = "213+ kernelCallStub_ << " const char* __ascendc_name = \"" << kernelInfo_.kernelName << "\";\n";
195- "AscPluginGenerator::ascendc_set_exception_dump_info(__ascendc_one_core_dump_size);\n";214+ 
196- funcImplCode << " if(__ascendc_ret != 0) {\n";215+ // when no template, only has 1 kernel type
197- funcImplCode << " ASC_PLUGIN_LAUNCH_LOGE(__ascendc_name, __ascendc_stream, __ascendc_blockDim, "216+ kernelCallStub_ << " uint32_t __ascendc_kType = " << KTYPE_TO_LAUNCH_PARAMS.at(defaultKtype) << ";\n";
198- "\"init assert dump failure!\");\n";217+ kernelCallStub_ << ManglingNameJudgeCode();
199- funcImplCode << " return;\n";218+ 
200- funcImplCode << " }\n";219+ if (!isSupportFifoDump && infoManager.IsDumpOn() && infoManager.HasAssert()) {
201- }220+ kernelCallStub_ << " __ascendc_ret = "
202- funcImplCode << " __ascendc_ret = AscPluginGenerator::LaunchAndProfiling(__ascendc_manglingName, "221+ "AscPluginGenerator::ascendc_set_exception_dump_info(__ascendc_one_core_dump_size);\n";
203- "__ascendc_blockDim, __ascendc_stream, (void **)&__ascendc_args, sizeof(__ascendc_args), __ascendc_kType);\n";222+ kernelCallStub_ << " if(__ascendc_ret != 0) {\n";
204- funcImplCode << " if(__ascendc_ret != 0) {\n";223+ kernelCallStub_ << " ASC_PLUGIN_LAUNCH_LOGE(__ascendc_name, __ascendc_stream, __ascendc_blockDim, "
205- funcImplCode << " ASC_PLUGIN_LAUNCH_LOGE(__ascendc_name, __ascendc_stream, __ascendc_blockDim, "224+ "\"init assert dump failure!\");\n";
206- "\"kernel launch failure!\");\n";225+ kernelCallStub_ << " return;\n";
207- funcImplCode << " return;\n";226+ kernelCallStub_ << " }\n";
208- funcImplCode << " }\n";227+ }
209- funcImplCode << " AscPluginGenerator::GetHandleUnregisterInst();\n";228+ const char* fmtLaunchAndProfiling =
210- if (!isSupportFifoDump && infoManager.IsDumpOn() && infoManager.HasPrintf()) {229+ " __ascendc_ret = AscPluginGenerator::LaunchAndProfiling(__ascendc_manglingName, "
211- funcImplCode << " Adx::AdumpPrintWorkSpace(__ascendc_args.__ascendc_dump, __ascendc_one_core_dump_size * "230+ "__ascendc_blockDim, __ascendc_stream, (void **)&__ascendc_args, sizeof(__ascendc_args), "
212- << maxCoreNum << ", __ascendc_stream, __ascendc_name);\n";231+ "__ascendc_kType, %s);\n";
213- }232+ constexpr uint32_t bufMaxSize = 512;
214- if (!isSupportFifoDump && infoManager.IsDumpOn()) {233+ char buffer[bufMaxSize];
215- funcImplCode << " FreeAscendMemDevice(__ascendc_args.__ascendc_dump);\n";234+ ShortSocVersion shortSoc = infoManager.GetShortSocVersion();
216- }235+ if (shortSoc == ShortSocVersion::ASCEND910_95 && infoManager.HasUbufDynamicSize()) {
217- funcImplCode << "}\n";236+ snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1, fmtLaunchAndProfiling, "__ascendc_ubufDynamicSize");
218- if (hasAnonymous) {237+ } else {
219- for (size_t i = 0; i < kernelInfo_.namespaces.size(); ++i) {238+ snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1, fmtLaunchAndProfiling, "0");
220- funcImplCode << "}\n";239+ }
240+ kernelCallStub_ << buffer;
241+ 
242+ kernelCallStub_ << " if(__ascendc_ret != 0) {\n";
243+ kernelCallStub_ << " ASC_PLUGIN_LAUNCH_LOGE(__ascendc_name, __ascendc_stream, __ascendc_blockDim, "
244+ "\"kernel launch failure!\");\n";
245+ kernelCallStub_ << " return;\n";
246+ kernelCallStub_ << " }\n";
247+ if (!isSupportFifoDump && infoManager.IsDumpOn() && (infoManager.HasPrintf() || infoManager.HasSimtPrintf())) {
248+ if (infoManager.HasSimtPrintf()) {
249+ kernelCallStub_
250+ << " Adx::AdumpPrintWorkSpace(__ascendc_args.__ascendc_dump, __ascendc_one_core_dump_size * "
251+ << maxCoreNum << " + 72 * 2048 * 2048, __ascendc_stream, __ascendc_name);\n";
252+ } else {
253+ kernelCallStub_
254+ << " Adx::AdumpPrintWorkSpace(__ascendc_args.__ascendc_dump, __ascendc_one_core_dump_size * "
255+ << maxCoreNum << ", __ascendc_stream, __ascendc_name);\n";
256+ }
257+ }
258+ if (!isSupportFifoDump && infoManager.IsDumpOn()) {
259+ kernelCallStub_ << " FreeAscendMemDevice(__ascendc_args.__ascendc_dump);\n";
260+ }
261+ kernelCallStub_ << "}\n";
262+ if (hasAnonymousSpace_) {
263+ for (size_t i = 0; i < kernelInfo_.namespaces.size(); ++i) {
264+ kernelCallStub_ << "}\n";
221 }265 }
222 }266 }
223- kernelCallStub_ << funcImplCode.str();
224}267}
225 268 
226std::string AscHostStubGenerator::GenCode()269std::string AscHostStubGenerator::GenCode()
227{270{
228 ASC_LOGI("Kernel [%s] : generate host stub.", kernelInfo_.kernelName.c_str());271 ASC_LOGI("Kernel [%s] : generate host stub.", kernelInfo_.kernelName.c_str());
272+ ParseKernelName();
229 GenStubFuncImpl();273 GenStubFuncImpl();
230 ASC_LOGD("type judge code is [\n%s\n]", typeJudgePreCode_.str().c_str());274 ASC_LOGD("type judge code is [\n%s\n]", typeJudgePreCode_.str().c_str());
231 ASC_LOGD("host stub code is [\n%s\n]", kernelCallStub_.str().c_str());275 ASC_LOGD("host stub code is [\n%s\n]", kernelCallStub_.str().c_str());
@@ -264,6 +264,11 @@ void InfoManager::SetHasPrintf(const bool hasPrintf)
264 hasPrintf_ = hasPrintf;264 hasPrintf_ = hasPrintf;
265}265}
266 266 
267+void InfoManager::SetHasSimtPrintf(const bool hasSimtPrintf)
268+{
269+ hasSimtPrintf_ = hasSimtPrintf;
270+}
271+ 
267void InfoManager::SetHasAssert(const bool hasAssert)272void InfoManager::SetHasAssert(const bool hasAssert)
268{273{
269 hasAssert_ = hasAssert;274 hasAssert_ = hasAssert;
@@ -384,14 +389,24 @@ bool InfoManager::HasPrintf() const
384 return hasPrintf_;389 return hasPrintf_;
385}390}
386 391 
392+bool InfoManager::HasSimtPrintf() const
393+{
394+ return hasSimtPrintf_;
395+}
396+ 
387bool InfoManager::HasAssert() const397bool InfoManager::HasAssert() const
388{398{
389 return hasAssert_;399 return hasAssert_;
390}400}
391 401 
402+bool InfoManager::HasUbufDynamicSize() const
403+{
404+ return hasUbufDynamicSize_;
405+}
406+ 
392bool InfoManager::IsDumpOn() const407bool InfoManager::IsDumpOn() const
393{408{
394- return userDumpStatus_ && (hasPrintf_ || hasAssert_);409+ return userDumpStatus_ && (hasPrintf_ || hasAssert_ || hasSimtPrintf_);
395}410}
396 411 
397bool InfoManager::IsFifoDumpOn() const412bool InfoManager::IsFifoDumpOn() const
@@ -421,7 +436,7 @@ bool InfoManager::IsAutoSyncOn() const
421 436 
422bool InfoManager::IsSupportFifoDump() const437bool InfoManager::IsSupportFifoDump() const
423{438{
424- return shortSocVersion_ == ShortSocVersion::ASCEND910B;439+ return shortSocVersion_ == ShortSocVersion::ASCEND910B || shortSocVersion_ == ShortSocVersion::ASCEND310P;
425}440}
426 441 
427bool InfoManager::HasKernelFunc() const442bool InfoManager::HasKernelFunc() const
@@ -14,7 +14,7 @@
14 */14 */
15#include "asc_interface.h"15#include "asc_interface.h"
16#include "asc_dev_section_generate.h"16#include "asc_dev_section_generate.h"
17-#include "asc_dev_funcRegistry_generate.h"17+#include "asc_dev_func_registry_generate.h"
18#include "asc_info_manager.h"18#include "asc_info_manager.h"
19#include "asc_ast_utils.h"19#include "asc_ast_utils.h"
20#include "asc_ast_device_analyzer.h"20#include "asc_ast_device_analyzer.h"
@@ -32,6 +32,7 @@ namespace AscPlugin {
32 32 
33namespace {33namespace {
34// pluginPath Example: /cann version/x86_64-linux/lib64/plugin/asc/libasc_plugin.so34// pluginPath Example: /cann version/x86_64-linux/lib64/plugin/asc/libasc_plugin.so
35+// cannPath: directory cann version or directory latest
35std::string ExtractCannPath(const std::string& pluginPath)36std::string ExtractCannPath(const std::string& pluginPath)
36{37{
37 const std::vector<std::string> potentialPath = {38 const std::vector<std::string> potentialPath = {
@@ -74,49 +75,6 @@ uint32_t InitCannPath()
74 return cannPathInit;75 return cannPathInit;
75}76}
76 77 
77-const std::string& GetCceAicoreArch(const CoreType coreType)
78-{
79- auto& manager = InfoManager::GetInstance();
80- ShortSocVersion soc = manager.GetShortSocVersion();
81- return CCE_AICORE_MAP.at({soc, coreType});
82-}
83- 
84-inline bool IsMixKernelType(const KernelMetaType kType)
85-{
86- return (kType == KernelMetaType::KERNEL_TYPE_MIX_AIC_1_0 || kType == KernelMetaType::KERNEL_TYPE_MIX_AIV_1_0 ||
87- kType == KernelMetaType::KERNEL_TYPE_MIX_AIC_1_1 || kType == KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2);
88-}
89- 
90-// Assume mangling name is A. If AIC_ONLY / AIV_ONLY => do not need update
91-// If MIX_AIC_1_0, MIX_AIV_1_0, MIX_AIC_1_1, MIX_AIC_1_2,
92-// then update -D<manglingName>=<manglingName>_mix_aic, -D<manglingName>=<manglingName>_mix_aiv
93-void UpdateManglingNameSuffix(std::vector<std::string>& compileOptions, const CoreType coreType)
94-{
95- auto& manager = InfoManager::GetInstance();
96- ShortSocVersion shortSoc = manager.GetShortSocVersion();
97- if (shortSoc == ShortSocVersion::ASCEND910B || shortSoc == ShortSocVersion::ASCEND910_95) {
98- for (const auto& funcInfo : InfoManager::GetInstance().GetGlobalSymbolInfo()) {
99- std::string manglingName = funcInfo.first;
100- KernelMetaType kType = std::get<0>(funcInfo.second);
101- bool isMixKernelType = IsMixKernelType(kType);
102- if (coreType == CoreType::CUBE && isMixKernelType) {
103- compileOptions.emplace_back(
104- "-D" + manglingName + "=" + manglingName.substr(DEVICE_STUB_PREFIX_LEN) + "_mix_aic");
105- } else if (coreType == CoreType::VEC && isMixKernelType) {
106- compileOptions.emplace_back(
107- "-D" + manglingName + "=" + manglingName.substr(DEVICE_STUB_PREFIX_LEN) + "_mix_aiv");
108- } else {
109- compileOptions.emplace_back("-D" + manglingName + "=" + manglingName.substr(DEVICE_STUB_PREFIX_LEN));
110- }
111- }
112- } else {
113- for (const auto& funcInfo : InfoManager::GetInstance().GetGlobalSymbolInfo()) {
114- std::string manglingName = funcInfo.first;
115- compileOptions.emplace_back("-D" + manglingName + "=" + manglingName.substr(DEVICE_STUB_PREFIX_LEN));
116- }
117- }
118-}
119- 
120void GenerateAclrtHeader(const std::string& headerPath)78void GenerateAclrtHeader(const std::string& headerPath)
121{79{
122 if (PathCheck(headerPath.c_str(), true) == PathStatus::NOT_EXIST) {80 if (PathCheck(headerPath.c_str(), true) == PathStatus::NOT_EXIST) {
@@ -230,11 +188,13 @@ int32_t PluginPrologue(const char** result, const char* config)
230 manager.SetCompileArgs(configInfo.compileArgs);188 manager.SetCompileArgs(configInfo.compileArgs);
231 manager.SetSourceFile(configInfo.source);189 manager.SetSourceFile(configInfo.source);
232 190 
233- // do AST analyze to extract kernel type and printf/assert191+ if (manager.GetShortSocVersion() != ShortSocVersion::ASCEND910B) {
234- AscPlugin::AscAstDeviceAnalyzer deviceAnalyzer(configInfo.source);192+ // do AST analyze to extract kernel type and printf/assert
235- if (deviceAnalyzer.Process() != ASC_SUCCESS) {193+ AscPlugin::AscAstDeviceAnalyzer deviceAnalyzer(configInfo.source);
236- ASC_LOGE("AscAstAnalyzer run failed. Please check log.");194+ if (deviceAnalyzer.Process() != ASC_SUCCESS) {
237- return ASC_FAILURE;195+ ASC_LOGE("AscAstAnalyzer run failed. Please check log.");
196+ return ASC_FAILURE;
197+ }
238 }198 }
239 199 
240 if (!manager.GetAclrtHeaderPath().empty()) {200 if (!manager.GetAclrtHeaderPath().empty()) {
@@ -259,13 +219,35 @@ int32_t PluginGenKernel(const char** result, const char* info)
259 if (fromJsonRes != ASC_SUCCESS) {219 if (fromJsonRes != ASC_SUCCESS) {
260 return fromJsonRes;220 return fromJsonRes;
261 }221 }
262- static auto flag = InfoManager::GetInstance().SetKernelFuncFlag();222+ auto &manager = InfoManager::GetInstance();
223+ static auto flag = manager.SetKernelFuncFlag();
263 (void)flag;224 (void)flag;
264- const auto& [kernelType, kfcScene] = GetKernelFuncScene(kernelInfo);
265 225 
266- const auto [deviceResult, deviceStub, metaInfo] = GetDeviceCode(kernelInfo, kernelType, kfcScene);226+ std::string deviceStub;
267- if (deviceResult != 0) {227+ std::string metaInfo;
268- return ASC_FAILURE;228+ std::unordered_set<KernelMetaType> kernelType;
229+ if (manager.GetShortSocVersion() != ShortSocVersion::ASCEND910B) { // deviceStub generate by bisheng in 71
230+ auto &&[kType, kfcScene] = GetKernelFuncScene(kernelInfo);
231+ auto &&[deviceResult, devStub, meta] = GetDeviceCode(kernelInfo, kType, kfcScene);
232+ if (deviceResult != 0) {
233+ return ASC_FAILURE;
234+ }
235+ deviceStub = std::move(devStub);
236+ metaInfo = std::move(meta);
237+ kernelType = std::move(kType);
238+ } else {
239+ if (kernelInfo.isTemplate) {
240+ for (const auto& tmpInst : kernelInfo.templateInstances) {
241+ manager.AddGlobalSymbolInfo(std::string(DEVICE_STUB_PREFIX) + tmpInst.instanceMangledName,
242+ KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2, kernelInfo.fileName, kernelInfo.lineNum, kernelInfo.colNum,
243+ KfcScene::Close);
244+ }
245+ } else {
246+ manager.AddGlobalSymbolInfo(std::string(DEVICE_STUB_PREFIX) + kernelInfo.kernelMangledName,
247+ KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2, kernelInfo.fileName, kernelInfo.lineNum, kernelInfo.colNum,
248+ KfcScene::Close);
249+ }
250+ kernelType = {KernelMetaType::KERNEL_TYPE_MIX_AIC_1_2};
269 }251 }
270 252 
271 std::string hostStub = GetHostStubCode(kernelInfo, kernelType);253 std::string hostStub = GetHostStubCode(kernelInfo, kernelType);
@@ -283,28 +265,14 @@ int32_t PluginEpilogue(const char** result)
283{265{
284 ASC_CHECK_NULLPTR(result, "PluginEpilogue");266 ASC_CHECK_NULLPTR(result, "PluginEpilogue");
285 267 
286- KernelTypeResult kernelTypeRes = CheckHasMixKernelFunc();268+ CompileOptionManager mng = CompileOptionManager();
287- // MIX_1_1 and MIX_1_2 with either one having KFC at same time is not supported269+ auto deviceCubeExtraCompileOptions = mng.GetDeviceCompileOptions(CoreType::CUBE);
288- if ((kernelTypeRes.hasMixOneToOneWithKfc && kernelTypeRes.hasMixOneToTwo) ||270+ auto deviceVecExtraCompileOptions = mng.GetDeviceCompileOptions(CoreType::VEC);
289- (kernelTypeRes.hasMixOneToTwoWithKfc && kernelTypeRes.hasMixOneToOne)) {271+ auto hostExtraCompileOptions = mng.GetHostCompileOptions();
272+ auto functionRegisterCode = FunctionRegistryImpl();
273+ if (deviceCubeExtraCompileOptions.empty() && deviceVecExtraCompileOptions.empty()) {
290 return ASC_FAILURE;274 return ASC_FAILURE;
291 }275 }
292- 
293- std::vector<std::string> hostExtraCompileOptions = GetHostCompileOptions();
294- std::vector<std::string> deviceCommonOptions = GetDeviceCommonCompileOptions(kernelTypeRes);
295- 
296- std::vector<std::string> deviceCubeExtraCompileOptions = deviceCommonOptions;
297- deviceCubeExtraCompileOptions.emplace_back("--cce-aicore-arch=" + GetCceAicoreArch(CoreType::CUBE));
298- UpdateManglingNameSuffix(deviceCubeExtraCompileOptions, CoreType::CUBE);
299- 
300- std::vector<std::string> deviceVecExtraCompileOptions = deviceCommonOptions;
301- deviceVecExtraCompileOptions.emplace_back("--cce-aicore-arch=" + GetCceAicoreArch(CoreType::VEC));
302- UpdateManglingNameSuffix(deviceVecExtraCompileOptions, CoreType::VEC);
303- if (InfoManager::GetInstance().GetShortSocVersion() == ShortSocVersion::ASCEND310P) {
304- deviceVecExtraCompileOptions.emplace_back("-D__ENABLE_VECTOR_CORE__");
305- }
306- 
307- std::string functionRegisterCode = FunctionRegistryImpl();
308 EpilogueResult res = {functionRegisterCode, hostExtraCompileOptions, deviceCubeExtraCompileOptions,276 EpilogueResult res = {functionRegisterCode, hostExtraCompileOptions, deviceCubeExtraCompileOptions,
309 deviceVecExtraCompileOptions};277 deviceVecExtraCompileOptions};
310 return DumpResultInfo(res, result);278 return DumpResultInfo(res, result);
@@ -324,7 +292,7 @@ int32_t PluginFatbinLink(const char** result)
324 }292 }
325 std::vector<std::string> linkOptions = {293 std::vector<std::string> linkOptions = {
326 // link libraies294 // link libraies
327- "-lascendc_runtime", "-lascendcl", "-lruntime", "-lerror_manager", "-lprofapi", "-lascendalog", "-lmmpa",295+ "-lascendc_runtime", "-lascendcl", "-lruntime", "-lerror_manager", "-lprofapi", "-lunified_dlog", "-lmmpa",
328 "-lascend_dump", "-lc_sec", "-lstdc++",296 "-lascend_dump", "-lc_sec", "-lstdc++",
329 // link path297 // link path
330 "-L" + cannPath + "/lib64"298 "-L" + cannPath + "/lib64"
@@ -325,7 +325,7 @@ std::string ToUpper(const std::string& str)
325std::string GetAscFeatureMetaSection(FeatureFlag flag)325std::string GetAscFeatureMetaSection(FeatureFlag flag)
326{326{
327 static uint32_t nameCounter = 0;327 static uint32_t nameCounter = 0;
328- std::string varName("static const struct AscendCFeatureFlag");328+ std::string varName("static const struct BinaryMetaAscFeature");
329 if (flag == FeatureFlag::ASC_L2CACHE_HINT_MASK) {329 if (flag == FeatureFlag::ASC_L2CACHE_HINT_MASK) {
330 varName += " __ascendc_feature_l2cache__";330 varName += " __ascendc_feature_l2cache__";
331 } else if (flag == FeatureFlag::ASC_PRINT_MASK) {331 } else if (flag == FeatureFlag::ASC_PRINT_MASK) {
Rtools/ascc/cmake/ASC_CMake/CMakeASCCompiler.cmake.intools/ascc/cmake/modules/CMakeASCCompiler.cmake.in+1-1
@@ -2,4 +2,4 @@ set(CMAKE_ASC_COMPILER "@CMAKE_ASC_COMPILER@")
2set(CMAKE_ASC_COMPILER_LOADED 1)2set(CMAKE_ASC_COMPILER_LOADED 1)
3set(CMAKE_ASC_SOURCE_FILE_EXTENSIONS @CMAKE_ASC_SOURCE_FILE_EXTENSIONS@)3set(CMAKE_ASC_SOURCE_FILE_EXTENSIONS @CMAKE_ASC_SOURCE_FILE_EXTENSIONS@)
4set(CMAKE_ASC_OUTPUT_EXTENSION @CMAKE_ASC_OUTPUT_EXTENSION@)4set(CMAKE_ASC_OUTPUT_EXTENSION @CMAKE_ASC_OUTPUT_EXTENSION@)
5-set(CMAKE_ASC_COMPILER_ENV_VAR "@CMAKE_ASC_COMPILER_ENV_VAR@")5+set(CMAKE_ASC_COMPILER_ENV_VAR "@CMAKE_ASC_COMPILER_ENV_VAR@")
@@ -0,0 +1,123 @@
1+include(CMakeCommonLanguageInclude)
2+ 
3+# dict: key -> value
4+function(map_get_value map_name key out_var)
5+ list(FIND ${map_name} ${key} index)
6+ if(index EQUAL -1)
7+ set(${out_var} "KEY_NOT_FOUND" PARENT_SCOPE)
8+ else()
9+ math(EXPR value_index "${index} + 1")
10+ list(GET ${map_name} ${value_index} value)
11+ set(${out_var} ${value} PARENT_SCOPE)
12+ endif()
13+endfunction()
14+ 
15+# Setup env variable: ASCEND_HOME_PATH
16+set(DEFAULT_ASCEND_PATH "/usr/local/Ascend/cann/")
17+if(NOT EXISTS $ENV{ASCEND_HOME_PATH})
18+ message(WARNING "Env variable ASCEND_HOME_PATH is not set. Set to default value ${DEFAULT_ASCEND_PATH}.")
19+ set(ASCEND_HOME_PATH ${DEFAULT_ASCEND_PATH})
20+else()
21+ set(ASCEND_HOME_PATH $ENV{ASCEND_HOME_PATH})
22+endif()
23+ 
24+# Check ASCEND_PRODUCT_TYPE is valid soc version. Current only supports 910B
25+set(ascend910b_list ascend910b1 ascend910b2 ascend910b2c ascend910b3 ascend910b4 ascend910b4-1 ascend910_9391
26+ ascend910_9381 ascend910_9372 ascend910_9392 ascend910_9382 ascend910_9362)
27+set(SOC_MAP
28+ "ascend910b1" "Ascend910B1" "ascend910b2" "Ascend910B2" "ascend910b2c" "Ascend910B2C"
29+ "ascend910b3" "Ascend910B3" "ascend910b4" "Ascend910B4" "ascend910b4-1" "Ascend910B4-1"
30+ "ascend910_9391" "Ascend910_9391" "ascend910_9381" "Ascend910_9381" "ascend910_9372" "Ascend910_9372"
31+ "ascend910_9392" "Ascend910_9392" "ascend910_9382" "Ascend910_9382" "ascend910_9362" "Ascend910_9362"
32+)
33+if(NOT DEFINED ASCEND_PRODUCT_TYPE)
34+ message(FATAL_ERROR "ASCEND_PRODUCT_TYPE must be defined.")
35+endif()
36+string(TOLOWER "${ASCEND_PRODUCT_TYPE}" LOWER_SOC_VERSION)
37+if(NOT LOWER_SOC_VERSION IN_LIST ascend910b_list)
38+ message(FATAL_ERROR "ASCEND_PRODUCT_TYPE ${ASCEND_PRODUCT_TYPE} is unsupported, support list is ${ascend910b_list}")
39+endif()
40+ 
41+# convert lower case soc to what ascc needed
42+map_get_value(SOC_MAP ${LOWER_SOC_VERSION} ASCEND_PRODUCT_TYPE)
43+ 
44+# 第一次编译时顺序: CMakeDetermineASCCompiler.cmake -> CMakeASCInformation.cmake -> asc_config.cmake
45+# 增量编译时顺序: CMakeASCInformation.cmake -> asc_config.cmake
46+message(STATUS "ASCEND_HOME_PATH: " ${ASCEND_HOME_PATH})
47+message(STATUS "ASCEND_PRODUCT_TYPE: " ${ASCEND_PRODUCT_TYPE})
48+ 
49+ 
50+set(CMAKE_COMPILE_AS_ASC_FLAG "-arch ${ASCEND_PRODUCT_TYPE}") # common compile options used in ascc
51+set(CMAKE_INCLUDE_FLAG_ASC "-I")
52+ 
53+# extension for the output of a compile for a single file
54+if(UNIX)
55+ set(CMAKE_ASC_OUTPUT_EXTENSION .o)
56+else()
57+ set(CMAKE_ASC_OUTPUT_EXTENSION .obj)
58+endif()
59+ 
60+set(CMAKE_DEPFILE_FLAGS_ASC "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
61+if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) AND CMAKE_GENERATOR MATCHES "Makefiles|WMake")
62+ # dependencies are computed by the compiler itself
63+ set(CMAKE_ASC_DEPFILE_FORMAT gcc)
64+ set(CMAKE_ASC_DEPENDS_USE_COMPILER TRUE)
65+endif()
66+ 
67+# -shared to create .so for shared library
68+if(NOT DEFINED CMAKE_SHARED_LIBRARY_CREATE_ASC_FLAGS)
69+ set(CMAKE_SHARED_LIBRARY_CREATE_ASC_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
70+endif()
71+# used for -Wl,-soname when creating shared library
72+if(NOT DEFINED CMAKE_SHARED_LIBRARY_SONAME_ASC_FLAG)
73+ set(CMAKE_SHARED_LIBRARY_SONAME_ASC_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG})
74+endif()
75+# used for -Wl,-rpath when link executable has shared library
76+if(NOT DEFINED CMAKE_EXECUTABLE_RUNTIME_ASC_FLAG)
77+ set(CMAKE_EXECUTABLE_RUNTIME_ASC_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG})
78+endif()
79+ 
80+# rule variable to compile a single object file: 编译一个.o的命令
81+# CMAKE_ASC_COMPILER: ascc
82+# CMAKE_COMPILE_AS_ASC_FLAG: -arch {soc_version}
83+if(NOT CMAKE_ASC_COMPILE_OBJECT)
84+ set(CMAKE_ASC_COMPILE_OBJECT
85+ "<CMAKE_ASC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> ${CMAKE_COMPILE_AS_ASC_FLAG} -o <OBJECT> -c <SOURCE>")
86+endif()
87+ 
88+# Create a static archive incrementally for large object file counts.
89+if(NOT DEFINED CMAKE_ASC_ARCHIVE_CREATE)
90+ set(CMAKE_ASC_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>")
91+endif()
92+# add without checking duplication
93+if(NOT DEFINED CMAKE_ASC_ARCHIVE_APPEND)
94+ set(CMAKE_ASC_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
95+endif()
96+if(NOT DEFINED CMAKE_ASC_ARCHIVE_FINISH)
97+ set(CMAKE_ASC_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
98+endif()
99+ 
100+# rule variable to create a shared module
101+if(NOT CMAKE_ASC_CREATE_SHARED_MODULE)
102+ set(CMAKE_ASC_CREATE_SHARED_MODULE ${CMAKE_ASC_CREATE_SHARED_LIBRARY})
103+endif()
104+ 
105+# when language is set to ASC, execute when add_executable. Add default link libraries and path in default.
106+# FLAGS: -D
107+# ASC_LINK_FLAGS: link options
108+set(DEFAULT_LINK_LIBS "-lascendc_runtime -lruntime -lerror_manager -lprofapi -lunified_dlog -lmmpa -lascend_dump -lc_sec")
109+set(DEFAULT_LINK_PATH "-L${ASCEND_HOME_PATH}/lib64")
110+if(NOT CMAKE_ASC_LINK_EXECUTABLE)
111+ set(CMAKE_ASC_LINK_EXECUTABLE
112+ "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_ASC_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${DEFAULT_LINK_PATH} ${DEFAULT_LINK_LIBS}")
113+endif()
114+ 
115+# rule variable to create a shared library: 编译一个.so的命令
116+# CMAKE_CXX_COMPILER:gcc
117+# must link with libascendc_runtime.a for elf_tool.c.o, ascendc_runtime.cpp.o
118+if(NOT CMAKE_ASC_CREATE_SHARED_LIBRARY)
119+ set(CMAKE_ASC_CREATE_SHARED_LIBRARY
120+ "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_ASC_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_ASC_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> ${DEFAULT_LINK_PATH} ${DEFAULT_LINK_LIBS}")
121+endif()
122+ 
123+set(CMAKE_ASC_INFORMATION_LOADED 1) # 标记Cmake已经加载初始化ASC编程语言
@@ -0,0 +1,14 @@
1+# CMakeDetermineASCCompiler.cmake用来初始化ascc的变量,增量编译时不会再次触发该文件
2+find_program(CMAKE_ASC_COMPILER NAMES "bishengcc" PATHS "$ENV{PATH}" "$ENV{ASCEND_HOME_PATH}" DOC "ASC Compiler")
3+mark_as_advanced(CMAKE_ASC_COMPILER)
4+ 
5+message(STATUS "CMAKE_ASC_COMPILER: " ${CMAKE_ASC_COMPILER})
6+ 
7+set(CMAKE_ASC_SOURCE_FILE_EXTENSIONS asc) # .asc后缀名自动用ascc, .cpp后缀名不会自动用ascc, 必须要手动指定
8+set(CMAKE_ASC_COMPILER_ENV_VAR "ASC") # Language命名为ASC
9+ 
10+# configure all variables set in this file
11+configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeASCCompiler.cmake.in
12+ ${CMAKE_PLATFORM_INFO_DIR}/CMakeASCCompiler.cmake
13+ @ONLY
14+)
Rtools/ascc/cmake/ASC_CMake/CMakeTestASCCompiler.cmaketools/ascc/cmake/modules/CMakeTestASCCompiler.cmake+0-0
文件重命名但无更改。
@@ -0,0 +1,55 @@
1+set(LIB_SUPPORT_TYPES SHARED STATIC)
2+ 
3+function(ascendc_executable target_name)
4+ if(ARGN)
5+ set_source_files_properties(${ARGN} PROPERTIES LANGUAGE ASC)
6+ add_executable(${target_name} ${ARGN})
7+ set_target_properties(${target_name} PROPERTIES LINKER_LANGUAGE ASC)
8+ endif()
9+endfunction()
10+ 
11+function(ascendc_library target_name target_type)
12+ if(NOT target_type IN_LIST LIB_SUPPORT_TYPES)
13+ message(FATAL_ERROR "target_type ${target_type} is unsupported, the support list is ${LIB_SUPPORT_TYPES}")
14+ endif()
15+ if(ARGN)
16+ set_source_files_properties(${ARGN} PROPERTIES LANGUAGE ASC)
17+ add_library(${target_name} ${target_type} ${ARGN})
18+ endif()
19+endfunction()
20+ 
21+function(ascendc_compile_definitions target_name target_scope)
22+ if(ARGN)
23+ target_compile_definitions(${target_name} ${target_scope} ${ARGN})
24+ endif()
25+endfunction()
26+ 
27+function(ascendc_compile_options target_name target_scope)
28+ if(ARGN)
29+ target_compile_options(${target_name} ${target_scope} ${ARGN})
30+ endif()
31+endfunction()
32+ 
33+function(ascendc_include_directories target_name target_scope)
34+ if(ARGN)
35+ target_include_directories(${target_name} ${target_scope} ${ARGN})
36+ endif()
37+endfunction()
38+ 
39+function(ascendc_link_libraries target_name target_scope)
40+ if(ARGN)
41+ target_link_libraries(${target_name} ${target_scope} ${ARGN})
42+ endif()
43+endfunction()
44+ 
45+function(ascendc_link_directories target_name target_scope)
46+ if(ARGN)
47+ target_link_directories(${target_name} ${target_scope} ${ARGN})
48+ endif()
49+endfunction()
50+ 
51+function(ascendc_link_options target_name target_scope)
52+ if(ARGN)
53+ target_link_options(${target_name} ${target_scope} ${ARGN})
54+ endif()
55+endfunction()
@@ -14,8 +14,6 @@ message(STATUS "CMAKE_BINARY_DIR=" ${CMAKE_BINARY_DIR})
14message(STATUS "CMAKE_CURRENT_SOURCE_DIR=" ${CMAKE_CURRENT_SOURCE_DIR})14message(STATUS "CMAKE_CURRENT_SOURCE_DIR=" ${CMAKE_CURRENT_SOURCE_DIR})
15 15 
16set(ASC_OP_COMPILE_BASE_WHL_NAME "asc_op_compile_base-0.1.0-py3-none-any.whl")16set(ASC_OP_COMPILE_BASE_WHL_NAME "asc_op_compile_base-0.1.0-py3-none-any.whl")
17-# set(ASC_OP_COMPILE_CHECK_WHL "checkwhl")
18-# set(ASC_OP_COMPILE_MOVE_WHL "movewhl")
19set(ASC_OP_COMPILE_BASE_DIR "./asc_op_compile_base_python")17set(ASC_OP_COMPILE_BASE_DIR "./asc_op_compile_base_python")
20set(ASC_OP_COMPILE_BASE_SRC "${CMAKE_CURRENT_SOURCE_DIR}")18set(ASC_OP_COMPILE_BASE_SRC "${CMAKE_CURRENT_SOURCE_DIR}")
21 19 
@@ -41,7 +39,7 @@ endif()
41target_link_libraries(asc_platform PRIVATE 39target_link_libraries(asc_platform PRIVATE
42 platform40 platform
43 mmpa41 mmpa
44- alog42+ unified_dlog
45 error_manager43 error_manager
46)44)
47target_compile_options(asc_platform PRIVATE 45target_compile_options(asc_platform PRIVATE
@@ -50,6 +48,7 @@ target_compile_options(asc_platform PRIVATE
50 -D_FORTIFY_SOURCE=248 -D_FORTIFY_SOURCE=2
51 -Os49 -Os
52 -D_GLIBCXX_USE_CXX11_ABI=050 -D_GLIBCXX_USE_CXX11_ABI=0
51+ -Werror
53)52)
54 53 
55target_link_options(asc_platform PRIVATE54target_link_options(asc_platform PRIVATE
@@ -61,8 +60,6 @@ add_custom_command(
61 TARGET asc_platform POST_BUILD60 TARGET asc_platform POST_BUILD
62 COMMAND ${CMAKE_COMMAND} -E echo "Source file: $<TARGET_FILE:asc_platform>"61 COMMAND ${CMAKE_COMMAND} -E echo "Source file: $<TARGET_FILE:asc_platform>"
63 COMMAND ${CMAKE_COMMAND} -E echo "Destination file: ${ASC_OP_COMPILE_BASE_DIR}/asc_op_compile_base/c_api/libasc_platform.so"62 COMMAND ${CMAKE_COMMAND} -E echo "Destination file: ${ASC_OP_COMPILE_BASE_DIR}/asc_op_compile_base/c_api/libasc_platform.so"
64- # COMMAND ${CMAKE_COMMAND} -E make_directory ${ASC_OP_COMPILE_BASE_DIR}
65- # COMMAND rm -r ${ASC_OP_COMPILE_BASE_DIR}/*
66 COMMAND ${CMAKE_COMMAND} -E make_directory ${ASC_OP_COMPILE_BASE_DIR}/asc_op_compile_base/c_api63 COMMAND ${CMAKE_COMMAND} -E make_directory ${ASC_OP_COMPILE_BASE_DIR}/asc_op_compile_base/c_api
67 COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:asc_platform> ${ASC_OP_COMPILE_BASE_DIR}/asc_op_compile_base/c_api/libasc_platform.so64 COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:asc_platform> ${ASC_OP_COMPILE_BASE_DIR}/asc_op_compile_base/c_api/libasc_platform.so
68 COMMAND ${CMAKE_STRIP} -s ${ASC_OP_COMPILE_BASE_DIR}/asc_op_compile_base/c_api/libasc_platform.so65 COMMAND ${CMAKE_STRIP} -s ${ASC_OP_COMPILE_BASE_DIR}/asc_op_compile_base/c_api/libasc_platform.so
@@ -76,7 +73,7 @@ add_custom_target(asc_platform_test
76 COMMAND ${CMAKE_COMMAND} -E echo "Copied libasc_platform.so to ${ASC_OP_COMPILE_BASE_SRC}/c_api/libasc_platform.so"73 COMMAND ${CMAKE_COMMAND} -E echo "Copied libasc_platform.so to ${ASC_OP_COMPILE_BASE_SRC}/c_api/libasc_platform.so"
77)74)
78 75 
79-# 生成 Python 轮子包76+# 生成 Python whl pkg
80add_custom_target(${ASC_OP_COMPILE_BASE_WHL_NAME} ALL77add_custom_target(${ASC_OP_COMPILE_BASE_WHL_NAME} ALL
81 COMMAND echo "[ASC_OP_COMPILE_BASE] Build target ${ASC_OP_COMPILE_BASE_WHL_NAME}" && pwd && 78 COMMAND echo "[ASC_OP_COMPILE_BASE] Build target ${ASC_OP_COMPILE_BASE_WHL_NAME}" && pwd &&
82 mkdir -p ${ASC_OP_COMPILE_BASE_DIR}/asc_op_compile_base/asc_op_compiler && 79 mkdir -p ${ASC_OP_COMPILE_BASE_DIR}/asc_op_compile_base/asc_op_compiler &&
@@ -46,6 +46,7 @@ class CompileInfo:
46 self.is_debug: bool = False46 self.is_debug: bool = False
47 self.compile_log_path = None47 self.compile_log_path = None
48 self.hard_sync: bool = False48 self.hard_sync: bool = False
49+ self.hard_kfc_server: bool = False
49 self.enable_deterministic: bool = False50 self.enable_deterministic: bool = False
50 self.tiling_key_kernel_type: dict = {}51 self.tiling_key_kernel_type: dict = {}
51 self.tiling_key_deterministic: dict = {}52 self.tiling_key_deterministic: dict = {}
@@ -56,6 +57,8 @@ class CompileInfo:
56 self.sub_core_type: int = -157 self.sub_core_type: int = -1
57 self.template_tiling_info: dict = {}58 self.template_tiling_info: dict = {}
58 self.tiling_key_struct_map: dict = {}59 self.tiling_key_struct_map: dict = {}
60+ self.register_tiling_struct: set = set() # tiling struct found in REGISTER_TILING_XXX
61+ self.tpl_tiling_struct: set = set() # tiling struct found in TPL
59 self.enable_final_super_kernel_compile: bool = False62 self.enable_final_super_kernel_compile: bool = False
60 # if enable_final_super_kernel_compile is True and super_kernel_objs is empty63 # if enable_final_super_kernel_compile is True and super_kernel_objs is empty
61 # means no fatbin, dst_file is the final file64 # means no fatbin, dst_file is the final file
@@ -347,7 +350,7 @@ class CommonUtility:
347 350 
348 @staticmethod351 @staticmethod
349 def ascendc_raise_python_err(err_code, msg):352 def ascendc_raise_python_err(err_code, msg):
350- CommonUtility.print_compile_log("", f"err_msg: {msg}.",353+ CommonUtility.print_compile_log("", f"{msg}",
351 AscendCLogLevel.LOG_ERROR)354 AscendCLogLevel.LOG_ERROR)
352 raise_tbe_python_err(err_code, msg)355 raise_tbe_python_err(err_code, msg)
353 356 
@@ -385,32 +388,6 @@ class CommonUtility:
385 return False388 return False
386 389 
387 390 
388- @staticmethod
389- def is_l300():
390- """return if current soc version is l300
391- 
392- Returns:
393- res: True means l300
394- """
395- short_soc_version = global_var_storage.get_variable("ascendc_short_soc_version")
396- if short_soc_version in ["KirinX90"]:
397- return True
398- return False
399- 
400- 
401- @staticmethod
402- def is_l311():
403- """return if current soc version is l311
404- 
405- Returns:
406- res: True means l311
407- """
408- short_soc_version = global_var_storage.get_variable("ascendc_short_soc_version")
409- if short_soc_version in ["Kirin9030"]:
410- return True
411- return False
412- 
413- 
414 @staticmethod391 @staticmethod
415 def is_support_super_kernel():392 def is_support_super_kernel():
416 """return if current soc version support super kernel393 """return if current soc version support super kernel
@@ -539,7 +516,6 @@ class CommonUtility:
539 return True516 return True
540 return False517 return False
541 518 
542- 
543 @staticmethod519 @staticmethod
544 def is_l300():520 def is_l300():
545 """return if current soc version is l300521 """return if current soc version is l300
@@ -552,7 +528,6 @@ class CommonUtility:
552 return True528 return True
553 return False529 return False
554 530 
555- 
556 @staticmethod531 @staticmethod
557 def is_l311():532 def is_l311():
558 """return if current soc version is l311533 """return if current soc version is l311
@@ -705,6 +680,12 @@ format(str(stage), output))
705 hex_num_str_list = list(map(reverser_hex_str, hex_num[::-1]))680 hex_num_str_list = list(map(reverser_hex_str, hex_num[::-1]))
706 hex_num_str = ''.join(hex_num_str_list)681 hex_num_str = ''.join(hex_num_str_list)
707 return hex_num_str682 return hex_num_str
683+
684+ @staticmethod
685+ def get_dump_core_num():
686+ if CommonUtility.is_c310() or CommonUtility.is_310r6():
687+ return 108
688+ return 75
708 689 
709 690 
710def is_enable_sanitizer(compile_options):691def is_enable_sanitizer(compile_options):
@@ -923,6 +904,8 @@ def convert_customized_config_to_inferchannel(config: CustomizedConfig):
923 tiling_struct_expr_map = {}904 tiling_struct_expr_map = {}
924 tiling_key_struct_map = \905 tiling_key_struct_map = \
925 {k: str(v.tiling_struct_name) for k, v in tiling_key_infos.items() if str(v.tiling_struct_name) != ''}906 {k: str(v.tiling_struct_name) for k, v in tiling_key_infos.items() if str(v.tiling_struct_name) != ''}
907+ register_tiling_struct = set()
908+ tpl_tiling_struct = set()
926 set_task_bar = False909 set_task_bar = False
927 wait_task_bar = False910 wait_task_bar = False
928 tiling_key_deterministic = {k: str(v.enable_deterministic).lower() for k, v in tiling_key_infos.items()}911 tiling_key_deterministic = {k: str(v.enable_deterministic).lower() for k, v in tiling_key_infos.items()}
@@ -931,7 +914,8 @@ def convert_customized_config_to_inferchannel(config: CustomizedConfig):
931 enable_deterministic, tiling_key_kernel_type, no_set_kernel_type,\914 enable_deterministic, tiling_key_kernel_type, no_set_kernel_type,\
932 default_kernel_type, dump_info, template_tiling_info,915 default_kernel_type, dump_info, template_tiling_info,
933 default_tiling_struct, tiling_struct_expr_map, tiling_key_struct_map,\916 default_tiling_struct, tiling_struct_expr_map, tiling_key_struct_map,\
934- set_task_bar, wait_task_bar, tiling_key_deterministic, None)917+ register_tiling_struct, tpl_tiling_struct, set_task_bar, wait_task_bar, \
918+ tiling_key_deterministic, None)
935 919 
936 920 
937def get_kernel_fun_name_with_tiling_key_and_kernel_type(compile_info: CompileInfo, tiling_key: int):921def get_kernel_fun_name_with_tiling_key_and_kernel_type(compile_info: CompileInfo, tiling_key: int):
@@ -162,7 +162,7 @@ TILINGKEY_PAR_COMPILE is {}".format(parallel_compile_check), AscendCLogLevel.LOG
162 ascendc_self_par_job_num = int(ascendc_self_par_job)162 ascendc_self_par_job_num = int(ascendc_self_par_job)
163 163 
164 if ci_big_makefile_par_switch or ascendc_self_par_job_num > 0:164 if ci_big_makefile_par_switch or ascendc_self_par_job_num > 0:
165- dstfile_with_pid = dstfile_name + str(os.getpid())165+ dstfile_with_pid = os.path.join(CommonUtility.get_kernel_meta_dir(), dstfile_name + "_" + str(os.getpid()))
166 write_mk(tiling_key_list, cmds_list, dstfile_with_pid, compile_log_path)166 write_mk(tiling_key_list, cmds_list, dstfile_with_pid, compile_log_path)
167 # when TILINGKEY_PARALLEL_COMPILATION_SWITCH and ASCENDC_PAR_COMPILE_JOB conflicts167 # when TILINGKEY_PARALLEL_COMPILATION_SWITCH and ASCENDC_PAR_COMPILE_JOB conflicts
168 # TILINGKEY_PARALLEL_COMPILATION_SWITCH first168 # TILINGKEY_PARALLEL_COMPILATION_SWITCH first
@@ -213,4 +213,4 @@ def search_in_line(line, keywords):
213def extract_file_path(line):213def extract_file_path(line):
214 pattern = re.compile(r'"([^"]+)"')214 pattern = re.compile(r'"([^"]+)"')
215 matches = pattern.findall(line)215 matches = pattern.findall(line)
216- return matches[0]216+ return matches[0]
@@ -387,15 +387,18 @@ class DFXSectionGenerator:
387 if not tiling_info.static_shape_flag and not global_var_storage.get_variable("ascendc_tiling_no_register"):387 if not tiling_info.static_shape_flag and not global_var_storage.get_variable("ascendc_tiling_no_register"):
388 self._generate_binary_for_tiling(tiling_key, tiling_info, compile_info)388 self._generate_binary_for_tiling(tiling_key, tiling_info, compile_info)
389 389 
390- section_content = f"// generate dfx section for tiling_key:{tiling_key}\n"390+ section_content = f"// generate dfx section for tiling_key:{tiling_key}"
391 if CommonUtility.is_v220() or CommonUtility.is_c310() or CommonUtility.is_310r6():391 if CommonUtility.is_v220() or CommonUtility.is_c310() or CommonUtility.is_310r6():
392- chip_version = CommonUtility.get_chip_version().upper()392+ if CommonUtility.is_v220():
393- cube_core_type = f"__DAV_{chip_version}_CUBE__"393+ cube_core_marco = "(defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201)"
394- vec_core_type = f"__DAV_{chip_version}_VEC__"394+ vec_core_marco = "(defined(__DAV_VEC__) && __NPU_ARCH__ == 2201)"
395+ elif CommonUtility.is_c310():
396+ cube_core_marco = "(defined(__DAV_CUBE__) && __NPU_ARCH__ == 3101)"
397+ vec_core_marco = "(defined(__DAV_VEC__) && __NPU_ARCH__ == 3101)"
395 else:398 else:
396 # for v200 cube_core_type is aicore type399 # for v200 cube_core_type is aicore type
397- cube_core_type = "__DAV_M200__"400+ cube_core_marco = "defined(__DAV_M200__)"
398- vec_core_type = "__DAV_M200_VEC__"401+ vec_core_marco = "defined(__DAV_M200_VEC__)"
399 402 
400 section_content_body = self.generate_dfx_section_for_one_tiling_key(tiling_key, kernel_name, \403 section_content_body = self.generate_dfx_section_for_one_tiling_key(tiling_key, kernel_name, \
401 compile_info, kernel_type_section)404 compile_info, kernel_type_section)
@@ -406,12 +409,12 @@ class DFXSectionGenerator:
406 section_content += self._generate_dfx_info_struct()409 section_content += self._generate_dfx_info_struct()
407 410 
408 if section_content_body is None or section_content_body == "":411 if section_content_body is None or section_content_body == "":
409- return section_content412+ return section_content + f"#endif\n"
410 413 
411 if compile_info.sub_core_type == CORE_TYPE_CUBE:414 if compile_info.sub_core_type == CORE_TYPE_CUBE:
412- section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL && defined({cube_core_type})\n"415+ section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL && {cube_core_marco}\n"
413 elif compile_info.sub_core_type == CORE_TYPE_VEC:416 elif compile_info.sub_core_type == CORE_TYPE_VEC:
414- section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL && defined({vec_core_type})\n"417+ section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL && {vec_core_marco}\n"
415 else:418 else:
416 section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL\n"419 section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL\n"
417 420 
@@ -119,20 +119,35 @@ def gen_global_isolation_macro(compile_info: CompileInfo, tiling_info: TilingInf
119 tiling_key = tiling_info.tiling_key119 tiling_key = tiling_info.tiling_key
120 120 
121 if CommonUtility.is_v220():121 if CommonUtility.is_v220():
122- macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_C220_VEC__)\n"122+ macro_branch_statment = \
123+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_VEC__) && __NPU_ARCH__ == 2201)\n"
123 # judge operator is aic only124 # judge operator is aic only
124 if compile_info.no_set_kernel_type is False:125 if compile_info.no_set_kernel_type is False:
125 kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]126 kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]
126 if kernel_type.value in [1, 3, 5, 6, 7]:127 if kernel_type.value in [1, 3, 5, 6, 7]:
127- macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_C220_CUBE__)\n"128+ macro_branch_statment = \
129+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201)\n"
128 elif compile_info.code_channel == CORE_TYPE_CUBE:130 elif compile_info.code_channel == CORE_TYPE_CUBE:
129- macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_C220_CUBE__)\n"131+ macro_branch_statment = \
132+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201)\n"
130 elif CommonUtility.is_v200():133 elif CommonUtility.is_v200():
131 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_M200__)\n"134 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_M200__)\n"
132 if compile_info.no_set_kernel_type is False:135 if compile_info.no_set_kernel_type is False:
133 kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]136 kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]
134 if kernel_type.value in [9]:137 if kernel_type.value in [9]:
135 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_M200_VEC__)\n"138 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_M200_VEC__)\n"
139+ elif (CommonUtility.is_c310() or CommonUtility.is_310r6()):
140+ macro_branch_statment = \
141+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_VEC__) && __NPU_ARCH__ == 3101)\n"
142+ # judge operator is aic only
143+ if compile_info.no_set_kernel_type is False:
144+ kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]
145+ if kernel_type.value in [1, 3, 5, 6, 7]:
146+ macro_branch_statment = \
147+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_CUBE__) && __NPU_ARCH__ == 3101)\n"
148+ elif compile_info.code_channel == CORE_TYPE_CUBE:
149+ macro_branch_statment = \
150+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_CUBE__) && __NPU_ARCH__ == 3101)\n"
136 else:151 else:
137 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL\n"152 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL\n"
138 return macro_branch_statment153 return macro_branch_statment
@@ -396,10 +411,11 @@ def get_tiling_key_struct_size_map(tiling_key_struct_size_map, name_part, compil
396 tiling_key_value = tiling_key_value[:-2]411 tiling_key_value = tiling_key_value[:-2]
397 tiling_key_struct_size_map[tiling_key_value] = (tiling_struct, dec_data)412 tiling_key_struct_size_map[tiling_key_value] = (tiling_struct, dec_data)
398 if compile_info.tiling_key_group_map is None:413 if compile_info.tiling_key_group_map is None:
399- return414+ return tiling_key_struct_size_map
400 if tiling_key_value in compile_info.tiling_key_group_map.keys():415 if tiling_key_value in compile_info.tiling_key_group_map.keys():
401 for tiling_key_slave in compile_info.tiling_key_group_map[tiling_key_value]:416 for tiling_key_slave in compile_info.tiling_key_group_map[tiling_key_value]:
402 tiling_key_struct_size_map[tiling_key_slave] = (tiling_struct, dec_data)417 tiling_key_struct_size_map[tiling_key_slave] = (tiling_struct, dec_data)
418+ return tiling_key_struct_size_map
403 419 
404 420 
405def gen_tiling_struct_and_dfx_section_head():421def gen_tiling_struct_and_dfx_section_head():
@@ -489,7 +505,7 @@ def gen_dfx_section_for_one_tiling_key_dynamic(compile_info: CompileInfo, tiling
489 tiling_info: TilingInfo, tiling_key_struct_size_map: dict):505 tiling_info: TilingInfo, tiling_key_struct_size_map: dict):
490 source = ""506 source = ""
491 if compile_info.no_set_kernel_type is False:507 if compile_info.no_set_kernel_type is False:
492- kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)] 508+ kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]
493 if kernel_type.value >= 6 and kernel_type.value <= 7:509 if kernel_type.value >= 6 and kernel_type.value <= 7:
494 cube_marker = "_mix_aic"510 cube_marker = "_mix_aic"
495 kernel_name = compile_info.kernel_name + '_%s' % tiling_key + cube_marker511 kernel_name = compile_info.kernel_name + '_%s' % tiling_key + cube_marker
@@ -390,13 +390,18 @@ def call_bisheng_v220(compile_info: CompileInfo, compile_option_tuple, tiling_in
390 390 
391 391 
392def get_ktype_section_head(variable_name: str):392def get_ktype_section_head(variable_name: str):
393- chip_version = CommonUtility.get_chip_version().upper()393+ section_var_head = ""
394- section_var = f""
395 if "mix_aic" in variable_name:394 if "mix_aic" in variable_name:
396- section_var += f"#if defined(__DAV_{chip_version}_CUBE__)\n"395+ if CommonUtility.is_v220():
396+ section_var_head += f"#if (defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201)\n"
397+ elif CommonUtility.is_c310():
398+ section_var_head += f"#if (defined(__DAV_CUBE__) && __NPU_ARCH__ == 3101)\n"
397 elif "mix_aiv" in variable_name:399 elif "mix_aiv" in variable_name:
398- section_var += f"#if defined(__DAV_{chip_version}_VEC__)\n"400+ if CommonUtility.is_v220():
399- return section_var401+ section_var_head += f"#if (defined(__DAV_VEC__) && __NPU_ARCH__ == 2201)\n"
402+ elif CommonUtility.is_c310():
403+ section_var_head += f"#if (defined(__DAV_VEC__) && __NPU_ARCH__ == 3101)\n"
404+ return section_var_head
400 405 
401 406 
402def get_ktype_section_variable(variable_name: str, section_func_name: str, kernel_meta_type: KernelMetaType):407def get_ktype_section_variable(variable_name: str, section_func_name: str, kernel_meta_type: KernelMetaType):
@@ -561,7 +566,6 @@ def v310_mode_cube_ofile(little_endian, binary_32) -> int:
561 '0110101000', # MOV_OUT _TO_L1 _MULTI_DN2NZ566 '0110101000', # MOV_OUT _TO_L1 _MULTI_DN2NZ
562 '0110101100', # MOV_OUT _TO_L1 _MULTI_ND2NZ567 '0110101100', # MOV_OUT _TO_L1 _MULTI_ND2NZ
563 '0110111010', # MOV_OUT_TO_L1_V2568 '0110111010', # MOV_OUT_TO_L1_V2
564- '0111010000', # MOV_OUT_TO_L1_ALIGN_V2
565 '0111011000', # LOAD_L1_TO_L0A_MX_2Dv2和LOAD_L1_TO_L0B_MX_2Dv2569 '0111011000', # LOAD_L1_TO_L0A_MX_2Dv2和LOAD_L1_TO_L0B_MX_2Dv2
566 '0110011100', # LOAD_L1_TO_L0A_3Dv2和LOAD_L1_TO_L0B_3Dv2570 '0110011100', # LOAD_L1_TO_L0A_3Dv2和LOAD_L1_TO_L0B_3Dv2
567 '0110011101',571 '0110011101',
@@ -581,7 +585,7 @@ def v310_mode_cube_ofile(little_endian, binary_32) -> int:
581 (little_endian[0] == 'f' and little_endian[1] in '2345abcd' and binary_32[30] == '0'),585 (little_endian[0] == 'f' and little_endian[1] in '2345abcd' and binary_32[30] == '0'),
582 586 
583 # DMA587 # DMA
584- (binary_32[:9] == '011100100' and binary_32[25:29] in ('0001', '0101')),588+ (binary_32[:9] == '011100100' and binary_32[25:29] in ('0001', '0101')), # DMA move inst, include MOV L1 TO UB
585 (high_10 in cube_high_low_map and binary_32[30:] == cube_high_low_map[high_10]),589 (high_10 in cube_high_low_map and binary_32[30:] == cube_high_low_map[high_10]),
586 (high_10 in cube_high_low2_map and binary_32[31] == cube_high_low2_map[high_10]),590 (high_10 in cube_high_low2_map and binary_32[31] == cube_high_low2_map[high_10]),
587 (high_10 in cube_high_map),591 (high_10 in cube_high_map),
@@ -41,8 +41,9 @@ INPUT_OUTPUT_DTYPE_LEN = {"float": 4, "bool": 1, "int32": 4, "int64": 8, "half":
41InferChannelParamsFromIFile = namedtuple('InferChannelParamsFromIFile', \41InferChannelParamsFromIFile = namedtuple('InferChannelParamsFromIFile', \
42 ['tiling_key_list', 'code_channel', 'hard_sync', 'no_kfc_server_flag', "enable_deterministic", \42 ['tiling_key_list', 'code_channel', 'hard_sync', 'no_kfc_server_flag', "enable_deterministic", \
43 'tiling_key_kernel_type', "no_set_kernel_type", "default_kernel_type", "dump_info", "template_tiling_info",\43 'tiling_key_kernel_type', "no_set_kernel_type", "default_kernel_type", "dump_info", "template_tiling_info",\
44- 'default_tiling_struct', 'tiling_struct_expr_map', 'tiling_key_struct_map', 'super_kernel_early_start_set_flag',\44+ 'default_tiling_struct', 'tiling_struct_expr_map', 'tiling_key_struct_map', 'register_tiling_struct', \
45- 'super_kernel_early_start_wait_flag', 'tiling_key_deterministic', 'tiling_key_group_map'])45+ 'tpl_tiling_struct', 'super_kernel_early_start_set_flag', 'super_kernel_early_start_wait_flag', \
46+ 'tiling_key_deterministic', 'tiling_key_group_map'])
46InferChannelParams = namedtuple('InferChannelParams', ['src_file', 'dst_file_header', \47InferChannelParams = namedtuple('InferChannelParams', ['src_file', 'dst_file_header', \
47 'compile_option_tuple', 'tiling_key', 'tiling_info', 'compile_log_path', 'no_kfc_server_flag'])48 'compile_option_tuple', 'tiling_key', 'tiling_info', 'compile_log_path', 'no_kfc_server_flag'])
48 49 
@@ -112,6 +113,7 @@ STR_TO_KERNEL_TYPE_L311 = {
112 "KERNEL_TYPE_MIX_AICORE" : KernelMetaType.KERNEL_TYPE_MIX_AICORE,113 "KERNEL_TYPE_MIX_AICORE" : KernelMetaType.KERNEL_TYPE_MIX_AICORE,
113}114}
114 115 
116+ 
115KERNEL_TYPE_TO_STR = {117KERNEL_TYPE_TO_STR = {
116 KernelMetaType.KERNEL_TYPE_AIV_ONLY : "KERNEL_TYPE_AIV_ONLY",118 KernelMetaType.KERNEL_TYPE_AIV_ONLY : "KERNEL_TYPE_AIV_ONLY",
117 KernelMetaType.KERNEL_TYPE_AIC_ONLY : "KERNEL_TYPE_AIC_ONLY",119 KernelMetaType.KERNEL_TYPE_AIC_ONLY : "KERNEL_TYPE_AIC_ONLY",
@@ -49,7 +49,7 @@ from .ascendc_compile_gen_code import get_code_for_l2_cache, \
49 gen_init_dump_code, add_op_param_to_workspace, _gen_compile_cmd, get_tiling_key_struct_size_map, \49 gen_init_dump_code, add_op_param_to_workspace, _gen_compile_cmd, get_tiling_key_struct_size_map, \
50 gen_tiling_struct_and_dfx_section_head, gen_tiling_struct_size_for_group_key, \50 gen_tiling_struct_and_dfx_section_head, gen_tiling_struct_size_for_group_key, \
51 gen_dfx_section_for_one_tiling_key_dynamic, gen_dfx_section_for_one_tiling_key_static, \51 gen_dfx_section_for_one_tiling_key_dynamic, gen_dfx_section_for_one_tiling_key_static, \
52- gen_tiling_struct_size_for_group_key_no_size52+ gen_tiling_struct_size_for_group_key_no_size, gen_global_isolation_macro
53from .ascendc_compile_gen_json import _gen_mix_json_from_seperate_json, \53from .ascendc_compile_gen_json import _gen_mix_json_from_seperate_json, \
54 _gen_mix_json_from_seperate_json_for_kernel_type, _dynamic_kernel_list_to_json, \54 _gen_mix_json_from_seperate_json_for_kernel_type, _dynamic_kernel_list_to_json, \
55 _dynamic_regbase_kernel_list_to_json, _static_regbase_kernel_list_to_json, _gen_mix_sub_json, \55 _dynamic_regbase_kernel_list_to_json, _static_regbase_kernel_list_to_json, _gen_mix_sub_json, \
@@ -431,8 +431,8 @@ def _gen_set_workspace_codes(is_mix: bool, is_single_and_using_hard_sync: bool,
431 source += "do {\n"431 source += "do {\n"
432 432 
433 # is_single_and_using_hard_sync scene not need clear workspace433 # is_single_and_using_hard_sync scene not need clear workspace
434- if is_mix and (not CommonUtility.is_c310()): # c310 doesn't need clearWorkspace434+ if is_mix and compile_info.hard_kfc_server:
435- source += f"#ifdef {MIX_CORE_MACRO} \n"435+ source += f"#if defined({MIX_CORE_MACRO}) && !defined(ENABLE_CV_COMM_VIA_SSBUF) \n"
436 source += " if constexpr (g_coreType == AscendC::AIC) {\n"436 source += " if constexpr (g_coreType == AscendC::AIC) {\n"
437 source += " matmul::clearWorkspace(workspace);\n"437 source += " matmul::clearWorkspace(workspace);\n"
438 source += add_time_stamp_codes('TIME_STAMP_WRAP_CLEAR_WK_SPAC', 2)438 source += add_time_stamp_codes('TIME_STAMP_WRAP_CLEAR_WK_SPAC', 2)
@@ -466,6 +466,25 @@ def _gen_set_mc2_ctx_param(opinfo: OpInfo):
466 return source466 return source
467 467 
468 468 
469+# When TPL struct is not registered through macro REGISTER_TILING, need to insert section code
470+def _gen_tpl_tiling_struct_section(compile_info: CompileInfo, tiling_info: TilingInfo):
471+ source = gen_global_isolation_macro(compile_info, tiling_info)
472+ tiling_struct_set = set()
473+ counter = 0
474+ for tiling_key in compile_info.tiling_key_list:
475+ original_tiling_struct = compile_info.tiling_key_struct_map[tiling_key]
476+ if original_tiling_struct in compile_info.tpl_tiling_struct and \
477+ original_tiling_struct not in compile_info.register_tiling_struct and \
478+ original_tiling_struct not in tiling_struct_set:
479+ source += f"static const uint64_t __ascendc_TPL_tiling_struct_{counter} __attribute__"
480+ source += \
481+ f"((used, section(\".ascendc_tiling.{original_tiling_struct}\"))) = sizeof({original_tiling_struct});\n"
482+ counter += 1
483+ tiling_struct_set.add(original_tiling_struct)
484+ source += f"#endif\n\n"
485+ return source
486+ 
487+ 
469def gen_meta_info_section(compile_info, op_info):488def gen_meta_info_section(compile_info, op_info):
470 489 
471 meta_info = {}490 meta_info = {}
@@ -634,6 +653,9 @@ def gen_kernel_fun(compile_info: CompileInfo, func_name: str, opinfo: OpInfo, \
634 func_name, opinfo, tiling_info, has_template=False)653 func_name, opinfo, tiling_info, has_template=False)
635 source += "#endif\n"654 source += "#endif\n"
636 655 
656+ if len(compile_info.tiling_key_struct_map) > 0:
657+ source += _gen_tpl_tiling_struct_section(compile_info, tiling_info)
658+ 
637 # aicore exception restart main block659 # aicore exception restart main block
638 if global_var_storage.get_variable("ascendc_enable_aicore_exception_restart"):660 if global_var_storage.get_variable("ascendc_enable_aicore_exception_restart"):
639 for key in tiling_info.tiling_key_list:661 for key in tiling_info.tiling_key_list:
@@ -798,7 +820,7 @@ def gen_tiling_struct_size_and_dfx_section_file(compile_info: CompileInfo, tilin
798 for tiling_key_slave in compile_info.tiling_key_group_map[tiling_key]:820 for tiling_key_slave in compile_info.tiling_key_group_map[tiling_key]:
799 source += gen_dfx_section_for_one_tiling_key_dynamic(compile_info, tiling_key_slave, \821 source += gen_dfx_section_for_one_tiling_key_dynamic(compile_info, tiling_key_slave, \
800 tiling_info, tiling_key_struct_size_map)822 tiling_info, tiling_key_struct_size_map)
801- 823+ 
802 try:824 try:
803 with os.fdopen(\825 with os.fdopen(\
804 os.open(out_file, os.O_TRUNC | os.O_RDWR | os.O_CREAT, stat.S_IWUSR | stat.S_IRUSR), 'w') as ofd:826 os.open(out_file, os.O_TRUNC | os.O_RDWR | os.O_CREAT, stat.S_IWUSR | stat.S_IRUSR), 'w') as ofd:
@@ -893,7 +915,8 @@ def _get_tiling_struct_without_register_size(compile_info: CompileInfo):
893 name_part = match.split('.ascendc_tiling.', 1)[1]915 name_part = match.split('.ascendc_tiling.', 1)[1]
894 name_part = name_part.rsplit('.', 1)[0]916 name_part = name_part.rsplit('.', 1)[0]
895 917 
896- get_tiling_key_struct_size_map(tiling_key_struct_size_map, name_part, compile_info, 0)918+ tiling_key_struct_size_map = get_tiling_key_struct_size_map(tiling_key_struct_size_map, \
919+ name_part, compile_info, 0)
897 920 
898 for section_name in section_name_set:921 for section_name in section_name_set:
899 objdump_cmd = ['llvm-objdump', '-s', '-j', '{}'.format(section_name), '{}'.format(compile_info.dst_file)]922 objdump_cmd = ['llvm-objdump', '-s', '-j', '{}'.format(section_name), '{}'.format(compile_info.dst_file)]
@@ -908,7 +931,8 @@ def _get_tiling_struct_without_register_size(compile_info: CompileInfo):
908 bytes_data = bytes.fromhex(hex_num_str)931 bytes_data = bytes.fromhex(hex_num_str)
909 dec_data = struct.unpack('>Q', bytes_data)[0]932 dec_data = struct.unpack('>Q', bytes_data)[0]
910 name_part = section_name.split('.ascendc_tiling.', 1)[1].rsplit('.', 1)[0]933 name_part = section_name.split('.ascendc_tiling.', 1)[1].rsplit('.', 1)[0]
911- get_tiling_key_struct_size_map(tiling_key_struct_size_map, name_part, compile_info, dec_data)934+ tiling_key_struct_size_map = get_tiling_key_struct_size_map(tiling_key_struct_size_map, \
935+ name_part, compile_info, dec_data)
912 max_tiling_size = max(max_tiling_size, dec_data)936 max_tiling_size = max(max_tiling_size, dec_data)
913 compile_info.max_tiling_size = max_tiling_size937 compile_info.max_tiling_size = max_tiling_size
914 return tiling_key_struct_size_map938 return tiling_key_struct_size_map
@@ -953,11 +977,17 @@ def _update_compile_option(kernel_name: str, compile_options: list, extend_optio
953 "include", "ascendc", "asc_devkit_version.h")977 "include", "ascendc", "asc_devkit_version.h")
954 compile_options.append("-I" + os.path.join(asc_path, "impl", "adv_api"))978 compile_options.append("-I" + os.path.join(asc_path, "impl", "adv_api"))
955 compile_options.append("-I" + os.path.join(asc_path, "impl", "basic_api"))979 compile_options.append("-I" + os.path.join(asc_path, "impl", "basic_api"))
980+ compile_options.append("-I" + os.path.join(asc_path, "impl", "c_api"))
981+ compile_options.append("-I" + os.path.join(asc_path, "impl", "micro_api"))
982+ compile_options.append("-I" + os.path.join(asc_path, "impl", "simt_api"))
956 compile_options.append("-I" + os.path.join(asc_path, "impl", "utils"))983 compile_options.append("-I" + os.path.join(asc_path, "impl", "utils"))
957 compile_options.append("-I" + os.path.join(asc_path, "include"))984 compile_options.append("-I" + os.path.join(asc_path, "include"))
958 compile_options.append("-I" + os.path.join(asc_path, "include", "adv_api"))985 compile_options.append("-I" + os.path.join(asc_path, "include", "adv_api"))
959 compile_options.append("-I" + os.path.join(asc_path, "include", "basic_api"))986 compile_options.append("-I" + os.path.join(asc_path, "include", "basic_api"))
960 compile_options.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))987 compile_options.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))
988+ compile_options.append("-I" + os.path.join(asc_path, "include", "c_api"))
989+ compile_options.append("-I" + os.path.join(asc_path, "include", "micro_api"))
990+ compile_options.append("-I" + os.path.join(asc_path, "include", "simt_api"))
961 compile_options.append("-I" + os.path.join(asc_path, "include", "utils"))991 compile_options.append("-I" + os.path.join(asc_path, "include", "utils"))
962 compile_options.append("-I" + os.path.join(asc_path, "..", "..", "include"))992 compile_options.append("-I" + os.path.join(asc_path, "..", "..", "include"))
963 compile_options.append("-I" + os.path.join(asc_path, "..", "..", "include", "ascendc"))993 compile_options.append("-I" + os.path.join(asc_path, "..", "..", "include", "ascendc"))
@@ -1051,6 +1081,7 @@ def compile_op_common_part(cce_file: str, origin_func_name: str, op_info: OpInfo
1051 compile_info.tiling_key_group_map = tiling_key_group_map1081 compile_info.tiling_key_group_map = tiling_key_group_map
1052 compile_info.compile_log_path = compile_log_path1082 compile_info.compile_log_path = compile_log_path
1053 compile_info.hard_sync = infered_info_from_ifile.hard_sync or hardware_sync_in_asm1083 compile_info.hard_sync = infered_info_from_ifile.hard_sync or hardware_sync_in_asm
1084+ compile_info.has_kfc_server = not infered_info_from_ifile.no_kfc_server_flag
1054 compile_info.enable_deterministic = infered_info_from_ifile.enable_deterministic1085 compile_info.enable_deterministic = infered_info_from_ifile.enable_deterministic
1055 compile_info.tiling_key_deterministic = infered_info_from_ifile.tiling_key_deterministic1086 compile_info.tiling_key_deterministic = infered_info_from_ifile.tiling_key_deterministic
1056 compile_info.tiling_key_kernel_type = infered_info_from_ifile.tiling_key_kernel_type1087 compile_info.tiling_key_kernel_type = infered_info_from_ifile.tiling_key_kernel_type
@@ -1062,6 +1093,8 @@ def compile_op_common_part(cce_file: str, origin_func_name: str, op_info: OpInfo
1062 else default_dump_info1093 else default_dump_info
1063 compile_info.template_tiling_info = infered_info_from_ifile.template_tiling_info1094 compile_info.template_tiling_info = infered_info_from_ifile.template_tiling_info
1064 compile_info.tiling_key_struct_map = infered_info_from_ifile.tiling_key_struct_map1095 compile_info.tiling_key_struct_map = infered_info_from_ifile.tiling_key_struct_map
1096+ compile_info.register_tiling_struct = infered_info_from_ifile.register_tiling_struct
1097+ compile_info.tpl_tiling_struct = infered_info_from_ifile.tpl_tiling_struct
1065 1098 
1066 set_dump_assert_flag(compile_info)1099 set_dump_assert_flag(compile_info)
1067 1100 
@@ -1223,7 +1256,6 @@ def compile_op(cce_file: str, origin_func_name: str, op_info: OpInfo, compile_op
1223 """1256 """
1224 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["compile_op_start"], AscendCLogLevel.LOG_INFO)1257 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["compile_op_start"], AscendCLogLevel.LOG_INFO)
1225 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["preprocess_start"], AscendCLogLevel.LOG_INFO)1258 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["preprocess_start"], AscendCLogLevel.LOG_INFO)
1226- process_ascendc_api_version(cce_file, compile_options, extend_options)
1227 # online compile reuses thread, dfx infos need to be reset.1259 # online compile reuses thread, dfx infos need to be reset.
1228 global_var_storage.global_storage_reset()1260 global_var_storage.global_storage_reset()
1229 if extend_options.get('opp_kernel_hidden_dat_path', None) is None and not os.path.exists(cce_file):1261 if extend_options.get('opp_kernel_hidden_dat_path', None) is None and not os.path.exists(cce_file):
@@ -1282,7 +1314,6 @@ def compile_op_with_customized_config(cce_file: str, origin_func_name: str, op_i
1282 """1314 """
1283 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["compile_op_start"], AscendCLogLevel.LOG_INFO)1315 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["compile_op_start"], AscendCLogLevel.LOG_INFO)
1284 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["preprocess_start"], AscendCLogLevel.LOG_INFO)1316 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["preprocess_start"], AscendCLogLevel.LOG_INFO)
1285- process_ascendc_api_version(cce_file, compile_options, extend_options)
1286 # online compile reuses thread, dfx infos need to be reset.1317 # online compile reuses thread, dfx infos need to be reset.
1287 global_var_storage.global_storage_reset()1318 global_var_storage.global_storage_reset()
1288 if extend_options.get('opp_kernel_hidden_dat_path', None) is None and not os.path.exists(cce_file):1319 if extend_options.get('opp_kernel_hidden_dat_path', None) is None and not os.path.exists(cce_file):
@@ -605,8 +605,10 @@ def gen_static_shape(tiling_def, tilingdata, struct_tiling_def_base, all_dynamic
605 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"605 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"
606 class_body += f"#include \"kernel_log.h\"\n"606 class_body += f"#include \"kernel_log.h\"\n"
607 class_body += "#else\n"607 class_body += "#else\n"
608+ class_body += "#ifndef __aicore__\n"
608 class_body += "#define __aicore__ [aicore]\n"609 class_body += "#define __aicore__ [aicore]\n"
609 class_body += "#endif\n"610 class_body += "#endif\n"
611+ class_body += "#endif\n"
610 if not global_var_storage.get_variable("ascendc_tiling_no_register"):612 if not global_var_storage.get_variable("ascendc_tiling_no_register"):
611 class_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"613 class_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"
612 # all tiling struct info by dynamic, except the only one top-level struct of static-shape one itself614 # all tiling struct info by dynamic, except the only one top-level struct of static-shape one itself
@@ -758,8 +760,10 @@ def gen_dynamic_shape(tiling_def, struct_tiling_def_base):
758 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"760 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"
759 class_body += f"#include \"kernel_log.h\"\n"761 class_body += f"#include \"kernel_log.h\"\n"
760 class_body += "#else\n"762 class_body += "#else\n"
763+ class_body += "#ifndef __aicore__\n"
761 class_body += "#define __aicore__ [aicore]\n"764 class_body += "#define __aicore__ [aicore]\n"
762 class_body += "#endif\n"765 class_body += "#endif\n"
766+ class_body += "#endif\n"
763 if not global_var_storage.get_variable("ascendc_tiling_no_register"):767 if not global_var_storage.get_variable("ascendc_tiling_no_register"):
764 class_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"768 class_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"
765 class_body += get_struct_shape(struct_tiling_def_base)769 class_body += get_struct_shape(struct_tiling_def_base)
@@ -974,8 +978,10 @@ def get_header_and_sub_struct_def(tiling_def, struct_tiling_def_base):
974 start_body += f"#ifdef ASCENDC_CPU_DEBUG\n"978 start_body += f"#ifdef ASCENDC_CPU_DEBUG\n"
975 start_body += f"#include \"kernel_log.h\"\n"979 start_body += f"#include \"kernel_log.h\"\n"
976 start_body += "#else\n"980 start_body += "#else\n"
981+ start_body += "#ifndef __aicore__\n"
977 start_body += "#define __aicore__ [aicore]\n"982 start_body += "#define __aicore__ [aicore]\n"
978 start_body += "#endif\n"983 start_body += "#endif\n"
984+ start_body += "#endif\n"
979 if not global_var_storage.get_variable("ascendc_tiling_no_register"):985 if not global_var_storage.get_variable("ascendc_tiling_no_register"):
980 start_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"986 start_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"
981 start_body += get_struct_shape(struct_tiling_def_base)987 start_body += get_struct_shape(struct_tiling_def_base)
@@ -1117,8 +1123,8 @@ def get_tiling_data_func_head():
1117def get_tiling_data_func():1123def get_tiling_data_func():
1118 class_body = "{\n"1124 class_body = "{\n"
1119 class_body += " constexpr uint64_t all_bytes = sizeof(T);\n"1125 class_body += " constexpr uint64_t all_bytes = sizeof(T);\n"
1120- class_body += "#if defined(ASCENDC_CPU_DEBUG) || defined(__DAV_C220_CUBE__) || defined(__DAV_C310_CUBE__) || \1126+ class_body += "#if defined(ASCENDC_CPU_DEBUG) || (defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201) || (defined \
1121-defined(__DAV_310R6_CUBE__) || defined(__GET_CODE_CHANNEL__)\n"1127+ (__DAV_CUBE__) && __NPU_ARCH__ == 3101) || defined(__DAV_310R6_CUBE__) || defined(__GET_CODE_CHANNEL__)\n"
1122 class_body += "#if defined(__DAV_C100__) || defined(ASCENDC_CPU_DEBUG)\n"1128 class_body += "#if defined(__DAV_C100__) || defined(ASCENDC_CPU_DEBUG)\n"
1123 class_body += get_dynamic_assign_tiling_data_by_size("all_bytes", "const __gm__", "(const __gm__ uint8_t *)\1129 class_body += get_dynamic_assign_tiling_data_by_size("all_bytes", "const __gm__", "(const __gm__ uint8_t *)\
1124p_tilingdata")1130p_tilingdata")
@@ -1126,24 +1132,25 @@ p_tilingdata")
1126 class_body += " copy_data_align64((uint8_t*)tilingdata, (__gm__ uint8_t *)p_tilingdata, all_bytes);\n"1132 class_body += " copy_data_align64((uint8_t*)tilingdata, (__gm__ uint8_t *)p_tilingdata, all_bytes);\n"
1127 class_body += "#endif\n"1133 class_body += "#endif\n"
1128 class_body += "#else\n"1134 class_body += "#else\n"
1129- class_body += "#if defined(__DAV_C310__) && defined(__ASCENDC_ENABLE_VEC_TAIL_TILING_COPY__) \n"1135+ class_body += "#if __NPU_ARCH__ == 3101 && defined(__ASCENDC_ENABLE_VEC_TAIL_TILING_COPY__) \n"
1130 class_body += _gen_tiling_copy_through_reserved_ub()1136 class_body += _gen_tiling_copy_through_reserved_ub()
1131 class_body += "#else \n"1137 class_body += "#else \n"
1132 class_body += " __ubuf__ uint8_t *tilingdata_in_ub = (__ubuf__ uint8_t *)get_imm(0);\n"1138 class_body += " __ubuf__ uint8_t *tilingdata_in_ub = (__ubuf__ uint8_t *)get_imm(0);\n"
1133 class_body += " constexpr uint32_t len_burst = (all_bytes + 31) / 32;\n"1139 class_body += " constexpr uint32_t len_burst = (all_bytes + 31) / 32;\n"
1134- class_body += "#if defined(__DAV_C310__) || defined(__DAV_310R6__) || __NPU_ARCH__ == 5102\n"1140+ class_body += "#if __NPU_ARCH__ == 3101 || defined(__DAV_310R6__) || __NPU_ARCH__ == 5102\n"
1135 class_body += " copy_gm_to_ubuf_align_v2((__ubuf__ uint8_t *)tilingdata_in_ub, \1141 class_body += " copy_gm_to_ubuf_align_v2((__ubuf__ uint8_t *)tilingdata_in_ub, \
1136(__gm__ uint8_t *)p_tilingdata, 0, 1, len_burst * 32, 0, 0, false, 0, 0, 0);\n"1142(__gm__ uint8_t *)p_tilingdata, 0, 1, len_burst * 32, 0, 0, false, 0, 0, 0);\n"
1137 class_body += get_tilingdata_preload()1143 class_body += get_tilingdata_preload()
1138- class_body += "#elif __NPU_ARCH__ != 3102\n"1144+ class_body += "#elif __NPU_ARCH__ == 3103 || __NPU_ARCH__ == 3003\n"
1139- class_body += " copy_gm_to_ubuf(((__ubuf__ uint8_t *)tilingdata_in_ub), p_tilingdata, 0, 1,\
1140-len_burst, 0, 0);\n"
1141- class_body += "#elif __NPU_ARCH__ == 3003\n"
1142 class_body += " copy_gm_to_ubuf(((__ubuf__ void *)tilingdata_in_ub), (__gm__ void *)p_tilingdata, 0, 1, \1145 class_body += " copy_gm_to_ubuf(((__ubuf__ void *)tilingdata_in_ub), (__gm__ void *)p_tilingdata, 0, 1, \
1143len_burst, 0, 0);\n"1146len_burst, 0, 0);\n"
1144 class_body += "#elif __NPU_ARCH__ == 3113\n"1147 class_body += "#elif __NPU_ARCH__ == 3113\n"
1145 class_body += " copy_gm_to_ubuf_align_v2((__ubuf__ uint8_t *)tilingdata_in_ub, \1148 class_body += " copy_gm_to_ubuf_align_v2((__ubuf__ uint8_t *)tilingdata_in_ub, \
1146(__gm__ uint8_t *)p_tilingdata, 0, 1, len_burst * 32, 0, 0, false, 0, 0);\n"1149(__gm__ uint8_t *)p_tilingdata, 0, 1, len_burst * 32, 0, 0, false, 0, 0);\n"
1150+ 
1151+ class_body += "#elif __NPU_ARCH__ != 3102\n"
1152+ class_body += " copy_gm_to_ubuf(((__ubuf__ uint8_t *)tilingdata_in_ub), p_tilingdata, 0, 1,\
1153+len_burst, 0, 0);\n"
1147 class_body += "#else\n"1154 class_body += "#else\n"
1148 class_body += " copy_gm_to_ubuf_align(((__ubuf__ uint8_t *)tilingdata_in_ub), (__gm__ uint8_t *)p_tilingdata,\1155 class_body += " copy_gm_to_ubuf_align(((__ubuf__ uint8_t *)tilingdata_in_ub), (__gm__ uint8_t *)p_tilingdata,\
11490, 1, all_bytes, 0, 0, 0, 0);\n"11560, 1, all_bytes, 0, 0, 0, 0);\n"
@@ -1270,8 +1277,10 @@ def gen_static_shape_v2(optype:str, tiling_struct: str, tiling_raw_data: str):
1270 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"1277 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"
1271 class_body += f"#include \"kernel_log.h\"\n"1278 class_body += f"#include \"kernel_log.h\"\n"
1272 class_body += "#else\n"1279 class_body += "#else\n"
1280+ class_body += "#ifndef __aicore__\n"
1273 class_body += "#define __aicore__ [aicore]\n"1281 class_body += "#define __aicore__ [aicore]\n"
1274 class_body += "#endif\n"1282 class_body += "#endif\n"
1283+ class_body += "#endif\n"
1275 if global_var_storage.get_variable("ascendc_tiling_no_register"):1284 if global_var_storage.get_variable("ascendc_tiling_no_register"):
1276 class_body += "#define ASCENDC_INTERNAL_STR(x) #x \n"1285 class_body += "#define ASCENDC_INTERNAL_STR(x) #x \n"
1277 class_body += "#define ASCENDC_INTERNAL_EXPAND_AND_STRINGIFY(x) ASCENDC_INTERNAL_STR(x) \n"1286 class_body += "#define ASCENDC_INTERNAL_EXPAND_AND_STRINGIFY(x) ASCENDC_INTERNAL_STR(x) \n"
@@ -1306,8 +1315,10 @@ def gen_dynamic_shape_v2(optype:str, tiling_struct: str):
1306 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"1315 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"
1307 class_body += f"#include \"kernel_log.h\"\n"1316 class_body += f"#include \"kernel_log.h\"\n"
1308 class_body += "#else\n"1317 class_body += "#else\n"
1318+ class_body += "#ifndef __aicore__\n"
1309 class_body += "#define __aicore__ [aicore]\n"1319 class_body += "#define __aicore__ [aicore]\n"
1310 class_body += "#endif\n"1320 class_body += "#endif\n"
1321+ class_body += "#endif\n"
1311 if global_var_storage.get_variable("ascendc_tiling_no_register"):1322 if global_var_storage.get_variable("ascendc_tiling_no_register"):
1312 class_body += "#define ASCENDC_INTERNAL_STR(x) #x \n"1323 class_body += "#define ASCENDC_INTERNAL_STR(x) #x \n"
1313 class_body += "#define ASCENDC_INTERNAL_EXPAND_AND_STRINGIFY(x) ASCENDC_INTERNAL_STR(x) \n"1324 class_body += "#define ASCENDC_INTERNAL_EXPAND_AND_STRINGIFY(x) ASCENDC_INTERNAL_STR(x) \n"
@@ -139,11 +139,7 @@ AscendCLogLevel.LOG_ERROR)
139 @staticmethod139 @staticmethod
140 def get_dump_info_from_i_file(content):140 def get_dump_info_from_i_file(content):
141 dump_info = {"dump_type": "", "dump_size": 1048576}141 dump_info = {"dump_type": "", "dump_size": 1048576}
142- actual_dump_size = 1048576142+ actual_dump_size = 1048576 * CommonUtility.get_dump_core_num()
143- if CommonUtility.is_c310() or CommonUtility.is_310r6():
144- actual_dump_size *= 108
145- else:
146- actual_dump_size *= 75
147 143 
148 match_printf = re.search(r"__enable_feature_for_compile_printf = 1", content)144 match_printf = re.search(r"__enable_feature_for_compile_printf = 1", content)
149 match_assert = re.search(r"__enable_feature_for_compile_assert = 1;", content)145 match_assert = re.search(r"__enable_feature_for_compile_assert = 1;", content)
@@ -171,13 +167,12 @@ AscendCLogLevel.LOG_ERROR)
171 if match:167 if match:
172 dump_info["dump_size"] = int(match.group(1))168 dump_info["dump_size"] = int(match.group(1))
173 169 
174- if CommonUtility.is_c310() or CommonUtility.is_310r6():170+ actual_dump_size = CommonUtility.get_dump_core_num() * dump_info["dump_size"]
175- actual_dump_size = 108 * dump_info["dump_size"]171+ 
176- else:
177- actual_dump_size = 75 * dump_info["dump_size"]
178 simt_in_c310 = match_simtvf and (CommonUtility.is_c310() or CommonUtility.is_310r6())172 simt_in_c310 = match_simtvf and (CommonUtility.is_c310() or CommonUtility.is_310r6())
179 if dump_info["dump_type"] != "" and simt_in_c310:173 if dump_info["dump_type"] != "" and simt_in_c310:
180- actual_dump_size = 1048576 * 108 + 72 * 2048 * 2048 # david 72 vec + 36 cube + simt174+ # david 72 vec + 36 cube + simt
175+ actual_dump_size = 1048576 * CommonUtility.get_dump_core_num() + 72 * 2048 * 2048
181 dump_info["dump_size"] = 1048576 # reserved for ONE_CORE_DUMP_SIZE176 dump_info["dump_size"] = 1048576 # reserved for ONE_CORE_DUMP_SIZE
182 177 
183 global_var_storage.set_variable("ascendc_required_dump_workspace_size", actual_dump_size)178 global_var_storage.set_variable("ascendc_required_dump_workspace_size", actual_dump_size)
@@ -357,6 +352,8 @@ REGISTER_TILING_DEFAULT')
357 find_kfc_server = False352 find_kfc_server = False
358 default_tiling_struct = ""353 default_tiling_struct = ""
359 tiling_struct_expr_map = {}354 tiling_struct_expr_map = {}
355+ register_tiling_struct = set()
356+ tpl_tiling_struct = set()
360 if not (CommonUtility.is_v220() or CommonUtility.is_c310() or CommonUtility.is_310r6()):357 if not (CommonUtility.is_v220() or CommonUtility.is_c310() or CommonUtility.is_310r6()):
361 code_channel = CORE_TYPE_MIX358 code_channel = CORE_TYPE_MIX
362 if global_var_storage.get_variable("ascendc_enable_super_kernel") is True:359 if global_var_storage.get_variable("ascendc_enable_super_kernel") is True:
@@ -464,6 +461,9 @@ REGISTER_TILING_DEFAULT')
464 KernelInfoInfer.get_tiling_key_kernel_type_in_group(tiling_key_kernel_type, \461 KernelInfoInfer.get_tiling_key_kernel_type_in_group(tiling_key_kernel_type, \
465 tiling_key_kernel_type_full)462 tiling_key_kernel_type_full)
466 463 
464+ for tiling_struct in tiling_struct_expr_map.keys():
465+ register_tiling_struct.add(tiling_struct)
466+ 
467 if declare_param_str and select_param_str:467 if declare_param_str and select_param_str:
468 # TPL468 # TPL
469 extract_template_tiling_info(declare_param_str, select_param_str)469 extract_template_tiling_info(declare_param_str, select_param_str)
@@ -550,11 +550,15 @@ REGISTER_TILING_DEFAULT')
550 tiling_struct_expr_map, compile_log_path, \550 tiling_struct_expr_map, compile_log_path, \
551 tiling_key_group_map)551 tiling_key_group_map)
552 552 
553+ for tiling_struct in tiling_key_struct_map.values():
554+ tpl_tiling_struct.add(tiling_struct)
555+ 
553 return InferChannelParamsFromIFile(tiling_key_list, code_channel, hard_sync, no_kfc_server_flag, \556 return InferChannelParamsFromIFile(tiling_key_list, code_channel, hard_sync, no_kfc_server_flag, \
554 enable_deterministic, tiling_key_kernel_type, no_set_kernel_type,\557 enable_deterministic, tiling_key_kernel_type, no_set_kernel_type,\
555 default_kernel_type, dump_info, decode_tiling_result,558 default_kernel_type, dump_info, decode_tiling_result,
556 default_tiling_struct, tiling_struct_expr_map, tiling_key_struct_map,\559 default_tiling_struct, tiling_struct_expr_map, tiling_key_struct_map,\
557- set_task_bar, wait_task_bar, tiling_key_deterministic, tiling_key_group_map)560+ register_tiling_struct, tpl_tiling_struct, set_task_bar, wait_task_bar, \
561+ tiling_key_deterministic, tiling_key_group_map)
558 562 
559 @staticmethod563 @staticmethod
560 def get_tiling_key_kernel_type_in_group(tiling_key_kernel_type, tiling_key_kernel_type_origin):564 def get_tiling_key_kernel_type_in_group(tiling_key_kernel_type, tiling_key_kernel_type_origin):
@@ -123,13 +123,7 @@ class LogUtil:
123 @staticmethod123 @staticmethod
124 def log_print(kernel_name: str, msg_info: str, log_level: AscendCLogLevel, option: Option = Option.DEFAULT):124 def log_print(kernel_name: str, msg_info: str, log_level: AscendCLogLevel, option: Option = Option.DEFAULT):
125 short_soc_version = global_var_storage.get_variable("ascendc_short_soc_version")125 short_soc_version = global_var_storage.get_variable("ascendc_short_soc_version")
126- current_time = datetime.now()126+ tim_head = datetime.now().strftime("[%Y-%m-%d %H:%M:%S]")
127- tim_head = "[{}-{}-{} {}:{}:{}]".format(current_time.year,
128- current_time.month,
129- current_time.day,
130- current_time.hour,
131- current_time.minute,
132- current_time.second)
133 level_info = " [{}]".format(LOG_LEVEL_TO_STR[log_level])127 level_info = " [{}]".format(LOG_LEVEL_TO_STR[log_level])
134 log_msg = tim_head + level_info128 log_msg = tim_head + level_info
135 if option is not LogUtil.Option.NON_SOC:129 if option is not LogUtil.Option.NON_SOC:
@@ -17,16 +17,16 @@ import stat
17from .global_storage import global_var_storage17from .global_storage import global_var_storage
18from .super_kernel_utility import KernelMetaType, \18from .super_kernel_utility import KernelMetaType, \
19 CommonUtility, gen_func_align_attribute19 CommonUtility, gen_func_align_attribute
20-from .super_kernel_op_compile import super_kernel_compile, gen_file_header20+from .super_kernel_op_compile import compile_super_kernel, gen_file_header
21from .super_kernel_constants import SuperKernelPreLoadMode, SuperKernelDataCacheMode, \21from .super_kernel_constants import SuperKernelPreLoadMode, SuperKernelDataCacheMode, \
22 SuperKernelEarlyStartMode, SubOperatorType, SuperKernelDebugDcciAllMode, SuperKernelDebugSyncAllMode, \22 SuperKernelEarlyStartMode, SubOperatorType, SuperKernelDebugDcciAllMode, SuperKernelDebugSyncAllMode, \
23- SuperKernelFeedSyncAllMode, SuperKernelProfilingMode, ERR_CODE23+ SuperKernelFeedSyncAllMode, SuperKernelProfilingMode, ERR_CODE, SuperKernelDeviceType
24from .super_kernel_compile_base import gen_super_dump_code24from .super_kernel_compile_base import gen_super_dump_code
25from .super_kernel_sub_op_infos import indent_code_func, SubOperatorInfos25from .super_kernel_sub_op_infos import indent_code_func, SubOperatorInfos
26from .super_kernel_op_infos import SuperOperatorInfos26from .super_kernel_op_infos import SuperOperatorInfos
27 27 
28 28 
29-def gen_early_start_config(pre_sub_operator: SubOperatorInfos, sub_operator: SubOperatorInfos):29+def kernel_meta_type_to_device_type(kernelMetaType: KernelMetaType):
30 aiv_configs = [30 aiv_configs = [
31 KernelMetaType.KERNEL_TYPE_AIV_ONLY,31 KernelMetaType.KERNEL_TYPE_AIV_ONLY,
32 KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0,32 KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0,
@@ -39,25 +39,41 @@ def gen_early_start_config(pre_sub_operator: SubOperatorInfos, sub_operator: Sub
39 KernelMetaType.KERNEL_TYPE_MIX_AIC_1_1,39 KernelMetaType.KERNEL_TYPE_MIX_AIC_1_1,
40 KernelMetaType.KERNEL_TYPE_MIX_AIC_1_2,40 KernelMetaType.KERNEL_TYPE_MIX_AIC_1_2,
41 ]41 ]
42- if pre_sub_operator.kernel_type in aic_configs:42+ 
43+ if kernelMetaType in aiv_configs:
44+ return SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIV.value
45+ if kernelMetaType in aic_configs:
46+ return SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value
47+ if kernelMetaType in mix_configs:
48+ return SuperKernelDeviceType.KERNEL_DEVICE_TYPE_MIX.value
49+ return SuperKernelDeviceType.KERNEL_DEVICE_TYPE_MAX.value
50+ 
51+ 
52+def gen_early_start_config(pre_sub_operator: SubOperatorInfos, sub_operator: SubOperatorInfos):
53+ pre_sub_operator_device_type = kernel_meta_type_to_device_type(pre_sub_operator.kernel_type)
54+ sub_operator_device_type = kernel_meta_type_to_device_type(sub_operator.kernel_type)
55+ 
56+ if pre_sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value:
43 prev_sub_kernel_config = 057 prev_sub_kernel_config = 0
44- elif pre_sub_operator.kernel_type in aiv_configs:58+ elif pre_sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIV.value:
45 prev_sub_kernel_config = 159 prev_sub_kernel_config = 1
46- elif pre_sub_operator.kernel_type in mix_configs:60+ elif pre_sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_MIX.value:
47 prev_sub_kernel_config = 261 prev_sub_kernel_config = 2
48 else:62 else:
49 CommonUtility().ascendc_raise_python_err(ERR_CODE, \63 CommonUtility().ascendc_raise_python_err(ERR_CODE, \
50- f"previous sub kernel type {pre_sub_operator.kernel_type} do not support!")64+ f"Do not support previous sub kernel device type: {pre_sub_operator_device_type}. \
65+ Should be AIC, AIV or MIX.")
51 66 
52- if sub_operator.kernel_type in aic_configs:67+ if sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value:
53 cur_sub_kernel_config = 068 cur_sub_kernel_config = 0
54- elif sub_operator.kernel_type in aiv_configs:69+ elif sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIV.value:
55 cur_sub_kernel_config = 170 cur_sub_kernel_config = 1
56- elif sub_operator.kernel_type in mix_configs:71+ elif sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_MIX.value:
57 cur_sub_kernel_config = 272 cur_sub_kernel_config = 2
58 else:73 else:
59 CommonUtility().ascendc_raise_python_err(ERR_CODE, \74 CommonUtility().ascendc_raise_python_err(ERR_CODE, \
60- f"current sub kernel type {sub_operator.kernel_type} do not support!")75+ f"Do not support current sub kernel device type: {sub_operator_device_type}. \
76+ Should be AIC, AIV or MIX.")
61 77 
62 super_kernel_early_start_config = (prev_sub_kernel_config << 2) | cur_sub_kernel_config78 super_kernel_early_start_config = (prev_sub_kernel_config << 2) | cur_sub_kernel_config
63 # sub_operator.elf.early_start_complement_wait_flag_block79 # sub_operator.elf.early_start_complement_wait_flag_block
@@ -811,16 +827,31 @@ if ASCEND_IS_AIC {{
811 827 
812 828 
813def gen_wait_block_extra_sync(super_operator, pre_sub_operator, sub_operator):829def gen_wait_block_extra_sync(super_operator, pre_sub_operator, sub_operator):
830+ pre_sub_operator_device_type = kernel_meta_type_to_device_type(pre_sub_operator.kernel_type)
831+ sub_operator_device_type = kernel_meta_type_to_device_type(sub_operator.kernel_type)
832+ 
814 extra_sync = ""833 extra_sync = ""
815- # some inter op barrier do not contain aiv only syncall, so extra sync will be needed834+ # When wait block runs on aiv block 0 and inter op barrier does not contain aiv only syncall,
816- extra_sync_pairs = {(KernelMetaType.KERNEL_TYPE_AIC_ONLY, KernelMetaType.KERNEL_TYPE_AIV_ONLY)}835+ # extra aiv syncall will be needed to ensure next op runs after wait block finishes.
836+ extra_aiv_sync_pairs = \
837+ {(SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value, SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIV.value),
838+ (SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value, SuperKernelDeviceType.KERNEL_DEVICE_TYPE_MIX.value)}
817 839 
818- if (pre_sub_operator.kernel_type, sub_operator.kernel_type) not in extra_sync_pairs:
819- return extra_sync
820 840 
821- # in sk aic only cases, inter op barrier contains aic only sync all, no extra sync will be needed841+ # When wait block runs on aic block 0 and inter op barrier does not contain aic only syncall,
822- extra_sync += "// extra sync for wait event\n"842+ # extra aic syncall will be needed to ensure next op runs after wait block finishes.
823- extra_sync += "AscendC::SyncAll<true>();\n\n"843+ extra_aic_sync_pairs = \
844+ {(SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIV.value, SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value)}
845+ 
846+ if (pre_sub_operator_device_type, sub_operator_device_type) in extra_aiv_sync_pairs:
847+ extra_sync += "// extra sync for wait event\n"
848+ extra_sync += "AscendC::SyncAll<true>();\n\n"
849+ elif (pre_sub_operator_device_type, sub_operator_device_type) in extra_aic_sync_pairs:
850+ extra_sync += """
851+// extra sync for wait event
852+ffts_cross_core_sync(PIPE_FIX, AscendC::GetffstMsg(0x0, AscendC::SYNC_AIC_FLAG));
853+wait_flag_dev(AscendC::SYNC_AIC_FLAG);
854+"""
824 855 
825 return extra_sync856 return extra_sync
826 857 
@@ -1016,5 +1047,5 @@ def compile(kernel_infos, called_kernel_name="ascendc_super_kernel_plus", impl_m
1016 CommonUtility().ascendc_raise_python_err(ERR_CODE, ("super kernel compile must provide op lists"))1047 CommonUtility().ascendc_raise_python_err(ERR_CODE, ("super kernel compile must provide op lists"))
1017 super_operator = SuperOperatorInfos(kernel_infos, called_kernel_name)1048 super_operator = SuperOperatorInfos(kernel_infos, called_kernel_name)
1018 gen_super_kernel_file(super_operator)1049 gen_super_kernel_file(super_operator)
1019- super_kernel_compile(super_operator.compile_info, super_operator.compile_log_path)1050+ compile_super_kernel(super_operator.compile_info, super_operator.compile_log_path)
1020 return1051 return
@@ -22,6 +22,14 @@ AI_CORE_STR = "AiCore"
22ERR_CODE = "EB0500"22ERR_CODE = "EB0500"
23 23 
24 24 
25+class SuperKernelDeviceType(enum.Enum):
26+ """super kernel device type"""
27+ KERNEL_DEVICE_TYPE_AIV = 0
28+ KERNEL_DEVICE_TYPE_AIC = 1
29+ KERNEL_DEVICE_TYPE_MIX = 2
30+ KERNEL_DEVICE_TYPE_MAX = 3
31+ 
32+ 
25class SuperKernelEarlyStartMode(enum.Enum):33class SuperKernelEarlyStartMode(enum.Enum):
26 """early start mode"""34 """early start mode"""
27 EarlyStartDisable = 035 EarlyStartDisable = 0
@@ -118,9 +118,9 @@ def gen_system_run_cfg(kernel_type):
118 file_header = ''118 file_header = ''
119 if kernel_type == KernelMetaType.KERNEL_TYPE_AIV_ONLY or \119 if kernel_type == KernelMetaType.KERNEL_TYPE_AIV_ONLY or \
120 kernel_type == KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0:120 kernel_type == KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0:
121- file_header += "#if defined(__DAV_C220_VEC__)\n"121+ file_header += "#if (defined(__DAV_VEC__) && __NPU_ARCH__ == 2201)\n"
122 else:122 else:
123- file_header += "#if defined(__DAV_C220_CUBE__)\n"123+ file_header += "#if (defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201)\n"
124 124
125 file_header += f" __gm__ struct OpSystemRunCfg g_opSystemRunCfg = {{{0}}};\n"125 file_header += f" __gm__ struct OpSystemRunCfg g_opSystemRunCfg = {{{0}}};\n"
126 file_header += f"#else\n"126 file_header += f"#else\n"
@@ -212,11 +212,17 @@ def gen_spk_kernel_call(super_split_info : SuperSplitInfo, split_mode, kernel_ty
212 212
213 cmds.append("-I" + os.path.join(asc_path, "impl", "adv_api"))213 cmds.append("-I" + os.path.join(asc_path, "impl", "adv_api"))
214 cmds.append("-I" + os.path.join(asc_path, "impl", "basic_api"))214 cmds.append("-I" + os.path.join(asc_path, "impl", "basic_api"))
215+ cmds.append("-I" + os.path.join(asc_path, "impl", "c_api"))
216+ cmds.append("-I" + os.path.join(asc_path, "impl", "micro_api"))
217+ cmds.append("-I" + os.path.join(asc_path, "impl", "simt_api"))
215 cmds.append("-I" + os.path.join(asc_path, "impl", "utils"))218 cmds.append("-I" + os.path.join(asc_path, "impl", "utils"))
216 cmds.append("-I" + os.path.join(asc_path, "include"))219 cmds.append("-I" + os.path.join(asc_path, "include"))
217 cmds.append("-I" + os.path.join(asc_path, "include", "adv_api"))220 cmds.append("-I" + os.path.join(asc_path, "include", "adv_api"))
218 cmds.append("-I" + os.path.join(asc_path, "include", "basic_api"))221 cmds.append("-I" + os.path.join(asc_path, "include", "basic_api"))
219 cmds.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))222 cmds.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))
223+ cmds.append("-I" + os.path.join(asc_path, "include", "c_api"))
224+ cmds.append("-I" + os.path.join(asc_path, "include", "micro_api"))
225+ cmds.append("-I" + os.path.join(asc_path, "include", "simt_api"))
220 cmds.append("-I" + os.path.join(asc_path, "include", "utils"))226 cmds.append("-I" + os.path.join(asc_path, "include", "utils"))
221 cmds.append("-I" + os.path.join(asc_path, "..", "ascendc", "act"))227 cmds.append("-I" + os.path.join(asc_path, "..", "ascendc", "act"))
222 cmds.append("-I" + os.path.join(asc_path, "impl"))228 cmds.append("-I" + os.path.join(asc_path, "impl"))
@@ -310,7 +316,7 @@ def localize_symbol_of_sk(split_mode, sks, spk_dst_file, compile_log_path):
310 run_local_cmd(local_synbol_cmds, compile_log_path)316 run_local_cmd(local_synbol_cmds, compile_log_path)
311 317 
312 318 
313-def super_kernel_compile(kernel_info, compile_log_path):319+def compile_super_kernel(kernel_info, compile_log_path, enable_features: dict = None):
314 global_var_storage.set_variable("super_kenel_save_sub_op_files", True)320 global_var_storage.set_variable("super_kenel_save_sub_op_files", True)
315 op_info = OpInfo()321 op_info = OpInfo()
316 compile_options = kernel_info["compile_option"]322 compile_options = kernel_info["compile_option"]
@@ -332,7 +338,8 @@ def super_kernel_compile(kernel_info, compile_log_path):
332 if CommonUtility.is_c310() or CommonUtility.is_310r6() or CommonUtility.is_m510():338 if CommonUtility.is_c310() or CommonUtility.is_310r6() or CommonUtility.is_m510():
333 compile_option_tuple.compile_options.append('--cce-no-dcache-flush')339 compile_option_tuple.compile_options.append('--cce-no-dcache-flush')
334 if kernel_info["timestamp_option"]:340 if kernel_info["timestamp_option"]:
335- compile_options.append('-DONE_CORE_DUMP_SIZE=' + str(compile_info.super_kernel_info["debug_size"] / 75))341+ compile_options.append('-DONE_CORE_DUMP_SIZE=' + str(compile_info.super_kernel_info["debug_size"] \
342+ / CommonUtility.get_dump_core_num()))
336 _compile_ascendc_cce_v220_with_kernel_type_for_static(compile_info, compile_option_tuple, tiling_info) 343 _compile_ascendc_cce_v220_with_kernel_type_for_static(compile_info, compile_option_tuple, tiling_info)
337 sub_objs = gen_super_kernel_link_obj_sequence(compile_info, kernel_info["sub_operator"], kernel_info["link_mode"],344 sub_objs = gen_super_kernel_link_obj_sequence(compile_info, kernel_info["sub_operator"], kernel_info["link_mode"],
338 kernel_info["split_mode"], compile_info.compile_log_path)345 kernel_info["split_mode"], compile_info.compile_log_path)
@@ -345,3 +352,7 @@ def super_kernel_compile(kernel_info, compile_log_path):
345 localization_sub_op_func_sym(compile_info.dst_file, kernel_info["sub_operator"])352 localization_sub_op_func_sym(compile_info.dst_file, kernel_info["sub_operator"])
346 _json_post_process(compile_info, op_info, tiling_info, True, True, compile_info.compile_log_path)353 _json_post_process(compile_info, op_info, tiling_info, True, True, compile_info.compile_log_path)
347 localize_symbol_of_sk(kernel_info["split_mode"], _sk_new, compile_info.dst_file, compile_info.compile_log_path)354 localize_symbol_of_sk(kernel_info["split_mode"], _sk_new, compile_info.dst_file, compile_info.compile_log_path)
355+ 
356+ 
357+def super_kernel_compile(kernel_info, compile_log_path):
358+ compile_super_kernel(kernel_info, compile_log_path)
@@ -58,7 +58,7 @@ def split_dynamic_o_in_super_kernel(orign_bin_path, rename_file_path, i, compile
58 if os.path.exists(new_bin_path):58 if os.path.exists(new_bin_path):
59 str_lst = f'WARNING: ALLREADY EXISTS split .o path: {new_bin_path}'59 str_lst = f'WARNING: ALLREADY EXISTS split .o path: {new_bin_path}'
60 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, compile_log_path)60 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, compile_log_path)
61- cmds = ['cp'] + ['-rf'] + [f'{orign_bin_path}'] + [f'{new_bin_path}']61+ cmds = ['cp'] + ['-rfL'] + [f'{orign_bin_path}'] + [f'{new_bin_path}']
62 try:62 try:
63 CommonUtility.dump_compile_log(cmds, CompileStage.SPLIT_SUB_OBJS, compile_log_path)63 CommonUtility.dump_compile_log(cmds, CompileStage.SPLIT_SUB_OBJS, compile_log_path)
64 subprocess.run(cmds)64 subprocess.run(cmds)
@@ -89,7 +89,7 @@ class SuperOperatorInfos:
89 self.creat_compile_log()89 self.creat_compile_log()
90 self.info_base = []90 self.info_base = []
91 self.super_kernel_params = []91 self.super_kernel_params = []
92- self.enable_double_stream:bool = False92+ self.enable_double_stream: bool = False
93 self.op_options = parse_super_kernel_options(kernel_infos.get("super_kernel_options", ""))93 self.op_options = parse_super_kernel_options(kernel_infos.get("super_kernel_options", ""))
94 self.split_mode = self.op_options.get('split-mode', 4)94 self.split_mode = self.op_options.get('split-mode', 4)
95 self.profiling_mode = self.op_options.get('profiling', SuperKernelProfilingMode.ProfilingDisable)95 self.profiling_mode = self.op_options.get('profiling', SuperKernelProfilingMode.ProfilingDisable)
@@ -501,11 +501,9 @@ class SuperOperatorInfos:
501 recv_info: {sub_op.recv_info}", AscendCLogLevel.LOG_DEBUG)501 recv_info: {sub_op.recv_info}", AscendCLogLevel.LOG_DEBUG)
502 502 
503 def creat_compile_log(self):503 def creat_compile_log(self):
504- op_debug_config_val = get_op_debug_config()504+ kernel_meta_dir = CommonUtility.get_kernel_meta_dir()
505- if "dump_cce" in op_debug_config_val:505+ distinct_tag = CommonUtility.get_distinct_filename_tag()
506- kernel_meta_dir = CommonUtility.get_kernel_meta_dir()506+ self.compile_log_path = os.path.join(kernel_meta_dir, self.kernel_name + distinct_tag + '.log')
507- distinct_tag = CommonUtility.get_distinct_filename_tag()
508- self.compile_log_path = os.path.join(kernel_meta_dir, self.kernel_name + distinct_tag + '.log')
509 507 
510 508 
511 def sub_op_connect_set(self, former_op, op):509 def sub_op_connect_set(self, former_op, op):
@@ -703,7 +701,7 @@ f"ERROR: ratio of super kernel debug-aic-num {debug_aic_num} to debug-aiv-num {d
703 if os.path.exists(new_bin_path):701 if os.path.exists(new_bin_path):
704 str_lst = f'WARNING: ALLREADY EXISTS split .o path: {new_bin_path}'702 str_lst = f'WARNING: ALLREADY EXISTS split .o path: {new_bin_path}'
705 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, self.compile_log_path)703 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, self.compile_log_path)
706- cmds = ['cp'] + ['-rf'] + [f'{orign_bin_path}'] + [f'{new_bin_path}']704+ cmds = ['cp'] + ['-rfL'] + [f'{orign_bin_path}'] + [f'{new_bin_path}']
707 try:705 try:
708 CommonUtility.dump_compile_log(cmds, CompileStage.SPLIT_SUB_OBJS, self.compile_log_path)706 CommonUtility.dump_compile_log(cmds, CompileStage.SPLIT_SUB_OBJS, self.compile_log_path)
709 subprocess.run(cmds)707 subprocess.run(cmds)
@@ -751,6 +749,9 @@ f"ERROR: ratio of super kernel debug-aic-num {debug_aic_num} to debug-aiv-num {d
751 749 
752 750 
753 def add_define_options(self, exist_dynamic_sub_ops, options: list):751 def add_define_options(self, exist_dynamic_sub_ops, options: list):
752+ if self.kernel_type == KernelMetaType.KERNEL_TYPE_MIX_AIC_1_1 and \
753+ (CommonUtility.is_c310() or CommonUtility.is_310r6()):
754+ options.append("-D__ASCENDC_DAVID_SPLIT_CORE__")
754 if exist_dynamic_sub_ops:755 if exist_dynamic_sub_ops:
755 options.append("-D__SUPER_KERNEL_DYNAMIC_BLOCK_NUM__")756 options.append("-D__SUPER_KERNEL_DYNAMIC_BLOCK_NUM__")
756 757 
@@ -800,11 +801,17 @@ f"ERROR: ratio of super kernel debug-aic-num {debug_aic_num} to debug-aiv-num {d
800 801
801 options.append("-I" + os.path.join(asc_path, "impl", "adv_api"))802 options.append("-I" + os.path.join(asc_path, "impl", "adv_api"))
802 options.append("-I" + os.path.join(asc_path, "impl", "basic_api"))803 options.append("-I" + os.path.join(asc_path, "impl", "basic_api"))
804+ options.append("-I" + os.path.join(asc_path, "impl", "c_api"))
805+ options.append("-I" + os.path.join(asc_path, "impl", "micro_api"))
806+ options.append("-I" + os.path.join(asc_path, "impl", "simt_api"))
803 options.append("-I" + os.path.join(asc_path, "impl", "utils"))807 options.append("-I" + os.path.join(asc_path, "impl", "utils"))
804 options.append("-I" + os.path.join(asc_path, "include"))808 options.append("-I" + os.path.join(asc_path, "include"))
805 options.append("-I" + os.path.join(asc_path, "include", "adv_api"))809 options.append("-I" + os.path.join(asc_path, "include", "adv_api"))
806 options.append("-I" + os.path.join(asc_path, "include", "basic_api"))810 options.append("-I" + os.path.join(asc_path, "include", "basic_api"))
807 options.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))811 options.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))
812+ options.append("-I" + os.path.join(asc_path, "include", "c_api"))
813+ options.append("-I" + os.path.join(asc_path, "include", "micro_api"))
814+ options.append("-I" + os.path.join(asc_path, "include", "simt_api"))
808 options.append("-I" + os.path.join(asc_path, "include", "utils"))815 options.append("-I" + os.path.join(asc_path, "include", "utils"))
809 options.append("-I" + os.path.join(asc_path, "..", "ascendc", "act"))816 options.append("-I" + os.path.join(asc_path, "..", "ascendc", "act"))
810 options.append("-I" + os.path.join(asc_path, "impl"))817 options.append("-I" + os.path.join(asc_path, "impl"))
@@ -902,20 +909,20 @@ split_dynamic_o_in_super_kernel(orign_bin_path, rename_file_path_list[i-1], i, s
902 "sub_operator": sub_operator_info,909 "sub_operator": sub_operator_info,
903 "kernel_file": self.kernel_file,910 "kernel_file": self.kernel_file,
904 "compile_option": options,911 "compile_option": options,
905- "kernel_name":self.kernel_name,912+ "kernel_name": self.kernel_name,
906 "link_mode": self.link_mode,913 "link_mode": self.link_mode,
907 "timestamp_option": self.timestamp_option,914 "timestamp_option": self.timestamp_option,
908- "debug_option":self.debug_option,915+ "debug_option": self.debug_option,
909- "debug_size":self.debug_size,916+ "debug_size": self.debug_size,
910 "split_mode": self.split_mode,917 "split_mode": self.split_mode,
911- "op_list" : self.op_list,918+ "op_list": self.op_list,
912 "sp_options": self.op_options,919 "sp_options": self.op_options,
913 "workspace_size": self.workspace_size,920 "workspace_size": self.workspace_size,
914 "param_offset": param_offset,921 "param_offset": param_offset,
915 "notify_param_offset": notify_param_offset,922 "notify_param_offset": notify_param_offset,
916 "wait_param_offset": wait_param_offset,923 "wait_param_offset": wait_param_offset,
917- "send_event_list":send_event_list,924+ "send_event_list": send_event_list,
918- "recv_event_list":recv_event_list925+ "recv_event_list": recv_event_list
919 }926 }
920 927 
921 928 
@@ -125,7 +125,7 @@ def split_kernel(sub_kernels_dict, func_name, obj_path, split_mode, compile_log_
125 if os.path.exists(new_bin_path):125 if os.path.exists(new_bin_path):
126 str_lst = f'ERROR: ALLREADY EXISTS split .o path: {new_bin_path}'126 str_lst = f'ERROR: ALLREADY EXISTS split .o path: {new_bin_path}'
127 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, compile_log_path)127 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, compile_log_path)
128- cmds = ['cp'] + ['-rf'] + [f'{obj_path}'] + [f'{new_bin_path}']128+ cmds = ['cp'] + ['-rfL'] + [f'{obj_path}'] + [f'{new_bin_path}']
129 run_local_cmd(cmds, compile_log_path)129 run_local_cmd(cmds, compile_log_path)
130 new_kernel_name = f"{func_name}_split{i}"130 new_kernel_name = f"{func_name}_split{i}"
131 cmds = ['llvm-objcopy', f'--redefine-sym={func_name}={new_kernel_name}', f'{new_bin_path}']131 cmds = ['llvm-objcopy', f'--redefine-sym={func_name}={new_kernel_name}', f'{new_bin_path}']
@@ -218,4 +218,4 @@ def gen_sub_kernel_name(current_kernel_name: str, arch: str, kernel_type: str, o
218 else:218 else:
219 raise_tbe_python_err(TBE_DEFAULT_PYTHON_ERROR_CODE, \219 raise_tbe_python_err(TBE_DEFAULT_PYTHON_ERROR_CODE, \
220 ("sub super kernel compile must provide super_kernel_sub_info"))220 ("sub super kernel compile must provide super_kernel_sub_info"))
221- return current_kernel_name221+ return current_kernel_name
@@ -46,6 +46,7 @@ class CompileInfo:
46 self.is_debug: bool = False46 self.is_debug: bool = False
47 self.compile_log_path = None47 self.compile_log_path = None
48 self.hard_sync: bool = False48 self.hard_sync: bool = False
49+ self.hard_kfc_server: bool = False
49 self.enable_deterministic: bool = False50 self.enable_deterministic: bool = False
50 self.tiling_key_kernel_type: dict = {}51 self.tiling_key_kernel_type: dict = {}
51 self.tiling_key_deterministic: dict = {}52 self.tiling_key_deterministic: dict = {}
@@ -56,6 +57,8 @@ class CompileInfo:
56 self.sub_core_type: int = -157 self.sub_core_type: int = -1
57 self.template_tiling_info: dict = {}58 self.template_tiling_info: dict = {}
58 self.tiling_key_struct_map: dict = {}59 self.tiling_key_struct_map: dict = {}
60+ self.register_tiling_struct: set = set() # tiling struct found in REGISTER_TILING_XXX
61+ self.tpl_tiling_struct: set = set() # tiling struct found in TPL
59 self.enable_final_super_kernel_compile: bool = False62 self.enable_final_super_kernel_compile: bool = False
60 # if enable_final_super_kernel_compile is True and super_kernel_objs is empty63 # if enable_final_super_kernel_compile is True and super_kernel_objs is empty
61 # means no fatbin, dst_file is the final file64 # means no fatbin, dst_file is the final file
@@ -347,7 +350,7 @@ class CommonUtility:
347 350 
348 @staticmethod351 @staticmethod
349 def ascendc_raise_python_err(err_code, msg):352 def ascendc_raise_python_err(err_code, msg):
350- CommonUtility.print_compile_log("", f"err_msg: {msg}.",353+ CommonUtility.print_compile_log("", f"{msg}",
351 AscendCLogLevel.LOG_ERROR)354 AscendCLogLevel.LOG_ERROR)
352 raise_tbe_python_err(err_code, msg)355 raise_tbe_python_err(err_code, msg)
353 356 
@@ -474,31 +477,6 @@ class CommonUtility:
474 return False477 return False
475 478 
476 479 
477- @staticmethod
478- def is_l300():
479- """return if current soc version is l300
480- 
481- Returns:
482- res: True means l300
483- """
484- short_soc_version = global_var_storage.get_variable("ascendc_short_soc_version")
485- if short_soc_version in ["KirinX90"]:
486- return True
487- return False
488- 
489- @staticmethod
490- def is_l311():
491- """return if current soc version is l311
492- 
493- Returns:
494- res: True means l311
495- """
496- short_soc_version = global_var_storage.get_variable("ascendc_short_soc_version")
497- if short_soc_version in ["Kirin9030"]:
498- return True
499- return False
500- 
501- 
502 @staticmethod480 @staticmethod
503 def is_has_ffts_mode():481 def is_has_ffts_mode():
504 """return if current soc version is has ffts mode482 """return if current soc version is has ffts mode
@@ -538,7 +516,6 @@ class CommonUtility:
538 return True516 return True
539 return False517 return False
540 518 
541- 
542 @staticmethod519 @staticmethod
543 def is_l300():520 def is_l300():
544 """return if current soc version is l300521 """return if current soc version is l300
@@ -551,7 +528,6 @@ class CommonUtility:
551 return True528 return True
552 return False529 return False
553 530 
554- 
555 @staticmethod531 @staticmethod
556 def is_l311():532 def is_l311():
557 """return if current soc version is l311533 """return if current soc version is l311
@@ -564,7 +540,6 @@ class CommonUtility:
564 return True540 return True
565 return False541 return False
566 542 
567- 
568 @staticmethod543 @staticmethod
569 def get_chip_version():544 def get_chip_version():
570 """get chip version for (c220/c310/310r6/510r2)545 """get chip version for (c220/c310/310r6/510r2)
@@ -705,6 +680,12 @@ format(str(stage), output))
705 hex_num_str_list = list(map(reverser_hex_str, hex_num[::-1]))680 hex_num_str_list = list(map(reverser_hex_str, hex_num[::-1]))
706 hex_num_str = ''.join(hex_num_str_list)681 hex_num_str = ''.join(hex_num_str_list)
707 return hex_num_str682 return hex_num_str
683+
684+ @staticmethod
685+ def get_dump_core_num():
686+ if CommonUtility.is_c310() or CommonUtility.is_310r6():
687+ return 108
688+ return 75
708 689 
709 690 
710def is_enable_sanitizer(compile_options):691def is_enable_sanitizer(compile_options):
@@ -923,6 +904,8 @@ def convert_customized_config_to_inferchannel(config: CustomizedConfig):
923 tiling_struct_expr_map = {}904 tiling_struct_expr_map = {}
924 tiling_key_struct_map = \905 tiling_key_struct_map = \
925 {k: str(v.tiling_struct_name) for k, v in tiling_key_infos.items() if str(v.tiling_struct_name) != ''}906 {k: str(v.tiling_struct_name) for k, v in tiling_key_infos.items() if str(v.tiling_struct_name) != ''}
907+ register_tiling_struct = set()
908+ tpl_tiling_struct = set()
926 set_task_bar = False909 set_task_bar = False
927 wait_task_bar = False910 wait_task_bar = False
928 tiling_key_deterministic = {k: str(v.enable_deterministic).lower() for k, v in tiling_key_infos.items()}911 tiling_key_deterministic = {k: str(v.enable_deterministic).lower() for k, v in tiling_key_infos.items()}
@@ -931,7 +914,8 @@ def convert_customized_config_to_inferchannel(config: CustomizedConfig):
931 enable_deterministic, tiling_key_kernel_type, no_set_kernel_type,\914 enable_deterministic, tiling_key_kernel_type, no_set_kernel_type,\
932 default_kernel_type, dump_info, template_tiling_info,915 default_kernel_type, dump_info, template_tiling_info,
933 default_tiling_struct, tiling_struct_expr_map, tiling_key_struct_map,\916 default_tiling_struct, tiling_struct_expr_map, tiling_key_struct_map,\
934- set_task_bar, wait_task_bar, tiling_key_deterministic, None)917+ register_tiling_struct, tpl_tiling_struct, set_task_bar, wait_task_bar, \
918+ tiling_key_deterministic, None)
935 919 
936 920 
937def get_kernel_fun_name_with_tiling_key_and_kernel_type(compile_info: CompileInfo, tiling_key: int):921def get_kernel_fun_name_with_tiling_key_and_kernel_type(compile_info: CompileInfo, tiling_key: int):
@@ -162,7 +162,7 @@ TILINGKEY_PAR_COMPILE is {}".format(parallel_compile_check), AscendCLogLevel.LOG
162 ascendc_self_par_job_num = int(ascendc_self_par_job)162 ascendc_self_par_job_num = int(ascendc_self_par_job)
163 163 
164 if ci_big_makefile_par_switch or ascendc_self_par_job_num > 0:164 if ci_big_makefile_par_switch or ascendc_self_par_job_num > 0:
165- dstfile_with_pid = dstfile_name + str(os.getpid())165+ dstfile_with_pid = os.path.join(CommonUtility.get_kernel_meta_dir(), dstfile_name + "_" + str(os.getpid()))
166 write_mk(tiling_key_list, cmds_list, dstfile_with_pid, compile_log_path)166 write_mk(tiling_key_list, cmds_list, dstfile_with_pid, compile_log_path)
167 # when TILINGKEY_PARALLEL_COMPILATION_SWITCH and ASCENDC_PAR_COMPILE_JOB conflicts167 # when TILINGKEY_PARALLEL_COMPILATION_SWITCH and ASCENDC_PAR_COMPILE_JOB conflicts
168 # TILINGKEY_PARALLEL_COMPILATION_SWITCH first168 # TILINGKEY_PARALLEL_COMPILATION_SWITCH first
@@ -213,4 +213,4 @@ def search_in_line(line, keywords):
213def extract_file_path(line):213def extract_file_path(line):
214 pattern = re.compile(r'"([^"]+)"')214 pattern = re.compile(r'"([^"]+)"')
215 matches = pattern.findall(line)215 matches = pattern.findall(line)
216- return matches[0]216+ return matches[0]
@@ -387,16 +387,19 @@ class DFXSectionGenerator:
387 if not tiling_info.static_shape_flag and not global_var_storage.get_variable("ascendc_tiling_no_register"):387 if not tiling_info.static_shape_flag and not global_var_storage.get_variable("ascendc_tiling_no_register"):
388 self._generate_binary_for_tiling(tiling_key, tiling_info, compile_info)388 self._generate_binary_for_tiling(tiling_key, tiling_info, compile_info)
389 389 
390- section_content = f"// generate dfx section for tiling_key:{tiling_key}\n"390+ section_content = f"// generate dfx section for tiling_key:{tiling_key}"
391 if CommonUtility.is_v220() or CommonUtility.is_c310() or CommonUtility.is_310r6():391 if CommonUtility.is_v220() or CommonUtility.is_c310() or CommonUtility.is_310r6():
392- chip_version = CommonUtility.get_chip_version().upper()392+ if CommonUtility.is_v220():
393- cube_core_type = f"__DAV_{chip_version}_CUBE__"393+ cube_core_marco = "(defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201)"
394- vec_core_type = f"__DAV_{chip_version}_VEC__"394+ vec_core_marco = "(defined(__DAV_VEC__) && __NPU_ARCH__ == 2201)"
395+ elif CommonUtility.is_c310():
396+ cube_core_marco = "(defined(__DAV_CUBE__) && __NPU_ARCH__ == 3101)"
397+ vec_core_marco = "(defined(__DAV_VEC__) && __NPU_ARCH__ == 3101)"
395 else:398 else:
396 # for v200 cube_core_type is aicore type399 # for v200 cube_core_type is aicore type
397- cube_core_type = "__DAV_M200__"400+ cube_core_marco = "defined(__DAV_M200__)"
398- vec_core_type = "__DAV_M200_VEC__"401+ vec_core_marco = "defined(__DAV_M200_VEC__)"
399- 402+ 
400 section_content_body = self.generate_dfx_section_for_one_tiling_key(tiling_key, kernel_name, \403 section_content_body = self.generate_dfx_section_for_one_tiling_key(tiling_key, kernel_name, \
401 compile_info, kernel_type_section)404 compile_info, kernel_type_section)
402 405 
@@ -406,12 +409,12 @@ class DFXSectionGenerator:
406 section_content += self._generate_dfx_info_struct()409 section_content += self._generate_dfx_info_struct()
407 410 
408 if section_content_body is None or section_content_body == "":411 if section_content_body is None or section_content_body == "":
409- return section_content412+ return section_content + f"#endif\n"
410 413 
411 if compile_info.sub_core_type == CORE_TYPE_CUBE:414 if compile_info.sub_core_type == CORE_TYPE_CUBE:
412- section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL && defined({cube_core_type})\n"415+ section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL && {cube_core_marco}\n"
413 elif compile_info.sub_core_type == CORE_TYPE_VEC:416 elif compile_info.sub_core_type == CORE_TYPE_VEC:
414- section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL && defined({vec_core_type})\n"417+ section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL && {vec_core_marco}\n"
415 else:418 else:
416 section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL\n"419 section_content += f"\n#if {TILING_KEY_MACRO} == {tiling_key}UL\n"
417 420 
@@ -119,20 +119,35 @@ def gen_global_isolation_macro(compile_info: CompileInfo, tiling_info: TilingInf
119 tiling_key = tiling_info.tiling_key119 tiling_key = tiling_info.tiling_key
120 120 
121 if CommonUtility.is_v220():121 if CommonUtility.is_v220():
122- macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_C220_VEC__)\n"122+ macro_branch_statment = \
123+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_VEC__) && __NPU_ARCH__ == 2201)\n"
123 # judge operator is aic only124 # judge operator is aic only
124 if compile_info.no_set_kernel_type is False:125 if compile_info.no_set_kernel_type is False:
125 kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]126 kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]
126 if kernel_type.value in [1, 3, 5, 6, 7]:127 if kernel_type.value in [1, 3, 5, 6, 7]:
127- macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_C220_CUBE__)\n"128+ macro_branch_statment = \
129+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201)\n"
128 elif compile_info.code_channel == CORE_TYPE_CUBE:130 elif compile_info.code_channel == CORE_TYPE_CUBE:
129- macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_C220_CUBE__)\n"131+ macro_branch_statment = \
132+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201)\n"
130 elif CommonUtility.is_v200():133 elif CommonUtility.is_v200():
131 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_M200__)\n"134 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_M200__)\n"
132 if compile_info.no_set_kernel_type is False:135 if compile_info.no_set_kernel_type is False:
133 kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]136 kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]
134 if kernel_type.value in [9]:137 if kernel_type.value in [9]:
135 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_M200_VEC__)\n"138 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL && defined(__DAV_M200_VEC__)\n"
139+ elif (CommonUtility.is_c310() or CommonUtility.is_310r6()):
140+ macro_branch_statment = \
141+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_VEC__) && __NPU_ARCH__ == 3101)\n"
142+ # judge operator is aic only
143+ if compile_info.no_set_kernel_type is False:
144+ kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]
145+ if kernel_type.value in [1, 3, 5, 6, 7]:
146+ macro_branch_statment = \
147+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_CUBE__) && __NPU_ARCH__ == 3101)\n"
148+ elif compile_info.code_channel == CORE_TYPE_CUBE:
149+ macro_branch_statment = \
150+ f"#if {TILING_KEY_MACRO} == {tiling_key}UL && (defined(__DAV_CUBE__) && __NPU_ARCH__ == 3101)\n"
136 else:151 else:
137 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL\n"152 macro_branch_statment = f"#if {TILING_KEY_MACRO} == {tiling_key}UL\n"
138 return macro_branch_statment153 return macro_branch_statment
@@ -396,10 +411,11 @@ def get_tiling_key_struct_size_map(tiling_key_struct_size_map, name_part, compil
396 tiling_key_value = tiling_key_value[:-2]411 tiling_key_value = tiling_key_value[:-2]
397 tiling_key_struct_size_map[tiling_key_value] = (tiling_struct, dec_data)412 tiling_key_struct_size_map[tiling_key_value] = (tiling_struct, dec_data)
398 if compile_info.tiling_key_group_map is None:413 if compile_info.tiling_key_group_map is None:
399- return414+ return tiling_key_struct_size_map
400 if tiling_key_value in compile_info.tiling_key_group_map.keys():415 if tiling_key_value in compile_info.tiling_key_group_map.keys():
401 for tiling_key_slave in compile_info.tiling_key_group_map[tiling_key_value]:416 for tiling_key_slave in compile_info.tiling_key_group_map[tiling_key_value]:
402 tiling_key_struct_size_map[tiling_key_slave] = (tiling_struct, dec_data)417 tiling_key_struct_size_map[tiling_key_slave] = (tiling_struct, dec_data)
418+ return tiling_key_struct_size_map
403 419 
404 420 
405def gen_tiling_struct_and_dfx_section_head():421def gen_tiling_struct_and_dfx_section_head():
@@ -489,7 +505,7 @@ def gen_dfx_section_for_one_tiling_key_dynamic(compile_info: CompileInfo, tiling
489 tiling_info: TilingInfo, tiling_key_struct_size_map: dict):505 tiling_info: TilingInfo, tiling_key_struct_size_map: dict):
490 source = ""506 source = ""
491 if compile_info.no_set_kernel_type is False:507 if compile_info.no_set_kernel_type is False:
492- kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)] 508+ kernel_type = compile_info.tiling_key_kernel_type[str(tiling_key)]
493 if kernel_type.value >= 6 and kernel_type.value <= 7:509 if kernel_type.value >= 6 and kernel_type.value <= 7:
494 cube_marker = "_mix_aic"510 cube_marker = "_mix_aic"
495 kernel_name = compile_info.kernel_name + '_%s' % tiling_key + cube_marker511 kernel_name = compile_info.kernel_name + '_%s' % tiling_key + cube_marker
@@ -390,13 +390,18 @@ def call_bisheng_v220(compile_info: CompileInfo, compile_option_tuple, tiling_in
390 390 
391 391 
392def get_ktype_section_head(variable_name: str):392def get_ktype_section_head(variable_name: str):
393- chip_version = CommonUtility.get_chip_version().upper()393+ section_var_head = ""
394- section_var = f""
395 if "mix_aic" in variable_name:394 if "mix_aic" in variable_name:
396- section_var += f"#if defined(__DAV_{chip_version}_CUBE__)\n"395+ if CommonUtility.is_v220():
396+ section_var_head += f"#if (defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201)\n"
397+ elif CommonUtility.is_c310():
398+ section_var_head += f"#if (defined(__DAV_CUBE__) && __NPU_ARCH__ == 3101)\n"
397 elif "mix_aiv" in variable_name:399 elif "mix_aiv" in variable_name:
398- section_var += f"#if defined(__DAV_{chip_version}_VEC__)\n"400+ if CommonUtility.is_v220():
399- return section_var401+ section_var_head += f"#if (defined(__DAV_VEC__) && __NPU_ARCH__ == 2201)\n"
402+ elif CommonUtility.is_c310():
403+ section_var_head += f"#if (defined(__DAV_VEC__) && __NPU_ARCH__ == 3101)\n"
404+ return section_var_head
400 405 
401 406 
402def get_ktype_section_variable(variable_name: str, section_func_name: str, kernel_meta_type: KernelMetaType):407def get_ktype_section_variable(variable_name: str, section_func_name: str, kernel_meta_type: KernelMetaType):
@@ -561,7 +566,6 @@ def v310_mode_cube_ofile(little_endian, binary_32) -> int:
561 '0110101000', # MOV_OUT _TO_L1 _MULTI_DN2NZ566 '0110101000', # MOV_OUT _TO_L1 _MULTI_DN2NZ
562 '0110101100', # MOV_OUT _TO_L1 _MULTI_ND2NZ567 '0110101100', # MOV_OUT _TO_L1 _MULTI_ND2NZ
563 '0110111010', # MOV_OUT_TO_L1_V2568 '0110111010', # MOV_OUT_TO_L1_V2
564- '0111010000', # MOV_OUT_TO_L1_ALIGN_V2
565 '0111011000', # LOAD_L1_TO_L0A_MX_2Dv2和LOAD_L1_TO_L0B_MX_2Dv2569 '0111011000', # LOAD_L1_TO_L0A_MX_2Dv2和LOAD_L1_TO_L0B_MX_2Dv2
566 '0110011100', # LOAD_L1_TO_L0A_3Dv2和LOAD_L1_TO_L0B_3Dv2570 '0110011100', # LOAD_L1_TO_L0A_3Dv2和LOAD_L1_TO_L0B_3Dv2
567 '0110011101',571 '0110011101',
@@ -581,7 +585,7 @@ def v310_mode_cube_ofile(little_endian, binary_32) -> int:
581 (little_endian[0] == 'f' and little_endian[1] in '2345abcd' and binary_32[30] == '0'),585 (little_endian[0] == 'f' and little_endian[1] in '2345abcd' and binary_32[30] == '0'),
582 586 
583 # DMA587 # DMA
584- (binary_32[:9] == '011100100' and binary_32[25:29] in ('0001', '0101')),588+ (binary_32[:9] == '011100100' and binary_32[25:29] in ('0001', '0101')), # DMA move inst, include MOV L1 TO UB
585 (high_10 in cube_high_low_map and binary_32[30:] == cube_high_low_map[high_10]),589 (high_10 in cube_high_low_map and binary_32[30:] == cube_high_low_map[high_10]),
586 (high_10 in cube_high_low2_map and binary_32[31] == cube_high_low2_map[high_10]),590 (high_10 in cube_high_low2_map and binary_32[31] == cube_high_low2_map[high_10]),
587 (high_10 in cube_high_map),591 (high_10 in cube_high_map),
@@ -41,8 +41,9 @@ INPUT_OUTPUT_DTYPE_LEN = {"float": 4, "bool": 1, "int32": 4, "int64": 8, "half":
41InferChannelParamsFromIFile = namedtuple('InferChannelParamsFromIFile', \41InferChannelParamsFromIFile = namedtuple('InferChannelParamsFromIFile', \
42 ['tiling_key_list', 'code_channel', 'hard_sync', 'no_kfc_server_flag', "enable_deterministic", \42 ['tiling_key_list', 'code_channel', 'hard_sync', 'no_kfc_server_flag', "enable_deterministic", \
43 'tiling_key_kernel_type', "no_set_kernel_type", "default_kernel_type", "dump_info", "template_tiling_info", \43 'tiling_key_kernel_type', "no_set_kernel_type", "default_kernel_type", "dump_info", "template_tiling_info", \
44- 'default_tiling_struct', 'tiling_struct_expr_map', 'tiling_key_struct_map', 'super_kernel_early_start_set_flag', \44+ 'default_tiling_struct', 'tiling_struct_expr_map', 'tiling_key_struct_map', 'register_tiling_struct', \
45- 'super_kernel_early_start_wait_flag', 'tiling_key_deterministic', 'tiling_key_group_map'])45+ 'tpl_tiling_struct', 'super_kernel_early_start_set_flag', 'super_kernel_early_start_wait_flag', \
46+ 'tiling_key_deterministic', 'tiling_key_group_map'])
46InferChannelParams = namedtuple('InferChannelParams', ['src_file', 'dst_file_header', \47InferChannelParams = namedtuple('InferChannelParams', ['src_file', 'dst_file_header', \
47 'compile_option_tuple', 'tiling_key', 'tiling_info', 'compile_log_path', 'no_kfc_server_flag'])48 'compile_option_tuple', 'tiling_key', 'tiling_info', 'compile_log_path', 'no_kfc_server_flag'])
48 49 
@@ -48,7 +48,7 @@ from .ascendc_compile_gen_code import get_code_for_l2_cache, \
48 gen_init_dump_code, add_op_param_to_workspace, _gen_compile_cmd, get_tiling_key_struct_size_map, \48 gen_init_dump_code, add_op_param_to_workspace, _gen_compile_cmd, get_tiling_key_struct_size_map, \
49 gen_tiling_struct_and_dfx_section_head, gen_tiling_struct_size_for_group_key, \49 gen_tiling_struct_and_dfx_section_head, gen_tiling_struct_size_for_group_key, \
50 gen_dfx_section_for_one_tiling_key_dynamic, gen_dfx_section_for_one_tiling_key_static, \50 gen_dfx_section_for_one_tiling_key_dynamic, gen_dfx_section_for_one_tiling_key_static, \
51- gen_tiling_struct_size_for_group_key_no_size51+ gen_tiling_struct_size_for_group_key_no_size, gen_global_isolation_macro
52from .ascendc_compile_gen_json import _gen_mix_json_from_seperate_json, \52from .ascendc_compile_gen_json import _gen_mix_json_from_seperate_json, \
53 _gen_mix_json_from_seperate_json_for_kernel_type, _dynamic_kernel_list_to_json, \53 _gen_mix_json_from_seperate_json_for_kernel_type, _dynamic_kernel_list_to_json, \
54 _dynamic_regbase_kernel_list_to_json, _static_regbase_kernel_list_to_json, _gen_mix_sub_json, \54 _dynamic_regbase_kernel_list_to_json, _static_regbase_kernel_list_to_json, _gen_mix_sub_json, \
@@ -106,7 +106,7 @@ def _json_except_info(compile_info: CompileInfo):
106 chip_version = CommonUtility.get_chip_version()106 chip_version = CommonUtility.get_chip_version()
107 if 'stream-fusion' in compile_info.super_kernel_info["sp_options"]:107 if 'stream-fusion' in compile_info.super_kernel_info["sp_options"]:
108 stream_fusion = compile_info.super_kernel_info["sp_options"]['stream-fusion']108 stream_fusion = compile_info.super_kernel_info["sp_options"]['stream-fusion']
109- if stream_fusion == SuperKernelStreamFusionMode.StreamFusionEnable:109+ if stream_fusion.value == SuperKernelStreamFusionMode.StreamFusionEnable.value:
110 key = 'stream'110 key = 'stream'
111 i = 0111 i = 0
112 for sub_op in compile_info.super_kernel_info["op_list"]:112 for sub_op in compile_info.super_kernel_info["op_list"]:
@@ -215,7 +215,7 @@ def _json_post_process(compile_info: CompileInfo, op_info: OpInfo, tiling_info:
215 js["runInfo"] = tiling_info.raw_run_info215 js["runInfo"] = tiling_info.raw_run_info
216 216 
217 # gen sub operator infos for super kernel feature217 # gen sub operator infos for super kernel feature
218- js = add_sub_super_kernel_info(js, tiling_info.static_shape_flag, compile_info) 218+ js = add_sub_super_kernel_info(js, tiling_info.static_shape_flag, compile_info)
219 219 
220 if compile_info.super_kernel_info.get("timestamp_option") is not None and \220 if compile_info.super_kernel_info.get("timestamp_option") is not None and \
221 compile_info.super_kernel_info.get("timestamp_option"):221 compile_info.super_kernel_info.get("timestamp_option"):
@@ -409,8 +409,8 @@ def _gen_set_workspace_codes(is_mix: bool, is_single_and_using_hard_sync: bool,
409 source += "do {\n"409 source += "do {\n"
410 410 
411 # is_single_and_using_hard_sync scene not need clear workspace411 # is_single_and_using_hard_sync scene not need clear workspace
412- if is_mix and (not CommonUtility.is_c310()): # c310 doesn't need clearWorkspace412+ if is_mix and compile_info.hard_kfc_server:
413- source += f"#ifdef {MIX_CORE_MACRO} \n"413+ source += f"#if defined({MIX_CORE_MACRO}) && !defined(ENABLE_CV_COMM_VIA_SSBUF) \n"
414 source += " if constexpr (g_coreType == AscendC::AIC) {\n"414 source += " if constexpr (g_coreType == AscendC::AIC) {\n"
415 source += " matmul::clearWorkspace(workspace);\n"415 source += " matmul::clearWorkspace(workspace);\n"
416 source += add_time_stamp_codes('TIME_STAMP_WRAP_CLEAR_WK_SPAC', 2)416 source += add_time_stamp_codes('TIME_STAMP_WRAP_CLEAR_WK_SPAC', 2)
@@ -444,6 +444,25 @@ def _gen_set_mc2_ctx_param(opinfo: OpInfo):
444 return source444 return source
445 445 
446 446 
447+# When TPL struct is not registered through macro REGISTER_TILING, need to insert section code
448+def _gen_tpl_tiling_struct_section(compile_info: CompileInfo, tiling_info: TilingInfo):
449+ source = gen_global_isolation_macro(compile_info, tiling_info)
450+ tiling_struct_set = set()
451+ counter = 0
452+ for tiling_key in compile_info.tiling_key_list:
453+ original_tiling_struct = compile_info.tiling_key_struct_map[tiling_key]
454+ if original_tiling_struct in compile_info.tpl_tiling_struct and \
455+ original_tiling_struct not in compile_info.register_tiling_struct and \
456+ original_tiling_struct not in tiling_struct_set:
457+ source += f"static const uint64_t __ascendc_TPL_tiling_struct_{counter} __attribute__"
458+ source += \
459+ f"((used, section(\".ascendc_tiling.{original_tiling_struct}\"))) = sizeof({original_tiling_struct});\n"
460+ counter += 1
461+ tiling_struct_set.add(original_tiling_struct)
462+ source += f"#endif\n\n"
463+ return source
464+ 
465+ 
447def gen_meta_info_section(compile_info, op_info):466def gen_meta_info_section(compile_info, op_info):
448 467 
449 meta_info = {}468 meta_info = {}
@@ -612,6 +631,9 @@ def gen_kernel_fun(compile_info: CompileInfo, func_name: str, opinfo: OpInfo, \
612 func_name, opinfo, tiling_info, has_template=False)631 func_name, opinfo, tiling_info, has_template=False)
613 source += "#endif\n"632 source += "#endif\n"
614 633 
634+ if len(compile_info.tiling_key_struct_map) > 0:
635+ source += _gen_tpl_tiling_struct_section(compile_info, tiling_info)
636+ 
615 # aicore exception restart main block637 # aicore exception restart main block
616 if global_var_storage.get_variable("ascendc_enable_aicore_exception_restart"):638 if global_var_storage.get_variable("ascendc_enable_aicore_exception_restart"):
617 for key in tiling_info.tiling_key_list:639 for key in tiling_info.tiling_key_list:
@@ -776,7 +798,7 @@ def gen_tiling_struct_size_and_dfx_section_file(compile_info: CompileInfo, tilin
776 for tiling_key_slave in compile_info.tiling_key_group_map[tiling_key]:798 for tiling_key_slave in compile_info.tiling_key_group_map[tiling_key]:
777 source += gen_dfx_section_for_one_tiling_key_dynamic(compile_info, tiling_key_slave, \799 source += gen_dfx_section_for_one_tiling_key_dynamic(compile_info, tiling_key_slave, \
778 tiling_info, tiling_key_struct_size_map)800 tiling_info, tiling_key_struct_size_map)
779- 801+ 
780 try:802 try:
781 with os.fdopen(\803 with os.fdopen(\
782 os.open(out_file, os.O_TRUNC | os.O_RDWR | os.O_CREAT, stat.S_IWUSR | stat.S_IRUSR), 'w') as ofd:804 os.open(out_file, os.O_TRUNC | os.O_RDWR | os.O_CREAT, stat.S_IWUSR | stat.S_IRUSR), 'w') as ofd:
@@ -871,7 +893,8 @@ def _get_tiling_struct_without_register_size(compile_info: CompileInfo):
871 name_part = match.split('.ascendc_tiling.', 1)[1]893 name_part = match.split('.ascendc_tiling.', 1)[1]
872 name_part = name_part.rsplit('.', 1)[0]894 name_part = name_part.rsplit('.', 1)[0]
873 895 
874- get_tiling_key_struct_size_map(tiling_key_struct_size_map, name_part, compile_info, 0)896+ tiling_key_struct_size_map = get_tiling_key_struct_size_map(tiling_key_struct_size_map, \
897+ name_part, compile_info, 0)
875 898 
876 for section_name in section_name_set:899 for section_name in section_name_set:
877 objdump_cmd = ['llvm-objdump', '-s', '-j', '{}'.format(section_name), '{}'.format(compile_info.dst_file)]900 objdump_cmd = ['llvm-objdump', '-s', '-j', '{}'.format(section_name), '{}'.format(compile_info.dst_file)]
@@ -886,7 +909,8 @@ def _get_tiling_struct_without_register_size(compile_info: CompileInfo):
886 bytes_data = bytes.fromhex(hex_num_str)909 bytes_data = bytes.fromhex(hex_num_str)
887 dec_data = struct.unpack('>Q', bytes_data)[0]910 dec_data = struct.unpack('>Q', bytes_data)[0]
888 name_part = section_name.split('.ascendc_tiling.', 1)[1].rsplit('.', 1)[0]911 name_part = section_name.split('.ascendc_tiling.', 1)[1].rsplit('.', 1)[0]
889- get_tiling_key_struct_size_map(tiling_key_struct_size_map, name_part, compile_info, dec_data)912+ tiling_key_struct_size_map = get_tiling_key_struct_size_map(tiling_key_struct_size_map, \
913+ name_part, compile_info, dec_data)
890 max_tiling_size = max(max_tiling_size, dec_data)914 max_tiling_size = max(max_tiling_size, dec_data)
891 compile_info.max_tiling_size = max_tiling_size915 compile_info.max_tiling_size = max_tiling_size
892 return tiling_key_struct_size_map916 return tiling_key_struct_size_map
@@ -912,13 +936,13 @@ def _update_compile_option(kernel_name: str, compile_options: list, extend_optio
912 import platform936 import platform
913 archlinux = platform.machine()937 archlinux = platform.machine()
914 if ascend_home_path is None or ascend_home_path == '':938 if ascend_home_path is None or ascend_home_path == '':
915- asc_opc_path = shutil.which("asc_opc") 939+ asc_opc_path = shutil.which("asc_opc")
916- if asc_opc_path is not None: 940+ if asc_opc_path is not None:
917 asc_opc_path_link = os.path.dirname(asc_opc_path)941 asc_opc_path_link = os.path.dirname(asc_opc_path)
918 asc_opc_real_path = os.path.realpath(asc_opc_path_link)942 asc_opc_real_path = os.path.realpath(asc_opc_path_link)
919- ascend_home_path = os.path.realpath( 943+ ascend_home_path = os.path.realpath(
920 os.path.join(asc_opc_real_path, "..", ".."))944 os.path.join(asc_opc_real_path, "..", ".."))
921- else: 945+ else:
922 ascend_home_path = "/usr/local/Ascend/cann"946 ascend_home_path = "/usr/local/Ascend/cann"
923 947 
924 if 'x86' in archlinux:948 if 'x86' in archlinux:
@@ -931,11 +955,17 @@ def _update_compile_option(kernel_name: str, compile_options: list, extend_optio
931 "include", "ascendc", "asc_devkit_version.h")955 "include", "ascendc", "asc_devkit_version.h")
932 compile_options.append("-I" + os.path.join(asc_path, "impl", "adv_api"))956 compile_options.append("-I" + os.path.join(asc_path, "impl", "adv_api"))
933 compile_options.append("-I" + os.path.join(asc_path, "impl", "basic_api"))957 compile_options.append("-I" + os.path.join(asc_path, "impl", "basic_api"))
958+ compile_options.append("-I" + os.path.join(asc_path, "impl", "c_api"))
959+ compile_options.append("-I" + os.path.join(asc_path, "impl", "micro_api"))
960+ compile_options.append("-I" + os.path.join(asc_path, "impl", "simt_api"))
934 compile_options.append("-I" + os.path.join(asc_path, "impl", "utils"))961 compile_options.append("-I" + os.path.join(asc_path, "impl", "utils"))
935 compile_options.append("-I" + os.path.join(asc_path, "include"))962 compile_options.append("-I" + os.path.join(asc_path, "include"))
936 compile_options.append("-I" + os.path.join(asc_path, "include", "adv_api"))963 compile_options.append("-I" + os.path.join(asc_path, "include", "adv_api"))
937 compile_options.append("-I" + os.path.join(asc_path, "include", "basic_api"))964 compile_options.append("-I" + os.path.join(asc_path, "include", "basic_api"))
938 compile_options.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))965 compile_options.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))
966+ compile_options.append("-I" + os.path.join(asc_path, "include", "c_api"))
967+ compile_options.append("-I" + os.path.join(asc_path, "include", "micro_api"))
968+ compile_options.append("-I" + os.path.join(asc_path, "include", "simt_api"))
939 compile_options.append("-I" + os.path.join(asc_path, "include", "utils"))969 compile_options.append("-I" + os.path.join(asc_path, "include", "utils"))
940 compile_options.append("-I" + os.path.join(asc_path, "..", "..", "include"))970 compile_options.append("-I" + os.path.join(asc_path, "..", "..", "include"))
941 compile_options.append("-I" + os.path.join(asc_path, "..", "..", "include", "ascendc"))971 compile_options.append("-I" + os.path.join(asc_path, "..", "..", "include", "ascendc"))
@@ -986,7 +1016,7 @@ def compile_op_common_part(cce_file: str, origin_func_name: str, op_info: OpInfo
986 tiling_key_group_map = infered_info_from_ifile.tiling_key_group_map1016 tiling_key_group_map = infered_info_from_ifile.tiling_key_group_map
987 context_tiling_key = get_context().get_addition("tiling_key")1017 context_tiling_key = get_context().get_addition("tiling_key")
988 # override customized tiling key list if the input is passed from1018 # override customized tiling key list if the input is passed from
989- customize_tiling_key = "customized_tiling_key_list" 1019+ customize_tiling_key = "customized_tiling_key_list"
990 if customize_tiling_key in extend_options and isinstance(extend_options[customize_tiling_key], list):1020 if customize_tiling_key in extend_options and isinstance(extend_options[customize_tiling_key], list):
991 context_tiling_key = extend_options[customize_tiling_key]1021 context_tiling_key = extend_options[customize_tiling_key]
992 if context_tiling_key:1022 if context_tiling_key:
@@ -1029,6 +1059,7 @@ def compile_op_common_part(cce_file: str, origin_func_name: str, op_info: OpInfo
1029 compile_info.tiling_key_group_map = tiling_key_group_map1059 compile_info.tiling_key_group_map = tiling_key_group_map
1030 compile_info.compile_log_path = compile_log_path1060 compile_info.compile_log_path = compile_log_path
1031 compile_info.hard_sync = infered_info_from_ifile.hard_sync or hardware_sync_in_asm1061 compile_info.hard_sync = infered_info_from_ifile.hard_sync or hardware_sync_in_asm
1062+ compile_info.has_kfc_server = not infered_info_from_ifile.no_kfc_server_flag
1032 compile_info.enable_deterministic = infered_info_from_ifile.enable_deterministic1063 compile_info.enable_deterministic = infered_info_from_ifile.enable_deterministic
1033 compile_info.tiling_key_deterministic = infered_info_from_ifile.tiling_key_deterministic1064 compile_info.tiling_key_deterministic = infered_info_from_ifile.tiling_key_deterministic
1034 compile_info.tiling_key_kernel_type = infered_info_from_ifile.tiling_key_kernel_type1065 compile_info.tiling_key_kernel_type = infered_info_from_ifile.tiling_key_kernel_type
@@ -1040,6 +1071,8 @@ def compile_op_common_part(cce_file: str, origin_func_name: str, op_info: OpInfo
1040 else default_dump_info1071 else default_dump_info
1041 compile_info.template_tiling_info = infered_info_from_ifile.template_tiling_info1072 compile_info.template_tiling_info = infered_info_from_ifile.template_tiling_info
1042 compile_info.tiling_key_struct_map = infered_info_from_ifile.tiling_key_struct_map1073 compile_info.tiling_key_struct_map = infered_info_from_ifile.tiling_key_struct_map
1074+ compile_info.register_tiling_struct = infered_info_from_ifile.register_tiling_struct
1075+ compile_info.tpl_tiling_struct = infered_info_from_ifile.tpl_tiling_struct
1043 1076 
1044 set_dump_assert_flag(compile_info)1077 set_dump_assert_flag(compile_info)
1045 1078 
@@ -1201,7 +1234,6 @@ def compile_op(cce_file: str, origin_func_name: str, op_info: OpInfo, compile_op
1201 """1234 """
1202 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["compile_op_start"], AscendCLogLevel.LOG_INFO)1235 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["compile_op_start"], AscendCLogLevel.LOG_INFO)
1203 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["preprocess_start"], AscendCLogLevel.LOG_INFO)1236 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["preprocess_start"], AscendCLogLevel.LOG_INFO)
1204- process_ascendc_api_version(cce_file, compile_options, extend_options)
1205 # online compile reuses thread, dfx infos need to be reset.1237 # online compile reuses thread, dfx infos need to be reset.
1206 global_var_storage.global_storage_reset()1238 global_var_storage.global_storage_reset()
1207 if extend_options.get('opp_kernel_hidden_dat_path', None) is None and not os.path.exists(cce_file):1239 if extend_options.get('opp_kernel_hidden_dat_path', None) is None and not os.path.exists(cce_file):
@@ -1259,7 +1291,6 @@ def compile_op_with_customized_config(cce_file: str, origin_func_name: str, op_i
1259 """1291 """
1260 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["compile_op_start"], AscendCLogLevel.LOG_INFO)1292 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["compile_op_start"], AscendCLogLevel.LOG_INFO)
1261 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["preprocess_start"], AscendCLogLevel.LOG_INFO)1293 LogUtil.detail_log_print(op_info.kernel_name, COMPILE_STAGE_MSG_INFO["preprocess_start"], AscendCLogLevel.LOG_INFO)
1262- process_ascendc_api_version(cce_file, compile_options, extend_options)
1263 # online compile reuses thread, dfx infos need to be reset.1294 # online compile reuses thread, dfx infos need to be reset.
1264 global_var_storage.global_storage_reset()1295 global_var_storage.global_storage_reset()
1265 if extend_options.get('opp_kernel_hidden_dat_path', None) is None and not os.path.exists(cce_file):1296 if extend_options.get('opp_kernel_hidden_dat_path', None) is None and not os.path.exists(cce_file):
@@ -606,8 +606,10 @@ def gen_static_shape(tiling_def, tilingdata, struct_tiling_def_base, all_dynamic
606 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"606 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"
607 class_body += f"#include \"kernel_log.h\"\n"607 class_body += f"#include \"kernel_log.h\"\n"
608 class_body += "#else\n"608 class_body += "#else\n"
609+ class_body += "#ifndef __aicore__\n"
609 class_body += "#define __aicore__ [aicore]\n"610 class_body += "#define __aicore__ [aicore]\n"
610 class_body += "#endif\n"611 class_body += "#endif\n"
612+ class_body += "#endif\n"
611 if not global_var_storage.get_variable("ascendc_tiling_no_register"):613 if not global_var_storage.get_variable("ascendc_tiling_no_register"):
612 class_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"614 class_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"
613 # all tiling struct info by dynamic, except the only one top-level struct of static-shape one itself615 # all tiling struct info by dynamic, except the only one top-level struct of static-shape one itself
@@ -759,8 +761,10 @@ def gen_dynamic_shape(tiling_def, struct_tiling_def_base):
759 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"761 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"
760 class_body += f"#include \"kernel_log.h\"\n"762 class_body += f"#include \"kernel_log.h\"\n"
761 class_body += "#else\n"763 class_body += "#else\n"
764+ class_body += "#ifndef __aicore__\n"
762 class_body += "#define __aicore__ [aicore]\n"765 class_body += "#define __aicore__ [aicore]\n"
763 class_body += "#endif\n"766 class_body += "#endif\n"
767+ class_body += "#endif\n"
764 if not global_var_storage.get_variable("ascendc_tiling_no_register"):768 if not global_var_storage.get_variable("ascendc_tiling_no_register"):
765 class_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"769 class_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"
766 class_body += get_struct_shape(struct_tiling_def_base)770 class_body += get_struct_shape(struct_tiling_def_base)
@@ -975,8 +979,10 @@ def get_header_and_sub_struct_def(tiling_def, struct_tiling_def_base):
975 start_body += f"#ifdef ASCENDC_CPU_DEBUG\n"979 start_body += f"#ifdef ASCENDC_CPU_DEBUG\n"
976 start_body += f"#include \"kernel_log.h\"\n"980 start_body += f"#include \"kernel_log.h\"\n"
977 start_body += "#else\n"981 start_body += "#else\n"
982+ start_body += "#ifndef __aicore__\n"
978 start_body += "#define __aicore__ [aicore]\n"983 start_body += "#define __aicore__ [aicore]\n"
979 start_body += "#endif\n"984 start_body += "#endif\n"
985+ start_body += "#endif\n"
980 if not global_var_storage.get_variable("ascendc_tiling_no_register"):986 if not global_var_storage.get_variable("ascendc_tiling_no_register"):
981 start_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"987 start_body += "#define REGISTER_TILINGDATA_SIZE(tiling_struct, counter) \n\n"
982 start_body += get_struct_shape(struct_tiling_def_base)988 start_body += get_struct_shape(struct_tiling_def_base)
@@ -1118,8 +1124,8 @@ def get_tiling_data_func_head():
1118def get_tiling_data_func():1124def get_tiling_data_func():
1119 class_body = "{\n"1125 class_body = "{\n"
1120 class_body += " constexpr uint64_t all_bytes = sizeof(T);\n"1126 class_body += " constexpr uint64_t all_bytes = sizeof(T);\n"
1121- class_body += "#if defined(ASCENDC_CPU_DEBUG) || defined(__DAV_C220_CUBE__) || defined(__DAV_C310_CUBE__) || \1127+ class_body += "#if defined(ASCENDC_CPU_DEBUG) || (defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201) || (defined \
1122-defined(__DAV_310R6_CUBE__) || defined(__GET_CODE_CHANNEL__)\n"1128+ (__DAV_CUBE__) && __NPU_ARCH__ == 3101) || defined(__DAV_310R6_CUBE__) || defined(__GET_CODE_CHANNEL__)\n"
1123 class_body += "#if defined(__DAV_C100__) || defined(ASCENDC_CPU_DEBUG)\n"1129 class_body += "#if defined(__DAV_C100__) || defined(ASCENDC_CPU_DEBUG)\n"
1124 class_body += get_dynamic_assign_tiling_data_by_size("all_bytes", "const __gm__", "(const __gm__ uint8_t *)\1130 class_body += get_dynamic_assign_tiling_data_by_size("all_bytes", "const __gm__", "(const __gm__ uint8_t *)\
1125p_tilingdata")1131p_tilingdata")
@@ -1127,24 +1133,21 @@ p_tilingdata")
1127 class_body += " copy_data_align64((uint8_t*)tilingdata, (__gm__ uint8_t *)p_tilingdata, all_bytes);\n"1133 class_body += " copy_data_align64((uint8_t*)tilingdata, (__gm__ uint8_t *)p_tilingdata, all_bytes);\n"
1128 class_body += "#endif\n"1134 class_body += "#endif\n"
1129 class_body += "#else\n"1135 class_body += "#else\n"
1130- class_body += "#if defined(__DAV_C310__) && defined(__ASCENDC_ENABLE_VEC_TAIL_TILING_COPY__) \n"1136+ class_body += "#if __NPU_ARCH__ == 3101 && defined(__ASCENDC_ENABLE_VEC_TAIL_TILING_COPY__) \n"
1131 class_body += _gen_tiling_copy_through_reserved_ub()1137 class_body += _gen_tiling_copy_through_reserved_ub()
1132 class_body += "#else \n"1138 class_body += "#else \n"
1133 class_body += " __ubuf__ uint8_t *tilingdata_in_ub = (__ubuf__ uint8_t *)get_imm(0);\n"1139 class_body += " __ubuf__ uint8_t *tilingdata_in_ub = (__ubuf__ uint8_t *)get_imm(0);\n"
1134 class_body += " constexpr uint32_t len_burst = (all_bytes + 31) / 32;\n"1140 class_body += " constexpr uint32_t len_burst = (all_bytes + 31) / 32;\n"
1135- class_body += "#if defined(__DAV_C310__) || defined(__DAV_310R6__) || __NPU_ARCH__ == 5102\n"1141+ class_body += "#if __NPU_ARCH__ == 3101 || defined(__DAV_310R6__) || __NPU_ARCH__ == 5102\n"
1136 class_body += " copy_gm_to_ubuf_align_v2((__ubuf__ uint8_t *)tilingdata_in_ub, \1142 class_body += " copy_gm_to_ubuf_align_v2((__ubuf__ uint8_t *)tilingdata_in_ub, \
1137(__gm__ uint8_t *)p_tilingdata, 0, 1, len_burst * 32, 0, 0, false, 0, 0, 0);\n"1143(__gm__ uint8_t *)p_tilingdata, 0, 1, len_burst * 32, 0, 0, false, 0, 0, 0);\n"
1138 class_body += get_tilingdata_preload()1144 class_body += get_tilingdata_preload()
1139- class_body += "#elif __NPU_ARCH__ != 3102\n"
1140- class_body += " copy_gm_to_ubuf(((__ubuf__ uint8_t *)tilingdata_in_ub), p_tilingdata, 0, 1,\
1141-len_burst, 0, 0);\n"
1142- class_body += "#elif __NPU_ARCH__ == 3003\n"
1143- class_body += " copy_gm_to_ubuf(((__ubuf__ void *)tilingdata_in_ub), (__gm__ void *)p_tilingdata, 0, 1, \
1144-len_burst, 0, 0);\n"
1145 class_body += "#elif __NPU_ARCH__ == 3113\n"1145 class_body += "#elif __NPU_ARCH__ == 3113\n"
1146 class_body += " copy_gm_to_ubuf_align_v2((__ubuf__ uint8_t *)tilingdata_in_ub, \1146 class_body += " copy_gm_to_ubuf_align_v2((__ubuf__ uint8_t *)tilingdata_in_ub, \
1147(__gm__ uint8_t *)p_tilingdata, 0, 1, len_burst * 32, 0, 0, false, 0, 0);\n"1147(__gm__ uint8_t *)p_tilingdata, 0, 1, len_burst * 32, 0, 0, false, 0, 0);\n"
1148+ class_body += "#elif __NPU_ARCH__ != 3102\n"
1149+ class_body += " copy_gm_to_ubuf(((__ubuf__ uint8_t *)tilingdata_in_ub), p_tilingdata, 0, 1,\
1150+len_burst, 0, 0);\n"
1148 class_body += "#else\n"1151 class_body += "#else\n"
1149 class_body += " copy_gm_to_ubuf_align(((__ubuf__ uint8_t *)tilingdata_in_ub), (__gm__ uint8_t *)p_tilingdata,\1152 class_body += " copy_gm_to_ubuf_align(((__ubuf__ uint8_t *)tilingdata_in_ub), (__gm__ uint8_t *)p_tilingdata,\
11500, 1, all_bytes, 0, 0, 0, 0);\n"11530, 1, all_bytes, 0, 0, 0, 0);\n"
@@ -1271,8 +1274,10 @@ def gen_static_shape_v2(optype: str, tiling_struct: str, tiling_raw_data: str):
1271 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"1274 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"
1272 class_body += f"#include \"kernel_log.h\"\n"1275 class_body += f"#include \"kernel_log.h\"\n"
1273 class_body += "#else\n"1276 class_body += "#else\n"
1277+ class_body += "#ifndef __aicore__\n"
1274 class_body += "#define __aicore__ [aicore]\n"1278 class_body += "#define __aicore__ [aicore]\n"
1275 class_body += "#endif\n"1279 class_body += "#endif\n"
1280+ class_body += "#endif\n"
1276 if global_var_storage.get_variable("ascendc_tiling_no_register"):1281 if global_var_storage.get_variable("ascendc_tiling_no_register"):
1277 class_body += "#define ASCENDC_INTERNAL_STR(x) #x \n"1282 class_body += "#define ASCENDC_INTERNAL_STR(x) #x \n"
1278 class_body += "#define ASCENDC_INTERNAL_EXPAND_AND_STRINGIFY(x) ASCENDC_INTERNAL_STR(x) \n"1283 class_body += "#define ASCENDC_INTERNAL_EXPAND_AND_STRINGIFY(x) ASCENDC_INTERNAL_STR(x) \n"
@@ -1307,8 +1312,10 @@ def gen_dynamic_shape_v2(optype: str, tiling_struct: str):
1307 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"1312 class_body += f"#ifdef ASCENDC_CPU_DEBUG\n"
1308 class_body += f"#include \"kernel_log.h\"\n"1313 class_body += f"#include \"kernel_log.h\"\n"
1309 class_body += "#else\n"1314 class_body += "#else\n"
1315+ class_body += "#ifndef __aicore__\n"
1310 class_body += "#define __aicore__ [aicore]\n"1316 class_body += "#define __aicore__ [aicore]\n"
1311 class_body += "#endif\n"1317 class_body += "#endif\n"
1318+ class_body += "#endif\n"
1312 if global_var_storage.get_variable("ascendc_tiling_no_register"):1319 if global_var_storage.get_variable("ascendc_tiling_no_register"):
1313 class_body += "#define ASCENDC_INTERNAL_STR(x) #x \n"1320 class_body += "#define ASCENDC_INTERNAL_STR(x) #x \n"
1314 class_body += "#define ASCENDC_INTERNAL_EXPAND_AND_STRINGIFY(x) ASCENDC_INTERNAL_STR(x) \n"1321 class_body += "#define ASCENDC_INTERNAL_EXPAND_AND_STRINGIFY(x) ASCENDC_INTERNAL_STR(x) \n"
@@ -1539,13 +1546,14 @@ def get_tiling_info_isolate(op_info: OpInfo, input_tiling_info_dict: dict):
1539 1546 
1540 # get tiling through old version1547 # get tiling through old version
1541 CommonUtility.print_compile_log(op_info.op_type, \1548 CommonUtility.print_compile_log(op_info.op_type, \
1542- "isolate gen tiling file failed, retry gen tiling file through old version.", \1549+ "isolate gen tiling file failed, retry gen tiling file through old version.", \
1543- AscendCLogLevel.LOG_INFO)1550+ AscendCLogLevel.LOG_INFO)
1544 return get_tiling_info(op_info, input_tiling_info_dict["tiling_key_list"], \1551 return get_tiling_info(op_info, input_tiling_info_dict["tiling_key_list"], \
1545 input_tiling_info_dict["value_depends"], input_tiling_info_dict["enable_vd"], \1552 input_tiling_info_dict["value_depends"], input_tiling_info_dict["enable_vd"], \
1546 input_tiling_info_dict["tiling_key_group_map"])1553 input_tiling_info_dict["tiling_key_group_map"])
1547 1554 
1548 1555 
1556+ 
1549def get_tiling_info(op_info: OpInfo, tiling_key_list: list = None, value_depends: dict = None, \1557def get_tiling_info(op_info: OpInfo, tiling_key_list: list = None, value_depends: dict = None, \
1550 enable_vd=False, tiling_key_group_map: dict = None):1558 enable_vd=False, tiling_key_group_map: dict = None):
1551 """get tiling define and tiling data registered by operator developer1559 """get tiling define and tiling data registered by operator developer
@@ -139,11 +139,7 @@ AscendCLogLevel.LOG_ERROR)
139 @staticmethod139 @staticmethod
140 def get_dump_info_from_i_file(content):140 def get_dump_info_from_i_file(content):
141 dump_info = {"dump_type": "", "dump_size": 1048576}141 dump_info = {"dump_type": "", "dump_size": 1048576}
142- actual_dump_size = 1048576142+ actual_dump_size = 1048576 * CommonUtility.get_dump_core_num()
143- if CommonUtility.is_c310() or CommonUtility.is_310r6():
144- actual_dump_size *= 108
145- else:
146- actual_dump_size *= 75
147 143 
148 match_printf = re.search(r"__enable_feature_for_compile_printf = 1", content)144 match_printf = re.search(r"__enable_feature_for_compile_printf = 1", content)
149 match_assert = re.search(r"__enable_feature_for_compile_assert = 1;", content)145 match_assert = re.search(r"__enable_feature_for_compile_assert = 1;", content)
@@ -171,13 +167,12 @@ AscendCLogLevel.LOG_ERROR)
171 if match:167 if match:
172 dump_info["dump_size"] = int(match.group(1))168 dump_info["dump_size"] = int(match.group(1))
173 169 
174- if CommonUtility.is_c310() or CommonUtility.is_310r6():170+ actual_dump_size = CommonUtility.get_dump_core_num() * dump_info["dump_size"]
175- actual_dump_size = 108 * dump_info["dump_size"]171+ 
176- else:
177- actual_dump_size = 75 * dump_info["dump_size"]
178 simt_in_c310 = match_simtvf and (CommonUtility.is_c310() or CommonUtility.is_310r6())172 simt_in_c310 = match_simtvf and (CommonUtility.is_c310() or CommonUtility.is_310r6())
179 if dump_info["dump_type"] != "" and simt_in_c310:173 if dump_info["dump_type"] != "" and simt_in_c310:
180- actual_dump_size = 1048576 * 108 + 72 * 2048 * 2048 # david 72 vec + 36 cube + simt174+ # david 72 vec + 36 cube + simt
175+ actual_dump_size = 1048576 * CommonUtility.get_dump_core_num() + 72 * 2048 * 2048
181 dump_info["dump_size"] = 1048576 # reserved for ONE_CORE_DUMP_SIZE176 dump_info["dump_size"] = 1048576 # reserved for ONE_CORE_DUMP_SIZE
182 177 
183 global_var_storage.set_variable("ascendc_required_dump_workspace_size", actual_dump_size)178 global_var_storage.set_variable("ascendc_required_dump_workspace_size", actual_dump_size)
@@ -357,6 +352,8 @@ REGISTER_TILING_DEFAULT')
357 find_kfc_server = False352 find_kfc_server = False
358 default_tiling_struct = ""353 default_tiling_struct = ""
359 tiling_struct_expr_map = {}354 tiling_struct_expr_map = {}
355+ register_tiling_struct = set()
356+ tpl_tiling_struct = set()
360 if not (CommonUtility.is_v220() or CommonUtility.is_c310() or CommonUtility.is_310r6()):357 if not (CommonUtility.is_v220() or CommonUtility.is_c310() or CommonUtility.is_310r6()):
361 code_channel = CORE_TYPE_MIX358 code_channel = CORE_TYPE_MIX
362 if global_var_storage.get_variable("ascendc_enable_super_kernel") is True:359 if global_var_storage.get_variable("ascendc_enable_super_kernel") is True:
@@ -464,6 +461,9 @@ REGISTER_TILING_DEFAULT')
464 KernelInfoInfer.get_tiling_key_kernel_type_in_group(tiling_key_kernel_type, \461 KernelInfoInfer.get_tiling_key_kernel_type_in_group(tiling_key_kernel_type, \
465 tiling_key_kernel_type_full)462 tiling_key_kernel_type_full)
466 463 
464+ for tiling_struct in tiling_struct_expr_map.keys():
465+ register_tiling_struct.add(tiling_struct)
466+ 
467 if declare_param_str and select_param_str:467 if declare_param_str and select_param_str:
468 # TPL468 # TPL
469 extract_template_tiling_info(declare_param_str, select_param_str)469 extract_template_tiling_info(declare_param_str, select_param_str)
@@ -550,11 +550,15 @@ REGISTER_TILING_DEFAULT')
550 tiling_struct_expr_map, compile_log_path, \550 tiling_struct_expr_map, compile_log_path, \
551 tiling_key_group_map)551 tiling_key_group_map)
552 552 
553+ for tiling_struct in tiling_key_struct_map.values():
554+ tpl_tiling_struct.add(tiling_struct)
555+ 
553 return InferChannelParamsFromIFile(tiling_key_list, code_channel, hard_sync, no_kfc_server_flag, \556 return InferChannelParamsFromIFile(tiling_key_list, code_channel, hard_sync, no_kfc_server_flag, \
554 enable_deterministic, tiling_key_kernel_type, no_set_kernel_type, \557 enable_deterministic, tiling_key_kernel_type, no_set_kernel_type, \
555 default_kernel_type, dump_info, decode_tiling_result,558 default_kernel_type, dump_info, decode_tiling_result,
556 default_tiling_struct, tiling_struct_expr_map, tiling_key_struct_map, \559 default_tiling_struct, tiling_struct_expr_map, tiling_key_struct_map, \
557- set_task_bar, wait_task_bar, tiling_key_deterministic, tiling_key_group_map)560+ register_tiling_struct, tpl_tiling_struct, set_task_bar, wait_task_bar, \
561+ tiling_key_deterministic, tiling_key_group_map)
558 562 
559 @staticmethod563 @staticmethod
560 def get_tiling_key_kernel_type_in_group(tiling_key_kernel_type, tiling_key_kernel_type_origin):564 def get_tiling_key_kernel_type_in_group(tiling_key_kernel_type, tiling_key_kernel_type_origin):
@@ -17,16 +17,16 @@ import stat
17from .global_storage import global_var_storage17from .global_storage import global_var_storage
18from .super_kernel_utility import KernelMetaType, \18from .super_kernel_utility import KernelMetaType, \
19 CommonUtility, gen_func_align_attribute19 CommonUtility, gen_func_align_attribute
20-from .super_kernel_op_compile import super_kernel_compile, gen_file_header20+from .super_kernel_op_compile import compile_super_kernel, gen_file_header
21from .super_kernel_constants import SuperKernelPreLoadMode, SuperKernelDataCacheMode, \21from .super_kernel_constants import SuperKernelPreLoadMode, SuperKernelDataCacheMode, \
22 SuperKernelEarlyStartMode, SubOperatorType, SuperKernelDebugDcciAllMode, SuperKernelDebugSyncAllMode, \22 SuperKernelEarlyStartMode, SubOperatorType, SuperKernelDebugDcciAllMode, SuperKernelDebugSyncAllMode, \
23- SuperKernelFeedSyncAllMode, SuperKernelProfilingMode, ERR_CODE23+ SuperKernelFeedSyncAllMode, SuperKernelProfilingMode, ERR_CODE, SuperKernelDeviceType
24from .super_kernel_compile_base import gen_super_dump_code24from .super_kernel_compile_base import gen_super_dump_code
25from .super_kernel_sub_op_infos import indent_code_func, SubOperatorInfos25from .super_kernel_sub_op_infos import indent_code_func, SubOperatorInfos
26from .super_kernel_op_infos import SuperOperatorInfos26from .super_kernel_op_infos import SuperOperatorInfos
27 27 
28 28 
29-def gen_early_start_config(pre_sub_operator: SubOperatorInfos, sub_operator: SubOperatorInfos):29+def kernel_meta_type_to_device_type(kernelMetaType: KernelMetaType):
30 aiv_configs = [30 aiv_configs = [
31 KernelMetaType.KERNEL_TYPE_AIV_ONLY,31 KernelMetaType.KERNEL_TYPE_AIV_ONLY,
32 KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0,32 KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0,
@@ -39,25 +39,41 @@ def gen_early_start_config(pre_sub_operator: SubOperatorInfos, sub_operator: Sub
39 KernelMetaType.KERNEL_TYPE_MIX_AIC_1_1,39 KernelMetaType.KERNEL_TYPE_MIX_AIC_1_1,
40 KernelMetaType.KERNEL_TYPE_MIX_AIC_1_2,40 KernelMetaType.KERNEL_TYPE_MIX_AIC_1_2,
41 ]41 ]
42- if pre_sub_operator.kernel_type in aic_configs:42+ 
43+ if kernelMetaType in aiv_configs:
44+ return SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIV.value
45+ if kernelMetaType in aic_configs:
46+ return SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value
47+ if kernelMetaType in mix_configs:
48+ return SuperKernelDeviceType.KERNEL_DEVICE_TYPE_MIX.value
49+ return SuperKernelDeviceType.KERNEL_DEVICE_TYPE_MAX.value
50+ 
51+ 
52+def gen_early_start_config(pre_sub_operator: SubOperatorInfos, sub_operator: SubOperatorInfos):
53+ pre_sub_operator_device_type = kernel_meta_type_to_device_type(pre_sub_operator.kernel_type)
54+ sub_operator_device_type = kernel_meta_type_to_device_type(sub_operator.kernel_type)
55+ 
56+ if pre_sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value:
43 prev_sub_kernel_config = 057 prev_sub_kernel_config = 0
44- elif pre_sub_operator.kernel_type in aiv_configs:58+ elif pre_sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIV.value:
45 prev_sub_kernel_config = 159 prev_sub_kernel_config = 1
46- elif pre_sub_operator.kernel_type in mix_configs:60+ elif pre_sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_MIX.value:
47 prev_sub_kernel_config = 261 prev_sub_kernel_config = 2
48 else:62 else:
49 CommonUtility().ascendc_raise_python_err(ERR_CODE, \63 CommonUtility().ascendc_raise_python_err(ERR_CODE, \
50- f"previous sub kernel type {pre_sub_operator.kernel_type} do not support!")64+ f"Do not support previous sub kernel device type: {pre_sub_operator_device_type}. \
65+ Should be AIC, AIV or MIX.")
51 66 
52- if sub_operator.kernel_type in aic_configs:67+ if sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value:
53 cur_sub_kernel_config = 068 cur_sub_kernel_config = 0
54- elif sub_operator.kernel_type in aiv_configs:69+ elif sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIV.value:
55 cur_sub_kernel_config = 170 cur_sub_kernel_config = 1
56- elif sub_operator.kernel_type in mix_configs:71+ elif sub_operator_device_type == SuperKernelDeviceType.KERNEL_DEVICE_TYPE_MIX.value:
57 cur_sub_kernel_config = 272 cur_sub_kernel_config = 2
58 else:73 else:
59 CommonUtility().ascendc_raise_python_err(ERR_CODE, \74 CommonUtility().ascendc_raise_python_err(ERR_CODE, \
60- f"current sub kernel type {sub_operator.kernel_type} do not support!")75+ f"Do not support current sub kernel device type: {sub_operator_device_type}. \
76+ Should be AIC, AIV or MIX.")
61 77 
62 super_kernel_early_start_config = (prev_sub_kernel_config << 2) | cur_sub_kernel_config78 super_kernel_early_start_config = (prev_sub_kernel_config << 2) | cur_sub_kernel_config
63 # sub_operator.elf.early_start_complement_wait_flag_block79 # sub_operator.elf.early_start_complement_wait_flag_block
@@ -132,10 +148,10 @@ wait_flag_dev(AscendC::SYNC_AIV_ONLY_ALL);
132def gen_inter_ops_barrier(super_operator: SuperOperatorInfos, \148def gen_inter_ops_barrier(super_operator: SuperOperatorInfos, \
133 pre_sub_operator: SubOperatorInfos, sub_operator: SubOperatorInfos):149 pre_sub_operator: SubOperatorInfos, sub_operator: SubOperatorInfos):
134 inter_ops_bar = "// begin inter ops barrier\n"150 inter_ops_bar = "// begin inter ops barrier\n"
135- if super_operator.early_start_mode != SuperKernelEarlyStartMode.EarlyStartDisable:151+ if super_operator.early_start_mode.value != SuperKernelEarlyStartMode.EarlyStartDisable.value:
136 inter_ops_bar += pre_sub_operator.early_start_complement_set_flag_block152 inter_ops_bar += pre_sub_operator.early_start_complement_set_flag_block
137- if super_operator.early_start_mode == SuperKernelEarlyStartMode.EarlyStartEnableV2 or \153+ if super_operator.early_start_mode.value == SuperKernelEarlyStartMode.EarlyStartEnableV2.value or \
138- super_operator.early_start_mode == SuperKernelEarlyStartMode.EarlyStartV2DisableSubKernel:154+ super_operator.early_start_mode.value == SuperKernelEarlyStartMode.EarlyStartV2DisableSubKernel.value:
139 inter_ops_bar += gen_early_start_config(pre_sub_operator, sub_operator)155 inter_ops_bar += gen_early_start_config(pre_sub_operator, sub_operator)
140 inter_ops_bar += sub_operator.early_start_complement_wait_flag_block156 inter_ops_bar += sub_operator.early_start_complement_wait_flag_block
141 else:157 else:
@@ -147,7 +163,7 @@ def gen_inter_ops_barrier(super_operator: SuperOperatorInfos, \
147 163 
148def gen_op_end_debug_dcci_all(super_operator: SuperOperatorInfos):164def gen_op_end_debug_dcci_all(super_operator: SuperOperatorInfos):
149 op_end_debug_dcci_all = ""165 op_end_debug_dcci_all = ""
150- if super_operator.debug_dcci_all_mode == SuperKernelDebugDcciAllMode.DebugDcciAllEnable:166+ if super_operator.debug_dcci_all_mode.value == SuperKernelDebugDcciAllMode.DebugDcciAllEnable.value:
151 op_end_debug_dcci_all += "// op end debug dcci all.\n"167 op_end_debug_dcci_all += "// op end debug dcci all.\n"
152 op_end_debug_dcci_all += f"pipe_barrier(PIPE_ALL);\n\168 op_end_debug_dcci_all += f"pipe_barrier(PIPE_ALL);\n\
153dcci((__gm__ uint64_t*)0, cache_line_t::ENTIRE_DATA_CACHE, dcci_dst_t::CACHELINE_OUT);\n\n"169dcci((__gm__ uint64_t*)0, cache_line_t::ENTIRE_DATA_CACHE, dcci_dst_t::CACHELINE_OUT);\n\n"
@@ -156,7 +172,7 @@ dcci((__gm__ uint64_t*)0, cache_line_t::ENTIRE_DATA_CACHE, dcci_dst_t::CACHELINE
156 172 
157def gen_op_end_debug_sync_all(super_operator: SuperOperatorInfos):173def gen_op_end_debug_sync_all(super_operator: SuperOperatorInfos):
158 op_end_debug_sync_all = ""174 op_end_debug_sync_all = ""
159- if super_operator.debug_sync_all_mode == SuperKernelDebugSyncAllMode.DebugSyncAllEnable:175+ if super_operator.debug_sync_all_mode.value == SuperKernelDebugSyncAllMode.DebugSyncAllEnable.value:
160 op_end_debug_sync_all += "// op end debug sync all.\n"176 op_end_debug_sync_all += "// op end debug sync all.\n"
161 op_end_debug_sync_all += get_sync_code_by_kernel_type(super_operator.kernel_type)177 op_end_debug_sync_all += get_sync_code_by_kernel_type(super_operator.kernel_type)
162 return op_end_debug_sync_all178 return op_end_debug_sync_all
@@ -164,7 +180,7 @@ def gen_op_end_debug_sync_all(super_operator: SuperOperatorInfos):
164 180 
165def gen_2_real_stream_op_end_debug_sync_all_by_arch(super_operator: SuperOperatorInfos, arch):181def gen_2_real_stream_op_end_debug_sync_all_by_arch(super_operator: SuperOperatorInfos, arch):
166 op_end_debug_sync_all = ""182 op_end_debug_sync_all = ""
167- if super_operator.debug_sync_all_mode == SuperKernelDebugSyncAllMode.DebugSyncAllEnable:183+ if super_operator.debug_sync_all_mode.value == SuperKernelDebugSyncAllMode.DebugSyncAllEnable.value:
168 op_end_debug_sync_all += "// op end debug sync all.\n"184 op_end_debug_sync_all += "// op end debug sync all.\n"
169 if arch == "aiv":185 if arch == "aiv":
170 op_end_debug_sync_all += f"pipe_barrier(PIPE_ALL);\n\186 op_end_debug_sync_all += f"pipe_barrier(PIPE_ALL);\n\
@@ -208,7 +224,7 @@ def gen_switch_case_call_block_of_dynamic_op(super_operator, next_sub_operator,
208 switch_case_call_block = ""224 switch_case_call_block = ""
209 225 
210 # if can not find free core before dynamic, wait for get tilingkey and block dim226 # if can not find free core before dynamic, wait for get tilingkey and block dim
211- if sub_operator.sub_op_task_type is SubOperatorType.DYNAMIC_OP \227+ if sub_operator.sub_op_task_type.value is SubOperatorType.DYNAMIC_OP.value \
212 and sub_operator.switch_func_called_flag is False:228 and sub_operator.switch_func_called_flag is False:
213 switch_case_call_block += \229 switch_case_call_block += \
214 tpl_of_gen_switch_case_call(sub_operator.start_block_idx, sub_operator, super_operator)230 tpl_of_gen_switch_case_call(sub_operator.start_block_idx, sub_operator, super_operator)
@@ -409,7 +425,7 @@ auto_gen_{super_operator.kernel_name}_kernel_{arch}(void) {{\n"
409 super_kernel_file += f" uint64_t aiv_func_addr_split{i} = 0;\n"425 super_kernel_file += f" uint64_t aiv_func_addr_split{i} = 0;\n"
410 super_kernel_file += f" uint64_t aic_func_addr_split{i} = 0;\n"426 super_kernel_file += f" uint64_t aic_func_addr_split{i} = 0;\n"
411 427 
412- if super_operator.preload_mode == SuperKernelPreLoadMode.PreLoadByWhole:428+ if super_operator.preload_mode.value == SuperKernelPreLoadMode.PreLoadByWhole.value:
413 super_kernel_file += indent_code_func(f"AscendC::PreLoad(8);\n")429 super_kernel_file += indent_code_func(f"AscendC::PreLoad(8);\n")
414 430 
415 for pre_sub_operator, sub_operator, next_sub_operator in zip([None] + sub_ops[:-1], \431 for pre_sub_operator, sub_operator, next_sub_operator in zip([None] + sub_ops[:-1], \
@@ -421,17 +437,17 @@ auto_gen_{super_operator.kernel_name}_kernel_{arch}(void) {{\n"
421 sub_operator, pre_sub_operator) 437 sub_operator, pre_sub_operator)
422 438 
423 # add preload of current func439 # add preload of current func
424- if super_operator.preload_mode == SuperKernelPreLoadMode.PreLoadStepByStep:440+ if super_operator.preload_mode.value == SuperKernelPreLoadMode.PreLoadStepByStep.value:
425 super_kernel_file += indent_code_func(sub_operator.preload_call_block)441 super_kernel_file += indent_code_func(sub_operator.preload_call_block)
426 442 
427 # add preload of next func, when n+1 preload instr;443 # add preload of next func, when n+1 preload instr;
428- if super_operator.preload_mode == SuperKernelPreLoadMode.PreloadByAdanvanceStep:444+ if super_operator.preload_mode.value == SuperKernelPreLoadMode.PreloadByAdanvanceStep.value:
429 if pre_sub_operator is None:445 if pre_sub_operator is None:
430 super_kernel_file += indent_code_func(sub_operator.preload_call_block)446 super_kernel_file += indent_code_func(sub_operator.preload_call_block)
431 if next_sub_operator is not None:447 if next_sub_operator is not None:
432 super_kernel_file += indent_code_func(next_sub_operator.preload_call_block)448 super_kernel_file += indent_code_func(next_sub_operator.preload_call_block)
433 449 
434- if super_operator.datacache_mode == SuperKernelDataCacheMode.DataCacheLoadAdancanceStep:450+ if super_operator.datacache_mode.value == SuperKernelDataCacheMode.DataCacheLoadAdancanceStep.value:
435 if pre_sub_operator is None:451 if pre_sub_operator is None:
436 super_kernel_file += indent_code_func(sub_operator.data_cache_preload_call)452 super_kernel_file += indent_code_func(sub_operator.data_cache_preload_call)
437 if next_sub_operator is not None:453 if next_sub_operator is not None:
@@ -448,7 +464,7 @@ event_list:{sub_operator.recv_event_list}")
448 464 
449 tmp_code, enable_syncall_flag = gen_feed_syncall_var_init_code(super_operator, sub_operator)465 tmp_code, enable_syncall_flag = gen_feed_syncall_var_init_code(super_operator, sub_operator)
450 super_kernel_file += indent_code_func(tmp_code)466 super_kernel_file += indent_code_func(tmp_code)
451- if super_operator.profiling_mode is SuperKernelProfilingMode.ProfilingEnable:467+ if super_operator.profiling_mode.value == SuperKernelProfilingMode.ProfilingEnable.value:
452 super_kernel_file += \468 super_kernel_file += \
453 indent_code_func(f"RecordProfiling({super_operator.info_base.index(sub_operator) + 1}, 0x8, true);\n")469 indent_code_func(f"RecordProfiling({super_operator.info_base.index(sub_operator) + 1}, 0x8, true);\n")
454 if enable_syncall_flag is False:470 if enable_syncall_flag is False:
@@ -458,7 +474,7 @@ event_list:{sub_operator.recv_event_list}")
458 super_kernel_file += indent_code_func(gen_op_end_debug_dcci_all(super_operator))474 super_kernel_file += indent_code_func(gen_op_end_debug_dcci_all(super_operator))
459 super_kernel_file += indent_code_func(gen_2_real_stream_op_end_debug_sync_all_by_arch(super_operator, arch))475 super_kernel_file += indent_code_func(gen_2_real_stream_op_end_debug_sync_all_by_arch(super_operator, arch))
460 476 
461- if super_operator.profiling_mode is SuperKernelProfilingMode.ProfilingEnable:477+ if super_operator.profiling_mode.value == SuperKernelProfilingMode.ProfilingEnable.value:
462 super_kernel_file += \478 super_kernel_file += \
463 indent_code_func(f"RecordProfiling({super_operator.info_base.index(sub_operator) + 1}, 0x8, false);\n")479 indent_code_func(f"RecordProfiling({super_operator.info_base.index(sub_operator) + 1}, 0x8, false);\n")
464 480 
@@ -485,7 +501,7 @@ event_list:{sub_operator.send_event_list}")
485 501 
486def gen_profling_func_code(super_operator):502def gen_profling_func_code(super_operator):
487 profiling_code = ""503 profiling_code = ""
488- if super_operator.profiling_mode is SuperKernelProfilingMode.ProfilingEnable:504+ if super_operator.profiling_mode.value == SuperKernelProfilingMode.ProfilingEnable.value:
489 profiling_code = \505 profiling_code = \
490"""506"""
491__BLOCK_LOCAL__ __inline__ uint32_t g_profiling_task_id;507__BLOCK_LOCAL__ __inline__ uint32_t g_profiling_task_id;
@@ -574,7 +590,7 @@ __aicore__ inline void InitProfiling(uint32_t taskId, GM_ADDR profilingPtr)
574 590 
575def gen_profiling_start_and_end_record(super_operator, is_start):591def gen_profiling_start_and_end_record(super_operator, is_start):
576 code = ""592 code = ""
577- if super_operator.profiling_mode is SuperKernelProfilingMode.ProfilingEnable:593+ if super_operator.profiling_mode.value == SuperKernelProfilingMode.ProfilingEnable.value:
578 if is_start:594 if is_start:
579 code = f"RecordProfiling(0, 0, true);\n"595 code = f"RecordProfiling(0, 0, true);\n"
580 else:596 else:
@@ -594,12 +610,12 @@ def gen_2_real_stream_super_kernel_file(super_operator):
594 if super_operator.sub_decl_list.get(sub_operator.kernel_name) is None:610 if super_operator.sub_decl_list.get(sub_operator.kernel_name) is None:
595 super_kernel_file += sub_operator.kernel_declare611 super_kernel_file += sub_operator.kernel_declare
596 super_kernel_params += sub_operator.kernel_params612 super_kernel_params += sub_operator.kernel_params
597- if sub_operator.sub_op_task_type is SubOperatorType.DYNAMIC_OP:613+ if sub_operator.sub_op_task_type.value == SubOperatorType.DYNAMIC_OP.value:
598 if super_operator.sub_decl_list.get(sub_operator.kernel_name) is None:614 if super_operator.sub_decl_list.get(sub_operator.kernel_name) is None:
599 super_kernel_file += sub_operator.dynamic_impl_func_block615 super_kernel_file += sub_operator.dynamic_impl_func_block
600 super_kernel_params += sub_operator.extra_kernel_params616 super_kernel_params += sub_operator.extra_kernel_params
601 exits_dynamic_op = True617 exits_dynamic_op = True
602- elif sub_operator.sub_op_task_type is SubOperatorType.STATIC_OP:618+ elif sub_operator.sub_op_task_type.value == SubOperatorType.STATIC_OP.value:
603 super_kernel_params += sub_operator.extra_kernel_params619 super_kernel_params += sub_operator.extra_kernel_params
604 super_operator.sub_decl_list[sub_operator.kernel_name] = '1'620 super_operator.sub_decl_list[sub_operator.kernel_name] = '1'
605 621 
@@ -617,23 +633,23 @@ def gen_2_real_stream_super_kernel_file(super_operator):
617auto_gen_{super_operator.kernel_name}_kernel(void) {{\n"633auto_gen_{super_operator.kernel_name}_kernel(void) {{\n"
618 super_kernel_file += " GM_ADDR *param_base = (GM_ADDR *)get_para_base();\n"634 super_kernel_file += " GM_ADDR *param_base = (GM_ADDR *)get_para_base();\n"
619 if super_operator.timestamp_option or \635 if super_operator.timestamp_option or \
620- super_operator.feed_sync_all_mode == SuperKernelFeedSyncAllMode.FeedSyncAllEnable:636+ super_operator.feed_sync_all_mode.value == SuperKernelFeedSyncAllMode.FeedSyncAllEnable.value:
621 ws_offset = len(super_operator.super_kernel_params) + 1637 ws_offset = len(super_operator.super_kernel_params) + 1
622 super_kernel_file += f" GM_ADDR workspace = param_base[{ws_offset}];\n"638 super_kernel_file += f" GM_ADDR workspace = param_base[{ws_offset}];\n"
623- if super_operator.feed_sync_all_mode == SuperKernelFeedSyncAllMode.FeedSyncAllEnable:639+ if super_operator.feed_sync_all_mode.value == SuperKernelFeedSyncAllMode.FeedSyncAllEnable.value:
624 super_kernel_file += f" AscendC::g_superKernelAutoSyncAllConfigGmBaseAddr = workspace;\n"640 super_kernel_file += f" AscendC::g_superKernelAutoSyncAllConfigGmBaseAddr = workspace;\n"
625 if super_operator.timestamp_option:641 if super_operator.timestamp_option:
626 is_mix = super_operator.kernel_type in \642 is_mix = super_operator.kernel_type in \
627 [KernelMetaType.KERNEL_TYPE_MIX_AIC_1_1, KernelMetaType.KERNEL_TYPE_MIX_AIC_1_2]643 [KernelMetaType.KERNEL_TYPE_MIX_AIC_1_1, KernelMetaType.KERNEL_TYPE_MIX_AIC_1_2]
628 super_kernel_file += gen_super_dump_code(is_mix, 1048576, super_operator.workspace_size)644 super_kernel_file += gen_super_dump_code(is_mix, 1048576, super_operator.workspace_size)
629- if super_operator.profiling_mode is SuperKernelProfilingMode.ProfilingEnable:645+ if super_operator.profiling_mode.value == SuperKernelProfilingMode.ProfilingEnable.value:
630 profiling_offset = ws_offset + 1646 profiling_offset = ws_offset + 1
631 super_kernel_file += f" GM_ADDR profilingPtr = param_base[{profiling_offset}];\n"647 super_kernel_file += f" GM_ADDR profilingPtr = param_base[{profiling_offset}];\n"
632 super_kernel_file += \648 super_kernel_file += \
633 f" uint32_t taskId = *((__gm__ uint32_t*)(get_para_base() + 8 * {profiling_offset + 1}));\n"649 f" uint32_t taskId = *((__gm__ uint32_t*)(get_para_base() + 8 * {profiling_offset + 1}));\n"
634 super_kernel_file += " InitProfiling(taskId, profilingPtr);\n"650 super_kernel_file += " InitProfiling(taskId, profilingPtr);\n"
635 else:651 else:
636- if super_operator.profiling_mode is SuperKernelProfilingMode.ProfilingEnable:652+ if super_operator.profiling_mode.value == SuperKernelProfilingMode.ProfilingEnable.value:
637 profiling_offset = len(super_operator.super_kernel_params) + 1653 profiling_offset = len(super_operator.super_kernel_params) + 1
638 super_kernel_file += f" GM_ADDR profilingPtr = param_base[{profiling_offset}];\n"654 super_kernel_file += f" GM_ADDR profilingPtr = param_base[{profiling_offset}];\n"
639 super_kernel_file += \655 super_kernel_file += \
@@ -688,7 +704,7 @@ def judge_need_feed_sync_all(super_operator, sub_op):
688 704 
689def gen_feed_syncall_var_init_code(super_operator, sub_op):705def gen_feed_syncall_var_init_code(super_operator, sub_op):
690 code = ""706 code = ""
691- if super_operator.feed_sync_all_mode == SuperKernelFeedSyncAllMode.FeedSyncAllDisable:707+ if super_operator.feed_sync_all_mode.value == SuperKernelFeedSyncAllMode.FeedSyncAllDisable.value:
692 return code, False708 return code, False
693 sub_op_index = super_operator.info_base.index(sub_op)709 sub_op_index = super_operator.info_base.index(sub_op)
694 total_op_num = len(super_operator.info_base)710 total_op_num = len(super_operator.info_base)
@@ -714,7 +730,7 @@ AscendC::g_superKernelAutoSyncAllConfigGmBaseAddr + {total_op_num} * 64 + {sub_o
714 730 
715def gen_clear_syncall_worskspace(super_operator):731def gen_clear_syncall_worskspace(super_operator):
716 gen_code = ""732 gen_code = ""
717- if super_operator.feed_sync_all_mode == SuperKernelFeedSyncAllMode.FeedSyncAllDisable:733+ if super_operator.feed_sync_all_mode.value == SuperKernelFeedSyncAllMode.FeedSyncAllDisable.value:
718 return gen_code734 return gen_code
719 if super_operator.kernel_type == KernelMetaType.KERNEL_TYPE_MIX_AIC_1_0:735 if super_operator.kernel_type == KernelMetaType.KERNEL_TYPE_MIX_AIC_1_0:
720 gen_code += \736 gen_code += \
@@ -811,16 +827,31 @@ if ASCEND_IS_AIC {{
811 827 
812 828 
813def gen_wait_block_extra_sync(super_operator, pre_sub_operator, sub_operator):829def gen_wait_block_extra_sync(super_operator, pre_sub_operator, sub_operator):
830+ pre_sub_operator_device_type = kernel_meta_type_to_device_type(pre_sub_operator.kernel_type)
831+ sub_operator_device_type = kernel_meta_type_to_device_type(sub_operator.kernel_type)
832+ 
814 extra_sync = ""833 extra_sync = ""
815- # some inter op barrier do not contain aiv only syncall, so extra sync will be needed834+ # When wait block runs on aiv block 0 and inter op barrier does not contain aiv only syncall,
816- extra_sync_pairs = {(KernelMetaType.KERNEL_TYPE_AIC_ONLY, KernelMetaType.KERNEL_TYPE_AIV_ONLY)}835+ # extra aiv syncall will be needed to ensure next op runs after wait block finishes.
836+ extra_aiv_sync_pairs = \
837+ {(SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value, SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIV.value),
838+ (SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value, SuperKernelDeviceType.KERNEL_DEVICE_TYPE_MIX.value)}
817 839 
818- if (pre_sub_operator.kernel_type, sub_operator.kernel_type) not in extra_sync_pairs:
819- return extra_sync
820 840 
821- # in sk aic only cases, inter op barrier contains aic only sync all, no extra sync will be needed841+ # When wait block runs on aic block 0 and inter op barrier does not contain aic only syncall,
822- extra_sync += "// extra sync for wait event\n"842+ # extra aic syncall will be needed to ensure next op runs after wait block finishes.
823- extra_sync += "AscendC::SyncAll<true>();\n\n"843+ extra_aic_sync_pairs = \
844+ {(SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIV.value, SuperKernelDeviceType.KERNEL_DEVICE_TYPE_AIC.value)}
845+ 
846+ if (pre_sub_operator_device_type, sub_operator_device_type) in extra_aiv_sync_pairs:
847+ extra_sync += "// extra sync for wait event\n"
848+ extra_sync += "AscendC::SyncAll<true>();\n\n"
849+ elif (pre_sub_operator_device_type, sub_operator_device_type) in extra_aic_sync_pairs:
850+ extra_sync += """
851+// extra sync for wait event
852+ffts_cross_core_sync(PIPE_FIX, AscendC::GetffstMsg(0x0, AscendC::SYNC_AIC_FLAG));
853+wait_flag_dev(AscendC::SYNC_AIC_FLAG);
854+"""
824 855 
825 return extra_sync856 return extra_sync
826 857 
@@ -864,7 +895,7 @@ def gen_super_kernel_file(super_operator):
864 for _, sub_operator in enumerate(sub_ops):895 for _, sub_operator in enumerate(sub_ops):
865 if super_operator.sub_decl_list.get(sub_operator.kernel_name) is None:896 if super_operator.sub_decl_list.get(sub_operator.kernel_name) is None:
866 super_kernel_file += sub_operator.kernel_declare897 super_kernel_file += sub_operator.kernel_declare
867- if sub_operator.sub_op_task_type is SubOperatorType.DYNAMIC_OP:898+ if sub_operator.sub_op_task_type.value == SubOperatorType.DYNAMIC_OP.value:
868 if super_operator.sub_decl_list.get(sub_operator.kernel_name) is None:899 if super_operator.sub_decl_list.get(sub_operator.kernel_name) is None:
869 super_kernel_file += sub_operator.dynamic_impl_func_block900 super_kernel_file += sub_operator.dynamic_impl_func_block
870 exits_dynamic_op = True901 exits_dynamic_op = True
@@ -876,26 +907,26 @@ def gen_super_kernel_file(super_operator):
876auto_gen_{super_operator.kernel_name}_kernel(void) {{\n"907auto_gen_{super_operator.kernel_name}_kernel(void) {{\n"
877 super_kernel_file += " GM_ADDR *param_base = (GM_ADDR *)get_para_base();\n"908 super_kernel_file += " GM_ADDR *param_base = (GM_ADDR *)get_para_base();\n"
878 if super_operator.timestamp_option or \909 if super_operator.timestamp_option or \
879- super_operator.feed_sync_all_mode == SuperKernelFeedSyncAllMode.FeedSyncAllEnable:910+ super_operator.feed_sync_all_mode.value == SuperKernelFeedSyncAllMode.FeedSyncAllEnable.value:
880 if CommonUtility.is_c310():911 if CommonUtility.is_c310():
881 ws_offset = len(super_operator.super_kernel_params)912 ws_offset = len(super_operator.super_kernel_params)
882 else:913 else:
883 ws_offset = len(super_operator.super_kernel_params) + 1914 ws_offset = len(super_operator.super_kernel_params) + 1
884 super_kernel_file += f" GM_ADDR workspace = param_base[{ws_offset}];\n"915 super_kernel_file += f" GM_ADDR workspace = param_base[{ws_offset}];\n"
885- if super_operator.feed_sync_all_mode == SuperKernelFeedSyncAllMode.FeedSyncAllEnable:916+ if super_operator.feed_sync_all_mode.value == SuperKernelFeedSyncAllMode.FeedSyncAllEnable.value:
886 super_kernel_file += f" AscendC::g_superKernelAutoSyncAllConfigGmBaseAddr = workspace;\n"917 super_kernel_file += f" AscendC::g_superKernelAutoSyncAllConfigGmBaseAddr = workspace;\n"
887 if super_operator.timestamp_option:918 if super_operator.timestamp_option:
888 is_mix = super_operator.kernel_type in \919 is_mix = super_operator.kernel_type in \
889 [KernelMetaType.KERNEL_TYPE_MIX_AIC_1_1, KernelMetaType.KERNEL_TYPE_MIX_AIC_1_2]920 [KernelMetaType.KERNEL_TYPE_MIX_AIC_1_1, KernelMetaType.KERNEL_TYPE_MIX_AIC_1_2]
890 super_kernel_file += gen_super_dump_code(is_mix, 1048576, super_operator.workspace_size)921 super_kernel_file += gen_super_dump_code(is_mix, 1048576, super_operator.workspace_size)
891- if super_operator.profiling_mode is SuperKernelProfilingMode.ProfilingEnable:922+ if super_operator.profiling_mode.value == SuperKernelProfilingMode.ProfilingEnable.value:
892 profiling_offset = ws_offset + 1923 profiling_offset = ws_offset + 1
893 super_kernel_file += f" GM_ADDR profilingPtr = param_base[{profiling_offset}];\n"924 super_kernel_file += f" GM_ADDR profilingPtr = param_base[{profiling_offset}];\n"
894 super_kernel_file += \925 super_kernel_file += \
895 f" uint32_t taskId = *((__gm__ uint32_t*)(get_para_base() + 8 * {profiling_offset + 1}));\n"926 f" uint32_t taskId = *((__gm__ uint32_t*)(get_para_base() + 8 * {profiling_offset + 1}));\n"
896 super_kernel_file += " InitProfiling(taskId, profilingPtr);\n"927 super_kernel_file += " InitProfiling(taskId, profilingPtr);\n"
897 else:928 else:
898- if super_operator.profiling_mode is SuperKernelProfilingMode.ProfilingEnable:929+ if super_operator.profiling_mode.value == SuperKernelProfilingMode.ProfilingEnable.value:
899 profiling_offset = len(super_operator.super_kernel_params) + 1930 profiling_offset = len(super_operator.super_kernel_params) + 1
900 super_kernel_file += f" GM_ADDR profilingPtr = param_base[{profiling_offset}];\n"931 super_kernel_file += f" GM_ADDR profilingPtr = param_base[{profiling_offset}];\n"
901 super_kernel_file += \932 super_kernel_file += \
@@ -917,7 +948,7 @@ auto_gen_{super_operator.kernel_name}_kernel(void) {{\n"
917 super_kernel_file += f" uint64_t aiv_func_addr_split{i} = 0;\n"948 super_kernel_file += f" uint64_t aiv_func_addr_split{i} = 0;\n"
918 super_kernel_file += f" uint64_t aic_func_addr_split{i} = 0;\n"949 super_kernel_file += f" uint64_t aic_func_addr_split{i} = 0;\n"
919 950 
920- if super_operator.preload_mode == SuperKernelPreLoadMode.PreLoadByWhole:951+ if super_operator.preload_mode.value == SuperKernelPreLoadMode.PreLoadByWhole.value:
921 super_kernel_file += indent_code_func(f"AscendC::PreLoad(8);\n")952 super_kernel_file += indent_code_func(f"AscendC::PreLoad(8);\n")
922 super_kernel_file += indent_code_func(gen_profiling_start_and_end_record(super_operator, True))953 super_kernel_file += indent_code_func(gen_profiling_start_and_end_record(super_operator, True))
923 for pre_sub_operator, sub_operator, next_sub_operator in zip([None] + sub_ops[:-1], \954 for pre_sub_operator, sub_operator, next_sub_operator in zip([None] + sub_ops[:-1], \
@@ -930,17 +961,17 @@ auto_gen_{super_operator.kernel_name}_kernel(void) {{\n"
930 sub_operator, pre_sub_operator) 961 sub_operator, pre_sub_operator)
931 962 
932 # add preload of current func963 # add preload of current func
933- if super_operator.preload_mode == SuperKernelPreLoadMode.PreLoadStepByStep:964+ if super_operator.preload_mode.value == SuperKernelPreLoadMode.PreLoadStepByStep.value:
934 super_kernel_file += indent_code_func(sub_operator.preload_call_block)965 super_kernel_file += indent_code_func(sub_operator.preload_call_block)
935 966 
936 # add preload of next func, when n+1 preload instr967 # add preload of next func, when n+1 preload instr
937- if super_operator.preload_mode == SuperKernelPreLoadMode.PreloadByAdanvanceStep:968+ if super_operator.preload_mode.value == SuperKernelPreLoadMode.PreloadByAdanvanceStep.value:
938 if pre_sub_operator is None:969 if pre_sub_operator is None:
939 super_kernel_file += indent_code_func(sub_operator.preload_call_block)970 super_kernel_file += indent_code_func(sub_operator.preload_call_block)
940 if next_sub_operator is not None:971 if next_sub_operator is not None:
941 super_kernel_file += indent_code_func(next_sub_operator.preload_call_block)972 super_kernel_file += indent_code_func(next_sub_operator.preload_call_block)
942 973 
943- if super_operator.datacache_mode == SuperKernelDataCacheMode.DataCacheLoadAdancanceStep:974+ if super_operator.datacache_mode.value == SuperKernelDataCacheMode.DataCacheLoadAdancanceStep.value:
944 if pre_sub_operator is None:975 if pre_sub_operator is None:
945 super_kernel_file += indent_code_func(sub_operator.data_cache_preload_call)976 super_kernel_file += indent_code_func(sub_operator.data_cache_preload_call)
946 if next_sub_operator is not None:977 if next_sub_operator is not None:
@@ -957,7 +988,7 @@ not have any recv event, op:{sub_operator.kernel_name}, event_list:{sub_operator
957 988 
958 tmp_code, enable_syncall_flag = gen_feed_syncall_var_init_code(super_operator, sub_operator)989 tmp_code, enable_syncall_flag = gen_feed_syncall_var_init_code(super_operator, sub_operator)
959 super_kernel_file += indent_code_func(tmp_code)990 super_kernel_file += indent_code_func(tmp_code)
960- if super_operator.profiling_mode is SuperKernelProfilingMode.ProfilingEnable:991+ if super_operator.profiling_mode.value == SuperKernelProfilingMode.ProfilingEnable.value:
961 super_kernel_file += \992 super_kernel_file += \
962 indent_code_func(f"RecordProfiling({super_operator.info_base.index(sub_operator) + 1}, 0x8, true);\n")993 indent_code_func(f"RecordProfiling({super_operator.info_base.index(sub_operator) + 1}, 0x8, true);\n")
963 if enable_syncall_flag is False:994 if enable_syncall_flag is False:
@@ -967,7 +998,7 @@ not have any recv event, op:{sub_operator.kernel_name}, event_list:{sub_operator
967 super_kernel_file += indent_code_func(gen_op_end_debug_dcci_all(super_operator))998 super_kernel_file += indent_code_func(gen_op_end_debug_dcci_all(super_operator))
968 super_kernel_file += indent_code_func(gen_op_end_debug_sync_all(super_operator))999 super_kernel_file += indent_code_func(gen_op_end_debug_sync_all(super_operator))
969 1000 
970- if super_operator.profiling_mode is SuperKernelProfilingMode.ProfilingEnable:1001+ if super_operator.profiling_mode.value == SuperKernelProfilingMode.ProfilingEnable.value:
971 super_kernel_file += \1002 super_kernel_file += \
972 indent_code_func(f"RecordProfiling({super_operator.info_base.index(sub_operator) + 1}, 0x8, false);\n")1003 indent_code_func(f"RecordProfiling({super_operator.info_base.index(sub_operator) + 1}, 0x8, false);\n")
973 1004 
@@ -1016,5 +1047,5 @@ def compile(kernel_infos, called_kernel_name="ascendc_super_kernel_plus", impl_m
1016 CommonUtility().ascendc_raise_python_err(ERR_CODE, ("super kernel compile must provide op lists"))1047 CommonUtility().ascendc_raise_python_err(ERR_CODE, ("super kernel compile must provide op lists"))
1017 super_operator = SuperOperatorInfos(kernel_infos, called_kernel_name)1048 super_operator = SuperOperatorInfos(kernel_infos, called_kernel_name)
1018 gen_super_kernel_file(super_operator)1049 gen_super_kernel_file(super_operator)
1019- super_kernel_compile(super_operator.compile_info, super_operator.compile_log_path)1050+ compile_super_kernel(super_operator.compile_info, super_operator.compile_log_path)
1020 return1051 return
@@ -22,6 +22,14 @@ AI_CORE_STR = "AiCore"
22ERR_CODE = "EB0500"22ERR_CODE = "EB0500"
23 23 
24 24 
25+class SuperKernelDeviceType(enum.Enum):
26+ """super kernel device type"""
27+ KERNEL_DEVICE_TYPE_AIV = 0
28+ KERNEL_DEVICE_TYPE_AIC = 1
29+ KERNEL_DEVICE_TYPE_MIX = 2
30+ KERNEL_DEVICE_TYPE_MAX = 3
31+ 
32+ 
25class SuperKernelEarlyStartMode(enum.Enum):33class SuperKernelEarlyStartMode(enum.Enum):
26 """early start mode"""34 """early start mode"""
27 EarlyStartDisable = 035 EarlyStartDisable = 0
@@ -81,15 +81,15 @@ link_mode: SuperKernelLinkMode, split_mode, compile_log_path=None):
81 objs_cube.append(sub_op["aic_bin"])81 objs_cube.append(sub_op["aic_bin"])
82 if "dynamic_bin" in sub_op:82 if "dynamic_bin" in sub_op:
83 objs_dynamic.append(sub_op["dynamic_bin"])83 objs_dynamic.append(sub_op["dynamic_bin"])
84- if link_mode == SuperKernelLinkMode.PerVecHerCube:84+ if link_mode.value == SuperKernelLinkMode.PerVecHerCube.value:
85 objs += super_kernl_files85 objs += super_kernl_files
86 objs += objs_vec86 objs += objs_vec
87 objs += objs_cube87 objs += objs_cube
88- elif link_mode == SuperKernelLinkMode.PerCubeHerVec:88+ elif link_mode.value == SuperKernelLinkMode.PerCubeHerVec.value:
89 objs += super_kernl_files89 objs += super_kernl_files
90 objs += objs_cube90 objs += objs_cube
91 objs += objs_vec91 objs += objs_vec
92- elif link_mode == SuperKernelLinkMode.PerCubeHerVecWithSuper:92+ elif link_mode.value == SuperKernelLinkMode.PerCubeHerVecWithSuper.value:
93 if len(super_kernl_files) == 1:93 if len(super_kernl_files) == 1:
94 objs += super_kernl_files94 objs += super_kernl_files
95 objs += objs_cube95 objs += objs_cube
@@ -118,9 +118,9 @@ def gen_system_run_cfg(kernel_type):
118 file_header = ''118 file_header = ''
119 if kernel_type == KernelMetaType.KERNEL_TYPE_AIV_ONLY or \119 if kernel_type == KernelMetaType.KERNEL_TYPE_AIV_ONLY or \
120 kernel_type == KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0:120 kernel_type == KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0:
121- file_header += "#if defined(__DAV_C220_VEC__)\n"121+ file_header += "#if (defined(__DAV_VEC__) && __NPU_ARCH__ == 2201)\n"
122 else:122 else:
123- file_header += "#if defined(__DAV_C220_CUBE__)\n"123+ file_header += "#if (defined(__DAV_CUBE__) && __NPU_ARCH__ == 2201)\n"
124 124
125 file_header += f" __gm__ struct OpSystemRunCfg g_opSystemRunCfg = {{{0}}};\n"125 file_header += f" __gm__ struct OpSystemRunCfg g_opSystemRunCfg = {{{0}}};\n"
126 file_header += f"#else\n"126 file_header += f"#else\n"
@@ -212,11 +212,17 @@ def gen_spk_kernel_call(super_split_info: SuperSplitInfo, split_mode, kernel_typ
212 212
213 cmds.append("-I" + os.path.join(asc_path, "impl", "adv_api"))213 cmds.append("-I" + os.path.join(asc_path, "impl", "adv_api"))
214 cmds.append("-I" + os.path.join(asc_path, "impl", "basic_api"))214 cmds.append("-I" + os.path.join(asc_path, "impl", "basic_api"))
215+ cmds.append("-I" + os.path.join(asc_path, "impl", "c_api"))
216+ cmds.append("-I" + os.path.join(asc_path, "impl", "micro_api"))
217+ cmds.append("-I" + os.path.join(asc_path, "impl", "simt_api"))
215 cmds.append("-I" + os.path.join(asc_path, "impl", "utils"))218 cmds.append("-I" + os.path.join(asc_path, "impl", "utils"))
216 cmds.append("-I" + os.path.join(asc_path, "include"))219 cmds.append("-I" + os.path.join(asc_path, "include"))
217 cmds.append("-I" + os.path.join(asc_path, "include", "adv_api"))220 cmds.append("-I" + os.path.join(asc_path, "include", "adv_api"))
218 cmds.append("-I" + os.path.join(asc_path, "include", "basic_api"))221 cmds.append("-I" + os.path.join(asc_path, "include", "basic_api"))
219 cmds.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))222 cmds.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))
223+ cmds.append("-I" + os.path.join(asc_path, "include", "c_api"))
224+ cmds.append("-I" + os.path.join(asc_path, "include", "micro_api"))
225+ cmds.append("-I" + os.path.join(asc_path, "include", "simt_api"))
220 cmds.append("-I" + os.path.join(asc_path, "include", "utils"))226 cmds.append("-I" + os.path.join(asc_path, "include", "utils"))
221 cmds.append("-I" + os.path.join(asc_path, "..", "ascendc", "act"))227 cmds.append("-I" + os.path.join(asc_path, "..", "ascendc", "act"))
222 cmds.append("-I" + os.path.join(asc_path, "impl"))228 cmds.append("-I" + os.path.join(asc_path, "impl"))
@@ -310,7 +316,7 @@ def localize_symbol_of_sk(split_mode, sks, spk_dst_file, compile_log_path):
310 run_local_cmd(local_synbol_cmds, compile_log_path)316 run_local_cmd(local_synbol_cmds, compile_log_path)
311 317 
312 318 
313-def super_kernel_compile(kernel_info, compile_log_path):319+def compile_super_kernel(kernel_info, compile_log_path, enable_features: dict = None):
314 global_var_storage.set_variable("super_kenel_save_sub_op_files", True)320 global_var_storage.set_variable("super_kenel_save_sub_op_files", True)
315 op_info = OpInfo()321 op_info = OpInfo()
316 compile_options = kernel_info["compile_option"]322 compile_options = kernel_info["compile_option"]
@@ -332,7 +338,8 @@ def super_kernel_compile(kernel_info, compile_log_path):
332 if CommonUtility.is_c310() or CommonUtility.is_310r6() or CommonUtility.is_m510():338 if CommonUtility.is_c310() or CommonUtility.is_310r6() or CommonUtility.is_m510():
333 compile_option_tuple.compile_options.append('--cce-no-dcache-flush')339 compile_option_tuple.compile_options.append('--cce-no-dcache-flush')
334 if kernel_info["timestamp_option"]:340 if kernel_info["timestamp_option"]:
335- compile_options.append('-DONE_CORE_DUMP_SIZE=' + str(compile_info.super_kernel_info["debug_size"] / 75))341+ compile_options.append('-DONE_CORE_DUMP_SIZE=' + str(compile_info.super_kernel_info["debug_size"] \
342+ / CommonUtility.get_dump_core_num()))
336 _compile_ascendc_cce_v220_with_kernel_type_for_static(compile_info, compile_option_tuple, tiling_info) 343 _compile_ascendc_cce_v220_with_kernel_type_for_static(compile_info, compile_option_tuple, tiling_info)
337 sub_objs = gen_super_kernel_link_obj_sequence(compile_info, kernel_info["sub_operator"], kernel_info["link_mode"],344 sub_objs = gen_super_kernel_link_obj_sequence(compile_info, kernel_info["sub_operator"], kernel_info["link_mode"],
338 kernel_info["split_mode"], compile_info.compile_log_path)345 kernel_info["split_mode"], compile_info.compile_log_path)
@@ -345,3 +352,7 @@ def super_kernel_compile(kernel_info, compile_log_path):
345 localization_sub_op_func_sym(compile_info.dst_file, kernel_info["sub_operator"])352 localization_sub_op_func_sym(compile_info.dst_file, kernel_info["sub_operator"])
346 _json_post_process(compile_info, op_info, tiling_info, True, True, compile_info.compile_log_path)353 _json_post_process(compile_info, op_info, tiling_info, True, True, compile_info.compile_log_path)
347 localize_symbol_of_sk(kernel_info["split_mode"], _sk_new, compile_info.dst_file, compile_info.compile_log_path)354 localize_symbol_of_sk(kernel_info["split_mode"], _sk_new, compile_info.dst_file, compile_info.compile_log_path)
355+ 
356+ 
357+def super_kernel_compile(kernel_info, compile_log_path):
358+ compile_super_kernel(kernel_info, compile_log_path)
@@ -58,7 +58,7 @@ def split_dynamic_o_in_super_kernel(orign_bin_path, rename_file_path, i, compile
58 if os.path.exists(new_bin_path):58 if os.path.exists(new_bin_path):
59 str_lst = f'WARNING: ALLREADY EXISTS split .o path: {new_bin_path}'59 str_lst = f'WARNING: ALLREADY EXISTS split .o path: {new_bin_path}'
60 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, compile_log_path)60 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, compile_log_path)
61- cmds = ['cp'] + ['-rf'] + [f'{orign_bin_path}'] + [f'{new_bin_path}']61+ cmds = ['cp'] + ['-rfL'] + [f'{orign_bin_path}'] + [f'{new_bin_path}']
62 try:62 try:
63 CommonUtility.dump_compile_log(cmds, CompileStage.SPLIT_SUB_OBJS, compile_log_path)63 CommonUtility.dump_compile_log(cmds, CompileStage.SPLIT_SUB_OBJS, compile_log_path)
64 subprocess.run(cmds)64 subprocess.run(cmds)
@@ -501,11 +501,9 @@ class SuperOperatorInfos:
501 recv_info: {sub_op.recv_info}", AscendCLogLevel.LOG_DEBUG)501 recv_info: {sub_op.recv_info}", AscendCLogLevel.LOG_DEBUG)
502 502 
503 def creat_compile_log(self):503 def creat_compile_log(self):
504- op_debug_config_val = get_op_debug_config()504+ kernel_meta_dir = CommonUtility.get_kernel_meta_dir()
505- if "dump_cce" in op_debug_config_val:505+ distinct_tag = CommonUtility.get_distinct_filename_tag()
506- kernel_meta_dir = CommonUtility.get_kernel_meta_dir()506+ self.compile_log_path = os.path.join(kernel_meta_dir, self.kernel_name + distinct_tag + '.log')
507- distinct_tag = CommonUtility.get_distinct_filename_tag()
508- self.compile_log_path = os.path.join(kernel_meta_dir, self.kernel_name + distinct_tag + '.log')
509 507 
510 508 
511 def sub_op_connect_set(self, former_op, op):509 def sub_op_connect_set(self, former_op, op):
@@ -546,7 +544,7 @@ f"ERROR: super kernel do not support self send/receive pair within 1 real stream
546 CommonUtility().ascendc_raise_python_err(ERR_CODE, (\544 CommonUtility().ascendc_raise_python_err(ERR_CODE, (\
547f"ERROR: super kernel do not support self send/receive pair within 1 real stream: oplist: {self.op_list} "))545f"ERROR: super kernel do not support self send/receive pair within 1 real stream: oplist: {self.op_list} "))
548 elif former_op.stream_index != op.stream_index and not connect_set:546 elif former_op.stream_index != op.stream_index and not connect_set:
549- if self.stream_fusin_mode == SuperKernelStreamFusionMode.StreamFusionEnable:547+ if self.stream_fusin_mode.value == SuperKernelStreamFusionMode.StreamFusionEnable.value:
550 CommonUtility.print_compile_log("", \548 CommonUtility.print_compile_log("", \
551 f"enter into 2 real stream mode, oplist: {self.op_list} ", AscendCLogLevel.LOG_DEBUG)549 f"enter into 2 real stream mode, oplist: {self.op_list} ", AscendCLogLevel.LOG_DEBUG)
552 self.enable_double_stream = True550 self.enable_double_stream = True
@@ -703,7 +701,7 @@ f"ERROR: ratio of super kernel debug-aic-num {debug_aic_num} to debug-aiv-num {d
703 if os.path.exists(new_bin_path):701 if os.path.exists(new_bin_path):
704 str_lst = f'WARNING: ALLREADY EXISTS split .o path: {new_bin_path}'702 str_lst = f'WARNING: ALLREADY EXISTS split .o path: {new_bin_path}'
705 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, self.compile_log_path)703 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, self.compile_log_path)
706- cmds = ['cp'] + ['-rf'] + [f'{orign_bin_path}'] + [f'{new_bin_path}']704+ cmds = ['cp'] + ['-rfL'] + [f'{orign_bin_path}'] + [f'{new_bin_path}']
707 try:705 try:
708 CommonUtility.dump_compile_log(cmds, CompileStage.SPLIT_SUB_OBJS, self.compile_log_path)706 CommonUtility.dump_compile_log(cmds, CompileStage.SPLIT_SUB_OBJS, self.compile_log_path)
709 subprocess.run(cmds)707 subprocess.run(cmds)
@@ -722,9 +720,9 @@ f"ERROR: ratio of super kernel debug-aic-num {debug_aic_num} to debug-aiv-num {d
722 def gen_super_kernel_params(self):720 def gen_super_kernel_params(self):
723 for sub_operator in self.info_base:721 for sub_operator in self.info_base:
724 self.super_kernel_params += sub_operator.kernel_params722 self.super_kernel_params += sub_operator.kernel_params
725- if sub_operator.sub_op_task_type is SubOperatorType.DYNAMIC_OP:723+ if sub_operator.sub_op_task_type.value == SubOperatorType.DYNAMIC_OP.value:
726 self.super_kernel_params += sub_operator.extra_kernel_params724 self.super_kernel_params += sub_operator.extra_kernel_params
727- elif sub_operator.sub_op_task_type is SubOperatorType.STATIC_OP:725+ elif sub_operator.sub_op_task_type.value == SubOperatorType.STATIC_OP.value:
728 self.super_kernel_params += sub_operator.extra_kernel_params726 self.super_kernel_params += sub_operator.extra_kernel_params
729 CommonUtility.dump_compile_log(['### SK Arg: FFTS', ','.join(self.super_kernel_params)], \727 CommonUtility.dump_compile_log(['### SK Arg: FFTS', ','.join(self.super_kernel_params)], \
730 CompileStage.SPLIT_SUB_OBJS, self.compile_log_path)728 CompileStage.SPLIT_SUB_OBJS, self.compile_log_path)
@@ -739,7 +737,7 @@ f"ERROR: ratio of super kernel debug-aic-num {debug_aic_num} to debug-aiv-num {d
739 737 
740 738 
741 def calc_workspace_size(self):739 def calc_workspace_size(self):
742- if self.feed_sync_all_mode == SuperKernelFeedSyncAllMode.FeedSyncAllDisable:740+ if self.feed_sync_all_mode.value == SuperKernelFeedSyncAllMode.FeedSyncAllDisable.value:
743 self.workspace_size = 0741 self.workspace_size = 0
744 return742 return
745 if self.kernel_type in [KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0, \743 if self.kernel_type in [KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0, \
@@ -751,18 +749,21 @@ f"ERROR: ratio of super kernel debug-aic-num {debug_aic_num} to debug-aiv-num {d
751 749 
752 750 
753 def add_define_options(self, exist_dynamic_sub_ops, options: list):751 def add_define_options(self, exist_dynamic_sub_ops, options: list):
752+ if self.kernel_type == KernelMetaType.KERNEL_TYPE_MIX_AIC_1_1 and \
753+ (CommonUtility.is_c310() or CommonUtility.is_310r6()):
754+ options.append("-D__ASCENDC_DAVID_SPLIT_CORE__")
754 if exist_dynamic_sub_ops:755 if exist_dynamic_sub_ops:
755 options.append("-D__SUPER_KERNEL_DYNAMIC_BLOCK_NUM__")756 options.append("-D__SUPER_KERNEL_DYNAMIC_BLOCK_NUM__")
756 757 
757- if self.early_start_mode != SuperKernelEarlyStartMode.EarlyStartDisable:758+ if self.early_start_mode.value != SuperKernelEarlyStartMode.EarlyStartDisable.value:
758 options.append("-D__ASCENDC_ENABLE_SET_NEXT_TASK_START")759 options.append("-D__ASCENDC_ENABLE_SET_NEXT_TASK_START")
759 options.append("-D__ASCENDC_ENABLE_WAIT_PRE_TASK_END")760 options.append("-D__ASCENDC_ENABLE_WAIT_PRE_TASK_END")
760- if self.early_start_mode == SuperKernelEarlyStartMode.EarlyStartEnableV1:761+ if self.early_start_mode.value == SuperKernelEarlyStartMode.EarlyStartEnableV1.value:
761 options.append("-D__ASCENDC_SUPERKERNEL_EARLY_START_V1")762 options.append("-D__ASCENDC_SUPERKERNEL_EARLY_START_V1")
762 else:763 else:
763 options.append("-D__ASCENDC_SUPERKERNEL_EARLY_START_V2")764 options.append("-D__ASCENDC_SUPERKERNEL_EARLY_START_V2")
764 765 
765- if self.feed_sync_all_mode == SuperKernelFeedSyncAllMode.FeedSyncAllEnable:766+ if self.feed_sync_all_mode.value == SuperKernelFeedSyncAllMode.FeedSyncAllEnable.value:
766 options.append("-D__ASCENDC_SUPERKERNEL_AUTO_SYNC_ALL__")767 options.append("-D__ASCENDC_SUPERKERNEL_AUTO_SYNC_ALL__")
767 768 
768 if self.timestamp_option:769 if self.timestamp_option:
@@ -800,11 +801,17 @@ f"ERROR: ratio of super kernel debug-aic-num {debug_aic_num} to debug-aiv-num {d
800 801
801 options.append("-I" + os.path.join(asc_path, "impl", "adv_api"))802 options.append("-I" + os.path.join(asc_path, "impl", "adv_api"))
802 options.append("-I" + os.path.join(asc_path, "impl", "basic_api"))803 options.append("-I" + os.path.join(asc_path, "impl", "basic_api"))
804+ options.append("-I" + os.path.join(asc_path, "impl", "c_api"))
805+ options.append("-I" + os.path.join(asc_path, "impl", "micro_api"))
806+ options.append("-I" + os.path.join(asc_path, "impl", "simt_api"))
803 options.append("-I" + os.path.join(asc_path, "impl", "utils"))807 options.append("-I" + os.path.join(asc_path, "impl", "utils"))
804 options.append("-I" + os.path.join(asc_path, "include"))808 options.append("-I" + os.path.join(asc_path, "include"))
805 options.append("-I" + os.path.join(asc_path, "include", "adv_api"))809 options.append("-I" + os.path.join(asc_path, "include", "adv_api"))
806 options.append("-I" + os.path.join(asc_path, "include", "basic_api"))810 options.append("-I" + os.path.join(asc_path, "include", "basic_api"))
807 options.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))811 options.append("-I" + os.path.join(asc_path, "include", "aicpu_api"))
812+ options.append("-I" + os.path.join(asc_path, "include", "c_api"))
813+ options.append("-I" + os.path.join(asc_path, "include", "micro_api"))
814+ options.append("-I" + os.path.join(asc_path, "include", "simt_api"))
808 options.append("-I" + os.path.join(asc_path, "include", "utils"))815 options.append("-I" + os.path.join(asc_path, "include", "utils"))
809 options.append("-I" + os.path.join(asc_path, "..", "ascendc", "act"))816 options.append("-I" + os.path.join(asc_path, "..", "ascendc", "act"))
810 options.append("-I" + os.path.join(asc_path, "impl"))817 options.append("-I" + os.path.join(asc_path, "impl"))
@@ -99,7 +99,7 @@ class NonEmptyParser(OptionParser):
99 def parse_option(self, value: str):99 def parse_option(self, value: str):
100 if len(value.strip()) <= 0:100 if len(value.strip()) <= 0:
101 CommonUtility().ascendc_raise_python_err(ERR_CODE,101 CommonUtility().ascendc_raise_python_err(ERR_CODE,
102-f"[Super Kernel] Invalid compile option: {self.key} option should not be empty.")102+ f"[Super Kernel] Invalid compile option: {self.key} option should not be empty.")
103 return value103 return value
104 104 
105 105 
@@ -63,15 +63,15 @@ def gen_gm_get_set_value_dcci_compile_options(compile_option_tuple, compile_info
63def gen_sub_super_kernel_early_start_compile_options(compile_option_tuple, compile_info):63def gen_sub_super_kernel_early_start_compile_options(compile_option_tuple, compile_info):
64 early_start_mode = compile_info.super_kernel_info["sp_options"].get('early-start', \64 early_start_mode = compile_info.super_kernel_info["sp_options"].get('early-start', \
65 SuperKernelEarlyStartMode.EarlyStartEnableV2)65 SuperKernelEarlyStartMode.EarlyStartEnableV2)
66- if early_start_mode == SuperKernelEarlyStartMode.EarlyStartDisable or \66+ if early_start_mode.value == SuperKernelEarlyStartMode.EarlyStartDisable.value or \
67- early_start_mode == SuperKernelEarlyStartMode.EarlyStartV2DisableSubKernel:67+ early_start_mode.value == SuperKernelEarlyStartMode.EarlyStartV2DisableSubKernel.value:
68 return68 return
69 sp_info = get_context().get_addition("super_kernel_sub_info")69 sp_info = get_context().get_addition("super_kernel_sub_info")
70 if len(sp_info) != 0 and "super_kernel_sub_loc" in sp_info:70 if len(sp_info) != 0 and "super_kernel_sub_loc" in sp_info:
71 super_kernel_sub_loc = sp_info["super_kernel_sub_loc"]71 super_kernel_sub_loc = sp_info["super_kernel_sub_loc"]
72- if early_start_mode == SuperKernelEarlyStartMode.EarlyStartEnableV1:72+ if early_start_mode.value == SuperKernelEarlyStartMode.EarlyStartEnableV1.value:
73 compile_option_tuple.compile_options.append("-D__ASCENDC_SUPERKERNEL_EARLY_START_V1")73 compile_option_tuple.compile_options.append("-D__ASCENDC_SUPERKERNEL_EARLY_START_V1")
74- elif early_start_mode == SuperKernelEarlyStartMode.EarlyStartEnableV2:74+ elif early_start_mode.value == SuperKernelEarlyStartMode.EarlyStartEnableV2.value:
75 compile_option_tuple.compile_options.append("-D__ASCENDC_SUPERKERNEL_EARLY_START_V2")75 compile_option_tuple.compile_options.append("-D__ASCENDC_SUPERKERNEL_EARLY_START_V2")
76 76 
77 if compile_info.super_kernel_early_start_set_flag and (super_kernel_sub_loc != "end"):77 if compile_info.super_kernel_early_start_set_flag and (super_kernel_sub_loc != "end"):
@@ -97,7 +97,7 @@ def sp_add_sub_op_block_dim_macro(compile_option_tuple, tiling_info):
97def sp_add_sub_op_feed_sync_all_macro(compile_info, compile_option_tuple):97def sp_add_sub_op_feed_sync_all_macro(compile_info, compile_option_tuple):
98 feed_sync_all_mode = compile_info.super_kernel_info["sp_options"].get('feed-sync-all', \98 feed_sync_all_mode = compile_info.super_kernel_info["sp_options"].get('feed-sync-all', \
99 SuperKernelFeedSyncAllMode.FeedSyncAllDisable)99 SuperKernelFeedSyncAllMode.FeedSyncAllDisable)
100- if feed_sync_all_mode == SuperKernelFeedSyncAllMode.FeedSyncAllEnable:100+ if feed_sync_all_mode.value == SuperKernelFeedSyncAllMode.FeedSyncAllEnable.value:
101 compile_option_tuple.compile_options.append(f"-D__ASCENDC_SUPERKERNEL_AUTO_SYNC_ALL__")101 compile_option_tuple.compile_options.append(f"-D__ASCENDC_SUPERKERNEL_AUTO_SYNC_ALL__")
102 102 
103 103 
@@ -107,7 +107,7 @@ def gen_sub_super_kernel_compile_options(compile_option_tuple, tiling_info, comp
107 sp_add_sub_op_feed_sync_all_macro(compile_info, compile_option_tuple)107 sp_add_sub_op_feed_sync_all_macro(compile_info, compile_option_tuple)
108 stream_fusion_mode = compile_info.super_kernel_info["sp_options"].get('stream-fusion', \108 stream_fusion_mode = compile_info.super_kernel_info["sp_options"].get('stream-fusion', \
109 SuperKernelStreamFusionMode.StreamFusionDisable)109 SuperKernelStreamFusionMode.StreamFusionDisable)
110- if stream_fusion_mode == SuperKernelStreamFusionMode.StreamFusionEnable:110+ if stream_fusion_mode.value == SuperKernelStreamFusionMode.StreamFusionEnable.value:
111 return111 return
112 # dynamic can not open early start, because do not now id in graph112 # dynamic can not open early start, because do not now id in graph
113 if tiling_info.static_shape_flag:113 if tiling_info.static_shape_flag:
@@ -125,7 +125,7 @@ def split_kernel(sub_kernels_dict, func_name, obj_path, split_mode, compile_log_
125 if os.path.exists(new_bin_path):125 if os.path.exists(new_bin_path):
126 str_lst = f'ERROR: ALLREADY EXISTS split .o path: {new_bin_path}'126 str_lst = f'ERROR: ALLREADY EXISTS split .o path: {new_bin_path}'
127 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, compile_log_path)127 CommonUtility.dump_compile_log([str_lst], CompileStage.SPLIT_SUB_OBJS, compile_log_path)
128- cmds = ['cp'] + ['-rf'] + [f'{obj_path}'] + [f'{new_bin_path}']128+ cmds = ['cp'] + ['-rfL'] + [f'{obj_path}'] + [f'{new_bin_path}']
129 run_local_cmd(cmds, compile_log_path)129 run_local_cmd(cmds, compile_log_path)
130 new_kernel_name = f"{func_name}_split{i}"130 new_kernel_name = f"{func_name}_split{i}"
131 cmds = ['llvm-objcopy', f'--redefine-sym={func_name}={new_kernel_name}', f'{new_bin_path}']131 cmds = ['llvm-objcopy', f'--redefine-sym={func_name}={new_kernel_name}', f'{new_bin_path}']
@@ -218,4 +218,4 @@ def gen_sub_kernel_name(current_kernel_name: str, arch: str, kernel_type: str, o
218 else:218 else:
219 raise_tbe_python_err(TBE_DEFAULT_PYTHON_ERROR_CODE, \219 raise_tbe_python_err(TBE_DEFAULT_PYTHON_ERROR_CODE, \
220 ("sub super kernel compile must provide super_kernel_sub_info"))220 ("sub super kernel compile must provide super_kernel_sub_info"))
221- return current_kernel_name221+ return current_kernel_name
@@ -134,7 +134,7 @@ class SubOperatorInfos:
134 134 
135 def gen_profiling_for_notify(self, index, end_flag):135 def gen_profiling_for_notify(self, index, end_flag):
136 code = ""136 code = ""
137- if self.profiling_mode is SuperKernelProfilingMode.ProfilingDisable:137+ if self.profiling_mode.value == SuperKernelProfilingMode.ProfilingDisable.value:
138 return code138 return code
139 if end_flag is False:139 if end_flag is False:
140 code = f"RecordProfiling({index}, 0x4, true);\n"140 code = f"RecordProfiling({index}, 0x4, true);\n"
@@ -144,7 +144,7 @@ class SubOperatorInfos:
144 144 
145 def gen_profiling_for_wait(self, index, end_flag):145 def gen_profiling_for_wait(self, index, end_flag):
146 code = ""146 code = ""
147- if self.profiling_mode is SuperKernelProfilingMode.ProfilingDisable:147+ if self.profiling_mode.value == SuperKernelProfilingMode.ProfilingDisable.value:
148 return code148 return code
149 if end_flag is False:149 if end_flag is False:
150 code = f"RecordProfiling({index}, 12, true);\n"150 code = f"RecordProfiling({index}, 12, true);\n"
@@ -254,7 +254,7 @@ param_offset={self.wait_param_offset + index}\n"
254 254 
255 255 
256 def code_gen(self, inner_event_id_set, enable_double_stream):256 def code_gen(self, inner_event_id_set, enable_double_stream):
257- if self.sub_op_task_type is SubOperatorType.DYNAMIC_OP:257+ if self.sub_op_task_type.value == SubOperatorType.DYNAMIC_OP.value:
258 self.process_of_dynamic_op(enable_double_stream)258 self.process_of_dynamic_op(enable_double_stream)
259 else:259 else:
260 self.extract_sub_op_bin_files()260 self.extract_sub_op_bin_files()
@@ -263,7 +263,7 @@ param_offset={self.wait_param_offset + index}\n"
263 263 
264 264 
265 def adjust_dynamic_op(self, spk_block_dim):265 def adjust_dynamic_op(self, spk_block_dim):
266- if self.sub_op_task_type is SubOperatorType.DYNAMIC_OP:266+ if self.sub_op_task_type.value == SubOperatorType.DYNAMIC_OP.value:
267 self.dynamic_impl_func_block = self.dynamic_impl_func_block.replace(267 self.dynamic_impl_func_block = self.dynamic_impl_func_block.replace(
268 "__placehoder__spk_block_dim__", f"{spk_block_dim}")268 "__placehoder__spk_block_dim__", f"{spk_block_dim}")
269 269 
@@ -295,7 +295,7 @@ param_offset={self.wait_param_offset + index}\n"
295 sub_operater_infos.get('sub_operator_call_dcci_before_kernel_start', False)295 sub_operater_infos.get('sub_operator_call_dcci_before_kernel_start', False)
296 self.call_dcci_after_kernel_end = \296 self.call_dcci_after_kernel_end = \
297 sub_operater_infos.get('sub_operator_call_dcci_after_kernel_end', False)297 sub_operater_infos.get('sub_operator_call_dcci_after_kernel_end', False)
298- if self.early_start_mode == SuperKernelEarlyStartMode.EarlyStartDisable \298+ if self.early_start_mode.value == SuperKernelEarlyStartMode.EarlyStartDisable.value \
299 and (self.early_start_set_flag or self.early_start_wait_flag):299 and (self.early_start_set_flag or self.early_start_wait_flag):
300 CommonUtility().ascendc_raise_python_err(ERR_CODE, \300 CommonUtility().ascendc_raise_python_err(ERR_CODE, \
301(f"sub operator {self.kernel_name} early-start mode set:{self.early_start_set_flag}, \301(f"sub operator {self.kernel_name} early-start mode set:{self.early_start_set_flag}, \
@@ -671,7 +671,7 @@ param_base[{dynamic_extra_param_offset + 1}], param_base[{dynamic_extra_param_of
671 671 
672 def sub_op_gen_feed_sync_all_code(self, end_flag):672 def sub_op_gen_feed_sync_all_code(self, end_flag):
673 code = ""673 code = ""
674- if self.feed_sync_all_mode == SuperKernelFeedSyncAllMode.FeedSyncAllDisable:674+ if self.feed_sync_all_mode.value == SuperKernelFeedSyncAllMode.FeedSyncAllDisable.value:
675 return code675 return code
676 if end_flag is False:676 if end_flag is False:
677 code += f"AscendC::SuperKernelAutoSyncAllEndImpl();\n"677 code += f"AscendC::SuperKernelAutoSyncAllEndImpl();\n"
@@ -745,7 +745,7 @@ f"""else {{
745 vector_call_func_block = f"if {core_type} {{\n"745 vector_call_func_block = f"if {core_type} {{\n"
746 vector_call_func_block += f" if ({condition_code}) {{\n"746 vector_call_func_block += f" if ({condition_code}) {{\n"
747 if gen_set_flag:747 if gen_set_flag:
748- if self.early_start_mode == SuperKernelEarlyStartMode.EarlyStartEnableV1:748+ if self.early_start_mode.value == SuperKernelEarlyStartMode.EarlyStartEnableV1.value:
749 vector_call_func_block += f" AscendC::SetNextTaskStart();\n"749 vector_call_func_block += f" AscendC::SetNextTaskStart();\n"
750 else:750 else:
751 if self.kernel_type in [KernelMetaType.KERNEL_TYPE_AIV_ONLY, KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0]\751 if self.kernel_type in [KernelMetaType.KERNEL_TYPE_AIV_ONLY, KernelMetaType.KERNEL_TYPE_MIX_AIV_1_0]\
@@ -78,4 +78,4 @@ def check_exist_instrinsic_when_super_kernel(dst_i_file):
78 f"{path_list[i]}, code line is : {line_result[i]}"78 f"{path_list[i]}, code line is : {line_result[i]}"
79 if i != len_result_symbol_list - 1:79 if i != len_result_symbol_list - 1:
80 result_str += '\n'80 result_str += '\n'
81- CommonUtility().ascendc_raise_python_err(ERR_CODE, result_str)81+ CommonUtility().ascendc_raise_python_err(ERR_CODE, result_str)
@@ -467,7 +467,8 @@ bool CceConfBase::SetOptionalCoreType(const std::string& key) {//COVER
467 Ascend_910_9592, Ascend_910_9595, Ascend_910_9596, Ascend_910_9581, Ascend_910_9582, Ascend_910_9583,467 Ascend_910_9592, Ascend_910_9595, Ascend_910_9596, Ascend_910_9581, Ascend_910_9582, Ascend_910_9583,
468 Ascend_910_9584, Ascend_910_9585, Ascend_910_9586, Ascend_910_9587, Ascend_910_9588, Ascend_910_9571,468 Ascend_910_9584, Ascend_910_9585, Ascend_910_9586, Ascend_910_9587, Ascend_910_9588, Ascend_910_9571,
469 Ascend_910_9572, Ascend_910_9573, Ascend_910_9574, Ascend_910_9575, Ascend_910_9576, Ascend_910_9577,469 Ascend_910_9572, Ascend_910_9573, Ascend_910_9574, Ascend_910_9575, Ascend_910_9576, Ascend_910_9577,
470- Ascend_910_9578, Ascend_910_95A1, Ascend_910_95A2, MC62CM12AA, KirinX90, Kirin9030470+ Ascend_910_9578, Ascend_910_95A1, Ascend_910_95A2, MC62CM12AA, KirinX90, Kirin9030,
471+ Ascend_910_950x
471 };472 };
472 if (soc_vector_core.find(this->target_opti_compilation_infos_.GetSocVersion()) ==473 if (soc_vector_core.find(this->target_opti_compilation_infos_.GetSocVersion()) ==
473 soc_vector_core.end()) {474 soc_vector_core.end()) {
@@ -515,7 +516,7 @@ bool CceConfBase::SetOptionalAicoreNum(const std::string& key) {//COVER
515 }516 }
516 if (!(soc_version == Ascend_310P1) && !(soc_version == Ascend_310P3) &&517 if (!(soc_version == Ascend_310P1) && !(soc_version == Ascend_310P3) &&
517 !(soc_version == Ascend_310P5) && !(soc_version == Ascend_310P7)) {518 !(soc_version == Ascend_310P5) && !(soc_version == Ascend_310P7)) {
518- CHECK(aicore_num <= max_aicore_num, ("Unsupported AICore_Num: " + std::to_string(aicore_num) + ".\n"));519+ CHECK(aicore_num <= max_aicore_num, ("Unsupported AICore_Num: " + std::to_string(aicore_num) + ".\n").c_str());
519 }520 }
520 if (aicore_num > 0) {521 if (aicore_num > 0) {
521 std::map<std::string, std::string> map_res;522 std::map<std::string, std::string> map_res;
@@ -113,6 +113,7 @@ constexpr const char* Ascend_910_9372 = "Ascend910_9372";
113constexpr const char* Ascend_910_9362 = "Ascend910_9362";113constexpr const char* Ascend_910_9362 = "Ascend910_9362";
114constexpr const char* Ascend_910_95 = "Ascend910_95";114constexpr const char* Ascend_910_95 = "Ascend910_95";
115constexpr const char* MC62CM12AA = "MC62CM12AA";115constexpr const char* MC62CM12AA = "MC62CM12AA";
116+constexpr const char* Ascend_910_950x = "Ascend910_950x";
116constexpr const char* Ascend_910_950y = "Ascend910_950y";117constexpr const char* Ascend_910_950y = "Ascend910_950y";
117constexpr const char* Ascend_910_950z = "Ascend910_950z";118constexpr const char* Ascend_910_950z = "Ascend910_950z";
118constexpr const char* Ascend_910_957b = "Ascend910_957b";119constexpr const char* Ascend_910_957b = "Ascend910_957b";
@@ -616,8 +617,7 @@ class CceConfBase {
616 Ascend_910_9584, Ascend_910_9585, Ascend_910_9586, Ascend_910_9587, Ascend_910_9588,617 Ascend_910_9584, Ascend_910_9585, Ascend_910_9586, Ascend_910_9587, Ascend_910_9588,
617 Ascend_910_9571, Ascend_910_9572, Ascend_910_9573, Ascend_910_9574, Ascend_910_9575,618 Ascend_910_9571, Ascend_910_9572, Ascend_910_9573, Ascend_910_9574, Ascend_910_9575,
618 Ascend_910_9576, Ascend_910_9577, Ascend_910_9578, Ascend_910_95A1, Ascend_910_95A2,619 Ascend_910_9576, Ascend_910_9577, Ascend_910_9578, Ascend_910_95A1, Ascend_910_95A2,
619- MC62CM12AA, KirinX90, Kirin9030620+ MC62CM12AA, KirinX90, Kirin9030, Ascend_910_950x};
620- };
621 enum platformconf::TIK_VERSION current_tik_version_ = platformconf::TIK_VERSION::TIK_1_0;621 enum platformconf::TIK_VERSION current_tik_version_ = platformconf::TIK_VERSION::TIK_1_0;
622 const std::map<const std::string, platformconf::TIK_VERSION> kStringToTikVersion = {622 const std::map<const std::string, platformconf::TIK_VERSION> kStringToTikVersion = {
623 {"TIK1.0", platformconf::TIK_VERSION::TIK_1_0},623 {"TIK1.0", platformconf::TIK_VERSION::TIK_1_0},
Mtools/build/asc_op_compile_base/c_api/asc_platform_api.cpp+3-2文件内容审核中,请稍后刷新重试
@@ -273,6 +273,9 @@ def _build_aicore_compile_cmd(src_file, dst_file, name="", is_ffts_needed=False,
273 if get_soc_spec("SHORT_SOC_VERSION") != ASCEND_610LITE and get_soc_spec("SHORT_SOC_VERSION") != BS9SX2A:273 if get_soc_spec("SHORT_SOC_VERSION") != ASCEND_610LITE and get_soc_spec("SHORT_SOC_VERSION") != BS9SX2A:
274 if get_soc_spec("SHORT_SOC_VERSION") != MC61AM21A and get_soc_spec("SHORT_SOC_VERSION") != ASCEND_910_95:274 if get_soc_spec("SHORT_SOC_VERSION") != MC61AM21A and get_soc_spec("SHORT_SOC_VERSION") != ASCEND_910_95:
275 cmd += ["--cce-auto-sync=off"]275 cmd += ["--cce-auto-sync=off"]
276+ if get_soc_spec("SHORT_SOC_VERSION") == ASCEND_910_95:
277+ cmd += ["--cce-long-scbz=true"]
278+ cmd += ["--cce-simd-vf-fusion=false"]
276 if current_build_config().get(enable_cce_licm_safe_hoist):279 if current_build_config().get(enable_cce_licm_safe_hoist):
277 cmd += ["-mllvm", "-licm-safe-hoist=true"]280 cmd += ["-mllvm", "-licm-safe-hoist=true"]
278 cmd += ["-mllvm", "-cce-aicore-jump-expand=false"]281 cmd += ["-mllvm", "-cce-aicore-jump-expand=false"]
@@ -1,89 +1,89 @@
1-#!/usr/bin/python1+#!/usr/bin/python
2-# -*- coding: utf-8 -*-2+# -*- coding: utf-8 -*-
3-# ----------------------------------------------------------------------------------------------------------3+# ----------------------------------------------------------------------------------------------------------
4-# Copyright (c) 2025 Huawei Technologies Co., Ltd.4+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6-# CANN Open Software License Agreement Version 2.0 (the "License").6+# CANN Open Software License Agreement Version 2.0 (the "License").
7-# Please refer to the License for details. You may not use this file except in compliance with the License.7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10-# See LICENSE in the root of the software repository for the full text of the License.10+# See LICENSE in the root of the software repository for the full text of the License.
11-# ----------------------------------------------------------------------------------------------------------11+# ----------------------------------------------------------------------------------------------------------
12-from .platform_info import ASCEND_03112+from .platform_info import ASCEND_031
13-from .platform_info import ASCEND_03513+from .platform_info import ASCEND_035
14-from .platform_info import ASCEND_035A14+from .platform_info import ASCEND_035A
15-from .platform_info import ASCEND_035B15+from .platform_info import ASCEND_035B
16-from .platform_info import ASCEND_31016+from .platform_info import ASCEND_310
17-from .platform_info import ASCEND_310B17+from .platform_info import ASCEND_310B
18-from .platform_info import AS31XM118+from .platform_info import AS31XM1
19-from .platform_info import ASCEND_91019+from .platform_info import ASCEND_910
20-from .platform_info import ASCEND_910H20+from .platform_info import ASCEND_910H
21-from .platform_info import ASCEND_910M21+from .platform_info import ASCEND_910M
22-from .platform_info import ASCEND_910P22+from .platform_info import ASCEND_910P
23-from .platform_info import HI3796CV300ES23+from .platform_info import HI3796CV300ES
24-from .platform_info import HI3796CV300CS24+from .platform_info import HI3796CV300CS
25-from .platform_info import SD340325+from .platform_info import SD3403
26-from .platform_info import ASCEND_61026+from .platform_info import ASCEND_610
27-from .platform_info import ASCEND_610LITE27+from .platform_info import ASCEND_610LITE
28-from .platform_info import BS9SX2A28+from .platform_info import BS9SX2A
29-from .platform_info import MC61AM21A29+from .platform_info import MC61AM21A
30-from .platform_info import ASCEND_310P30+from .platform_info import ASCEND_310P
31-from .platform_info import BS9SX1A31+from .platform_info import BS9SX1A
32-from .platform_info import AIC_BS9SX1A32+from .platform_info import AIC_BS9SX1A
33-from .platform_info import VEC_BS9SX1A33+from .platform_info import VEC_BS9SX1A
34-from .platform_info import ASCEND_610B34+from .platform_info import ASCEND_610B
35-from .platform_info import ASCEND_910B35+from .platform_info import ASCEND_910B
36-from .platform_info import ASCEND_910_9336+from .platform_info import ASCEND_910_93
37-from .platform_info import ASCEND_910_9537+from .platform_info import ASCEND_910_95
38-from .platform_info import ASCEND_SD38+from .platform_info import ASCEND_SD
39-from .platform_info import _AIC_ENGINE39+from .platform_info import _AIC_ENGINE
40-from .platform_info import _VEC_ENGINE40+from .platform_info import _VEC_ENGINE
41-from .platform_info import AIC_310P41+from .platform_info import AIC_310P
42-from .platform_info import VEC_310P42+from .platform_info import VEC_310P
43-from .platform_info import AIC_61043+from .platform_info import AIC_610
44-from .platform_info import VEC_61044+from .platform_info import VEC_610
45-from .platform_info import AIC_610B45+from .platform_info import AIC_610B
46-from .platform_info import VEC_610B46+from .platform_info import VEC_610B
47-from .platform_info import AIC_310B47+from .platform_info import AIC_310B
48-from .platform_info import VEC_310B48+from .platform_info import VEC_310B
49-from .platform_info import HI3796CV300ESAIC49+from .platform_info import HI3796CV300ESAIC
50-from .platform_info import HI3796CV300CSAIC50+from .platform_info import HI3796CV300CSAIC
51-from .platform_info import SD3403AIC51+from .platform_info import SD3403AIC
52-from .platform_info import ASCEND_910BAIC52+from .platform_info import ASCEND_910BAIC
53-from .platform_info import ASCEND_910BVEC53+from .platform_info import ASCEND_910BVEC
54-from .platform_info import ASCEND_910_93AIC54+from .platform_info import ASCEND_910_93AIC
55-from .platform_info import ASCEND_910_93VEC55+from .platform_info import ASCEND_910_93VEC
56-from .platform_info import ASCEND_SD_AIC56+from .platform_info import ASCEND_SD_AIC
57-from .platform_info import scope_cbuf57+from .platform_info import scope_cbuf
58-from .platform_info import SOC_VERSION58+from .platform_info import SOC_VERSION
59-from .platform_info import FULL_SOC_VERSION59+from .platform_info import FULL_SOC_VERSION
60-from .platform_info import SHORT_SOC_VERSION60+from .platform_info import SHORT_SOC_VERSION
61-from .platform_info import CORE_NUM61+from .platform_info import CORE_NUM
62-from .platform_info import UB_SIZE62+from .platform_info import UB_SIZE
63-from .platform_info import L2_SIZE63+from .platform_info import L2_SIZE
64-from .platform_info import L1_SIZE64+from .platform_info import L1_SIZE
65-from .platform_info import FB_SIZE65+from .platform_info import FB_SIZE
66-from .platform_info import FB0_SIZE66+from .platform_info import FB0_SIZE
67-from .platform_info import FB1_SIZE67+from .platform_info import FB1_SIZE
68-from .platform_info import FB2_SIZE68+from .platform_info import FB2_SIZE
69-from .platform_info import FB3_SIZE69+from .platform_info import FB3_SIZE
70-from .platform_info import BT_SIZE70+from .platform_info import BT_SIZE
71-from .platform_info import CUBE_SIZE71+from .platform_info import CUBE_SIZE
72-from .platform_info import L0A_SIZE72+from .platform_info import L0A_SIZE
73-from .platform_info import L0B_SIZE73+from .platform_info import L0B_SIZE
74-from .platform_info import L0C_SIZE74+from .platform_info import L0C_SIZE
75-from .platform_info import SMASK_SIZE75+from .platform_info import SMASK_SIZE
76-from .platform_info import UNZIP76+from .platform_info import UNZIP
77-from .platform_info import VREG_SIZE77+from .platform_info import VREG_SIZE
78-from .platform_info import AREG_SIZE78+from .platform_info import AREG_SIZE
79-from .platform_info import PREG_SIZE79+from .platform_info import PREG_SIZE
80-from .platform_info import UREG_SIZE80+from .platform_info import UREG_SIZE
81-from .platform_info import CUBE_VECTOR_SPLIT81+from .platform_info import CUBE_VECTOR_SPLIT
82-from .platform_info import COMPILER_ARCH82+from .platform_info import COMPILER_ARCH
83-from .platform_info import set_current_compile_soc_info83+from .platform_info import set_current_compile_soc_info
84-from .platform_info import get_soc_spec84+from .platform_info import get_soc_spec
85-from .platform_info import VECTOR_INST_BLOCK_WIDTH85+from .platform_info import VECTOR_INST_BLOCK_WIDTH
86-from .platform_info import get_block_size86+from .platform_info import get_block_size
87-from .platform_info_ import VERSION_MINI87+from .platform_info_ import VERSION_MINI
88- 88+ 
89from .cce_buffer import cur_cce_product_params89from .cce_buffer import cur_cce_product_params
@@ -1,19 +1,19 @@
1-#!/usr/bin/python1+#!/usr/bin/python
2-# -*- coding: utf-8 -*-2+# -*- coding: utf-8 -*-
3-# ----------------------------------------------------------------------------------------------------------3+# ----------------------------------------------------------------------------------------------------------
4-# Copyright (c) 2025 Huawei Technologies Co., Ltd.4+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6-# CANN Open Software License Agreement Version 2.0 (the "License").6+# CANN Open Software License Agreement Version 2.0 (the "License").
7-# Please refer to the License for details. You may not use this file except in compliance with the License.7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10-# See LICENSE in the root of the software repository for the full text of the License.10+# See LICENSE in the root of the software repository for the full text of the License.
11-# ----------------------------------------------------------------------------------------------------------11+# ----------------------------------------------------------------------------------------------------------
12-api_check_support_func = {}12+api_check_support_func = {}
13-TIK_API_CHECK_SUPPORT_FUNC_TYPE = "TIK"13+TIK_API_CHECK_SUPPORT_FUNC_TYPE = "TIK"
14-DSL_API_CHECK_SUPPORT_FUNC_TYPE = "DSL"14+DSL_API_CHECK_SUPPORT_FUNC_TYPE = "DSL"
15- 15+ 
16-# product version16+# product version
17-# This is used for DSL/AutoSchedule ONLY!17+# This is used for DSL/AutoSchedule ONLY!
18-# For other components, use te.platform.get_soc_spec("SHORT_SOC_VERSION")!18+# For other components, use te.platform.get_soc_spec("SHORT_SOC_VERSION")!
19-VERSION_MINI = "1910"19+VERSION_MINI = "1910"
@@ -1,27 +1,27 @@
1-#!/usr/bin/python1+#!/usr/bin/python
2-# -*- coding: utf-8 -*-2+# -*- coding: utf-8 -*-
3-# ----------------------------------------------------------------------------------------------------------3+# ----------------------------------------------------------------------------------------------------------
4-# Copyright (c) 2025 Huawei Technologies Co., Ltd.4+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6-# CANN Open Software License Agreement Version 2.0 (the "License").6+# CANN Open Software License Agreement Version 2.0 (the "License").
7-# Please refer to the License for details. You may not use this file except in compliance with the License.7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10-# See LICENSE in the root of the software repository for the full text of the License.10+# See LICENSE in the root of the software repository for the full text of the License.
11-# ----------------------------------------------------------------------------------------------------------11+# ----------------------------------------------------------------------------------------------------------
12-"""12+"""
13-tbe register13+tbe register
14-"""14+"""
15-from .register_api import register_operator15+from .register_api import register_operator
16-from .register_api import get_operator16+from .register_api import get_operator
17-from .register_api import get_op_compute17+from .register_api import get_op_compute
18-from .register_api import register_param_generalization18+from .register_api import register_param_generalization
19-from .register_api import get_param_generalization19+from .register_api import get_param_generalization
20-from .register_api import get_fusion_buildcfg20+from .register_api import get_fusion_buildcfg
21-from .register_api import set_fusion_buildcfg21+from .register_api import set_fusion_buildcfg
22- 22+ 
23- 23+ 
24-from .class_manager import InvokeStage24+from .class_manager import InvokeStage
25-from .class_manager import Priority25+from .class_manager import Priority
26-from .class_manager import OpCompute26+from .class_manager import OpCompute
27-from .class_manager import Operator27+from .class_manager import Operator
@@ -1,157 +1,157 @@
1-#!/usr/bin/python1+#!/usr/bin/python
2-# -*- coding: utf-8 -*-2+# -*- coding: utf-8 -*-
3-# ----------------------------------------------------------------------------------------------------------3+# ----------------------------------------------------------------------------------------------------------
4-# Copyright (c) 2025 Huawei Technologies Co., Ltd.4+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6-# CANN Open Software License Agreement Version 2.0 (the "License").6+# CANN Open Software License Agreement Version 2.0 (the "License").
7-# Please refer to the License for details. You may not use this file except in compliance with the License.7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10-# See LICENSE in the root of the software repository for the full text of the License.10+# See LICENSE in the root of the software repository for the full text of the License.
11-# ----------------------------------------------------------------------------------------------------------11+# ----------------------------------------------------------------------------------------------------------
12-"""12+"""
13-operation function manager13+operation function manager
14-"""14+"""
15-import functools15+import functools
16- 16+ 
17-from .class_manager import Operator, OpCompute17+from .class_manager import Operator, OpCompute
18- 18+ 
19-# op compute func dict19+# op compute func dict
20-_op_computes = {}20+_op_computes = {}
21-# op realization func dict21+# op realization func dict
22-_operators = {}22+_operators = {}
23-# op param generalization func dict23+# op param generalization func dict
24-# 'pylint: disable=C010324+# 'pylint: disable=C0103
25-_generalization = {}25+_generalization = {}
26-_op_no_trans_bool_to_s8 = {}26+_op_no_trans_bool_to_s8 = {}
27- 27+ 
28- 28+ 
29-def register_operator(op_type, pattern=None, trans_bool_to_s8=True):29+def register_operator(op_type, pattern=None, trans_bool_to_s8=True):
30- """30+ """
31- register op realization func31+ register op realization func
32- 32+ 
33- Parameters33+ Parameters
34- ----------34+ ----------
35- op_type : string35+ op_type : string
36- op type36+ op type
37- pattern: string37+ pattern: string
38- op fusion pattern38+ op fusion pattern
39- trans_bool_to_s8: bool39+ trans_bool_to_s8: bool
40- if need trans bool to int840+ if need trans bool to int8
41- Returns41+ Returns
42- -------42+ -------
43- decorator : decorator43+ decorator : decorator
44- decorator to register realization func44+ decorator to register realization func
45- """45+ """
46- if op_type is None:46+ if op_type is None:
47- raise RuntimeError("register operator failed, op_type is none")47+ raise RuntimeError("register operator failed, op_type is none")
48- global _op_no_trans_bool_to_s848+ global _op_no_trans_bool_to_s8
49- if not trans_bool_to_s8:49+ if not trans_bool_to_s8:
50- _op_no_trans_bool_to_s8[op_type] = "True"50+ _op_no_trans_bool_to_s8[op_type] = "True"
51- global _operators51+ global _operators
52- def decorator(func):52+ def decorator(func):
53- @functools.wraps(func)53+ @functools.wraps(func)
54- def wrapper(*args, **kwargs):54+ def wrapper(*args, **kwargs):
55- return func(*args, **kwargs)55+ return func(*args, **kwargs)
56- _operators[op_type] = Operator(pattern, wrapper)56+ _operators[op_type] = Operator(pattern, wrapper)
57- return wrapper57+ return wrapper
58- return decorator58+ return decorator
59- 59+ 
60- 60+ 
61-def register_op_compute(op_type, op_mode="dynamic", support_fusion=True):61+def register_op_compute(op_type, op_mode="dynamic", support_fusion=True):
62- """62+ """
63- register op compute func63+ register op compute func
64- 64+ 
65- Parameters65+ Parameters
66- ----------66+ ----------
67- op_type: string67+ op_type: string
68- op_func_name(old process) or op type(new process)68+ op_func_name(old process) or op type(new process)
69- op_mode: string69+ op_mode: string
70- dynamic or static shape70+ dynamic or static shape
71- support_fusion: bool71+ support_fusion: bool
72- support dynamic shape UB fusion72+ support dynamic shape UB fusion
73- fusion_pattern: string73+ fusion_pattern: string
74- undefined(default) or func(diff shape, diff pattern) or Elewise/Conv/...74+ undefined(default) or func(diff shape, diff pattern) or Elewise/Conv/...
75- 75+ 
76- Returns76+ Returns
77- -------77+ -------
78- decorator : decorator78+ decorator : decorator
79- decorator to register compute func79+ decorator to register compute func
80- support_bfp16 case:80+ support_bfp16 case:
81- decorator to return output_tensor81+ decorator to return output_tensor
82- """82+ """
83- if op_type is None:83+ if op_type is None:
84- raise RuntimeError("register op compute failed, op_type is none")84+ raise RuntimeError("register op compute failed, op_type is none")
85- global _op_computes85+ global _op_computes
86- global _op_register_pattern86+ global _op_register_pattern
87- def decorator(func):87+ def decorator(func):
88- @functools.wraps(func)88+ @functools.wraps(func)
89- def wrapper(*args, **kwargs):89+ def wrapper(*args, **kwargs):
90- return func(*args, **kwargs)90+ return func(*args, **kwargs)
91- 91+ 
92- _op_register_pattern.pop(op_type)92+ _op_register_pattern.pop(op_type)
93- _op_computes[(op_type, op_mode)] = OpCompute(support_fusion, wrapper)93+ _op_computes[(op_type, op_mode)] = OpCompute(support_fusion, wrapper)
94- return wrapper94+ return wrapper
95- return decorator95+ return decorator
96- 96+ 
97- 97+ 
98-def get_op_compute(op_type, op_mode="dynamic"):98+def get_op_compute(op_type, op_mode="dynamic"):
99- """99+ """
100- :return:100+ :return:
101- """101+ """
102- if op_type is None:102+ if op_type is None:
103- raise RuntimeError("get op compute failed, op_type is none")103+ raise RuntimeError("get op compute failed, op_type is none")
104- return _op_computes.get((op_type, op_mode))104+ return _op_computes.get((op_type, op_mode))
105- 105+ 
106- 106+ 
107-def get_operator(op_type):107+def get_operator(op_type):
108- """108+ """
109- :return:109+ :return:
110- """110+ """
111- if op_type is None:111+ if op_type is None:
112- raise RuntimeError("get operator failed, op_type is none")112+ raise RuntimeError("get operator failed, op_type is none")
113- return _operators.get(op_type)113+ return _operators.get(op_type)
114- 114+ 
115- 115+ 
116-def register_param_generalization(op_type):116+def register_param_generalization(op_type):
117- """117+ """
118- register op param generalization func118+ register op param generalization func
119- 119+ 
120- Parameters120+ Parameters
121- ----------121+ ----------
122- op_type : string122+ op_type : string
123- op type123+ op type
124- 124+ 
125- Returns125+ Returns
126- -------126+ -------
127- decorator : decorator127+ decorator : decorator
128- decorator to register generalization func128+ decorator to register generalization func
129- """129+ """
130- if op_type is None:130+ if op_type is None:
131- raise RuntimeError("register generalization func failed, op_type is none")131+ raise RuntimeError("register generalization func failed, op_type is none")
132- global _generalization132+ global _generalization
133- def decorator(func):133+ def decorator(func):
134- @functools.wraps(func)134+ @functools.wraps(func)
135- def wrapper(*args, **kwargs):135+ def wrapper(*args, **kwargs):
136- return func(*args, **kwargs)136+ return func(*args, **kwargs)
137- 137+ 
138- _generalization[op_type] = wrapper138+ _generalization[op_type] = wrapper
139- return wrapper139+ return wrapper
140- return decorator140+ return decorator
141- 141+ 
142- 142+ 
143-def get_param_generalization(op_type):143+def get_param_generalization(op_type):
144- """144+ """
145- :return:145+ :return:
146- """146+ """
147- if op_type is None:147+ if op_type is None:
148- raise RuntimeError("get generalization func failed, op_type is none")148+ raise RuntimeError("get generalization func failed, op_type is none")
149- return _generalization.get(op_type)149+ return _generalization.get(op_type)
150- 150+ 
151- 151+ 
152-def is_no_need_trans_bool_to_s8(op_type):152+def is_no_need_trans_bool_to_s8(op_type):
153- global _op_no_trans_bool_to_s8153+ global _op_no_trans_bool_to_s8
154- if op_type in _op_no_trans_bool_to_s8.keys():154+ if op_type in _op_no_trans_bool_to_s8.keys():
155- return _op_no_trans_bool_to_s8[op_type] == "True"155+ return _op_no_trans_bool_to_s8[op_type] == "True"
156- else:156+ else:
157 return False157 return False
@@ -84,20 +84,20 @@ class AscendLog:
84 self.level.event_enable = 184 self.level.event_enable = 1
85 self.level.event_disable = 085 self.level.event_disable = 0
86 try:86 try:
87- self.log = ctypes.cdll.LoadLibrary('libascendalog.so')87+ self.log = ctypes.cdll.LoadLibrary('libunified_dlog.so')
88 except OSError:88 except OSError:
89 ld_path = os.getenv('LD_LIBRARY_PATH')89 ld_path = os.getenv('LD_LIBRARY_PATH')
90 if ld_path is None:90 if ld_path is None:
91- print('[Warning]Can not find libascendalog.so')91+ print('[Warning]Can not find libunified_dlog.so')
92 return92 return
93 path_list = ld_path.split(':')93 path_list = ld_path.split(':')
94 for path in path_list:94 for path in path_list:
95- target_path = os.path.join(path, 'libascendalog.so')95+ target_path = os.path.join(path, 'libunified_dlog.so')
96 if os.path.isfile(target_path):96 if os.path.isfile(target_path):
97 self.log = ctypes.cdll.LoadLibrary(target_path)97 self.log = ctypes.cdll.LoadLibrary(target_path)
98 break98 break
99 if self.log is None:99 if self.log is None:
100- print('[Warning]Can not find libascendalog.so')100+ print('[Warning]Can not find libunified_dlog.so')
101 else:101 else:
102 print("success to load log")102 print("success to load log")
103 finally:103 finally:
@@ -112,7 +112,7 @@ class AscendLog:
112 """112 """
113 if self.log is None:113 if self.log is None:
114 return114 return
115- self.log.DlogRecordForC(ctypes.c_int(module), self.level.debug,115+ self.log.DlogRecord(ctypes.c_int(module), self.level.debug,
116 ctypes.c_char_p(fmt.encode("utf-8")))116 ctypes.c_char_p(fmt.encode("utf-8")))
117 117 
118 def info(self: any, module: any, fmt: str) -> None:118 def info(self: any, module: any, fmt: str) -> None:
@@ -124,7 +124,7 @@ class AscendLog:
124 """124 """
125 if self.log is None:125 if self.log is None:
126 return126 return
127- self.log.DlogRecordForC(ctypes.c_int(module), self.level.info,127+ self.log.DlogRecord(ctypes.c_int(module), self.level.info,
128 ctypes.c_char_p(fmt.encode("utf-8")))128 ctypes.c_char_p(fmt.encode("utf-8")))
129 129 
130 def warn(self: any, module: any, fmt: str) -> None:130 def warn(self: any, module: any, fmt: str) -> None:
@@ -136,7 +136,7 @@ class AscendLog:
136 """136 """
137 if self.log is None:137 if self.log is None:
138 return138 return
139- self.log.DlogRecordForC(ctypes.c_int(module), self.level.warning,139+ self.log.DlogRecord(ctypes.c_int(module), self.level.warning,
140 ctypes.c_char_p(fmt.encode("utf-8")))140 ctypes.c_char_p(fmt.encode("utf-8")))
141 141 
142 def error(self: any, module: any, fmt: str) -> None:142 def error(self: any, module: any, fmt: str) -> None:
@@ -148,7 +148,7 @@ class AscendLog:
148 """148 """
149 if self.log is None:149 if self.log is None:
150 return150 return
151- self.log.DlogRecordForC(ctypes.c_int(module), self.level.error,151+ self.log.DlogRecord(ctypes.c_int(module), self.level.error,
152 ctypes.c_char_p(fmt.encode("utf-8")))152 ctypes.c_char_p(fmt.encode("utf-8")))
153 153 
154 def event(self: any, module: any, fmt: str) -> None:154 def event(self: any, module: any, fmt: str) -> None:
@@ -160,7 +160,7 @@ class AscendLog:
160 """160 """
161 if self.log is None:161 if self.log is None:
162 return162 return
163- self.log.DlogRecordForC(ctypes.c_int(module), self.level.event,163+ self.log.DlogRecord(ctypes.c_int(module), self.level.event,
164 ctypes.c_char_p(fmt.encode("utf-8")))164 ctypes.c_char_p(fmt.encode("utf-8")))
165 165 
166 def set_level(self: any, module: any, level: any, event: any) -> None:166 def set_level(self: any, module: any, level: any, event: any) -> None:
@@ -173,7 +173,7 @@ class AscendLog:
173 """173 """
174 if self.log is None:174 if self.log is None:
175 return175 return
176- self.log.DlogSetlevelForC(ctypes.c_int(module), ctypes.c_int(level),176+ self.log.dlog_setlevel(ctypes.c_int(module), ctypes.c_int(level),
177 ctypes.c_int(event))177 ctypes.c_int(event))
178 178 
179 179 
@@ -1,75 +1,75 @@
1-#!/usr/bin/python1+#!/usr/bin/python
2-# -*- coding: utf-8 -*-2+# -*- coding: utf-8 -*-
3-# ----------------------------------------------------------------------------------------------------------3+# ----------------------------------------------------------------------------------------------------------
4-# Copyright (c) 2025 Huawei Technologies Co., Ltd.4+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6-# CANN Open Software License Agreement Version 2.0 (the "License").6+# CANN Open Software License Agreement Version 2.0 (the "License").
7-# Please refer to the License for details. You may not use this file except in compliance with the License.7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10-# See LICENSE in the root of the software repository for the full text of the License.10+# See LICENSE in the root of the software repository for the full text of the License.
11-# ----------------------------------------------------------------------------------------------------------11+# ----------------------------------------------------------------------------------------------------------
12-"""12+"""
13-tbe utils13+tbe utils
14-"""14+"""
15-from . import const15+from . import const
16- 16+ 
17- 17+ 
18-from .para_check import KERNEL_NAME18+from .para_check import KERNEL_NAME
19-from .para_check import REQUIRED_INPUT19+from .para_check import REQUIRED_INPUT
20-from .para_check import OPTION_INPUT20+from .para_check import OPTION_INPUT
21-from .para_check import DYNAMIC_INPUT21+from .para_check import DYNAMIC_INPUT
22-from .para_check import REQUIRED_OUTPUT22+from .para_check import REQUIRED_OUTPUT
23-from .para_check import OPTION_OUTPUT23+from .para_check import OPTION_OUTPUT
24-from .para_check import DYNAMIC_OUTPUT24+from .para_check import DYNAMIC_OUTPUT
25-from .para_check import REQUIRED_ATTR_INT25+from .para_check import REQUIRED_ATTR_INT
26-from .para_check import REQUIRED_ATTR_FLOAT26+from .para_check import REQUIRED_ATTR_FLOAT
27-from .para_check import REQUIRED_ATTR_STR27+from .para_check import REQUIRED_ATTR_STR
28-from .para_check import REQUIRED_ATTR_BOOL28+from .para_check import REQUIRED_ATTR_BOOL
29-from .para_check import REQUIRED_ATTR_TYPE29+from .para_check import REQUIRED_ATTR_TYPE
30-from .para_check import REQUIRED_ATTR_LIST_INT30+from .para_check import REQUIRED_ATTR_LIST_INT
31-from .para_check import REQUIRED_ATTR_LIST_FLOAT31+from .para_check import REQUIRED_ATTR_LIST_FLOAT
32-from .para_check import REQUIRED_ATTR_LIST_BOOL32+from .para_check import REQUIRED_ATTR_LIST_BOOL
33-from .para_check import REQUIRED_ATTR_LIST_LIST_INT33+from .para_check import REQUIRED_ATTR_LIST_LIST_INT
34-from .para_check import OPTION_ATTR_INT34+from .para_check import OPTION_ATTR_INT
35-from .para_check import OPTION_ATTR_FLOAT35+from .para_check import OPTION_ATTR_FLOAT
36-from .para_check import OPTION_ATTR_STR36+from .para_check import OPTION_ATTR_STR
37-from .para_check import OPTION_ATTR_BOOL37+from .para_check import OPTION_ATTR_BOOL
38-from .para_check import OPTION_ATTR_TYPE38+from .para_check import OPTION_ATTR_TYPE
39-from .para_check import OPTION_ATTR_LIST_INT39+from .para_check import OPTION_ATTR_LIST_INT
40-from .para_check import OPTION_ATTR_LIST_FLOAT40+from .para_check import OPTION_ATTR_LIST_FLOAT
41-from .para_check import OPTION_ATTR_LIST_BOOL41+from .para_check import OPTION_ATTR_LIST_BOOL
42-from .para_check import OPTION_ATTR_LIST_LIST_INT42+from .para_check import OPTION_ATTR_LIST_LIST_INT
43-from .para_check import OP_ERROR_CODE_00043+from .para_check import OP_ERROR_CODE_000
44-from .para_check import OP_ERROR_CODE_00144+from .para_check import OP_ERROR_CODE_001
45-from .para_check import OP_ERROR_CODE_00245+from .para_check import OP_ERROR_CODE_002
46-from .para_check import OP_ERROR_CODE_00346+from .para_check import OP_ERROR_CODE_003
47-from .para_check import OP_ERROR_CODE_00447+from .para_check import OP_ERROR_CODE_004
48-from .para_check import OP_ERROR_CODE_00548+from .para_check import OP_ERROR_CODE_005
49-from .para_check import OP_ERROR_CODE_00649+from .para_check import OP_ERROR_CODE_006
50-from .para_check import OP_ERROR_CODE_00750+from .para_check import OP_ERROR_CODE_007
51-from .para_check import OP_ERROR_CODE_00851+from .para_check import OP_ERROR_CODE_008
52-from .para_check import OP_ERROR_CODE_00952+from .para_check import OP_ERROR_CODE_009
53-from .para_check import OP_ERROR_CODE_01053+from .para_check import OP_ERROR_CODE_010
54-from .para_check import OP_ERROR_CODE_01154+from .para_check import OP_ERROR_CODE_011
55-from .para_check import OP_ERROR_CODE_01255+from .para_check import OP_ERROR_CODE_012
56-from .para_check import OP_ERROR_CODE_01356+from .para_check import OP_ERROR_CODE_013
57-from .para_check import OP_ERROR_CODE_01457+from .para_check import OP_ERROR_CODE_014
58-from .para_check import OP_ERROR_CODE_01558+from .para_check import OP_ERROR_CODE_015
59-from .para_check import OP_ERROR_CODE_01659+from .para_check import OP_ERROR_CODE_016
60-from .para_check import OP_ERROR_CODE_01760+from .para_check import OP_ERROR_CODE_017
61-from .para_check import OP_ERROR_CODE_01861+from .para_check import OP_ERROR_CODE_018
62-from .para_check import OP_ERROR_CODE_01962+from .para_check import OP_ERROR_CODE_019
63-from .para_check import OP_ERROR_CODE_02063+from .para_check import OP_ERROR_CODE_020
64-from .para_check import OP_ERROR_CODE_02164+from .para_check import OP_ERROR_CODE_021
65-from .para_check import OP_ERROR_CODE_02265+from .para_check import OP_ERROR_CODE_022
66-from .para_check import OP_ERROR_CODE_02366+from .para_check import OP_ERROR_CODE_023
67-from .para_check import OP_ERROR_CODE_02467+from .para_check import OP_ERROR_CODE_024
68-from .para_check import OP_ERROR_CODE_02568+from .para_check import OP_ERROR_CODE_025
69-from .para_check import OP_ERROR_CODE_02669+from .para_check import OP_ERROR_CODE_026
70-from .para_check import OP_ERROR_CODE_02770+from .para_check import OP_ERROR_CODE_027
71-from .para_check import OpParamInfoKey71+from .para_check import OpParamInfoKey
72-from .para_check import TensorFormat72+from .para_check import TensorFormat
73-from .para_check import ALL_DTYPE_LIST73+from .para_check import ALL_DTYPE_LIST
74-from .para_check import check_op_params74+from .para_check import check_op_params
75-from .para_check import check_shape75+from .para_check import check_shape
@@ -49,7 +49,9 @@ def info(log_msg, *log_paras):
49 co_filename = inspect.currentframe().f_back.f_code.co_filename49 co_filename = inspect.currentframe().f_back.f_code.co_filename
50 filename = os.path.basename(co_filename)50 filename = os.path.basename(co_filename)
51 log_str = '[%s:%d][%s] ' % (filename, line_no, funcname)51 log_str = '[%s:%d][%s] ' % (filename, line_no, funcname)
52- log_all_msg = log_str + log_msg % log_paras52+ if log_paras:
53+ log_msg = log_msg % log_paras
54+ log_all_msg = log_str + log_msg
53 55 
54 if IS_USE_SLOG:56 if IS_USE_SLOG:
55 S_LOGGER.info(S_LOGGER.module.tbe, log_all_msg)57 S_LOGGER.info(S_LOGGER.module.tbe, log_all_msg)
@@ -68,7 +70,9 @@ def debug(log_msg, *log_paras):
68 co_filename = inspect.currentframe().f_back.f_code.co_filename70 co_filename = inspect.currentframe().f_back.f_code.co_filename
69 filename = os.path.basename(co_filename)71 filename = os.path.basename(co_filename)
70 log_str = '[%s:%d][%s] ' % (filename, line_no, funcname)72 log_str = '[%s:%d][%s] ' % (filename, line_no, funcname)
71- log_all_msg = log_str + log_msg % log_paras73+ if log_paras:
74+ log_msg = log_msg % log_paras
75+ log_all_msg = log_str + log_msg
72 76 
73 if IS_USE_SLOG:77 if IS_USE_SLOG:
74 S_LOGGER.debug(S_LOGGER.module.tbe, log_all_msg)78 S_LOGGER.debug(S_LOGGER.module.tbe, log_all_msg)
@@ -87,7 +91,9 @@ def warn(log_msg, *log_paras):
87 co_filename = inspect.currentframe().f_back.f_code.co_filename91 co_filename = inspect.currentframe().f_back.f_code.co_filename
88 filename = os.path.basename(co_filename)92 filename = os.path.basename(co_filename)
89 log_str = '[%s:%d][%s] ' % (filename, line_no, funcname)93 log_str = '[%s:%d][%s] ' % (filename, line_no, funcname)
90- log_all_msg = log_str + log_msg % log_paras94+ if log_paras:
95+ log_msg = log_msg % log_paras
96+ log_all_msg = log_str + log_msg
91 97 
92 if IS_USE_SLOG:98 if IS_USE_SLOG:
93 S_LOGGER.warn(S_LOGGER.module.tbe, log_all_msg)99 S_LOGGER.warn(S_LOGGER.module.tbe, log_all_msg)
@@ -106,7 +112,9 @@ def error(log_msg, *log_paras):
106 co_filename = inspect.currentframe().f_back.f_code.co_filename112 co_filename = inspect.currentframe().f_back.f_code.co_filename
107 filename = os.path.basename(co_filename)113 filename = os.path.basename(co_filename)
108 log_str = '[%s:%d][%s] ' % (filename, line_no, funcname)114 log_str = '[%s:%d][%s] ' % (filename, line_no, funcname)
109- log_all_msg = log_str + log_msg % log_paras115+ if log_paras:
116+ log_msg = log_msg % log_paras
117+ log_all_msg = log_str + log_msg
110 118 
111 if IS_USE_SLOG:119 if IS_USE_SLOG:
112 S_LOGGER.error(S_LOGGER.module.tbe, log_all_msg)120 S_LOGGER.error(S_LOGGER.module.tbe, log_all_msg)
@@ -125,7 +133,9 @@ def event(log_msg, *log_paras):
125 co_filename = inspect.currentframe().f_back.f_code.co_filename133 co_filename = inspect.currentframe().f_back.f_code.co_filename
126 filename = os.path.basename(co_filename)134 filename = os.path.basename(co_filename)
127 log_str = '[%s:%d][%s] ' % (filename, line_no, funcname)135 log_str = '[%s:%d][%s] ' % (filename, line_no, funcname)
128- log_all_msg = log_str + log_msg % log_paras136+ if log_paras:
137+ log_msg = log_msg % log_paras
138+ log_all_msg = log_str + log_msg
129 139 
130 if IS_USE_SLOG:140 if IS_USE_SLOG:
131 S_LOGGER.event(S_LOGGER.module.tbe, log_all_msg)141 S_LOGGER.event(S_LOGGER.module.tbe, log_all_msg)
@@ -121,13 +121,7 @@ class LogUtil:
121 @staticmethod121 @staticmethod
122 def log_print(kernel_name: str, msg_info: str, log_level: AscendCLogLevel, option: Option = Option.DEFAULT):122 def log_print(kernel_name: str, msg_info: str, log_level: AscendCLogLevel, option: Option = Option.DEFAULT):
123 short_soc_version = get_soc_spec("SHORT_SOC_VERSION")123 short_soc_version = get_soc_spec("SHORT_SOC_VERSION")
124- current_time = datetime.now()124+ tim_head = datetime.now().strftime("[%Y-%m-%d %H:%M:%S]")
125- tim_head = "[{}-{}-{} {}:{}:{}]".format(current_time.year,
126- current_time.month,
127- current_time.day,
128- current_time.hour,
129- current_time.minute,
130- current_time.second)
131 level_info = " [{}]".format(LOG_LEVEL_TO_STR[log_level])125 level_info = " [{}]".format(LOG_LEVEL_TO_STR[log_level])
132 log_msg = tim_head + level_info126 log_msg = tim_head + level_info
133 if option is not LogUtil.Option.NON_SOC:127 if option is not LogUtil.Option.NON_SOC:
@@ -135,13 +135,16 @@ class TensorFormat(Enum):
135 ND_RNN_BIAS = "ND_RNN_BIAS"135 ND_RNN_BIAS = "ND_RNN_BIAS"
136 FRACTAL_NZ_C0_16 = "FRACTAL_NZ_C0_16"136 FRACTAL_NZ_C0_16 = "FRACTAL_NZ_C0_16"
137 FRACTAL_NZ_C0_32 = "FRACTAL_NZ_C0_32"137 FRACTAL_NZ_C0_32 = "FRACTAL_NZ_C0_32"
138+ FRACTAL_NZ_C0_2 = "FRACTAL_NZ_C0_2"
139+ FRACTAL_NZ_C0_4 = "FRACTAL_NZ_C0_4"
140+ FRACTAL_NZ_C0_8 = "FRACTAL_NZ_C0_8"
138 141 
139 142 
140ALL_FORMAT_LIST = [entry.value for entry in TensorFormat]143ALL_FORMAT_LIST = [entry.value for entry in TensorFormat]
141ALL_DTYPE_LIST = ("int4", "int8", "uint8", "int16", "uint16", "int32", "uint32", "bfloat16",144ALL_DTYPE_LIST = ("int4", "int8", "uint8", "int16", "uint16", "int32", "uint32", "bfloat16",
142 "int64", "uint64", "float16", "float32", "float64", "bool", "uint1", "double",145 "int64", "uint64", "float16", "float32", "float64", "bool", "uint1", "double",
143 "complex32", "complex64", "complex128", "hifloat8", "float8_e4m3fn", "float8_e5m2", "float8_e8m0",146 "complex32", "complex64", "complex128", "hifloat8", "float8_e4m3fn", "float8_e5m2", "float8_e8m0",
144- "float4_e2m1", "float4_e1m2")147+ "float4_e2m1", "float4_e1m2", "int2")
145OP_NAME = ""148OP_NAME = ""
146PARAM_NAME = ""149PARAM_NAME = ""
147 150 
@@ -1,36 +1,36 @@
1-# ----------------------------------------------------------------------------------------------------------1+# ----------------------------------------------------------------------------------------------------------
2-# Copyright (c) 2025 Huawei Technologies Co., Ltd.2+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
3-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of3+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4-# CANN Open Software License Agreement Version 2.0 (the "License").4+# CANN Open Software License Agreement Version 2.0 (the "License").
5-# Please refer to the License for details. You may not use this file except in compliance with the License.5+# Please refer to the License for details. You may not use this file except in compliance with the License.
6-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,6+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.7+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8-# See LICENSE in the root of the software repository for the full text of the License.8+# See LICENSE in the root of the software repository for the full text of the License.
9-# ----------------------------------------------------------------------------------------------------------9+# ----------------------------------------------------------------------------------------------------------
10-project (asc_opc)10+project (asc_opc)
11- 11+ 
12-#build opc whl pkg12+#build opc whl pkg
13-message(STATUS "CMAKE_BINARY_DIR=" ${CMAKE_BINARY_DIR})13+message(STATUS "CMAKE_BINARY_DIR=" ${CMAKE_BINARY_DIR})
14-message(STATUS "CMAKE_CURRENT_SOURCE_DIR=" ${CMAKE_CURRENT_SOURCE_DIR})14+message(STATUS "CMAKE_CURRENT_SOURCE_DIR=" ${CMAKE_CURRENT_SOURCE_DIR})
15- 15+ 
16-set(OPC_WHL_NAME "asc_opc_tool-0.1.0-py3-none-any.whl")16+set(OPC_WHL_NAME "asc_opc_tool-0.1.0-py3-none-any.whl")
17-set(OPC_DIR "./opc_python")17+set(OPC_DIR "./opc_python")
18-set(OPC_BASE "${CMAKE_CURRENT_SOURCE_DIR}")18+set(OPC_BASE "${CMAKE_CURRENT_SOURCE_DIR}")
19- 19+ 
20-add_custom_target(${OPC_WHL_NAME} ALL20+add_custom_target(${OPC_WHL_NAME} ALL
21- COMMAND echo "[OPC] Build target ${OPC_WHL_NAME}" &&21+ COMMAND echo "[OPC] Build target ${OPC_WHL_NAME}" &&
22- mkdir -p ${OPC_DIR}/asc_opc_tool && rm -rf ${OPC_DIR}/asc_opc_tool/* &&22+ mkdir -p ${OPC_DIR}/asc_opc_tool && rm -rf ${OPC_DIR}/asc_opc_tool/* &&
23- cp -rf ${OPC_BASE}/python/asc_opc_tool/* ${OPC_DIR}/asc_opc_tool/ &&23+ cp -rf ${OPC_BASE}/python/asc_opc_tool/* ${OPC_DIR}/asc_opc_tool/ &&
24- cp -rf ${OPC_BASE}/setup.py ${OPC_DIR}/ &&24+ cp -rf ${OPC_BASE}/setup.py ${OPC_DIR}/ &&
25- cd ${OPC_DIR} && ${HI_PYTHON} setup.py bdist_wheel && cd - &&25+ cd ${OPC_DIR} && ${HI_PYTHON} setup.py bdist_wheel && cd - &&
26- ls && pwd &&26+ ls && pwd &&
27- mkdir ${CMAKE_INSTALL_PREFIX}/lib -p &&27+ mkdir ${CMAKE_INSTALL_PREFIX}/lib -p &&
28- ${CMAKE_COMMAND} -E rename ${OPC_DIR}/dist/asc_opc*.whl ${CMAKE_INSTALL_PREFIX}/lib/${OPC_WHL_NAME} &&28+ ${CMAKE_COMMAND} -E rename ${OPC_DIR}/dist/asc_opc*.whl ${CMAKE_INSTALL_PREFIX}/lib/${OPC_WHL_NAME} &&
29- echo "[OPC] Build target ${OPC_WHL_NAME} end"29+ echo "[OPC] Build target ${OPC_WHL_NAME} end"
30-)30+)
31- 31+ 
32-if(BUILD_OPEN_PROJECT)32+if(BUILD_OPEN_PROJECT)
33- install(FILES ${OPC_BASE}/asc_opc33+ install(FILES ${OPC_BASE}/asc_opc
34- DESTINATION ${INSTALL_LIBRARY_DIR}/bin34+ DESTINATION ${INSTALL_LIBRARY_DIR}/bin
35- )35+ )
36endif()36endif()
@@ -1,14 +1,14 @@
1-#!/usr/bin/env python1+#!/usr/bin/env python
2-# -*- coding: UTF-8 -*-2+# -*- coding: UTF-8 -*-
3-# ----------------------------------------------------------------------------------------------------------3+# ----------------------------------------------------------------------------------------------------------
4-# Copyright (c) 2025 Huawei Technologies Co., Ltd.4+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6-# CANN Open Software License Agreement Version 2.0 (the "License").6+# CANN Open Software License Agreement Version 2.0 (the "License").
7-# Please refer to the License for details. You may not use this file except in compliance with the License.7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10-# See LICENSE in the root of the software repository for the full text of the License.10+# See LICENSE in the root of the software repository for the full text of the License.
11-# ----------------------------------------------------------------------------------------------------------11+# ----------------------------------------------------------------------------------------------------------
12-"""12+"""
13-op complication13+op complication
14-"""14+"""
@@ -1,542 +1,542 @@
1-#!/usr/bin/env python1+#!/usr/bin/env python
2-# -*- coding: UTF-8 -*-2+# -*- coding: UTF-8 -*-
3-# ----------------------------------------------------------------------------------------------------------3+# ----------------------------------------------------------------------------------------------------------
4-# Copyright (c) 2025 Huawei Technologies Co., Ltd.4+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6-# CANN Open Software License Agreement Version 2.0 (the "License").6+# CANN Open Software License Agreement Version 2.0 (the "License").
7-# Please refer to the License for details. You may not use this file except in compliance with the License.7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10-# See LICENSE in the root of the software repository for the full text of the License.10+# See LICENSE in the root of the software repository for the full text of the License.
11-# ----------------------------------------------------------------------------------------------------------11+# ----------------------------------------------------------------------------------------------------------
12-"""12+"""
13-Parse ops-info and store op info13+Parse ops-info and store op info
14-"""14+"""
15-import os15+import os
16-import json16+import json
17-from pathlib import Path17+from pathlib import Path
18-from asc_op_compile_base.common.platform import platform_info18+from asc_op_compile_base.common.platform import platform_info
19-from asc_op_compile_base.common.utils import log as logger19+from asc_op_compile_base.common.utils import log as logger
20-from constant import (OpParamType, AttrtypeMapDict)20+from constant import (OpParamType, AttrtypeMapDict)
21-from opc_common import read_json_file21+from opc_common import read_json_file
22- 22+ 
23- 23+ 
24-class InOrOutputInfo:24+class InOrOutputInfo:
25- def __init__(self, inout_i):25+ def __init__(self, inout_i):
26- self.param_type = OpParamType.DEFAULT26+ self.param_type = OpParamType.DEFAULT
27- self.inout_i = inout_i27+ self.inout_i = inout_i
28- self.name = ""28+ self.name = ""
29- 29+ 
30- 30+ 
31-class AttrInfo:31+class AttrInfo:
32- def __init__(self, attr_name):32+ def __init__(self, attr_name):
33- self.param_type = OpParamType.DEFAULT33+ self.param_type = OpParamType.DEFAULT
34- self.name = attr_name34+ self.name = attr_name
35- self.default_value = None35+ self.default_value = None
36- self.type = None36+ self.type = None
37- self.index = 037+ self.index = 0
38- self.value = None38+ self.value = None
39- 39+ 
40- 40+ 
41-class OpKernelInfo:41+class OpKernelInfo:
42- def __init__(self, op_type):42+ def __init__(self, op_type):
43- self.init_flag = False # type: bool43+ self.init_flag = False # type: bool
44- self.op_type = op_type # type: str44+ self.op_type = op_type # type: str
45- self.op_imp_path = "" # type:str45+ self.op_imp_path = "" # type:str
46- self.op_pattern = []46+ self.op_pattern = []
47- self.is_support_dynamic_shape = False47+ self.is_support_dynamic_shape = False
48- self.is_support_dynamic_rank = False48+ self.is_support_dynamic_rank = False
49- self.input_mem_continues = False49+ self.input_mem_continues = False
50- self.output_mem_continues = False50+ self.output_mem_continues = False
51- self.core_type = []51+ self.core_type = []
52- self.op_info = {}52+ self.op_info = {}
53- self.is_heavy_o_p = False # type bool53+ self.is_heavy_o_p = False # type bool
54- self.input_infos_ = [] # type: list[InOrOutputInfo]54+ self.input_infos_ = [] # type: list[InOrOutputInfo]
55- self.output_infos_ = [] # type: list[InOrOutputInfo]55+ self.output_infos_ = [] # type: list[InOrOutputInfo]
56- self.attr_infos_ = [] # type: list[attr]56+ self.attr_infos_ = [] # type: list[attr]
57- self.enable_vector_core = False57+ self.enable_vector_core = False
58- 58+ 
59- @staticmethod59+ @staticmethod
60- def get_str_from_op_content(op_type, op_content, key1, key2):60+ def get_str_from_op_content(op_type, op_content, key1, key2):
61- key1_pos = op_content.get(key1)61+ key1_pos = op_content.get(key1)
62- if key1_pos is None:62+ if key1_pos is None:
63- if key1 != "reshapeType" and key2 != "defaultValue":63+ if key1 != "reshapeType" and key2 != "defaultValue":
64- logger.debug("Op {} not found {} in OpContent!".format(op_type, key1))64+ logger.debug("Op {} not found {} in OpContent!".format(op_type, key1))
65- return False, key1_pos65+ return False, key1_pos
66- 66+ 
67- key2_pos = key1_pos.get(key2)67+ key2_pos = key1_pos.get(key2)
68- if key2_pos is None:68+ if key2_pos is None:
69- if key1 != "reshapeType" and key2 != "defaultValue":69+ if key1 != "reshapeType" and key2 != "defaultValue":
70- logger.debug("Op {} not found {}.{} in OpContent!".format(op_type, key1, key2))70+ logger.debug("Op {} not found {}.{} in OpContent!".format(op_type, key1, key2))
71- return False, key2_pos71+ return False, key2_pos
72- 72+ 
73- return True, key2_pos73+ return True, key2_pos
74- 74+ 
75- @staticmethod75+ @staticmethod
76- def get_inout_flags(op_content, input_list, output_list):76+ def get_inout_flags(op_content, input_list, output_list):
77- for key, _ in op_content.items():77+ for key, _ in op_content.items():
78- if key.startswith("input") or key.startswith("Input"):78+ if key.startswith("input") or key.startswith("Input"):
79- input_list.append(key)79+ input_list.append(key)
80- elif key.startswith("output") or key.startswith("Output"):80+ elif key.startswith("output") or key.startswith("Output"):
81- output_list.append(key)81+ output_list.append(key)
82- 82+ 
83- @staticmethod83+ @staticmethod
84- def get_attr_list(op_type, op_content, attr_list):84+ def get_attr_list(op_type, op_content, attr_list):
85- if "attr" not in op_content:85+ if "attr" not in op_content:
86- return86+ return
87- attrs = op_content.get("attr")87+ attrs = op_content.get("attr")
88- if not isinstance(attrs, dict):88+ if not isinstance(attrs, dict):
89- logger.error("op_type: {} has wrong type. {}".format(op_type, str(attrs)))89+ logger.error("op_type: {} has wrong type. {}".format(op_type, str(attrs)))
90- return90+ return
91- attr_str = attrs.get("list", "")91+ attr_str = attrs.get("list", "")
92- split_list = attr_str.split(",")92+ split_list = attr_str.split(",")
93- logger.debug("Op {} attr_str in OpContent is {}".format(op_type, attr_str))93+ logger.debug("Op {} attr_str in OpContent is {}".format(op_type, attr_str))
94- for attr in split_list:94+ for attr in split_list:
95- attr_list.append(attr)95+ attr_list.append(attr)
96- 96+ 
97- def __feed_inout_info(self, op_content, inout_list, op_kernel_info, is_input):97+ def __feed_inout_info(self, op_content, inout_list, op_kernel_info, is_input):
98- def sort_input_key(x):98+ def sort_input_key(x):
99- return int(x[5:])99+ return int(x[5:])
100- 100+ 
101- def sort_output_key(x):101+ def sort_output_key(x):
102- return int(x[6:])102+ return int(x[6:])
103- 103+ 
104- inout_list.sort(key=sort_input_key) if is_input else inout_list.sort(key=sort_output_key)104+ inout_list.sort(key=sort_input_key) if is_input else inout_list.sort(key=sort_output_key)
105- inout_infos = list()105+ inout_infos = list()
106- for inouti in inout_list:106+ for inouti in inout_list:
107- inout_info = InOrOutputInfo(inouti)107+ inout_info = InOrOutputInfo(inouti)
108- inout_content = op_content.get(inouti, None)108+ inout_content = op_content.get(inouti, None)
109- if inout_content is None:109+ if inout_content is None:
110- logger.error("wrong key %s.", inouti)110+ logger.error("wrong key %s.", inouti)
111- return False111+ return False
112- inout_info.param_type = inout_content.get("paramType", None)112+ inout_info.param_type = inout_content.get("paramType", None)
113- inout_info.name = inout_content.get("name", None)113+ inout_info.name = inout_content.get("name", None)
114- inout_infos.append(inout_info)114+ inout_infos.append(inout_info)
115- if is_input:115+ if is_input:
116- op_kernel_info.input_infos_ = inout_infos116+ op_kernel_info.input_infos_ = inout_infos
117- else:117+ else:
118- op_kernel_info.output_infos_ = inout_infos118+ op_kernel_info.output_infos_ = inout_infos
119- return True119+ return True
120- 120+ 
121- def parse_input_and_output_from_content(self, op_type, op_content, op_kernel_info):121+ def parse_input_and_output_from_content(self, op_type, op_content, op_kernel_info):
122- input_list = list()122+ input_list = list()
123- output_list = list()123+ output_list = list()
124- self.get_inout_flags(op_content, input_list, output_list)124+ self.get_inout_flags(op_content, input_list, output_list)
125- 125+ 
126- if not self.__feed_inout_info(op_content, input_list, op_kernel_info, True):126+ if not self.__feed_inout_info(op_content, input_list, op_kernel_info, True):
127- logger.error("op_type:%s has wrong input key.", op_type)127+ logger.error("op_type:%s has wrong input key.", op_type)
128- return False128+ return False
129- if not self.__feed_inout_info(op_content, output_list, op_kernel_info, False):129+ if not self.__feed_inout_info(op_content, output_list, op_kernel_info, False):
130- logger.error("op_type:%s has wrong output key.", op_type)130+ logger.error("op_type:%s has wrong output key.", op_type)
131- return False131+ return False
132- return True132+ return True
133- 133+ 
134- @staticmethod134+ @staticmethod
135- def get_default_attr_value(param_type, default_value):135+ def get_default_attr_value(param_type, default_value):
136- if default_value is None:136+ if default_value is None:
137- return None137+ return None
138- if param_type == "int":138+ if param_type == "int":
139- return int(default_value)139+ return int(default_value)
140- return default_value140+ return default_value
141- 141+ 
142- def parse_attrs_from_content(self, op_type, op_content, op_kernel_info):142+ def parse_attrs_from_content(self, op_type, op_content, op_kernel_info):
143- attrs = list()143+ attrs = list()
144- self.get_attr_list(op_type, op_content, attrs)144+ self.get_attr_list(op_type, op_content, attrs)
145- 145+ 
146- attr_infos = list()146+ attr_infos = list()
147- for index, attri in enumerate(attrs):147+ for index, attri in enumerate(attrs):
148- attr_name = "attr_" + attri148+ attr_name = "attr_" + attri
149- attr_info = AttrInfo(attri)149+ attr_info = AttrInfo(attri)
150- attr_content = op_content.get(attr_name, None)150+ attr_content = op_content.get(attr_name, None)
151- if attr_content is None:151+ if attr_content is None:
152- logger.error("op_type:%s has wrong key %s.", op_type, attr_name)152+ logger.error("op_type:%s has wrong key %s.", op_type, attr_name)
153- return False153+ return False
154- attr_info.index = index154+ attr_info.index = index
155- attr_info.param_type = attr_content.get("paramType", None)155+ attr_info.param_type = attr_content.get("paramType", None)
156- attr_info.type = attr_content.get("type", None)156+ attr_info.type = attr_content.get("type", None)
157- attr_type = AttrtypeMapDict.get(attr_info.type, None)157+ attr_type = AttrtypeMapDict.get(attr_info.type, None)
158- if attr_type is None:158+ if attr_type is None:
159- logger.warn("attr_info.type:%s may not supported.", attr_info.type)159+ logger.warn("attr_info.type:%s may not supported.", attr_info.type)
160- else:160+ else:
161- attr_info.type = attr_type161+ attr_info.type = attr_type
162- attr_info.default_value = self.get_default_attr_value(attr_info.type,162+ attr_info.default_value = self.get_default_attr_value(attr_info.type,
163- attr_content.get("defaultValue", None))163+ attr_content.get("defaultValue", None))
164- attr_info.value = attr_content.get("value", None)164+ attr_info.value = attr_content.get("value", None)
165- attr_infos.append(attr_info)165+ attr_infos.append(attr_info)
166- logger.debug("op_type: {} add attr_info: {}.".format(op_type, attr_info.name))166+ logger.debug("op_type: {} add attr_info: {}.".format(op_type, attr_info.name))
167- op_kernel_info.attr_infos_ = attr_infos167+ op_kernel_info.attr_infos_ = attr_infos
168- return True168+ return True
169- 169+ 
170- def parse_basic_parameter(self, op_type, op_content, op_kernel_info):170+ def parse_basic_parameter(self, op_type, op_content, op_kernel_info):
171- op_pattern_dict = {"formatAgnostic": 0, "broadcast": 1, "reduce": 2, "dynamic": 3}171+ op_pattern_dict = {"formatAgnostic": 0, "broadcast": 1, "reduce": 2, "dynamic": 3}
172- 172+ 
173- # parse the op.pattern of the op173+ # parse the op.pattern of the op
174- result, op_pattern_str = self.get_str_from_op_content(op_type, op_content, "op", "pattern")174+ result, op_pattern_str = self.get_str_from_op_content(op_type, op_content, "op", "pattern")
175- if result and op_pattern_str is not None:175+ if result and op_pattern_str is not None:
176- op_pattern_iter = op_pattern_dict.get(op_pattern_str)176+ op_pattern_iter = op_pattern_dict.get(op_pattern_str)
177- if op_pattern_iter is not None:177+ if op_pattern_iter is not None:
178- op_kernel_info.op_pattern.append(op_pattern_iter)178+ op_kernel_info.op_pattern.append(op_pattern_iter)
179- 179+ 
180- # parse the imp_path.path of the op180+ # parse the imp_path.path of the op
181- result, op_imp_path_str = self.get_str_from_op_content(op_type, op_content, "imp_path", "path")181+ result, op_imp_path_str = self.get_str_from_op_content(op_type, op_content, "imp_path", "path")
182- res_status = result and op_imp_path_str is not None182+ res_status = result and op_imp_path_str is not None
183- if res_status:183+ if res_status:
184- op_kernel_info.op_imp_path = op_imp_path_str184+ op_kernel_info.op_imp_path = op_imp_path_str
185- 185+ 
186- # parse the dynamic_format.flag of the op186+ # parse the dynamic_format.flag of the op
187- dynamic_format_str = ""187+ dynamic_format_str = ""
188- result, dynamic_format_str = self.get_str_from_op_content(op_type, op_content, "dynamicFormat", "flag")188+ result, dynamic_format_str = self.get_str_from_op_content(op_type, op_content, "dynamicFormat", "flag")
189- res_status = result and dynamic_format_str is not None and dynamic_format_str.lower() == "true"189+ res_status = result and dynamic_format_str is not None and dynamic_format_str.lower() == "true"
190- if res_status:190+ if res_status:
191- op_kernel_info.op_pattern.append(op_pattern_dict.get("dynamic"))191+ op_kernel_info.op_pattern.append(op_pattern_dict.get("dynamic"))
192- 192+ 
193- # parse the dynamicCompileStatic.flag of the op193+ # parse the dynamicCompileStatic.flag of the op
194- result, dynamic_compile_static_str = self.get_str_from_op_content(op_type, op_content,194+ result, dynamic_compile_static_str = self.get_str_from_op_content(op_type, op_content,
195- "dynamicCompileStatic", "flag")195+ "dynamicCompileStatic", "flag")
196- res_status = result and dynamic_compile_static_str is not None196+ res_status = result and dynamic_compile_static_str is not None
197- if res_status:197+ if res_status:
198- op_kernel_info.dynamic_compile_static = dynamic_compile_static_str198+ op_kernel_info.dynamic_compile_static = dynamic_compile_static_str
199- logger.debug("op_type:{} support dynamic_compile_static.".format(op_kernel_info.op_type))199+ logger.debug("op_type:{} support dynamic_compile_static.".format(op_kernel_info.op_type))
200- else:200+ else:
201- op_kernel_info.dynamic_compile_static = "false"201+ op_kernel_info.dynamic_compile_static = "false"
202- logger.debug("op_type:{} not support dynamic_compile_static.".format(op_kernel_info.op_type))202+ logger.debug("op_type:{} not support dynamic_compile_static.".format(op_kernel_info.op_type))
203- 203+ 
204- # parse the dynamic_shape_support of the op204+ # parse the dynamic_shape_support of the op
205- result, dynamic_shape_support_str = self.get_str_from_op_content(op_type, op_content, "dynamicShapeSupport",205+ result, dynamic_shape_support_str = self.get_str_from_op_content(op_type, op_content, "dynamicShapeSupport",
206- "flag")206+ "flag")
207- res_status = result and dynamic_shape_support_str is not None \207+ res_status = result and dynamic_shape_support_str is not None \
208- and dynamic_shape_support_str.lower() == "true"208+ and dynamic_shape_support_str.lower() == "true"
209- if res_status:209+ if res_status:
210- op_kernel_info.is_support_dynamic_shape = True210+ op_kernel_info.is_support_dynamic_shape = True
211- 211+ 
212- return True212+ return True
213- 213+ 
214- def parse_basic_parameter_arg(self, op_type, op_content, op_kernel_info):214+ def parse_basic_parameter_arg(self, op_type, op_content, op_kernel_info):
215- kcore_type_dict = {"Aicore": 0, "VectorCore": 1, "Mix": 2, "mix": 2, "Dynamic": 3, "dynamic": 3}215+ kcore_type_dict = {"Aicore": 0, "VectorCore": 1, "Mix": 2, "mix": 2, "Dynamic": 3, "dynamic": 3}
216- 216+ 
217- # parse the dynamic_rank_support of the op217+ # parse the dynamic_rank_support of the op
218- result, dynamic_rank_support_str = self.get_str_from_op_content(op_type, op_content, "dynamicRankSupport",218+ result, dynamic_rank_support_str = self.get_str_from_op_content(op_type, op_content, "dynamicRankSupport",
219- "flag")219+ "flag")
220- res_status = result and dynamic_rank_support_str is not None \220+ res_status = result and dynamic_rank_support_str is not None \
221- and dynamic_rank_support_str.lower() == "true"221+ and dynamic_rank_support_str.lower() == "true"
222- if res_status:222+ if res_status:
223- logger.debug("op_type:{} is support dynamic rank.".format(op_kernel_info.op_type))223+ logger.debug("op_type:{} is support dynamic rank.".format(op_kernel_info.op_type))
224- op_kernel_info.is_support_dynamic_rank = True224+ op_kernel_info.is_support_dynamic_rank = True
225- 225+ 
226- # parse the input_mem_continues.flag226+ # parse the input_mem_continues.flag
227- result, input_mem_continues_str = self.get_str_from_op_content(op_type, op_content, "inputMemContinues",227+ result, input_mem_continues_str = self.get_str_from_op_content(op_type, op_content, "inputMemContinues",
228- "flag")228+ "flag")
229- res_status = result and input_mem_continues_str is not None \229+ res_status = result and input_mem_continues_str is not None \
230- and input_mem_continues_str.lower() == "true"230+ and input_mem_continues_str.lower() == "true"
231- if res_status:231+ if res_status:
232- op_kernel_info.input_mem_continues = True232+ op_kernel_info.input_mem_continues = True
233- 233+ 
234- # parse the out_mem_continues.flag234+ # parse the out_mem_continues.flag
235- result, output_mem_continues_str = self.get_str_from_op_content(op_type, op_content, "outputMemContinues",235+ result, output_mem_continues_str = self.get_str_from_op_content(op_type, op_content, "outputMemContinues",
236- "value")236+ "value")
237- res_status = result and output_mem_continues_str is not None \237+ res_status = result and output_mem_continues_str is not None \
238- and output_mem_continues_str.lower() == "true"238+ and output_mem_continues_str.lower() == "true"
239- if res_status:239+ if res_status:
240- op_kernel_info.output_mem_continues = True240+ op_kernel_info.output_mem_continues = True
241- 241+ 
242- # parse the core_type242+ # parse the core_type
243- result, core_type_str = self.get_str_from_op_content(op_type, op_content, "coreType", "flag")243+ result, core_type_str = self.get_str_from_op_content(op_type, op_content, "coreType", "flag")
244- core_type_iter = kcore_type_dict.get(core_type_str)244+ core_type_iter = kcore_type_dict.get(core_type_str)
245- if core_type_iter is not None:245+ if core_type_iter is not None:
246- op_kernel_info.core_type.append(core_type_iter)246+ op_kernel_info.core_type.append(core_type_iter)
247- 247+ 
248- # parse the enable_vector_core of the op248+ # parse the enable_vector_core of the op
249- result, enable_vector_core_str = self.get_str_from_op_content(op_type, op_content, "enableVectorCore",249+ result, enable_vector_core_str = self.get_str_from_op_content(op_type, op_content, "enableVectorCore",
250- "flag")250+ "flag")
251- res_status = result and enable_vector_core_str is not None \251+ res_status = result and enable_vector_core_str is not None \
252- and enable_vector_core_str.lower() == "true"252+ and enable_vector_core_str.lower() == "true"
253- if res_status:253+ if res_status:
254- logger.debug("op_type:{} is support customized vector core.".format(op_kernel_info.op_type))254+ logger.debug("op_type:{} is support customized vector core.".format(op_kernel_info.op_type))
255- op_kernel_info.enable_vector_core = True255+ op_kernel_info.enable_vector_core = True
256- 256+ 
257- return True257+ return True
258- 258+ 
259- def init_op_info(self, op_type, op_content, op_kernel_info):259+ def init_op_info(self, op_type, op_content, op_kernel_info):
260- """260+ """
261- parse op_info261+ parse op_info
262- """262+ """
263- op_kernel_info.op_info["flagPartial"] = False263+ op_kernel_info.op_info["flagPartial"] = False
264- op_kernel_info.op_info["flagAsync"] = False264+ op_kernel_info.op_info["flagAsync"] = False
265- op_kernel_info.op_info["computeCost"] = 10265+ op_kernel_info.op_info["computeCost"] = 10
266- 266+ 
267- # parse op_file267+ # parse op_file
268- result, op_file = self.get_str_from_op_content(op_type, op_content, "opFile", "value")268+ result, op_file = self.get_str_from_op_content(op_type, op_content, "opFile", "value")
269- if result and op_file is not None:269+ if result and op_file is not None:
270- logger.debug("Op {} get op_file value is {}.".format(op_type, op_file))270+ logger.debug("Op {} get op_file value is {}.".format(op_type, op_file))
271- op_kernel_info.op_info["opFileName"] = op_file271+ op_kernel_info.op_info["opFileName"] = op_file
272- else:272+ else:
273- logger.debug("Op {} can't {} get op_file value".format(op_type, op_type))273+ logger.debug("Op {} can't {} get op_file value".format(op_type, op_type))
274- op_kernel_info.op_info["opFileName"] = ""274+ op_kernel_info.op_info["opFileName"] = ""
275- 275+ 
276- # parse op_func276+ # parse op_func
277- result, op_interface = self.get_str_from_op_content(op_type, op_content, "opInterface", "value")277+ result, op_interface = self.get_str_from_op_content(op_type, op_content, "opInterface", "value")
278- if result and op_interface is not None:278+ if result and op_interface is not None:
279- logger.debug("Op {} get op_interface value is {}.".format(op_type, op_interface))279+ logger.debug("Op {} get op_interface value is {}.".format(op_type, op_interface))
280- op_kernel_info.op_info["opFuncName"] = op_interface280+ op_kernel_info.op_info["opFuncName"] = op_interface
281- else:281+ else:
282- logger.debug("Op {} can't {} get op_interface value".format(op_type, op_type))282+ logger.debug("Op {} can't {} get op_interface value".format(op_type, op_type))
283- op_kernel_info.op_info["opFuncName"] = ""283+ op_kernel_info.op_info["opFuncName"] = ""
284- 284+ 
285- # parse op_impl_switch285+ # parse op_impl_switch
286- result, op_impl_switch = self.get_str_from_op_content(op_type, op_content, "opImplSwitch", "value")286+ result, op_impl_switch = self.get_str_from_op_content(op_type, op_content, "opImplSwitch", "value")
287- if result and op_impl_switch is not None:287+ if result and op_impl_switch is not None:
288- logger.debug("Op {} get op_impl_switch value is {}.".format(op_type, op_impl_switch))288+ logger.debug("Op {} get op_impl_switch value is {}.".format(op_type, op_impl_switch))
289- op_kernel_info.op_info["opImplSwitch"] = op_impl_switch289+ op_kernel_info.op_info["opImplSwitch"] = op_impl_switch
290- 290+ 
291- return True291+ return True
292- 292+ 
293- def initialize_op_kernel_info(self, op_type, op_content, op_kernel_info):293+ def initialize_op_kernel_info(self, op_type, op_content, op_kernel_info):
294- """294+ """
295- parse single op295+ parse single op
296- """296+ """
297- if op_kernel_info.init_flag:297+ if op_kernel_info.init_flag:
298- logger.debug("op_kernel_info has been initialized.")298+ logger.debug("op_kernel_info has been initialized.")
299- return True299+ return True
300- op_kernel_info.op_type = op_type300+ op_kernel_info.op_type = op_type
301- 301+ 
302- if not self.parse_basic_parameter(op_type, op_content, op_kernel_info):302+ if not self.parse_basic_parameter(op_type, op_content, op_kernel_info):
303- logger.debug("parse basic parameter did not succeed.")303+ logger.debug("parse basic parameter did not succeed.")
304- return False304+ return False
305- 305+ 
306- if not self.parse_basic_parameter_arg(op_type, op_content, op_kernel_info):306+ if not self.parse_basic_parameter_arg(op_type, op_content, op_kernel_info):
307- logger.debug("parse basic parameter arg did not succeed.")307+ logger.debug("parse basic parameter arg did not succeed.")
308- return False308+ return False
309- 309+ 
310- if not self.init_op_info(op_type, op_content, op_kernel_info):310+ if not self.init_op_info(op_type, op_content, op_kernel_info):
311- logger.debug("init op info did not succeed.")311+ logger.debug("init op info did not succeed.")
312- return False312+ return False
313- 313+ 
314- if not self.parse_input_and_output_from_content(op_type, op_content, op_kernel_info):314+ if not self.parse_input_and_output_from_content(op_type, op_content, op_kernel_info):
315- logger.debug("init op input info did not succeed.")315+ logger.debug("init op input info did not succeed.")
316- return False316+ return False
317- 317+ 
318- if not self.parse_attrs_from_content(op_type, op_content, op_kernel_info):318+ if not self.parse_attrs_from_content(op_type, op_content, op_kernel_info):
319- logger.debug("init attrs did not succeed.")319+ logger.debug("init attrs did not succeed.")
320- return False320+ return False
321- op_kernel_info.init_flag = True321+ op_kernel_info.init_flag = True
322- return True322+ return True
323- 323+ 
324- 324+ 
325-class SubOpInfoStore:325+class SubOpInfoStore:
326- """326+ """
327- save op store info with instance327+ save op store info with instance
328- """328+ """
329- op_kernel_info_dict = {}329+ op_kernel_info_dict = {}
330- op_builtin_info_dict = {}330+ op_builtin_info_dict = {}
331- op_custom_info_list = []331+ op_custom_info_list = []
332- op_vendor_info_list = []332+ op_vendor_info_list = []
333- 333+ 
334- 334+ 
335- def __init__(self):335+ def __init__(self):
336- pass336+ pass
337- 337+ 
338- # singletom pattern338+ # singletom pattern
339- def __new__(cls, *args, **kwargs):339+ def __new__(cls, *args, **kwargs):
340- _ = args340+ _ = args
341- _ = kwargs341+ _ = kwargs
342- if not hasattr(cls, "_instance"):342+ if not hasattr(cls, "_instance"):
343- cls._instance = object.__new__(cls)343+ cls._instance = object.__new__(cls)
344- return cls._instance344+ return cls._instance
345- 345+ 
346- def set_op_content(self, op_builtin_info_dict):346+ def set_op_content(self, op_builtin_info_dict):
347- """347+ """
348- set_op_content348+ set_op_content
349- """349+ """
350- self.op_builtin_info_dict = op_builtin_info_dict350+ self.op_builtin_info_dict = op_builtin_info_dict
351- 351+ 
352- def set_op_custom(self, op_custom_list):352+ def set_op_custom(self, op_custom_list):
353- """353+ """
354- set_op_custom354+ set_op_custom
355- """355+ """
356- self.op_custom_info_list = op_custom_list356+ self.op_custom_info_list = op_custom_list
357- 357+ 
358- def set_op_vendors(self, op_vendor_list):358+ def set_op_vendors(self, op_vendor_list):
359- """359+ """
360- set_op_vendors360+ set_op_vendors
361- """361+ """
362- self.op_vendor_info_list = op_vendor_list362+ self.op_vendor_info_list = op_vendor_list
363- 363+ 
364- def construct_op_kernel_info(self, op_type):364+ def construct_op_kernel_info(self, op_type):
365- """365+ """
366- parse compute op366+ parse compute op
367- op select priority: SCEND_CUSTOM_OPP_PATH > vendors > built-in367+ op select priority: SCEND_CUSTOM_OPP_PATH > vendors > built-in
368- """368+ """
369- for op_custom_dict in self.op_custom_info_list:369+ for op_custom_dict in self.op_custom_info_list:
370- if not isinstance(op_custom_dict, dict):370+ if not isinstance(op_custom_dict, dict):
371- logger.warn("{} is not dict type.".format(op_custom_dict))371+ logger.warn("{} is not dict type.".format(op_custom_dict))
372- continue372+ continue
373- 373+ 
374- if (self.construct_op_info_from_dict(op_type, op_custom_dict)):374+ if (self.construct_op_info_from_dict(op_type, op_custom_dict)):
375- logger.debug("op_type:{} is find in custom path.".format(op_type))375+ logger.debug("op_type:{} is find in custom path.".format(op_type))
376- return True376+ return True
377- 377+ 
378- for op_vendor in self.op_vendor_info_list:378+ for op_vendor in self.op_vendor_info_list:
379- if not isinstance(op_vendor, dict):379+ if not isinstance(op_vendor, dict):
380- logger.warn("{} is not dict type.".format(op_vendor))380+ logger.warn("{} is not dict type.".format(op_vendor))
381- continue381+ continue
382- if (self.construct_op_info_from_dict(op_type, op_vendor)):382+ if (self.construct_op_info_from_dict(op_type, op_vendor)):
383- logger.debug("op_type:{} is find in vendor path.".format(op_type))383+ logger.debug("op_type:{} is find in vendor path.".format(op_type))
384- return True384+ return True
385- 385+ 
386- return self.construct_op_info_from_dict(op_type, self.op_builtin_info_dict)386+ return self.construct_op_info_from_dict(op_type, self.op_builtin_info_dict)
387- 387+ 
388- def construct_op_info_from_dict(self, op_type, op_content_dict):388+ def construct_op_info_from_dict(self, op_type, op_content_dict):
389- """389+ """
390- parse compute op390+ parse compute op
391- """391+ """
392- op_content = op_content_dict.get(op_type)392+ op_content = op_content_dict.get(op_type)
393- op_kernel_info = OpKernelInfo(op_type)393+ op_kernel_info = OpKernelInfo(op_type)
394- if op_content is None:394+ if op_content is None:
395- logger.debug("op_type:{} is not exist.".format(op_type))395+ logger.debug("op_type:{} is not exist.".format(op_type))
396- return False396+ return False
397- else:397+ else:
398- if not op_kernel_info.initialize_op_kernel_info(op_type, op_content, op_kernel_info):398+ if not op_kernel_info.initialize_op_kernel_info(op_type, op_content, op_kernel_info):
399- logger.debug("opKernelInfo {} initialize did not succeed.".format(op_type))399+ logger.debug("opKernelInfo {} initialize did not succeed.".format(op_type))
400- return False400+ return False
401- 401+ 
402- logger.debug("opKernelInfo {} initialize success.".format(op_type))402+ logger.debug("opKernelInfo {} initialize success.".format(op_type))
403- self.op_kernel_info_dict[op_type] = op_kernel_info403+ self.op_kernel_info_dict[op_type] = op_kernel_info
404- return True404+ return True
405- 405+ 
406- 406+ 
407-class OpPathParse(object):407+class OpPathParse(object):
408- """408+ """
409- parse Ascend path and store409+ parse Ascend path and store
410- """410+ """
411- custom_opp_path_list = []411+ custom_opp_path_list = []
412- vendors_opp_path_list = []412+ vendors_opp_path_list = []
413- 413+ 
414- def __init__(self):414+ def __init__(self):
415- pass415+ pass
416- 416+ 
417- # singletom pattern417+ # singletom pattern
418- def __new__(cls, *args, **kwargs):418+ def __new__(cls, *args, **kwargs):
419- _ = args419+ _ = args
420- _ = kwargs420+ _ = kwargs
421- if not hasattr(cls, "_instance"):421+ if not hasattr(cls, "_instance"):
422- cls._instance = object.__new__(cls)422+ cls._instance = object.__new__(cls)
423- return cls._instance423+ return cls._instance
424- 424+ 
425- def start_parse(self):425+ def start_parse(self):
426- """426+ """
427- generate_custom_opp_list427+ generate_custom_opp_list
428- generate_vendor_opp_list428+ generate_vendor_opp_list
429- """429+ """
430- self.generate_custom_opp_list()430+ self.generate_custom_opp_list()
431- self.generate_vendor_opp_list()431+ self.generate_vendor_opp_list()
432- 432+ 
433- def generate_custom_opp_list(self):433+ def generate_custom_opp_list(self):
434- """434+ """
435- generate_custom_opp_list435+ generate_custom_opp_list
436- """436+ """
437- custom_opp_path = os.getenv("ASCEND_CUSTOM_OPP_PATH")437+ custom_opp_path = os.getenv("ASCEND_CUSTOM_OPP_PATH")
438- 438+ 
439- if custom_opp_path:439+ if custom_opp_path:
440- if ":" not in custom_opp_path:440+ if ":" not in custom_opp_path:
441- self.custom_opp_path_list.append(custom_opp_path.strip())441+ self.custom_opp_path_list.append(custom_opp_path.strip())
442- else:442+ else:
443- self.custom_opp_path_list = custom_opp_path.split(":")443+ self.custom_opp_path_list = custom_opp_path.split(":")
444- self.custom_opp_path_list = [opp_path.strip() for opp_path in self.custom_opp_path_list]444+ self.custom_opp_path_list = [opp_path.strip() for opp_path in self.custom_opp_path_list]
445- 445+ 
446- for index, custom in enumerate(self.custom_opp_path_list):446+ for index, custom in enumerate(self.custom_opp_path_list):
447- logger.debug("index: {} custom_opp_path: {}".format(index, custom))447+ logger.debug("index: {} custom_opp_path: {}".format(index, custom))
448- 448+ 
449- def generate_vendor_opp_list(self):449+ def generate_vendor_opp_list(self):
450- """450+ """
451- generate_custom_opp_list451+ generate_custom_opp_list
452- """452+ """
453- ascend_opp_path = os.getenv("ASCEND_OPP_PATH")453+ ascend_opp_path = os.getenv("ASCEND_OPP_PATH")
454- config_path = "{}/vendors/config.ini".format(ascend_opp_path)454+ config_path = "{}/vendors/config.ini".format(ascend_opp_path)
455- 455+ 
456- content = ""456+ content = ""
457- if Path(config_path).is_file():457+ if Path(config_path).is_file():
458- with open(config_path, 'r') as f:458+ with open(config_path, 'r') as f:
459- for line in f.readlines():459+ for line in f.readlines():
460- if "load_priority" in line:460+ if "load_priority" in line:
461- content = line461+ content = line
462- f.close()462+ f.close()
463- 463+ 
464- logger.debug("load_priority content is: {}.".format(content))464+ logger.debug("load_priority content is: {}.".format(content))
465- if content.strip():465+ if content.strip():
466- custom_str = content.split("=")466+ custom_str = content.split("=")
467- if "," in custom_str[1].lower():467+ if "," in custom_str[1].lower():
468- custom_list = custom_str[1].split(",")468+ custom_list = custom_str[1].split(",")
469- custom_list = [opp_path.strip() for opp_path in custom_list]469+ custom_list = [opp_path.strip() for opp_path in custom_list]
470- for custom in custom_list:470+ for custom in custom_list:
471- curr_custom = "{}/vendors/{}".format(ascend_opp_path, custom)471+ curr_custom = "{}/vendors/{}".format(ascend_opp_path, custom)
472- if curr_custom not in self.vendors_opp_path_list:472+ if curr_custom not in self.vendors_opp_path_list:
473- self.vendors_opp_path_list.append(curr_custom.strip())473+ self.vendors_opp_path_list.append(curr_custom.strip())
474- else:474+ else:
475- logger.debug("{}'s already exsited.".format(curr_custom))475+ logger.debug("{}'s already exsited.".format(curr_custom))
476- else:476+ else:
477- curr_custom = "{}/vendors/{}".format(ascend_opp_path, custom_str[1])477+ curr_custom = "{}/vendors/{}".format(ascend_opp_path, custom_str[1])
478- self.vendors_opp_path_list.append(curr_custom.strip())478+ self.vendors_opp_path_list.append(curr_custom.strip())
479- 479+ 
480- for index, custom in enumerate(self.vendors_opp_path_list):480+ for index, custom in enumerate(self.vendors_opp_path_list):
481- logger.debug("index: {} custom_opp_path: {}.".format(index, custom))481+ logger.debug("index: {} custom_opp_path: {}.".format(index, custom))
482- 482+ 
483- def get_custom_opp_path_list(self):483+ def get_custom_opp_path_list(self):
484- """484+ """
485- get_custom_opp_path_list485+ get_custom_opp_path_list
486- """486+ """
487- return self.custom_opp_path_list487+ return self.custom_opp_path_list
488- 488+ 
489- def get_vendors_opp_path_list(self):489+ def get_vendors_opp_path_list(self):
490- """490+ """
491- get_vendors_opp_path_list491+ get_vendors_opp_path_list
492- """492+ """
493- return self.vendors_opp_path_list493+ return self.vendors_opp_path_list
494- 494+ 
495- 495+ 
496-def load_set_op_content(json_path):496+def load_set_op_content(json_path):
497- op_builtin_info_dict = dict()497+ op_builtin_info_dict = dict()
498- try:498+ try:
499- with open(json_path, "r") as file_in:499+ with open(json_path, "r") as file_in:
500- op_builtin_info_dict = json.load(file_in)500+ op_builtin_info_dict = json.load(file_in)
501- except Exception as e:501+ except Exception as e:
502- logger.warn("load file[%s] failed, reason: %s.", json_path, str(e))502+ logger.warn("load file[%s] failed, reason: %s.", json_path, str(e))
503- finally:503+ finally:
504- pass504+ pass
505- SubOpInfoStore().set_op_content(op_builtin_info_dict)505+ SubOpInfoStore().set_op_content(op_builtin_info_dict)
506- 506+ 
507- 507+ 
508-def load_op_info_store(soc_version):508+def load_op_info_store(soc_version):
509- platform_info.set_current_compile_soc_info(soc_version)509+ platform_info.set_current_compile_soc_info(soc_version)
510- ascend_opp_path = os.getenv("ASCEND_OPP_PATH")510+ ascend_opp_path = os.getenv("ASCEND_OPP_PATH")
511- short_soc_version = platform_info.get_soc_spec("SHORT_SOC_VERSION").lower()511+ short_soc_version = platform_info.get_soc_spec("SHORT_SOC_VERSION").lower()
512- json_path = "{}/built-in/op_impl/ai_core/tbe/config/{}/aic-{}-ops-info.json".format(ascend_opp_path,512+ json_path = "{}/built-in/op_impl/ai_core/tbe/config/{}/aic-{}-ops-info.json".format(ascend_opp_path,
513- short_soc_version, short_soc_version)513+ short_soc_version, short_soc_version)
514- logger.debug("json_path is {}.".format(json_path))514+ logger.debug("json_path is {}.".format(json_path))
515- load_set_op_content(json_path)515+ load_set_op_content(json_path)
516- 516+ 
517- OpPathParse().start_parse()517+ OpPathParse().start_parse()
518- custom_opp_path_list = OpPathParse().get_custom_opp_path_list()518+ custom_opp_path_list = OpPathParse().get_custom_opp_path_list()
519- if custom_opp_path_list:519+ if custom_opp_path_list:
520- custom_dict_list = []520+ custom_dict_list = []
521- for custom_opp_path in custom_opp_path_list:521+ for custom_opp_path in custom_opp_path_list:
522- custom_opp_json_path = "{}/op_impl/ai_core/tbe/config/{}/aic-{}-ops-info.json".format(custom_opp_path,522+ custom_opp_json_path = "{}/op_impl/ai_core/tbe/config/{}/aic-{}-ops-info.json".format(custom_opp_path,
523- short_soc_version, short_soc_version)523+ short_soc_version, short_soc_version)
524- custom_dict = read_json_file(custom_opp_json_path)524+ custom_dict = read_json_file(custom_opp_json_path)
525- if None:525+ if None:
526- logger.debug("json_path is {}.".format(json_path))526+ logger.debug("json_path is {}.".format(json_path))
527- continue527+ continue
528- custom_dict_list.append(custom_dict)528+ custom_dict_list.append(custom_dict)
529- SubOpInfoStore().set_op_custom(custom_dict_list)529+ SubOpInfoStore().set_op_custom(custom_dict_list)
530- 530+ 
531- vendors_opp_path_list = OpPathParse().get_vendors_opp_path_list()531+ vendors_opp_path_list = OpPathParse().get_vendors_opp_path_list()
532- if vendors_opp_path_list:532+ if vendors_opp_path_list:
533- vendor_dict_list = []533+ vendor_dict_list = []
534- for vendor_opp_path in vendors_opp_path_list:534+ for vendor_opp_path in vendors_opp_path_list:
535- vendor_opp_json_path = "{}/op_impl/ai_core/tbe/config/{}/aic-{}-ops-info.json".format(vendor_opp_path,535+ vendor_opp_json_path = "{}/op_impl/ai_core/tbe/config/{}/aic-{}-ops-info.json".format(vendor_opp_path,
536- short_soc_version, short_soc_version)536+ short_soc_version, short_soc_version)
537- vendor_dict = read_json_file(vendor_opp_json_path)537+ vendor_dict = read_json_file(vendor_opp_json_path)
538- if None:538+ if None:
539- logger.debug("json_path is {}.".format(json_path))539+ logger.debug("json_path is {}.".format(json_path))
540- continue540+ continue
541- vendor_dict_list.append(vendor_dict)541+ vendor_dict_list.append(vendor_dict)
542- SubOpInfoStore().set_op_vendors(vendor_dict_list)542+ SubOpInfoStore().set_op_vendors(vendor_dict_list)
@@ -1,342 +1,342 @@
1-#!/usr/bin/env python1+#!/usr/bin/env python
2-# -*- coding: UTF-8 -*-2+# -*- coding: UTF-8 -*-
3-# ----------------------------------------------------------------------------------------------------------3+# ----------------------------------------------------------------------------------------------------------
4-# Copyright (c) 2025 Huawei Technologies Co., Ltd.4+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6-# CANN Open Software License Agreement Version 2.0 (the "License").6+# CANN Open Software License Agreement Version 2.0 (the "License").
7-# Please refer to the License for details. You may not use this file except in compliance with the License.7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10-# See LICENSE in the root of the software repository for the full text of the License.10+# See LICENSE in the root of the software repository for the full text of the License.
11-# ----------------------------------------------------------------------------------------------------------11+# ----------------------------------------------------------------------------------------------------------
12- 12+ 
13-"""13+"""
14-op manager14+op manager
15-"""15+"""
16-import importlib16+import importlib
17-from importlib import util17+from importlib import util
18-import copy18+import copy
19-import os19+import os
20-import sys20+import sys
21-from pathlib import Path21+from pathlib import Path
22-import asc_op_compile_base.common.register as tbe_register22+import asc_op_compile_base.common.register as tbe_register
23-from asc_op_compile_base.common.utils import log as logger23+from asc_op_compile_base.common.utils import log as logger
24-from constant import OpcOptions24+from constant import OpcOptions
25-from opc_common import (normalize_func_name, get_file_real_path, LogLevel, opc_log_full)25+from opc_common import (normalize_func_name, get_file_real_path, LogLevel, opc_log_full)
26-from op_info_store import SubOpInfoStore, OpPathParse26+from op_info_store import SubOpInfoStore, OpPathParse
27- 27+ 
28-MIDDLE_PATH_LIST = (28+MIDDLE_PATH_LIST = (
29- "op_impl/ai_core/tbe",29+ "op_impl/ai_core/tbe",
30- "op_impl/vector_core/tbe"30+ "op_impl/vector_core/tbe"
31-)31+)
32- 32+ 
33- 33+ 
34-def op_register_get_func(sub_op_info_store, op_type, impl_type):34+def op_register_get_func(sub_op_info_store, op_type, impl_type):
35- """35+ """
36- query the operator information base and finally return op func36+ query the operator information base and finally return op func
37- """37+ """
38- result = sub_op_info_store.construct_op_kernel_info(op_type)38+ result = sub_op_info_store.construct_op_kernel_info(op_type)
39- if result:39+ if result:
40- op_kernel_info = sub_op_info_store.op_kernel_info_dict.get(op_type)40+ op_kernel_info = sub_op_info_store.op_kernel_info_dict.get(op_type)
41- if op_kernel_info is not None:41+ if op_kernel_info is not None:
42- op_file_name = op_kernel_info.op_info.get("opFileName")42+ op_file_name = op_kernel_info.op_info.get("opFileName")
43- op_func_name = op_kernel_info.op_info.get("opFuncName")43+ op_func_name = op_kernel_info.op_info.get("opFuncName")
44- if op_file_name != "":44+ if op_file_name != "":
45- op_path = "{}.{}".format(impl_type, op_file_name)45+ op_path = "{}.{}".format(impl_type, op_file_name)
46- opm = importlib.import_module(op_path)46+ opm = importlib.import_module(op_path)
47- if op_func_name != "":47+ if op_func_name != "":
48- return getattr(opm, op_func_name)48+ return getattr(opm, op_func_name)
49- else:49+ else:
50- op_func = normalize_func_name(op_type)50+ op_func = normalize_func_name(op_type)
51- return getattr(opm, op_func)51+ return getattr(opm, op_func)
52- else:52+ else:
53- op_path = "{}.{}".format(impl_type, normalize_func_name(op_type))53+ op_path = "{}.{}".format(impl_type, normalize_func_name(op_type))
54- opm = importlib.import_module(op_path)54+ opm = importlib.import_module(op_path)
55- if op_func_name != "":55+ if op_func_name != "":
56- return getattr(opm, op_func_name)56+ return getattr(opm, op_func_name)
57- else:57+ else:
58- op_func = normalize_func_name(op_type)58+ op_func = normalize_func_name(op_type)
59- return getattr(opm, op_func)59+ return getattr(opm, op_func)
60- else:60+ else:
61- logger.debug("{}'s op_kernel_info is null.".format(op_type))61+ logger.debug("{}'s op_kernel_info is null.".format(op_type))
62- return None62+ return None
63- 63+ 
64- else:64+ else:
65- logger.debug("[Graph] Unable to parse the operator information")65+ logger.debug("[Graph] Unable to parse the operator information")
66- return None66+ return None
67- 67+ 
68- 68+ 
69-def get_inout_info_from_opstore(op_type):69+def get_inout_info_from_opstore(op_type):
70- """70+ """
71- get_inout_info_from_opstore71+ get_inout_info_from_opstore
72- """72+ """
73- result = SubOpInfoStore().construct_op_kernel_info(op_type)73+ result = SubOpInfoStore().construct_op_kernel_info(op_type)
74- if not result:74+ if not result:
75- logger.warn("Op {} is not found in opstore.".format(op_type))75+ logger.warn("Op {} is not found in opstore.".format(op_type))
76- return None, None76+ return None, None
77- op_kernel_info = SubOpInfoStore().op_kernel_info_dict.get(op_type)77+ op_kernel_info = SubOpInfoStore().op_kernel_info_dict.get(op_type)
78- if op_kernel_info is None:78+ if op_kernel_info is None:
79- logger.warn("Op {} kernel_info is None.".format(op_type))79+ logger.warn("Op {} kernel_info is None.".format(op_type))
80- return None, None80+ return None, None
81- return op_kernel_info.input_infos_, op_kernel_info.output_infos_81+ return op_kernel_info.input_infos_, op_kernel_info.output_infos_
82- 82+ 
83- 83+ 
84-def get_attr_info_from_opstore(op_type):84+def get_attr_info_from_opstore(op_type):
85- """85+ """
86- get_attr_info_from_opstore86+ get_attr_info_from_opstore
87- """87+ """
88- result = SubOpInfoStore().construct_op_kernel_info(op_type)88+ result = SubOpInfoStore().construct_op_kernel_info(op_type)
89- if not result:89+ if not result:
90- logger.warn("Op {} is not found in opstore.".format(op_type))90+ logger.warn("Op {} is not found in opstore.".format(op_type))
91- return None91+ return None
92- op_kernel_info = SubOpInfoStore().op_kernel_info_dict.get(op_type)92+ op_kernel_info = SubOpInfoStore().op_kernel_info_dict.get(op_type)
93- if op_kernel_info is None:93+ if op_kernel_info is None:
94- logger.warn("Op {} kernel_info is None.".format(op_type))94+ logger.warn("Op {} kernel_info is None.".format(op_type))
95- return None95+ return None
96- return op_kernel_info.attr_infos_96+ return op_kernel_info.attr_infos_
97- 97+ 
98- 98+ 
99-def get_op_impl_switch_from_opstore(op_type):99+def get_op_impl_switch_from_opstore(op_type):
100- """100+ """
101- get_op_impl_switch_from_opstore101+ get_op_impl_switch_from_opstore
102- """102+ """
103- result = SubOpInfoStore().construct_op_kernel_info(op_type)103+ result = SubOpInfoStore().construct_op_kernel_info(op_type)
104- if not result:104+ if not result:
105- logger.warn("Op {} is not found in opstore.".format(op_type))105+ logger.warn("Op {} is not found in opstore.".format(op_type))
106- return None106+ return None
107- op_kernel_info = SubOpInfoStore().op_kernel_info_dict.get(op_type)107+ op_kernel_info = SubOpInfoStore().op_kernel_info_dict.get(op_type)
108- if op_kernel_info is None:108+ if op_kernel_info is None:
109- logger.warn("Op {} kernel_info is None.".format(op_type))109+ logger.warn("Op {} kernel_info is None.".format(op_type))
110- return None110+ return None
111- return op_kernel_info.op_info.get("opImplSwitch", None)111+ return op_kernel_info.op_info.get("opImplSwitch", None)
112- 112+ 
113- 113+ 
114-def get_enable_vector_core_from_opstore(op_type):114+def get_enable_vector_core_from_opstore(op_type):
115- """115+ """
116- get_enable_vector_core_from_opstore116+ get_enable_vector_core_from_opstore
117- """117+ """
118- result = SubOpInfoStore().construct_op_kernel_info(op_type)118+ result = SubOpInfoStore().construct_op_kernel_info(op_type)
119- if not result:119+ if not result:
120- logger.warn("Op {} is not found in opstore.".format(op_type))120+ logger.warn("Op {} is not found in opstore.".format(op_type))
121- return None121+ return None
122- op_kernel_info = SubOpInfoStore().op_kernel_info_dict.get(op_type)122+ op_kernel_info = SubOpInfoStore().op_kernel_info_dict.get(op_type)
123- if op_kernel_info is None:123+ if op_kernel_info is None:
124- logger.warn("Op {} kernel_info is None.".format(op_type))124+ logger.warn("Op {} kernel_info is None.".format(op_type))
125- return None125+ return None
126- return op_kernel_info.enable_vector_core126+ return op_kernel_info.enable_vector_core
127- 127+ 
128- 128+ 
129-def get_dynamic_compile_static_from_opstore(op_type):129+def get_dynamic_compile_static_from_opstore(op_type):
130- """130+ """
131- get_dynamic_compile_static_from_opstore131+ get_dynamic_compile_static_from_opstore
132- """132+ """
133- result = SubOpInfoStore().construct_op_kernel_info(op_type)133+ result = SubOpInfoStore().construct_op_kernel_info(op_type)
134- if not result:134+ if not result:
135- logger.warn("Op {} is not found in opstore.".format(op_type))135+ logger.warn("Op {} is not found in opstore.".format(op_type))
136- return None136+ return None
137- op_kernel_info = SubOpInfoStore().op_kernel_info_dict.get(op_type)137+ op_kernel_info = SubOpInfoStore().op_kernel_info_dict.get(op_type)
138- if op_kernel_info is None:138+ if op_kernel_info is None:
139- logger.warn("Op {} kernel_info is None.".format(op_type))139+ logger.warn("Op {} kernel_info is None.".format(op_type))
140- return None140+ return None
141- return op_kernel_info.dynamic_compile_static141+ return op_kernel_info.dynamic_compile_static
142- 142+ 
143- 143+ 
144-def get_dynamic_compile_static(op_type, op_info):144+def get_dynamic_compile_static(op_type, op_info):
145- """145+ """
146- get_dynamic_compile_static146+ get_dynamic_compile_static
147- """147+ """
148- dynamic_compile_static = get_dynamic_compile_static_from_opstore(op_type)148+ dynamic_compile_static = get_dynamic_compile_static_from_opstore(op_type)
149- logger.debug("Op {} dynamic_compile_static is {}.".format(op_type, dynamic_compile_static))149+ logger.debug("Op {} dynamic_compile_static is {}.".format(op_type, dynamic_compile_static))
150- 150+ 
151- if dynamic_compile_static == "tune":151+ if dynamic_compile_static == "tune":
152- dynamic_compile_static_update, _ = get_dynamic_compile_static_from_kb(op_type, op_info)152+ dynamic_compile_static_update, _ = get_dynamic_compile_static_from_kb(op_type, op_info)
153- if dynamic_compile_static_update not in {"true", "false", None} :153+ if dynamic_compile_static_update not in {"true", "false", None} :
154- logger.error("Op {} dynamic_compile_static {} invalid.".format(op_type, dynamic_comiple_static))154+ logger.error("Op {} dynamic_compile_static {} invalid.".format(op_type, dynamic_comiple_static))
155- return None155+ return None
156- elif dynamic_compile_static_update is None:156+ elif dynamic_compile_static_update is None:
157- return dynamic_compile_static157+ return dynamic_compile_static
158- else:158+ else:
159- logger.debug("{}'s dynamic_compile_static update to {}.".format(op_type, dynamic_compile_static_update))159+ logger.debug("{}'s dynamic_compile_static update to {}.".format(op_type, dynamic_compile_static_update))
160- return dynamic_compile_static_update160+ return dynamic_compile_static_update
161- else:161+ else:
162- return dynamic_compile_static162+ return dynamic_compile_static
163- 163+ 
164- 164+ 
165-def get_op_impl_switch(op_type, op_info):165+def get_op_impl_switch(op_type, op_info):
166- """166+ """
167- get_op_impl_switch167+ get_op_impl_switch
168- """168+ """
169- op_impl_switch = get_op_impl_switch_from_opstore(op_type)169+ op_impl_switch = get_op_impl_switch_from_opstore(op_type)
170- if op_impl_switch:170+ if op_impl_switch:
171- lst = op_impl_switch.split(',')171+ lst = op_impl_switch.split(',')
172- if len(lst) > 1:172+ if len(lst) > 1:
173- _, op_impl_switch = get_dynamic_compile_static_from_kb(op_type, op_info)173+ _, op_impl_switch = get_dynamic_compile_static_from_kb(op_type, op_info)
174- return op_impl_switch174+ return op_impl_switch
175- 175+ 
176- logger.debug("{}'s op_impl_switch is {}.".format(op_type, op_impl_switch))176+ logger.debug("{}'s op_impl_switch is {}.".format(op_type, op_impl_switch))
177- return op_impl_switch177+ return op_impl_switch
178- 178+ 
179- 179+ 
180-def get_mode_name_from_vendors_path(vendor_path):180+def get_mode_name_from_vendors_path(vendor_path):
181- """181+ """
182- get_mode_name_from_vendors_path182+ get_mode_name_from_vendors_path
183- """183+ """
184- index = vendor_path.find("vendors/") + len("vendors/")184+ index = vendor_path.find("vendors/") + len("vendors/")
185- op_mode_name = vendor_path[index:]185+ op_mode_name = vendor_path[index:]
186- op_mode_name = op_mode_name + "_impl"186+ op_mode_name = op_mode_name + "_impl"
187- logger.info("vendor_path is {}, op_mode_name is {}.".format(vendor_path, op_mode_name))187+ logger.info("vendor_path is {}, op_mode_name is {}.".format(vendor_path, op_mode_name))
188- return op_mode_name188+ return op_mode_name
189- 189+ 
190- 190+ 
191-def find_mode_file_from_custom(op_type, custom_opp_path_list):191+def find_mode_file_from_custom(op_type, custom_opp_path_list):
192- """192+ """
193- find_mode_name_op_py_file193+ find_mode_name_op_py_file
194- """194+ """
195- op_type_name = normalize_func_name(op_type)195+ op_type_name = normalize_func_name(op_type)
196- # In the custom_opp_path_list header, the priority is the highest196+ # In the custom_opp_path_list header, the priority is the highest
197- for op_path_custom in custom_opp_path_list:197+ for op_path_custom in custom_opp_path_list:
198- index = op_path_custom.rfind('/') + 1198+ index = op_path_custom.rfind('/') + 1
199- op_mode_name = op_path_custom[index:]199+ op_mode_name = op_path_custom[index:]
200- if not op_mode_name:200+ if not op_mode_name:
201- logger.info("{} find op op_mode_name from {} is None.".format(op_type, op_path_custom))201+ logger.info("{} find op op_mode_name from {} is None.".format(op_type, op_path_custom))
202- continue202+ continue
203- logger.info("op {} op_mode_name is {}.".format(op_type, op_mode_name))203+ logger.info("op {} op_mode_name is {}.".format(op_type, op_mode_name))
204- for middle_path in MIDDLE_PATH_LIST:204+ for middle_path in MIDDLE_PATH_LIST:
205- middle_path = "{}/{}".format(middle_path, op_mode_name)205+ middle_path = "{}/{}".format(middle_path, op_mode_name)
206- py_module_path = "{}/{}".format(op_path_custom, middle_path)206+ py_module_path = "{}/{}".format(op_path_custom, middle_path)
207- op_py_file = get_file_real_path(op_path_custom, op_type_name, "py", middle_path)207+ op_py_file = get_file_real_path(op_path_custom, op_type_name, "py", middle_path)
208- logger.debug("op: {} op file is {}, py_module_path is {}.".format(op_type, op_py_file, py_module_path))208+ logger.debug("op: {} op file is {}, py_module_path is {}.".format(op_type, op_py_file, py_module_path))
209- if op_py_file is not None and Path(op_py_file).is_file():209+ if op_py_file is not None and Path(op_py_file).is_file():
210- ogger.debug("op: {} op file is {}.".format(op_type, op_py_file))210+ ogger.debug("op: {} op file is {}.".format(op_type, op_py_file))
211- if py_module_path not in sys.path:211+ if py_module_path not in sys.path:
212- logger.debug("op: {} add py_module_path is {}.".format(op_type, py_module_path))212+ logger.debug("op: {} add py_module_path is {}.".format(op_type, py_module_path))
213- sys.path.append(py_module_path)213+ sys.path.append(py_module_path)
214- return op_mode_name, op_py_file214+ return op_mode_name, op_py_file
215- 215+ 
216- return None, None216+ return None, None
217- 217+ 
218- 218+ 
219-def find_mode_file_from_vendors(op_type, vendors_opp_path_list):219+def find_mode_file_from_vendors(op_type, vendors_opp_path_list):
220- """220+ """
221- find_mode_file_from_vendors221+ find_mode_file_from_vendors
222- """222+ """
223- op_type_name = normalize_func_name(op_type)223+ op_type_name = normalize_func_name(op_type)
224- # In the custom_opp_path_list header, the priority is the highest224+ # In the custom_opp_path_list header, the priority is the highest
225- for op_path_custom in vendors_opp_path_list:225+ for op_path_custom in vendors_opp_path_list:
226- op_mode_name = get_mode_name_from_vendors_path(op_path_custom)226+ op_mode_name = get_mode_name_from_vendors_path(op_path_custom)
227- if not op_mode_name:227+ if not op_mode_name:
228- logger.debug("{} find op op_mode_name from {} is None.".format(op_type, op_path_custom))228+ logger.debug("{} find op op_mode_name from {} is None.".format(op_type, op_path_custom))
229- continue229+ continue
230- logger.debug("op {} op_mode_name is {}.".format(op_type, op_mode_name))230+ logger.debug("op {} op_mode_name is {}.".format(op_type, op_mode_name))
231- for middle_path in MIDDLE_PATH_LIST:231+ for middle_path in MIDDLE_PATH_LIST:
232- py_module_path = "{}/{}".format(op_path_custom, middle_path)232+ py_module_path = "{}/{}".format(op_path_custom, middle_path)
233- middle_file_path = "{}/{}".format(middle_path, op_mode_name)233+ middle_file_path = "{}/{}".format(middle_path, op_mode_name)
234- op_py_file = get_file_real_path(op_path_custom, op_type_name, "py", middle_file_path)234+ op_py_file = get_file_real_path(op_path_custom, op_type_name, "py", middle_file_path)
235- logger.debug("op: {} op file is {}, py_module_path is {}.".format(op_type, op_py_file, py_module_path))235+ logger.debug("op: {} op file is {}, py_module_path is {}.".format(op_type, op_py_file, py_module_path))
236- if op_py_file is not None and Path(op_py_file).is_file():236+ if op_py_file is not None and Path(op_py_file).is_file():
237- logger.debug("op: {} op file is {}.".format(op_type, op_py_file))237+ logger.debug("op: {} op file is {}.".format(op_type, op_py_file))
238- if py_module_path not in sys.path:238+ if py_module_path not in sys.path:
239- sys.path.append(py_module_path)239+ sys.path.append(py_module_path)
240- return op_mode_name, op_py_file240+ return op_mode_name, op_py_file
241- 241+ 
242- # dynamic242+ # dynamic
243- py_module_path = "{}/{}".format(op_path_custom, middle_path)243+ py_module_path = "{}/{}".format(op_path_custom, middle_path)
244- middle_file_path = "{}/{}/dynamic".format(middle_path, op_mode_name)244+ middle_file_path = "{}/{}/dynamic".format(middle_path, op_mode_name)
245- op_py_file = get_file_real_path(op_path_custom, op_type_name, "py", middle_file_path)245+ op_py_file = get_file_real_path(op_path_custom, op_type_name, "py", middle_file_path)
246- logger.debug("op: {} op file is {}, py_module_path is {}.".format(op_type, op_py_file, py_module_path))246+ logger.debug("op: {} op file is {}, py_module_path is {}.".format(op_type, op_py_file, py_module_path))
247- if op_py_file is not None and Path(op_py_file).is_file():247+ if op_py_file is not None and Path(op_py_file).is_file():
248- if py_module_path not in sys.path:248+ if py_module_path not in sys.path:
249- sys.path.append(py_module_path)249+ sys.path.append(py_module_path)
250- op_mode_name = "{}.dynamic".format(op_mode_name)250+ op_mode_name = "{}.dynamic".format(op_mode_name)
251- return op_mode_name, op_py_file251+ return op_mode_name, op_py_file
252- 252+ 
253- return None, None253+ return None, None
254- 254+ 
255- 255+ 
256-def get_dynamic_compile_static_from_kb(op_type, op_info):256+def get_dynamic_compile_static_from_kb(op_type, op_info):
257- """257+ """
258- get_dynamic_compile_static_from_cann258+ get_dynamic_compile_static_from_cann
259- """259+ """
260- return None, None260+ return None, None
261- 261+ 
262- 262+ 
263-def get_built_in_op_operator(op_type, dynamic_compile_static, is_dynamic):263+def get_built_in_op_operator(op_type, dynamic_compile_static, is_dynamic):
264- """264+ """
265- get_built_in_op_operator265+ get_built_in_op_operator
266- """266+ """
267- if dynamic_compile_static == "true" or is_dynamic:267+ if dynamic_compile_static == "true" or is_dynamic:
268- importlib.import_module("impl.dynamic")268+ importlib.import_module("impl.dynamic")
269- op_operator = tbe_register.get_operator(op_type)269+ op_operator = tbe_register.get_operator(op_type)
270- if op_operator is not None:270+ if op_operator is not None:
271- logger.debug("{}'s op_operator is not null.".format(op_type))271+ logger.debug("{}'s op_operator is not null.".format(op_type))
272- return op_operator.get_func()272+ return op_operator.get_func()
273- else:273+ else:
274- logger.debug("{}'s op_compute is None, this is an unregistered operator.".format(op_type))274+ logger.debug("{}'s op_compute is None, this is an unregistered operator.".format(op_type))
275- return op_register_get_func(SubOpInfoStore(), op_type, "impl.dynamic")275+ return op_register_get_func(SubOpInfoStore(), op_type, "impl.dynamic")
276- elif dynamic_compile_static == "false":276+ elif dynamic_compile_static == "false":
277- return op_register_get_func(SubOpInfoStore(), op_type, "impl")277+ return op_register_get_func(SubOpInfoStore(), op_type, "impl")
278- else:278+ else:
279- logger.warn("{} dynamic_compile_static is None.".format(op_type))279+ logger.warn("{} dynamic_compile_static is None.".format(op_type))
280- return None280+ return None
281- 281+ 
282- 282+ 
283-def get_single_op_operator(op_type, dynamic_compile_static, is_dynamic):283+def get_single_op_operator(op_type, dynamic_compile_static, is_dynamic):
284- """284+ """
285- get_single_op_operator285+ get_single_op_operator
286- """286+ """
287- op_type_name = normalize_func_name(op_type)287+ op_type_name = normalize_func_name(op_type)
288- custom_opp_path_list = OpPathParse().get_custom_opp_path_list()288+ custom_opp_path_list = OpPathParse().get_custom_opp_path_list()
289- if custom_opp_path_list:289+ if custom_opp_path_list:
290- op_mode_name, op_py_file = find_mode_file_from_custom(op_type, custom_opp_path_list)290+ op_mode_name, op_py_file = find_mode_file_from_custom(op_type, custom_opp_path_list)
291- logger.debug("{}'s op_mode_name is {}, op_py_file is {}.".format(op_type, op_mode_name, op_py_file))291+ logger.debug("{}'s op_mode_name is {}, op_py_file is {}.".format(op_type, op_mode_name, op_py_file))
292- if op_py_file is not None and Path(op_py_file).is_file():292+ if op_py_file is not None and Path(op_py_file).is_file():
293- op_mode = "{}.{}".format(op_mode_name, op_type_name)293+ op_mode = "{}.{}".format(op_mode_name, op_type_name)
294- logger.debug("{} op module {}.".format(op_type, op_mode))294+ logger.debug("{} op module {}.".format(op_type, op_mode))
295- opm = importlib.import_module(op_mode)295+ opm = importlib.import_module(op_mode)
296- return getattr(opm, op_type_name)296+ return getattr(opm, op_type_name)
297- 297+ 
298- vendors_opp_path_list = OpPathParse().get_vendors_opp_path_list()298+ vendors_opp_path_list = OpPathParse().get_vendors_opp_path_list()
299- if vendors_opp_path_list:299+ if vendors_opp_path_list:
300- op_mode_name, op_py_file = find_mode_file_from_vendors(op_type, vendors_opp_path_list)300+ op_mode_name, op_py_file = find_mode_file_from_vendors(op_type, vendors_opp_path_list)
301- logger.debug("{}'s op_mode_name is {}, op_py_file is {}.".format(op_type, op_mode_name, op_py_file))301+ logger.debug("{}'s op_mode_name is {}, op_py_file is {}.".format(op_type, op_mode_name, op_py_file))
302- if op_py_file is not None and Path(op_py_file).is_file():302+ if op_py_file is not None and Path(op_py_file).is_file():
303- op_mode = "{}.{}".format(op_mode_name, op_type_name)303+ op_mode = "{}.{}".format(op_mode_name, op_type_name)
304- logger.debug("{} op module {}.".format(op_type, op_mode))304+ logger.debug("{} op module {}.".format(op_type, op_mode))
305- opm = importlib.import_module(op_mode)305+ opm = importlib.import_module(op_mode)
306- return getattr(opm, op_type_name)306+ return getattr(opm, op_type_name)
307- 307+ 
308- return get_built_in_op_operator(op_type, dynamic_compile_static, is_dynamic)308+ return get_built_in_op_operator(op_type, dynamic_compile_static, is_dynamic)
309- 309+ 
310- 310+ 
311-def get_core_type_from_op_content(op_type):311+def get_core_type_from_op_content(op_type):
312- """312+ """
313- get core_type from op content313+ get core_type from op content
314- """314+ """
315- op_content = SubOpInfoStore().op_builtin_info_dict.get(op_type)315+ op_content = SubOpInfoStore().op_builtin_info_dict.get(op_type)
316- if op_content is None:316+ if op_content is None:
317- logger.debug("op_content %s is not exist.", op_type)317+ logger.debug("op_content %s is not exist.", op_type)
318- return None318+ return None
319- else:319+ else:
320- core_type_dict = op_content.get("coreType")320+ core_type_dict = op_content.get("coreType")
321- if core_type_dict is None:321+ if core_type_dict is None:
322- logger.debug("%s coreType is not exist.", op_type)322+ logger.debug("%s coreType is not exist.", op_type)
323- return None323+ return None
324- else:324+ else:
325- core_type = core_type_dict["value"]325+ core_type = core_type_dict["value"]
326- return core_type326+ return core_type
327- 327+ 
328- 328+ 
329-def is_valid_module_path(module_path):329+def is_valid_module_path(module_path):
330- if not os.path.isabs(module_path):330+ if not os.path.isabs(module_path):
331- logger.info("path is not abs path.")331+ logger.info("path is not abs path.")
332- return None332+ return None
333- module_dir, module_name = os.path.split(module_path)333+ module_dir, module_name = os.path.split(module_path)
334- module_name = os.path.splitext(module_name)[0]334+ module_name = os.path.splitext(module_name)[0]
335- try:335+ try:
336- spec = util.spec_from_file_location(module_name, module_path)336+ spec = util.spec_from_file_location(module_name, module_path)
337- opm = util.module_from_spec(spec)337+ opm = util.module_from_spec(spec)
338- spec.loader.exec_module(opm)338+ spec.loader.exec_module(opm)
339- return opm339+ return opm
340- except ImportError as e:340+ except ImportError as e:
341- logger.debug("Import op_path {} did not succeed".format(module_path))341+ logger.debug("Import op_path {} did not succeed".format(module_path))
342- return None342+ return None
@@ -1,45 +1,45 @@
1-#!/usr/bin/env python1+#!/usr/bin/env python
2-# -*- coding: UTF-8 -*-2+# -*- coding: UTF-8 -*-
3-# ----------------------------------------------------------------------------------------------------------3+# ----------------------------------------------------------------------------------------------------------
4-# Copyright (c) 2025 Huawei Technologies Co., Ltd.4+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6-# CANN Open Software License Agreement Version 2.0 (the "License").6+# CANN Open Software License Agreement Version 2.0 (the "License").
7-# Please refer to the License for details. You may not use this file except in compliance with the License.7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10-# See LICENSE in the root of the software repository for the full text of the License.10+# See LICENSE in the root of the software repository for the full text of the License.
11-# ----------------------------------------------------------------------------------------------------------11+# ----------------------------------------------------------------------------------------------------------
12-"""12+"""
13-opc api13+opc api
14-"""14+"""
15-import sys15+import sys
16-from asc_op_compile_base.common.utils import log as logger16+from asc_op_compile_base.common.utils import log as logger
17-from opc import OpcOptionParser17+from opc import OpcOptionParser
18-from op_compilation import OpCompilation18+from op_compilation import OpCompilation
19-from op_info_store import load_op_info_store19+from op_info_store import load_op_info_store
20-from constant import (OpcOptions, OpcCompileMode)20+from constant import (OpcOptions, OpcCompileMode)
21- 21+ 
22- 22+ 
23-def compile_op(op_params, build_options):23+def compile_op(op_params, build_options):
24- """24+ """
25- Provides API compile operator for external callers.25+ Provides API compile operator for external callers.
26- """26+ """
27- opt_parser = OpcOptionParser()27+ opt_parser = OpcOptionParser()
28- res = opt_parser.parse_build_options(build_options)28+ res = opt_parser.parse_build_options(build_options)
29- if not res:29+ if not res:
30- logger.error("parse_build_options is failed.")30+ logger.error("parse_build_options is failed.")
31- opt_parser.set_option(OpcOptions.OP_COMPILE_MODE, OpcCompileMode.SINGLE_OP_DICT_MODE)31+ opt_parser.set_option(OpcOptions.OP_COMPILE_MODE, OpcCompileMode.SINGLE_OP_DICT_MODE)
32- 32+ 
33- if not opt_parser.check_input_params():33+ if not opt_parser.check_input_params():
34- logger.error("Opc tool compile failed.")34+ logger.error("Opc tool compile failed.")
35- return False35+ return False
36- 36+ 
37- load_op_info_store(opt_parser.get_option(OpcOptions.SOC_VERSION))37+ load_op_info_store(opt_parser.get_option(OpcOptions.SOC_VERSION))
38- opt_parser.set_option(OpcOptions.OP_PARAMS, op_params)38+ opt_parser.set_option(OpcOptions.OP_PARAMS, op_params)
39- op_compile = OpCompilation(opt_parser.get_all_options())39+ op_compile = OpCompilation(opt_parser.get_all_options())
40- if op_compile.op_compilation():40+ if op_compile.op_compilation():
41- logger.info("Opc tool compile success.")41+ logger.info("Opc tool compile success.")
42- return True42+ return True
43- else:43+ else:
44- logger.error("Opc tool compile failed.")44+ logger.error("Opc tool compile failed.")
45- return False45+ return False
Mtools/build/asc_opc/python/asc_opc_tool/opc_common.py+0-0文件内容审核中,请稍后刷新重试
@@ -1,39 +1,39 @@
1-#!/usr/bin/env python1+#!/usr/bin/env python
2-# -*- coding: UTF-8 -*-2+# -*- coding: UTF-8 -*-
3-# ----------------------------------------------------------------------------------------------------------3+# ----------------------------------------------------------------------------------------------------------
4-# Copyright (c) 2025 Huawei Technologies Co., Ltd.4+# Copyright (c) 2025 Huawei Technologies Co., Ltd.
5-# This program is free software, you can redistribute it and/or modify it under the terms and conditions of5+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
6-# CANN Open Software License Agreement Version 2.0 (the "License").6+# CANN Open Software License Agreement Version 2.0 (the "License").
7-# Please refer to the License for details. You may not use this file except in compliance with the License.7+# Please refer to the License for details. You may not use this file except in compliance with the License.
8-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,8+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
9-# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.9+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
10-# See LICENSE in the root of the software repository for the full text of the License.10+# See LICENSE in the root of the software repository for the full text of the License.
11-# ----------------------------------------------------------------------------------------------------------11+# ----------------------------------------------------------------------------------------------------------
12-"""12+"""
13-Setup opc package13+Setup opc package
14-"""14+"""
15-import sys15+import sys
16- 16+ 
17-from setuptools import find_packages17+from setuptools import find_packages
18- 18+ 
19-# need to use distutils.core for correct placement of cython dll19+# need to use distutils.core for correct placement of cython dll
20-if "--inplace" in sys.argv:20+if "--inplace" in sys.argv:
21- from distutils.core import setup21+ from distutils.core import setup
22- from distutils.extension import Extension22+ from distutils.extension import Extension
23-else:23+else:
24- from setuptools import setup24+ from setuptools import setup
25- from setuptools.extension import Extension25+ from setuptools.extension import Extension
26- 26+ 
27- 27+ 
28-setup(name='asc_opc_tool',28+setup(name='asc_opc_tool',
29- version='0.1.0',29+ version='0.1.0',
30- description="asc_opc_tool: asc op complication tool",30+ description="asc_opc_tool: asc op complication tool",
31- zip_safe=False,31+ zip_safe=False,
32- install_requires=[32+ install_requires=[
33- 'numpy',33+ 'numpy',
34- 'decorator',34+ 'decorator',
35- 'attrs',35+ 'attrs',
36- 'psutil',36+ 'psutil',
37- ],37+ ],
38- packages=find_packages())38+ packages=find_packages())
39- 39+ 
@@ -8,6 +8,7 @@ target_link_libraries(ascendc_pack_kernel PRIVATE
8target_compile_options(ascendc_pack_kernel PRIVATE8target_compile_options(ascendc_pack_kernel PRIVATE
9 -fpie9 -fpie
10 -fstack-protector-all10 -fstack-protector-all
11+ -Werror
11)12)
12 13 
13target_link_options(ascendc_pack_kernel PRIVATE14target_link_options(ascendc_pack_kernel PRIVATE
@@ -11,34 +11,25 @@ add_library(ascend_runtime_base OBJECT ascendc_runtime.cpp aicpu_rt.cpp)
11 11 
12if(BUILD_OPEN_PROJECT)12if(BUILD_OPEN_PROJECT)
13 target_include_directories(ascend_runtime_base PRIVATE13 target_include_directories(ascend_runtime_base PRIVATE
14- ${ASCEND_CANN_PACKAGE_PATH}/include/base
15- ${ASCEND_CANN_PACKAGE_PATH}/pkg_inc/base
16 ${ASCEND_CANN_PACKAGE_PATH}/pkg_inc/runtime14 ${ASCEND_CANN_PACKAGE_PATH}/pkg_inc/runtime
17- ${ASCEND_CANN_PACKAGE_PATH}/pkg_inc/runtime/runtime
18 ${ASCEND_CANN_PACKAGE_PATH}/pkg_inc/profiling15 ${ASCEND_CANN_PACKAGE_PATH}/pkg_inc/profiling
19 ${ASCEND_CANN_PACKAGE_PATH}/pkg_inc16 ${ASCEND_CANN_PACKAGE_PATH}/pkg_inc
20- ${ASCEND_CANN_PACKAGE_PATH}/include/ge
21- ${ASCEND_CANN_PACKAGE_PATH}/include
22 ${ASCEND_CANN_PACKAGE_PATH}/include/acl17 ${ASCEND_CANN_PACKAGE_PATH}/include/acl
23- ${CMAKE_CURRENT_SOURCE_DIR}/../../../include18+ ${ASCEND_CANN_PACKAGE_PATH}/include
24 ${CMAKE_CURRENT_SOURCE_DIR}/../common19 ${CMAKE_CURRENT_SOURCE_DIR}/../common
25 )20 )
26else()21else()
27 target_include_directories(ascend_runtime_base PRIVATE22 target_include_directories(ascend_runtime_base PRIVATE
28- ${TOP_DIR}/ace/npuruntime/inc/runtime/23+ ${TOP_DIR}/runtime/include/external
24+ ${TOP_DIR}/runtime/include/external/acl
29 ${TOP_DIR}/ace/npuruntime/inc/25 ${TOP_DIR}/ace/npuruntime/inc/
30- ${TOP_DIR}/ace/npuruntime/acl/inc/external/
31 ${TOP_DIR}/metadef/inc26 ${TOP_DIR}/metadef/inc
32 ${TOP_DIR}/metadef/inc/external/27 ${TOP_DIR}/metadef/inc/external/
33 ${TOP_DIR}/abl/msprof/inc28 ${TOP_DIR}/abl/msprof/inc
34- ${TOP_DIR}/abl/msprof/inc/toolchain
35 ${TOP_DIR}/abl/libc_sec/include29 ${TOP_DIR}/abl/libc_sec/include
36 ${TOP_DIR}/abl/mmpa/inc30 ${TOP_DIR}/abl/mmpa/inc
37 ${TOP_DIR}/abl/slog/inc/toolchain31 ${TOP_DIR}/abl/slog/inc/toolchain
38 ${TOP_DIR}/asc/asc-devkit/tools/build/common32 ${TOP_DIR}/asc/asc-devkit/tools/build/common
39- ${TOP_DIR}/asc/asc-devkit/include
40- ${TOP_DIR}/runtime/include/external/acl
41- ${TOP_DIR}/runtime/include/external
42 )33 )
43endif()34endif()
44 35 
@@ -47,12 +38,13 @@ target_compile_options(ascend_runtime_base PRIVATE
47 -Wfloat-equal38 -Wfloat-equal
48 -fvisibility-inlines-hidden39 -fvisibility-inlines-hidden
49 -fvisibility=hidden40 -fvisibility=hidden
41+ -Werror
50)42)
51 43 
52target_link_libraries(ascend_runtime_base PRIVATE44target_link_libraries(ascend_runtime_base PRIVATE
53 $<BUILD_INTERFACE:intf_pub>45 $<BUILD_INTERFACE:intf_pub>
54 mmpa46 mmpa
55- alog47+ unified_dlog
56 $<$<BOOL:${BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG}>:acl_rt>48 $<$<BOOL:${BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG}>:acl_rt>
57 $<$<NOT:$<BOOL:${BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG}>>:ascendcl>49 $<$<NOT:$<BOOL:${BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG}>>:ascendcl>
58)50)
@@ -17,29 +17,14 @@
17#include <utility>17#include <utility>
18#include <cstdint>18#include <cstdint>
19#include <mutex>19#include <mutex>
20-#include <functional>
21#include <unordered_set>20#include <unordered_set>
22-#include <iostream>
23#include <unordered_map>21#include <unordered_map>
22+#include <string>
24 23 
25-#include <string.h>24+#include "runtime/rt_ffts.h"
26-#include <sys/types.h>
27-#include <stdlib.h>
28-#include <stdio.h>
29- 
30-#include "runtime/context.h"
31-#include "runtime/base.h"
32#include "runtime/kernel.h"25#include "runtime/kernel.h"
33-#include "runtime/stream.h"
34-#include "rt_ffts.h"
35-#include "kernel.h"
36-#include "aprof_pub.h"
37-#include "mmpa/mmpa_api.h"
38-#include "acl/acl_rt.h"
39-#include "mem.h"
40-#include "ascendc_tool_log.h"
41#include "acl_rt.h"26#include "acl_rt.h"
42-#include "acl/acl_base.h"27+#include "ascendc_tool_log.h"
43 28 
44#ifdef __cplusplus29#ifdef __cplusplus
45extern "C" {30extern "C" {
@@ -80,6 +65,8 @@ bool AscendCheckSoCVersion(const char *socVersion, char *errMsg)
80 {"ascend910_957b", "ascend910_95"},65 {"ascend910_957b", "ascend910_95"},
81 {"ascend910_957c", "ascend910_95"},66 {"ascend910_957c", "ascend910_95"},
82 {"ascend910_957d", "ascend910_95"},67 {"ascend910_957d", "ascend910_95"},
68+ {"ascend910_950x", "ascend910_95"},
69+ {"ascend910_950y", "ascend910_95"},
83 {"ascend910_950z", "ascend910_95"},70 {"ascend910_950z", "ascend910_95"},
84 {"ascend910_958a", "ascend910_95"},71 {"ascend910_958a", "ascend910_95"},
85 {"ascend910_95a1", "ascend910_95"},72 {"ascend910_95a1", "ascend910_95"},
@@ -125,7 +112,7 @@ bool AscendCheckSoCVersion(const char *socVersion, char *errMsg)
125 {"ascend310b3", "ascend310b"},112 {"ascend310b3", "ascend310b"},
126 {"ascend310b4", "ascend310b"},113 {"ascend310b4", "ascend310b"},
127 {"kirinx90", "kirinx90"},114 {"kirinx90", "kirinx90"},
128- {"kirin9030", "kirin9030"},115+ {"kirin9030", "kirin9030"}
129 };116 };
130 117 
131 static const std::unordered_map<std::string, std::string> ascendcOriSocVersionMap {118 static const std::unordered_map<std::string, std::string> ascendcOriSocVersionMap {
@@ -148,9 +135,11 @@ bool AscendCheckSoCVersion(const char *socVersion, char *errMsg)
148 {"ascend910_957b", "Ascend910_957b"},135 {"ascend910_957b", "Ascend910_957b"},
149 {"ascend910_957c", "Ascend910_957c"},136 {"ascend910_957c", "Ascend910_957c"},
150 {"ascend910_957d", "Ascend910_957d"},137 {"ascend910_957d", "Ascend910_957d"},
138+ {"ascend910_950x", "Ascend910_950x"},
139+ {"ascend910_950y", "Ascend910_950y"},
151 {"ascend910_950z", "Ascend910_950z"},140 {"ascend910_950z", "Ascend910_950z"},
152 {"ascend910_958a", "Ascend910_958a"},141 {"ascend910_958a", "Ascend910_958a"},
153- {"ascend910_95a1", "ascend910_95A1"}, 142+ {"ascend910_95a1", "ascend910_95A1"},
154 {"ascend910_95a2", "ascend910_95A2"},143 {"ascend910_95a2", "ascend910_95A2"},
155 {"ascend910_9591", "ascend910_9591"},144 {"ascend910_9591", "ascend910_9591"},
156 {"ascend910_9592", "ascend910_9592"},145 {"ascend910_9592", "ascend910_9592"},
@@ -171,7 +160,7 @@ bool AscendCheckSoCVersion(const char *socVersion, char *errMsg)
171 {"ascend910_9575", "ascend910_9575"},160 {"ascend910_9575", "ascend910_9575"},
172 {"ascend910_9576", "ascend910_9576"},161 {"ascend910_9576", "ascend910_9576"},
173 {"ascend910_9577", "ascend910_9577"},162 {"ascend910_9577", "ascend910_9577"},
174- {"ascend910_9578", "ascend910_9578"}, 163+ {"ascend910_9578", "ascend910_9578"},
175 164 
176 {"ascend910a", "Ascend910A"},165 {"ascend910a", "Ascend910A"},
177 {"ascend910proa", "Ascend910ProA"},166 {"ascend910proa", "Ascend910ProA"},
@@ -193,7 +182,7 @@ bool AscendCheckSoCVersion(const char *socVersion, char *errMsg)
193 {"ascend310b3", "Ascend310B3"},182 {"ascend310b3", "Ascend310B3"},
194 {"ascend310b4", "Ascend310B4"},183 {"ascend310b4", "Ascend310B4"},
195 {"kirinx90", "KirinX90"},184 {"kirinx90", "KirinX90"},
196- {"kirin9030", "Kirin9030"},185+ {"kirin9030", "Kirin9030"}
197 };186 };
198 187 
199 std::string compileSocVersion = std::string(socVersion);188 std::string compileSocVersion = std::string(socVersion);
@@ -228,6 +217,39 @@ bool AscendCheckSoCVersion(const char *socVersion, char *errMsg)
228 }217 }
229 return true;218 return true;
230}219}
220+ 
221+int32_t AscendDevBinaryLazyRegister(const char* binBuf, size_t binSize, void** handle)
222+{
223+ constexpr uint32_t optLen = 2;
224+ aclrtBinaryLoadOption opList[optLen] = {
225+ {ACL_RT_BINARY_LOAD_OPT_LAZY_MAGIC, {ACL_RT_BINARY_MAGIC_ELF_AICORE}},
226+ {ACL_RT_BINARY_LOAD_OPT_LAZY_LOAD, {/* isLazyLoad = */1}}
227+ };
228+ aclrtBinaryLoadOptions opts = {opList, optLen};
229+ return aclrtBinaryLoadFromData(binBuf, binSize, &opts, handle);
230+}
231+ 
232+int32_t AscendGetFuncFromBinary(void* const binHandle, const char* kernelName, void** funcHandle)
233+{
234+ return aclrtBinaryGetFunction(binHandle, kernelName, funcHandle);
235+}
236+ 
237+int32_t AscendLaunchKernelWithHostArgs(void* funcHandle,
238+ uint32_t blockDim, void* stream, void* hostArgs, size_t argsSize, uint32_t ubufDynamicSize)
239+{
240+ if (ubufDynamicSize == 0) {
241+ return aclrtLaunchKernelWithHostArgs(funcHandle, blockDim, stream, nullptr, hostArgs, argsSize, nullptr, 0);
242+ }
243+ constexpr uint32_t attrLen = 1;
244+ aclrtLaunchKernelAttrValue attrValue = {0};
245+ attrValue.localMemorySize = ubufDynamicSize;
246+ aclrtLaunchKernelAttr attrList[attrLen] = {
247+ {static_cast<aclrtLaunchKernelAttrId>(2)/* ACL_RT_LAUNCH_KERNEL_ATTR_LOCAL_MEMORY_SIZE */, attrValue},
248+ };
249+ aclrtLaunchKernelCfg cfg = {attrList, attrLen};
250+ return aclrtLaunchKernelWithHostArgs(funcHandle, blockDim, stream, &cfg, hostArgs, argsSize, nullptr, 0);
251+}
252+ 
231uint32_t RegisterAscendBinary(const char *fileBuf, size_t fileSize, uint32_t type, void **handle)253uint32_t RegisterAscendBinary(const char *fileBuf, size_t fileSize, uint32_t type, void **handle)
232{254{
233 rtDevBinary_t binary;255 rtDevBinary_t binary;
@@ -283,7 +305,7 @@ uint32_t LaunchAscendKernel(void *handle, const uint64_t key, const uint32_t blo
283}305}
284 306 
285int32_t AscendKernelLaunchWithFlagV2(const char *stubFunc, const uint32_t blockDim, void **args, uint32_t size,307int32_t AscendKernelLaunchWithFlagV2(const char *stubFunc, const uint32_t blockDim, void **args, uint32_t size,
286- const rtStream_t stream)308+ const rtStream_t stream, const uint32_t ubufDynamicSize)
287{309{
288 rtArgsEx_t argsInfo = {310 rtArgsEx_t argsInfo = {
289 .args = nullptr,311 .args = nullptr,
@@ -297,6 +319,11 @@ int32_t AscendKernelLaunchWithFlagV2(const char *stubFunc, const uint32_t blockD
297 .reserved = {0, 0, 0, 0}};319 .reserved = {0, 0, 0, 0}};
298 argsInfo.args = static_cast<void*>(args);320 argsInfo.args = static_cast<void*>(args);
299 argsInfo.argsSize = size;321 argsInfo.argsSize = size;
322+ if (ubufDynamicSize > 0) {
323+ rtTaskCfgInfo_t cfgInfo{};
324+ cfgInfo.localMemorySize = ubufDynamicSize;
325+ return rtKernelLaunchWithFlagV2(stubFunc, blockDim, &argsInfo, nullptr, stream, 0, &cfgInfo);
326+ }
300 return rtKernelLaunchWithFlagV2(stubFunc, blockDim, &argsInfo, nullptr, stream, 0, nullptr);327 return rtKernelLaunchWithFlagV2(stubFunc, blockDim, &argsInfo, nullptr, stream, 0, nullptr);
301}328}
302 329 
@@ -444,20 +471,22 @@ void ReportAscendProf(const char *name, uint32_t blockDim, uint32_t taskType, co
444 471 
445uint32_t AllocAscendMemDevice(void **devMem, uint64_t size)472uint32_t AllocAscendMemDevice(void **devMem, uint64_t size)
446{473{
447- const rtError_t rtErr = rtMalloc(devMem, size, RT_MEMORYINFO_HBM_HUGE, 0);474+ constexpr aclrtMemMallocPolicy policy =
475+ static_cast<aclrtMemMallocPolicy>(ACL_MEM_MALLOC_HUGE_ONLY | ACL_MEM_TYPE_HIGH_BAND_WIDTH);
476+ const aclError rtErr = aclrtMalloc(devMem, size, policy);
448 if (rtErr != 0) {477 if (rtErr != 0) {
449 ASCENDLOGE(" alloc device memory failed, runtime result = %d\n", rtErr);478 ASCENDLOGE(" alloc device memory failed, runtime result = %d\n", rtErr);
450- return rtErr;479+ return static_cast<uint32_t>(rtErr);
451 }480 }
452 return 0;481 return 0;
453}482}
454 483 
455uint32_t FreeAscendMemDevice(void *devMem)484uint32_t FreeAscendMemDevice(void *devMem)
456{485{
457- const rtError_t rtErr = aclrtFree(devMem);486+ const aclError rtErr = aclrtFree(devMem);
458 if (rtErr != 0) {487 if (rtErr != 0) {
459 ASCENDLOGE(" free device memory failed, runtime result = %d\n", rtErr);488 ASCENDLOGE(" free device memory failed, runtime result = %d\n", rtErr);
460- return rtErr;489+ return static_cast<uint32_t>(rtErr);
461 }490 }
462 return 0;491 return 0;
463}492}
@@ -686,6 +715,117 @@ uint32_t GetCoreNumForMixVectorCore(uint32_t *aiCoreNum, uint32_t *vectorCoreNum
686 return 0;715 return 0;
687}716}
688 717 
718+typedef struct {
719+ unsigned int ktype;
720+} AscendCFunMetaKType;
721+ 
722+typedef struct {
723+ unsigned short taskRation0;
724+ unsigned short taskRation1;
725+} AscendCFunMetaMixCoreType;
726+ 
727+uint32_t AscendCFunctionGetMetaInfoKtype(const rtFuncHandle funcHandle, unsigned int *kernelType)
728+{
729+ uint64_t data;
730+ const rtError_t rtErr = rtFunctionGetMetaInfo(funcHandle, RT_FUNCTION_TYPE_KERNEL_TYPE, &data, sizeof(unsigned int));
731+ if (rtErr != 0) {
732+ ASCENDLOGE(" get function meta info ktype failed, runtime result = %d\n", rtErr);
733+ return rtErr;
734+ }
735+ AscendCFunMetaKType* metaKtype = reinterpret_cast<AscendCFunMetaKType*>(data);
736+ *kernelType = metaKtype->ktype;
737+ return 0;
738+}
739+ 
740+uint32_t AscendCFunctionGetMetaInfoCoreRation(const rtFuncHandle funcHandle, unsigned short *aicRation,
741+ unsigned short *aivRation)
742+{
743+ uint64_t data;
744+ const rtError_t rtErr = rtFunctionGetMetaInfo(funcHandle, RT_FUNCTION_TYPE_MIX_TASK_RATION, &data,
745+ sizeof(unsigned int));
746+ if (rtErr != 0) {
747+ ASCENDLOGE(" get function meta info core ration failed, runtime result = %d\n", rtErr);
748+ return rtErr;
749+ }
750+ AscendCFunMetaMixCoreType* mixration = reinterpret_cast<AscendCFunMetaMixCoreType*>(data);
751+ *aicRation = mixration->taskRation0;
752+ *aivRation = mixration->taskRation1;
753+ return 0;
754+}
755+ 
756+typedef enum KernelType : unsigned int {
757+ K_TYPE_AICORE = 1,
758+ K_TYPE_AIC = 2,
759+ K_TYPE_AIV = 3,
760+ K_TYPE_MIX_AIC_MAIN = 4,
761+ K_TYPE_MIX_AIV_MAIN = 5,
762+ K_TYPE_AIC_ROLLBACK = 6,
763+ K_TYPE_AIV_ROLLBACK = 7,
764+ K_TYPE_MAX
765+} KernelTypeAsc;
766+ 
767+enum KernelMetaTypeAsc {
768+ KERNEL_TYPE_AIV_ONLY = 0,
769+ KERNEL_TYPE_AIC_ONLY = 1,
770+ KERNEL_TYPE_MIX_AIV_1_0 = 2,
771+ KERNEL_TYPE_MIX_AIC_1_0 = 3,
772+ KERNEL_TYPE_MIX_AIC_1_1 = 4,
773+ KERNEL_TYPE_MIX_AIC_1_2 = 5,
774+ KERNEL_TYPE_AICORE = 6
775+};
776+ 
777+uint32_t AscendCGetProfkTypeImpl(const rtFuncHandle funcHandle)
778+{
779+ static const std::unordered_map<KernelMetaTypeAsc, uint32_t> kernelTaskTypeMap = {
780+ {KERNEL_TYPE_AICORE, 2},
781+ {KERNEL_TYPE_AIV_ONLY, 5},
782+ {KERNEL_TYPE_AIC_ONLY, 6},
783+ {KERNEL_TYPE_MIX_AIV_1_0, 7},
784+ {KERNEL_TYPE_MIX_AIC_1_0, 8},
785+ {KERNEL_TYPE_MIX_AIC_1_1, 9},
786+ {KERNEL_TYPE_MIX_AIC_1_2, 10}
787+ };
788+ unsigned int curKernelType;
789+ uint32_t ret = AscendCFunctionGetMetaInfoKtype(funcHandle, &curKernelType);
790+ if (ret != 0) {
791+ ASCENDLOGE(" AscendCFunctionGetMetaInfoKtype failure! ret %d \n", ret);
792+ return 5; // 5 is KERNEL_TYPE_AIV_ONLY
793+ }
794+ if (curKernelType == K_TYPE_MIX_AIC_MAIN || curKernelType == K_TYPE_MIX_AIV_MAIN) {
795+ unsigned short coreAicRation;
796+ unsigned short coreAivRation;
797+ uint32_t res = AscendCFunctionGetMetaInfoCoreRation(funcHandle, &coreAicRation, &coreAivRation);
798+ if (res != 0) {
799+ ASCENDLOGE(" AscendCFunctionGetMetaInfoCoreRation failure! ret %d \n", ret);
800+ return 5; // 5 is KERNEL_TYPE_AIV_ONLY
801+ }
802+ if (curKernelType == K_TYPE_MIX_AIV_MAIN && coreAicRation == 0 && coreAivRation == 1) {
803+ return kernelTaskTypeMap.at(KERNEL_TYPE_MIX_AIV_1_0);
804+ }
805+ if (curKernelType == K_TYPE_MIX_AIC_MAIN) {
806+ if (coreAicRation == 1 && coreAivRation == 0) {
807+ return kernelTaskTypeMap.at(KERNEL_TYPE_MIX_AIC_1_0);
808+ }
809+ if (coreAicRation == 1 && coreAivRation == 1) {
810+ return kernelTaskTypeMap.at(KERNEL_TYPE_MIX_AIC_1_1);
811+ }
812+ if (coreAicRation == 1 && coreAivRation == 2) { // aic num 1, aiv num 2
813+ return kernelTaskTypeMap.at(KERNEL_TYPE_MIX_AIC_1_2);
814+ }
815+ }
816+ } else if (curKernelType == K_TYPE_AIC || curKernelType == K_TYPE_AIC_ROLLBACK) {
817+ return kernelTaskTypeMap.at(KERNEL_TYPE_AIC_ONLY);
818+ } else if (curKernelType == K_TYPE_AIV || curKernelType == K_TYPE_AIV_ROLLBACK) {
819+ return kernelTaskTypeMap.at(KERNEL_TYPE_AIV_ONLY);
820+ } else if (curKernelType == K_TYPE_AICORE) {
821+ return kernelTaskTypeMap.at(KERNEL_TYPE_AICORE);
822+ } else {
823+ ASCENDLOGE(" Get unsupported kernel Type %d \n", curKernelType);
824+ return 5; // 5 is KERNEL_TYPE_AIV_ONLY
825+ }
826+ return 5; // 5 is KERNEL_TYPE_AIV_ONLY
827+}
828+ 
689#ifdef __cplusplus829#ifdef __cplusplus
690}830}
691#endif831#endif
@@ -49,6 +49,7 @@ extern "C" {
49#endif49#endif
50 50 
51using rtStream_t = void*;51using rtStream_t = void*;
52+using rtFuncHandle = void*;
52extern "C" void ReportAscendProf(const char *name, uint32_t blockDim, uint32_t taskType, const uint64_t startTime);53extern "C" void ReportAscendProf(const char *name, uint32_t blockDim, uint32_t taskType, const uint64_t startTime);
53extern "C" uint32_t AllocAscendMemDevice(void **devMem, uint64_t size);54extern "C" uint32_t AllocAscendMemDevice(void **devMem, uint64_t size);
54extern "C" uint32_t FreeAscendMemDevice(void *devMem);55extern "C" uint32_t FreeAscendMemDevice(void *devMem);
@@ -61,6 +62,15 @@ extern "C" bool AscendCheckSoCVersion(const char *socVersion, char *errMsg);
61extern "C" uint32_t GetCoreNumForMixVectorCore(uint32_t *aiCoreNum, uint32_t *vectorCoreNum);62extern "C" uint32_t GetCoreNumForMixVectorCore(uint32_t *aiCoreNum, uint32_t *vectorCoreNum);
62extern "C" int32_t AscendDevBinaryRegister(const void *fileBuf, size_t fileSize, void **handle);63extern "C" int32_t AscendDevBinaryRegister(const void *fileBuf, size_t fileSize, void **handle);
63extern "C" int32_t AscendFunctionRegister(void *handle, const char *stubFunc);64extern "C" int32_t AscendFunctionRegister(void *handle, const char *stubFunc);
64-extern "C" int32_t AscendKernelLaunchWithFlagV2(const char *stubFunc, const uint32_t blockDim, void **args, uint32_t size,65+extern "C" int32_t AscendKernelLaunchWithFlagV2(const char *stubFunc, const uint32_t blockDim, void **args,
65- const rtStream_t stream);66+ uint32_t size, const rtStream_t stream, const uint32_t ubufDynamicSize);
67+extern "C" int32_t AscendDevBinaryLazyRegister(const char* binBuf, size_t binSize, void** handle);
68+extern "C" int32_t AscendGetFuncFromBinary(void* const binHandle, const char* kernelName, void** funcHandle);
69+extern "C" int32_t AscendLaunchKernelWithHostArgs(void* funcHandle,
70+ uint32_t blockDim, void* stream, void* hostArgs, size_t argsSize, uint32_t ubufDynamicSize);
71+extern "C" uint32_t AscendCFunctionGetMetaInfoKtype(const rtFuncHandle funcHandle, unsigned int *kernelType);
72+extern "C" uint32_t AscendCFunctionGetMetaInfoCoreRation(const rtFuncHandle funcHandle, unsigned short *aicRation,
73+ unsigned short *aivRation);
74+extern "C" uint32_t AscendCGetProfkTypeImpl(const rtFuncHandle funcHandle);
75+ 
66#endif // __ASCENDC_RUNTIME_H__76#endif // __ASCENDC_RUNTIME_H__
@@ -16,41 +16,33 @@
16#include <inttypes.h>16#include <inttypes.h>
17#include "mmpa/mmpa_api.h"17#include "mmpa/mmpa_api.h"
18#include "external/ge_common/ge_api_error_codes.h"18#include "external/ge_common/ge_api_error_codes.h"
19-#include "alog_pub.h"19+#include "dlog_pub.h"
20 20 
21#define ASCENDC_MODULE_NAME static_cast<int32_t>(ASCENDCKERNEL)21#define ASCENDC_MODULE_NAME static_cast<int32_t>(ASCENDCKERNEL)
22 22 
23#if !(defined(UT_TEST) || defined(ST_TEST))23#if !(defined(UT_TEST) || defined(ST_TEST))
24-#define ASCENDLOGE(format, ...) \24+#define ASCENDLOGE(format, ...) \
25- do { \25+ do { \
26- if (AlogCheckDebugLevel(ASCENDC_MODULE_NAME, DLOG_ERROR) == 1) { \26+ dlog_error(ASCENDC_MODULE_NAME, " %d [%s:%d][%s]" format "\n", mmGetTid(), \
27- AlogRecord(ASCENDC_MODULE_NAME, DLOG_TYPE_DEBUG, DLOG_ERROR, " %d [%s:%d][%s]" format "\n", mmGetTid(), \27+ __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
28- __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
29- } \
30 } while (0)28 } while (0)
31 29 
32-#define ASCENDLOGW(format, ...) \30+#define ASCENDLOGW(format, ...) \
33- do { \31+ do { \
34- if (AlogCheckDebugLevel(ASCENDC_MODULE_NAME, DLOG_WARN) == 1) { \32+ dlog_warn(ASCENDC_MODULE_NAME, " %d [%s:%d][%s]" format "\n", mmGetTid(), \
35- AlogRecord(ASCENDC_MODULE_NAME, DLOG_TYPE_DEBUG, DLOG_WARN, " %d [%s:%d][%s]" format "\n", mmGetTid(), \33+ __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
36- __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
37- } \
38 } while (0)34 } while (0)
39 35 
40-#define ASCENDLOGI(format, ...) \36+#define ASCENDLOGI(format, ...) \
41- do { \37+ do { \
42- if (AlogCheckDebugLevel(ASCENDC_MODULE_NAME, DLOG_INFO) == 1) { \38+ dlog_info(ASCENDC_MODULE_NAME, " %d [%s:%d][%s]" format "\n", mmGetTid(), \
43- AlogRecord(ASCENDC_MODULE_NAME, DLOG_TYPE_DEBUG, DLOG_INFO, " %d [%s:%d][%s]" format "\n", mmGetTid(), \39+ __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
44- __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
45- } \
46 } while (0)40 } while (0)
47 41 
48-#define ASCENDLOGD(format, ...) \42+#define ASCENDLOGD(format, ...) \
49- do { \43+ do { \
50- if (AlogCheckDebugLevel(ASCENDC_MODULE_NAME, DLOG_DEBUG) == 1) { \44+ dlog_debug(ASCENDC_MODULE_NAME, " %d [%s:%d][%s]" format "\n", mmGetTid(), \
51- AlogRecord(ASCENDC_MODULE_NAME, DLOG_TYPE_DEBUG, DLOG_DEBUG, " %d [%s:%d][%s]" format "\n", mmGetTid(), \45+ __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
52- __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
53- } \
54 } while (0)46 } while (0)
55#else47#else
56#define ASCENDLOGE48#define ASCENDLOGE
@@ -12,6 +12,7 @@ add_library(elf_tool_obj OBJECT ascendc_elf_tool.c)
12target_compile_options(elf_tool_obj PRIVATE12target_compile_options(elf_tool_obj PRIVATE
13 -Wextra13 -Wextra
14 -Wfloat-equal14 -Wfloat-equal
15+ -Werror
15 )16 )
16 17 
17if(BUILD_OPEN_PROJECT)18if(BUILD_OPEN_PROJECT)
The file is empty
The file is empty
@@ -1,5 +0,0 @@
1-set(CMAKE_AICPU_COMPILER "@CMAKE_AICPU_COMPILER@")
2-set(CMAKE_AICPU_COMPILER_LOADED 1)
3-set(CMAKE_AICPU_SOURCE_FILE_EXTENSIONS @CMAKE_AICPU_SOURCE_FILE_EXTENSIONS@)
4-set(CMAKE_AICPU_OUTPUT_EXTENSION @CMAKE_AICPU_OUTPUT_EXTENSION@)
5-set(CMAKE_AICPU_COMPILER_ENV_VAR "@CMAKE_AICPU_COMPILER_ENV_VAR@")
@@ -1 +0,0 @@
1-set(CMAKE_AICPU_COMPILER_WORKS 1 CACHE INTERNAL "")
@@ -15,11 +15,12 @@ import json
15from pathlib import Path15from pathlib import Path
16import inspect16import inspect
17import sys17import sys
18+import os
18 19 
19 20 
20def extract_info_lines(filename):21def extract_info_lines(filename):
21 matching_lines = []22 matching_lines = []
22- 23+ 
23 try:24 try:
24 with open(filename, 'r', encoding='utf-8') as file:25 with open(filename, 'r', encoding='utf-8') as file:
25 for line in file:26 for line in file:
@@ -53,7 +54,7 @@ def extract_info_lines(filename):
53 raise RuntimeError(f"INFO: {frame.f_code.co_filename}:line {frame.f_lineno}: No log starting with [INFO] "54 raise RuntimeError(f"INFO: {frame.f_code.co_filename}:line {frame.f_lineno}: No log starting with [INFO] "
54 "ASC was found.Please check if the log file is empty or if the ASCEND_GLOBAL_EVENT_ENABLE"55 "ASC was found.Please check if the log file is empty or if the ASCEND_GLOBAL_EVENT_ENABLE"
55 " environment variable for controlling the compilation time stamp is not set to 1. ")56 " environment variable for controlling the compilation time stamp is not set to 1. ")
56- 57+ 
57 return matching_lines58 return matching_lines
58 59 
59 60 
@@ -103,7 +104,7 @@ def build_traceEvents(len_pid, optype, trace_events, timestamp, pid, tid, tiling
103 for i in range(len_pid):104 for i in range(len_pid):
104 num = int(i / 12) * 7# 除12是因为,打12个时间点,只有7个tiling信息105 num = int(i / 12) * 7# 除12是因为,打12个时间点,只有7个tiling信息
105 idx = i % 12106 idx = i % 12
106- if idx == 11: 107+ if idx == 11:
107 continue108 continue
108 if idx == 0:109 if idx == 0:
109 name = optype[num] + " compile op"110 name = optype[num] + " compile op"
@@ -115,11 +116,11 @@ def build_traceEvents(len_pid, optype, trace_events, timestamp, pid, tid, tiling
115 "ts": timestamp[i],116 "ts": timestamp[i],
116 "pid": pid[i],117 "pid": pid[i],
117 "tid": tid[i],118 "tid": tid[i],
118- "args": { 119+ "args": {
119- "tiling_key": tilingtype[num] 120+ "tiling_key": tilingtype[num]
120- } 121+ }
121 })122 })
122- last_i = i + 11 123+ last_i = i + 11
123 trace_events.append({124 trace_events.append({
124 "optype": optype[num],125 "optype": optype[num],
125 "name": name,126 "name": name,
@@ -146,7 +147,7 @@ def build_traceEvents(len_pid, optype, trace_events, timestamp, pid, tid, tiling
146def common_trace_event(trace_events, compile_stage, optype, timestamp, pid, tid, tilingtype):147def common_trace_event(trace_events, compile_stage, optype, timestamp, pid, tid, tilingtype):
147 name, stage = compile_stage.rsplit(' ', 1)148 name, stage = compile_stage.rsplit(' ', 1)
148 if (stage == "start"):149 if (stage == "start"):
149- trace_events.append({ 150+ trace_events.append({
150 "optype": optype,151 "optype": optype,
151 "name": name,152 "name": name,
152 "cat": "compile_op",153 "cat": "compile_op",
@@ -154,12 +155,12 @@ def common_trace_event(trace_events, compile_stage, optype, timestamp, pid, tid,
154 "ts": timestamp,155 "ts": timestamp,
155 "pid": pid,156 "pid": pid,
156 "tid": tid,157 "tid": tid,
157- "args": { 158+ "args": {
158 "tiling_key": tilingtype159 "tiling_key": tilingtype
159 }160 }
160 })161 })
161 if (stage == "end"):162 if (stage == "end"):
162- trace_events.append({ 163+ trace_events.append({
163 "optype": optype,164 "optype": optype,
164 "name": name,165 "name": name,
165 "cat": "compile_op",166 "cat": "compile_op",
@@ -168,12 +169,81 @@ def common_trace_event(trace_events, compile_stage, optype, timestamp, pid, tid,
168 "pid": pid,169 "pid": pid,
169 "tid": tid170 "tid": tid
170 })171 })
171- 172+ 
172 return trace_events173 return trace_events
173 174 
174 175 
176+def group_lines_by_first_number_flat(lines):
177+ grouped = {}
178+ pattern = re.compile(r'\bASC\(\s*(\d+)\s*,', re.IGNORECASE)
179+ 
180+ for line in lines:
181+ match = pattern.search(line)
182+ if match:
183+ first_num = int(match.group(1))
184+ else:
185+ first_num = None # 无法提取时用 None 表示
186+ 
187+ if first_num not in grouped:
188+ grouped[first_num] = []
189+ grouped[first_num].append(line)
190+ 
191+ # 按 first_number 从小到大排序(None 放最后)
192+ sorted_groups = sorted(grouped.items(), key=lambda x: x[0] if x[0] is not None else float('inf'))
193+ 
194+ # 将所有分组的行按顺序拼接成一个 flat 列表
195+ result = []
196+ for _, group_lines in sorted_groups:
197+ result.extend(group_lines) # 按顺序添加组内所有行
198+ 
199+ with open('datalog.txt', 'w', encoding='utf-8') as f:
200+ for item in result:
201+ f.write(f"{item}\n")
202+ 
203+ # 调用函数
204+ txtlist = []
205+ extract_lines_with_condition(txtlist, result)
206+ 
207+ return txtlist
208+ 
209+ 
210+def extract_lines_with_condition(txtlist, result):
211+ if os.path.exists("check_info.txt"):
212+ with open("check_info.txt", 'w', encoding='utf-8') as f:
213+ f.write("")
214+ 
215+ listline = []
216+ for line_num, line in enumerate(result):
217+ if 'compile op start ,' in line:
218+ listline.append(line_num)
219+ 
220+ #遍历相邻行号对,检查差值是否为12
221+ for i in range(len(listline) - 1):
222+ a = listline[i]
223+ b = listline[i + 1]
224+ 
225+ if b - a == 12:
226+ txtlist.extend(line.strip() for line in result[a:b])
227+ else:
228+ with open("check_info.txt", 'a', encoding='utf-8') as out_f:
229+ for content in result[a:b]:
230+ out_f.write(content + '\n')
231+ out_f.write('=======================================================================\n')
232+ if os.path.exists("check_info.txt") and os.path.getsize("check_info.txt") > 0:
233+ print(
234+ "[WARNING]: Some operator log reads failed.\n"
235+ "Failed operator details are in 'check_info.txt'.\n"
236+ "Please check if the operators are compiled correctly "
237+ "by referring to the operator names and original log files."
238+ )
239+ 
240+ 
241+ return txtlist
242+ 
243+ 
175def compile_trace(input_file, output_file):244def compile_trace(input_file, output_file):
176- matching_lines = extract_info_lines(input_file)245+ matching_lines_old = extract_info_lines(input_file)
246+ matching_lines = group_lines_by_first_number_flat(matching_lines_old)
177 pid = []247 pid = []
178 tid = []248 tid = []
179 timestamp = []249 timestamp = []
@@ -186,7 +256,7 @@ def compile_trace(input_file, output_file):
186 pid.append(p)256 pid.append(p)
187 #timestamp257 #timestamp
188 match = re.search(r'timestamp:\s*(\d+)ns', line)258 match = re.search(r'timestamp:\s*(\d+)ns', line)
189- ts = int(match.group(1))259+ ts = float(match.group(1)) / 1000000
190 timestamp.append(ts)260 timestamp.append(ts)
191 #tid261 #tid
192 match = re.search(r'\[tid:\s*(\d+)\]', line)262 match = re.search(r'\[tid:\s*(\d+)\]', line)
@@ -259,4 +329,3 @@ if __name__ == "__main__":
259 except Exception as e:329 except Exception as e:
260 print(f"{e}")330 print(f"{e}")
261 exit(1)331 exit(1)
262-