已合并
【PR】: 压缩so回退 #2761
guo-yanjun创建于 6月11日
【PR】: 压缩so回退 #2761
已合并
共 17 个文件变更+78-949
| @@ -215,4 +215,4 @@ dfx_error_manager: | |||
| 215 | unrelease: | 215 | unrelease: |
| 216 | llt: | 216 | llt: |
| 217 | ut_check: true | 217 | ut_check: true |
| 218 | - st_check: false | 218 | + st_check: false |
| @@ -1,401 +0,0 @@ | |||
| 1 | -#!/usr/bin/env python3 | ||
| 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 | -import os | ||
| 13 | -import re | ||
| 14 | -import sys | ||
| 15 | -import logging | ||
| 16 | -from enum import Enum | ||
| 17 | - | ||
| 18 | -ACL_RT_SET = {"acl_rt_impl.h"} | ||
| 19 | -ACL_MODEL_SET = set() | ||
| 20 | -ACL_OP_EXECUTOR_SET = set() | ||
| 21 | -WRAPPER_FILE_NAME = "acl_rt_wrapper.h" | ||
| 22 | -TARGET_WRAPPER_MAPS = ( | ||
| 23 | - "ACL_FUNC_MAP", | ||
| 24 | - "ACL_RT_FUNC_MAP", | ||
| 25 | - "ACL_MDLRI_FUNC_MAP", | ||
| 26 | - "ACL_MDL_FUNC_MAP", | ||
| 27 | - "ACL_RT_ALLOCATOR_FUNC_MAP", | ||
| 28 | -) | ||
| 29 | - | ||
| 30 | - | ||
| 31 | -def get_func_infos(func): | ||
| 32 | - pattern = (r'((?:(?:const|volatile|static)\s+)*\w+(?:\s*\*+\s*)?)' | ||
| 33 | - r'\s*(\w+)\s*\(' | ||
| 34 | - r'(\s*(?:(?:(?:(?:const|volatile|static)\s+)*\w+(?:\s*(?:\*+\s*)+)?)\s*\w+\s*' | ||
| 35 | - r'(?:\[[^\]]*?\])*(?:,[\s\.]*)?)*)\)') | ||
| 36 | - match = re.search(pattern, func) | ||
| 37 | - if match: | ||
| 38 | - return_type = match.group(1) | ||
| 39 | - func_name = match.group(2) | ||
| 40 | - params = match.group(3) | ||
| 41 | - | ||
| 42 | - if params == "void": | ||
| 43 | - param_names = [] | ||
| 44 | - else: | ||
| 45 | - param_pattern = r'\b(\w+)\s*(?:\[[^\]]*?\])*(?:,|$)' | ||
| 46 | - param_names = re.findall(param_pattern, params) | ||
| 47 | - return return_type, func_name, param_names | ||
| 48 | - else: | ||
| 49 | - logging.warning("No match func: %s", func) | ||
| 50 | - return None, None, None | ||
| 51 | - | ||
| 52 | -PATTERN_FUNCTION = re.compile(r'ACL_FUNC_VISIBILITY\s+\n*(.+\w+\([^();]*\);)') | ||
| 53 | - | ||
| 54 | -HANDLE_GET = '\n' \ | ||
| 55 | - 'std::string GetSoPath(const void *instance, std::string so_name)\n' \ | ||
| 56 | - '{\n' \ | ||
| 57 | - ' Dl_info dlInfo;\n' \ | ||
| 58 | - ' std::string realFilePath;\n' \ | ||
| 59 | - ' if (dladdr(instance, &dlInfo) == 0) {\n' \ | ||
| 60 | - ' printf("Call dladdr failed.\\n");\n' \ | ||
| 61 | - ' return realFilePath;\n' \ | ||
| 62 | - ' }\n' \ | ||
| 63 | - ' std::string soPath = dlInfo.dli_fname;\n' \ | ||
| 64 | - ' if (soPath.empty()) {\n' \ | ||
| 65 | - ' printf("So file path is empty.\\n");\n' \ | ||
| 66 | - ' return realFilePath;\n' \ | ||
| 67 | - ' }\n' \ | ||
| 68 | - ' char resolvedPath[PATH_MAX] = {0x00};\n' \ | ||
| 69 | - ' if (realpath(soPath.c_str(), resolvedPath) == NULL) {\n' \ | ||
| 70 | - ' printf("Got realpath failed, soPath is %s.\\n", soPath.c_str());\n' \ | ||
| 71 | - ' return realFilePath;\n' \ | ||
| 72 | - ' }\n' \ | ||
| 73 | - ' std::string soFilePath = resolvedPath;\n' \ | ||
| 74 | - ' std::string::size_type pos = soFilePath.rfind(\'/\');\n' \ | ||
| 75 | - ' if (pos == std::string::npos) {\n' \ | ||
| 76 | - ' printf("Invalid path %s, not contain /\\n", soFilePath.c_str());\n' \ | ||
| 77 | - ' return realFilePath;\n' \ | ||
| 78 | - ' }\n' \ | ||
| 79 | - ' realFilePath = soFilePath.substr(0, pos + 1);\n' \ | ||
| 80 | - ' return realFilePath + so_name;\n' \ | ||
| 81 | - '}\n' \ | ||
| 82 | - '\n' \ | ||
| 83 | - '\n' \ | ||
| 84 | - 'void *GetSoHandleAclRt() {\n' \ | ||
| 85 | - ' static void *dl_handle = dlopen(GetSoPath((void *)GetSoHandleAclRt, \ | ||
| 86 | -"libruntime.so").c_str(), RTLD_NOW | RTLD_GLOBAL);\n' \ | ||
| 87 | - ' if (!dl_handle) {\n' \ | ||
| 88 | - ' printf("Falied to dlopen libruntime.so, please check your install environment.\\n");\n' \ | ||
| 89 | - ' _exit(-1);\n' \ | ||
| 90 | - ' }\n' \ | ||
| 91 | - ' return dl_handle;\n' \ | ||
| 92 | - '}\n' \ | ||
| 93 | - '\n' \ | ||
| 94 | - '\n' \ | ||
| 95 | - 'void *GetSoHandleAclModel() {\n' \ | ||
| 96 | - ' static void *dl_handle = dlopen(GetSoPath((void *)GetSoHandleAclModel, \ | ||
| 97 | -"libacl_mdl.so").c_str(), RTLD_NOW | RTLD_GLOBAL);\n' \ | ||
| 98 | - ' if (!dl_handle) {\n' \ | ||
| 99 | - ' printf("Falied to dlopen libacl_mdl.so, please check your install environment.\\n");\n' \ | ||
| 100 | - ' _exit(-1);\n' \ | ||
| 101 | - ' }\n' \ | ||
| 102 | - ' return dl_handle;\n' \ | ||
| 103 | - '}\n' \ | ||
| 104 | - '\n' \ | ||
| 105 | - '\n' \ | ||
| 106 | - 'void *GetSoHandleAclOpExecutor() {\n' \ | ||
| 107 | - ' static void *dl_handle = dlopen(GetSoPath((void *)GetSoHandleAclOpExecutor, \ | ||
| 108 | -"libacl_op_executor.so").c_str(), RTLD_NOW | RTLD_GLOBAL);\n' \ | ||
| 109 | - ' if (!dl_handle) {\n' \ | ||
| 110 | - ' printf("Falied to dlopen libacl_op_executor.so, please check your install environment.\\n");\n' \ | ||
| 111 | - ' _exit(-1);\n' \ | ||
| 112 | - ' }\n' \ | ||
| 113 | - ' return dl_handle;\n' \ | ||
| 114 | - '}\n' \ | ||
| 115 | - '\n' \ | ||
| 116 | - '#define ASSERT_SOHANDLE_VALID(handle)\\\n' \ | ||
| 117 | - 'if (!handle) {\\\n' \ | ||
| 118 | - ' printf("handle for \'%s\' is null.\\n", __FUNCTION__);\\\n' \ | ||
| 119 | - ' _exit(-1);\\\n' \ | ||
| 120 | - '}\n' | ||
| 121 | - | ||
| 122 | - | ||
| 123 | -class PathType(Enum): | ||
| 124 | - RUNTIME_INC = 1 | ||
| 125 | - GE_INC = 2 | ||
| 126 | - | ||
| 127 | - | ||
| 128 | -def collect_header_files(path, path_type): | ||
| 129 | - """input path,return relevant header files""" | ||
| 130 | - acl_headers = [] | ||
| 131 | - for root, _, files in os.walk(path): | ||
| 132 | - files.sort() | ||
| 133 | - for file in files: | ||
| 134 | - file_name = file.split("/")[-1] | ||
| 135 | - if path_type == PathType.RUNTIME_INC and file_name in ACL_RT_SET: | ||
| 136 | - file_path = os.path.join(root, file) | ||
| 137 | - file_path = file_path.replace('\\', '/') | ||
| 138 | - acl_headers.append(file_path) | ||
| 139 | - elif path_type == PathType.GE_INC and (file_name in ACL_MODEL_SET or file_name in ACL_OP_EXECUTOR_SET): | ||
| 140 | - file_path = os.path.join(root, file) | ||
| 141 | - file_path = file_path.replace('\\', '/') | ||
| 142 | - acl_headers.append(file_path) | ||
| 143 | - return acl_headers | ||
| 144 | - | ||
| 145 | - | ||
| 146 | -def collect_functions(file_path): | ||
| 147 | - file_name = os.path.basename(file_path) | ||
| 148 | - if file_name in ACL_RT_SET: | ||
| 149 | - function_entries = [] | ||
| 150 | - seen_symbols = set() | ||
| 151 | - wrapper_path = os.path.join(os.path.dirname(file_path), WRAPPER_FILE_NAME) | ||
| 152 | - if os.path.exists(wrapper_path): | ||
| 153 | - wrapper_entries = collect_functions_from_wrapper(wrapper_path) | ||
| 154 | - for entry in wrapper_entries: | ||
| 155 | - symbol_name = entry["symbol"] | ||
| 156 | - if symbol_name in seen_symbols: | ||
| 157 | - continue | ||
| 158 | - seen_symbols.add(symbol_name) | ||
| 159 | - function_entries.append(entry) | ||
| 160 | - else: | ||
| 161 | - logging.warning("wrapper file not found, fallback to regex parse: %s", wrapper_path) | ||
| 162 | - visibility_entries = collect_functions_from_visibility(file_path) | ||
| 163 | - for entry in visibility_entries: | ||
| 164 | - symbol_name = entry["symbol"] | ||
| 165 | - if symbol_name in seen_symbols: | ||
| 166 | - continue | ||
| 167 | - seen_symbols.add(symbol_name) | ||
| 168 | - function_entries.append(entry) | ||
| 169 | - return function_entries | ||
| 170 | - return collect_functions_from_visibility(file_path) | ||
| 171 | - | ||
| 172 | - | ||
| 173 | -def collect_functions_from_visibility(file_path): | ||
| 174 | - function_entries = [] | ||
| 175 | - with open(file_path, encoding='utf-8') as f: | ||
| 176 | - content = f.read() | ||
| 177 | - matches = PATTERN_FUNCTION.findall(content) | ||
| 178 | - for signature in matches: | ||
| 179 | - return_type, func_name, param_names = get_func_infos(signature) | ||
| 180 | - if return_type is None or func_name is None: | ||
| 181 | - continue | ||
| 182 | - sig_match = re.search(r'\w+\s*(\([^;]*\))\s*;', signature) | ||
| 183 | - if sig_match is None: | ||
| 184 | - logging.warning("No signature body match for function: %s", signature) | ||
| 185 | - continue | ||
| 186 | - func_signature = sig_match.group(1).strip() | ||
| 187 | - call_args = "()" | ||
| 188 | - if len(param_names) > 0: | ||
| 189 | - call_args = "(" + ", ".join(param_names) + ")" | ||
| 190 | - function_entries.append({ | ||
| 191 | - "symbol": func_name, | ||
| 192 | - "return_type": return_type.strip(), | ||
| 193 | - "signature": func_signature, | ||
| 194 | - "call_args": call_args | ||
| 195 | - }) | ||
| 196 | - return function_entries | ||
| 197 | - | ||
| 198 | - | ||
| 199 | -def split_top_level_commas(text): | ||
| 200 | - parts = [] | ||
| 201 | - depth = 0 | ||
| 202 | - start = 0 | ||
| 203 | - for i, ch in enumerate(text): | ||
| 204 | - if ch == '(': | ||
| 205 | - depth += 1 | ||
| 206 | - elif ch == ')': | ||
| 207 | - depth -= 1 | ||
| 208 | - elif ch == ',' and depth == 0: | ||
| 209 | - parts.append(text[start:i].strip()) | ||
| 210 | - start = i + 1 | ||
| 211 | - parts.append(text[start:].strip()) | ||
| 212 | - return parts | ||
| 213 | - | ||
| 214 | - | ||
| 215 | -def extract_wrapper_macro_body(content, macro_name): | ||
| 216 | - lines = content.splitlines() | ||
| 217 | - define_prefix = "#define {}(".format(macro_name) | ||
| 218 | - collecting = False | ||
| 219 | - body_lines = [] | ||
| 220 | - for line in lines: | ||
| 221 | - stripped = line.strip() | ||
| 222 | - if not collecting: | ||
| 223 | - if stripped.startswith(define_prefix): | ||
| 224 | - collecting = True | ||
| 225 | - continue | ||
| 226 | - body_lines.append(line) | ||
| 227 | - if not line.rstrip().endswith("\\"): | ||
| 228 | - break | ||
| 229 | - return "\n".join(body_lines) | ||
| 230 | - | ||
| 231 | - | ||
| 232 | -def parse_wrapper_entries(wrapper_body): | ||
| 233 | - function_entries = [] | ||
| 234 | - idx = 0 | ||
| 235 | - while True: | ||
| 236 | - start = wrapper_body.find("_(", idx) | ||
| 237 | - if start == -1: | ||
| 238 | - break | ||
| 239 | - depth = 1 | ||
| 240 | - end = start + 2 | ||
| 241 | - while end < len(wrapper_body) and depth > 0: | ||
| 242 | - if wrapper_body[end] == '(': | ||
| 243 | - depth += 1 | ||
| 244 | - elif wrapper_body[end] == ')': | ||
| 245 | - depth -= 1 | ||
| 246 | - end += 1 | ||
| 247 | - if depth != 0: | ||
| 248 | - logging.warning("unmatched function tuple when parsing wrapper map, start=%d", start) | ||
| 249 | - break | ||
| 250 | - tuple_body = wrapper_body[start + 2:end - 1].strip() | ||
| 251 | - idx = end | ||
| 252 | - | ||
| 253 | - fields = split_top_level_commas(tuple_body) | ||
| 254 | - if len(fields) != 4: | ||
| 255 | - continue | ||
| 256 | - | ||
| 257 | - return_type, func_name, signature, call_args = [field.strip() for field in fields] | ||
| 258 | - symbol_name = "{}Impl".format(func_name) | ||
| 259 | - function_entries.append({ | ||
| 260 | - "symbol": symbol_name, | ||
| 261 | - "return_type": return_type, | ||
| 262 | - "signature": signature, | ||
| 263 | - "call_args": call_args | ||
| 264 | - }) | ||
| 265 | - return function_entries | ||
| 266 | - | ||
| 267 | - | ||
| 268 | -def collect_functions_from_wrapper(wrapper_path): | ||
| 269 | - function_entries = [] | ||
| 270 | - seen_symbols = set() | ||
| 271 | - with open(wrapper_path, encoding='utf-8') as f: | ||
| 272 | - content = f.read() | ||
| 273 | - | ||
| 274 | - for map_name in TARGET_WRAPPER_MAPS: | ||
| 275 | - map_body = extract_wrapper_macro_body(content, map_name) | ||
| 276 | - if map_body == "": | ||
| 277 | - logging.warning("map not found in wrapper: %s", map_name) | ||
| 278 | - continue | ||
| 279 | - parsed_entries = parse_wrapper_entries(map_body) | ||
| 280 | - logging.info("parsed map %s, functions numbers:%s", map_name, len(parsed_entries)) | ||
| 281 | - for entry in parsed_entries: | ||
| 282 | - symbol_name = entry["symbol"] | ||
| 283 | - if symbol_name in seen_symbols: | ||
| 284 | - continue | ||
| 285 | - seen_symbols.add(symbol_name) | ||
| 286 | - function_entries.append(entry) | ||
| 287 | - | ||
| 288 | - return function_entries | ||
| 289 | - | ||
| 290 | - | ||
| 291 | -def process_headers(headers, inc_dir, content): | ||
| 292 | - total = 0 | ||
| 293 | - for header in headers: | ||
| 294 | - if not header.endswith('.h'): | ||
| 295 | - continue | ||
| 296 | - file_name = os.path.basename(header) | ||
| 297 | - so_handler = "GetSoHandleAclRt" | ||
| 298 | - if file_name in ACL_RT_SET: | ||
| 299 | - so_handler = "GetSoHandleAclRt" | ||
| 300 | - if file_name in ACL_OP_EXECUTOR_SET: | ||
| 301 | - so_handler = "GetSoHandleAclOpExecutor" | ||
| 302 | - if file_name in ACL_MODEL_SET: | ||
| 303 | - so_handler = "GetSoHandleAclModel" | ||
| 304 | - content.append("// stub for {}\n".format(header[len(inc_dir):])) | ||
| 305 | - function_entries = collect_functions(header) | ||
| 306 | - logging.info("inc file:%s, functions numbers:%s", header, len(function_entries)) | ||
| 307 | - total += len(function_entries) | ||
| 308 | - for function_entry in function_entries: | ||
| 309 | - content.append("{}\n".format(implement_function(function_entry, so_handler))) | ||
| 310 | - content.append("\n") | ||
| 311 | - return total | ||
| 312 | - | ||
| 313 | - | ||
| 314 | -def implement_function(function_entry, so_handler): | ||
| 315 | - symbol_name = function_entry["symbol"].strip() | ||
| 316 | - return_type = function_entry["return_type"].strip() | ||
| 317 | - signature = function_entry["signature"].strip() | ||
| 318 | - call_args = function_entry["call_args"].strip() | ||
| 319 | - declaration = "{} {}{}".format(return_type, symbol_name, signature) | ||
| 320 | - func_ptr = "{} (*){}".format(return_type, signature) | ||
| 321 | - func_prototype = "{} (*temp_func_ptr){}".format(return_type, signature) | ||
| 322 | - | ||
| 323 | - function_def = "" | ||
| 324 | - function_def += declaration | ||
| 325 | - function_def += '\n' | ||
| 326 | - function_def += '{\n' | ||
| 327 | - function_def += ' static ' + func_prototype + ' =' | ||
| 328 | - function_def += '\n' | ||
| 329 | - function_def += ' (' + func_ptr + ')dlsym(' + so_handler + '(), "' + symbol_name + '");\n' | ||
| 330 | - function_def += ' ASSERT_SOHANDLE_VALID(temp_func_ptr);\n' | ||
| 331 | - function_def += ' return temp_func_ptr' | ||
| 332 | - function_def += call_args | ||
| 333 | - function_def += ';' | ||
| 334 | - function_def += '\n' | ||
| 335 | - function_def += '}' | ||
| 336 | - return function_def | ||
| 337 | - | ||
| 338 | - | ||
| 339 | -def generate_stub_file(ge_inc_dir, runtime_inc_dir): | ||
| 340 | - """input inc_dir and return relevant contents""" | ||
| 341 | - ge_header_files = collect_header_files(ge_inc_dir, PathType.GE_INC) | ||
| 342 | - runtime_header_files = collect_header_files(runtime_inc_dir, PathType.RUNTIME_INC) | ||
| 343 | - logging.info("header files has been generated") | ||
| 344 | - acl_content = generate_function(ge_header_files, runtime_header_files, ge_inc_dir, runtime_inc_dir) | ||
| 345 | - logging.info("acl_content has been generated") | ||
| 346 | - return acl_content | ||
| 347 | - | ||
| 348 | - | ||
| 349 | -def generate_function(ge_header_files, runtime_header_files, ge_inc_dir, runtime_inc_dir): | ||
| 350 | - includes = [] | ||
| 351 | - includes.append('#include <stdio.h>\n') | ||
| 352 | - includes.append('#include <dlfcn.h>\n') | ||
| 353 | - includes.append('#include <unistd.h>\n') | ||
| 354 | - includes.append('#include <limits.h>\n') | ||
| 355 | - includes.append('#include <string>\n') | ||
| 356 | - includes.append('#include <cstdarg>\n') | ||
| 357 | - # generate includes | ||
| 358 | - for header in ge_header_files: | ||
| 359 | - if not header.endswith('.h'): | ||
| 360 | - continue | ||
| 361 | - include_str = '#include "acl/{}"\n'.format(header[len(ge_inc_dir):]) | ||
| 362 | - includes.append(include_str) | ||
| 363 | - for header in runtime_header_files: | ||
| 364 | - if not header.endswith('.h'): | ||
| 365 | - continue | ||
| 366 | - include_str = '#include "{}"\n'.format(header[len(runtime_inc_dir):]) | ||
| 367 | - includes.append(include_str) | ||
| 368 | - | ||
| 369 | - content = includes | ||
| 370 | - content.append('// LCOV_EXCL_START\n') | ||
| 371 | - content.append(HANDLE_GET) | ||
| 372 | - logging.info("include concent build success") | ||
| 373 | - total = 0 | ||
| 374 | - content.append('\n') | ||
| 375 | - # generate implement | ||
| 376 | - total += process_headers(ge_header_files, ge_inc_dir, content) | ||
| 377 | - total += process_headers(runtime_header_files, runtime_inc_dir, content) | ||
| 378 | - logging.info("implement concent build success") | ||
| 379 | - logging.info('total functions number is %s', total) | ||
| 380 | - content.append('// LCOV_EXCL_STOP\n') | ||
| 381 | - return content | ||
| 382 | - | ||
| 383 | - | ||
| 384 | -def gen_code(ge_inc_dir, runtime_inc_dir, stub_path): | ||
| 385 | - """input inc_dir and relevant cpp files""" | ||
| 386 | - if not ge_inc_dir.endswith('/'): | ||
| 387 | - ge_inc_dir += '/' | ||
| 388 | - if not runtime_inc_dir.endswith('/'): | ||
| 389 | - runtime_inc_dir += '/' | ||
| 390 | - acl_content = generate_stub_file(ge_inc_dir, runtime_inc_dir) | ||
| 391 | - with open(stub_path, mode='w', encoding='utf-8') as f: | ||
| 392 | - f.writelines(acl_content) | ||
| 393 | - | ||
| 394 | -if __name__ == '__main__': | ||
| 395 | - ge_include_dir = sys.argv[1] | ||
| 396 | - runtime_include_dir = sys.argv[2] | ||
| 397 | - stub_file = sys.argv[3] | ||
| 398 | - ge_inc_dir = os.path.abspath(ge_include_dir) | ||
| 399 | - runtime_inc_dir = os.path.abspath(runtime_include_dir) | ||
| 400 | - logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='[%(levelname)s] %(message)s') | ||
| 401 | - gen_code(ge_inc_dir, runtime_inc_dir, stub_file) | ||
| @@ -19,7 +19,6 @@ target_include_directories(acl_rt PRIVATE | |||
| 19 | ${CMAKE_CURRENT_LIST_DIR} | 19 | ${CMAKE_CURRENT_LIST_DIR} |
| 20 | ${CMAKE_CURRENT_LIST_DIR}/.. | 20 | ${CMAKE_CURRENT_LIST_DIR}/.. |
| 21 | ${CMAKE_CURRENT_LIST_DIR}/../aclrt_impl | 21 | ${CMAKE_CURRENT_LIST_DIR}/../aclrt_impl |
| 22 | - ${CMAKE_CURRENT_LIST_DIR}/../../../pkg_inc/dump | ||
| 23 | ) | 22 | ) |
| 24 | 23 | ||
| 25 | target_compile_options(acl_rt PRIVATE | 24 | target_compile_options(acl_rt PRIVATE |
| @@ -43,12 +42,11 @@ target_link_libraries(acl_rt | |||
| 43 | PRIVATE | 42 | PRIVATE |
| 44 | $<BUILD_INTERFACE:intf_pub> | 43 | $<BUILD_INTERFACE:intf_pub> |
| 45 | -Wl,--no-as-needed | 44 | -Wl,--no-as-needed |
| 46 | - runtime | 45 | + acl_rt_impl |
| 47 | - ascend_dump | ||
| 48 | - -lstdc++ | ||
| 49 | -Wl,--as-needed | 46 | -Wl,--as-needed |
| 50 | -ldl | 47 | -ldl |
| 51 | -lpthread | 48 | -lpthread |
| 49 | + -lstdc++ | ||
| 52 | PUBLIC | 50 | PUBLIC |
| 53 | $<BUILD_INTERFACE:acl_rt_headers> | 51 | $<BUILD_INTERFACE:acl_rt_headers> |
| 54 | ) | 52 | ) |
| @@ -10,30 +10,6 @@ | |||
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | -namespace { | ||
| 18 | -int32_t SetDumpConfigByShim(const acl::AdumpDumpConfigInfo& configInfo) | ||
| 19 | -{ | ||
| 20 | - Adx::DumpConfigInfo adxConfigInfo; | ||
| 21 | - adxConfigInfo.dumpConfigPath = configInfo.dumpConfigPath; | ||
| 22 | - adxConfigInfo.dumpConfigData = configInfo.dumpConfigData; | ||
| 23 | - adxConfigInfo.dumpConfigSize = configInfo.dumpConfigSize; | ||
| 24 | - return Adx::AdumpSetDumpConfig(adxConfigInfo); | ||
| 25 | -} | ||
| 26 | - | ||
| 27 | -__attribute__((constructor)) void InitializeAscendDump() | ||
| 28 | -{ | ||
| 29 | - acl::AdumpCallbacks callbacks; | ||
| 30 | - callbacks.setDumpConfig = SetDumpConfigByShim; | ||
| 31 | - callbacks.unsetDump = Adx::AdumpUnSetDump; | ||
| 32 | - callbacks.serverInit = AdxDataDumpServerInit; | ||
| 33 | - callbacks.serverUnInit = AdxDataDumpServerUnInit; | ||
| 34 | - acl::SetAdumpCallbacks(callbacks); | ||
| 35 | -} | ||
| 36 | -} // namespace | ||
| 37 | 13 | ||
| 38 | ACL_FUNC_MAP(ACL_RT_CPP) | 14 | ACL_FUNC_MAP(ACL_RT_CPP) |
| 39 | 15 | ||
| @@ -9,30 +9,40 @@ | |||
| 9 | # ----------------------------------------------------------------------------------------------------------- | 9 | # ----------------------------------------------------------------------------------------------------------- |
| 10 | 10 | ||
| 11 | ############ libacl_rt_impl.so ############ | 11 | ############ libacl_rt_impl.so ############ |
| 12 | -# This library provides runtime forwarding to libruntime.so using auto-generated stubs. | ||
| 13 | -set(ACL_RT_IMPL_STUB_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/../../../scripts/package/runtime/scripts/gen_dynamic_stub.py) | ||
| 14 | -set(ACL_RT_IMPL_HEADER ${CMAKE_CURRENT_LIST_DIR}/acl_rt_impl.h) | ||
| 15 | -set(ACL_RT_WRAPPER_HEADER ${CMAKE_CURRENT_LIST_DIR}/acl_rt_wrapper.h) | ||
| 16 | -set(ACL_RT_IMPL_STUB_CPP ${CMAKE_CURRENT_BINARY_DIR}/acl_rt_impl_stub.cpp) | ||
| 17 | - | ||
| 18 | -add_custom_command( | ||
| 19 | - OUTPUT ${ACL_RT_IMPL_STUB_CPP} | ||
| 20 | - COMMAND ${CMAKE_COMMAND} -E echo "Generating stub files:acl_rt_impl_stub.cpp." | ||
| 21 | - COMMAND python3 ${ACL_RT_IMPL_STUB_SCRIPT} | ||
| 22 | - ${CMAKE_CURRENT_LIST_DIR}/../../../air/inc/external/acl | ||
| 23 | - ${CMAKE_CURRENT_LIST_DIR} | ||
| 24 | - ${ACL_RT_IMPL_STUB_CPP} | ||
| 25 | - COMMAND ${CMAKE_COMMAND} -E echo "Generating stub files end." | ||
| 26 | - DEPENDS | ||
| 27 | - ${ACL_RT_IMPL_STUB_SCRIPT} | ||
| 28 | - ${ACL_RT_IMPL_HEADER} | ||
| 29 | - ${ACL_RT_WRAPPER_HEADER} | ||
| 30 | - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
| 31 | - VERBATIM | ||
| 32 | -) | ||
| 33 | - | ||
| 34 | add_library(acl_rt_impl SHARED | 12 | add_library(acl_rt_impl SHARED |
| 35 | - ${ACL_RT_IMPL_STUB_CPP} | 13 | + ../common/log_inner.cpp |
| 14 | + ../common/prof_reporter.cpp | ||
| 15 | + ../common/resource_statistics.cpp | ||
| 16 | + acl.cpp | ||
| 17 | + log.cpp | ||
| 18 | + device.cpp | ||
| 19 | + dfx.cpp | ||
| 20 | + event.cpp | ||
| 21 | + stream.cpp | ||
| 22 | + memory.cpp | ||
| 23 | + context.cpp | ||
| 24 | + callback.cpp | ||
| 25 | + group.cpp | ||
| 26 | + kernel.cpp | ||
| 27 | + notify.cpp | ||
| 28 | + label.cpp | ||
| 29 | + acl_rt_impl_base.cpp | ||
| 30 | + model_ri.cpp | ||
| 31 | + data_buffer.cpp | ||
| 32 | + allocator.cpp | ||
| 33 | + callback_api.cpp | ||
| 34 | + init_callback_manager.cpp | ||
| 35 | + snapshot.cpp | ||
| 36 | + types/fp16.cpp | ||
| 37 | + types/fp16_impl.cpp | ||
| 38 | + ../common/json_parser.cpp | ||
| 39 | + ../utils/string_utils.cpp | ||
| 40 | + ../utils/cann_info_utils.cpp | ||
| 41 | + ../utils/hash_utils.cpp | ||
| 42 | + ../utils/file_utils.cpp | ||
| 43 | + toolchain/dump.cpp | ||
| 44 | + toolchain/profiling.cpp | ||
| 45 | + toolchain/profiling_manager.cpp | ||
| 36 | ) | 46 | ) |
| 37 | 47 | ||
| 38 | set(ACL_INC_EXTERNAL_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../include/external) | 48 | set(ACL_INC_EXTERNAL_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../include/external) |
| @@ -40,6 +50,17 @@ set(ACL_INC_EXTERNAL_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../include/external) | |||
| 40 | target_include_directories(acl_rt_impl PRIVATE | 50 | target_include_directories(acl_rt_impl PRIVATE |
| 41 | ${ACL_INC_EXTERNAL_DIR} | 51 | ${ACL_INC_EXTERNAL_DIR} |
| 42 | ${CMAKE_CURRENT_LIST_DIR} | 52 | ${CMAKE_CURRENT_LIST_DIR} |
| 53 | + ${CMAKE_CURRENT_LIST_DIR}/.. | ||
| 54 | + ${CMAKE_CURRENT_LIST_DIR}/../aclrt_impl | ||
| 55 | + ${RUNTIME_DIR}/pkg_inc | ||
| 56 | + ${RUNTIME_DIR}/pkg_inc/runtime | ||
| 57 | + ${RUNTIME_DIR}/pkg_inc/runtime/runtime | ||
| 58 | + ${RUNTIME_DIR}/pkg_inc/dump | ||
| 59 | + ${RUNTIME_DIR}/src | ||
| 60 | + ${RUNTIME_DIR}/src/inc | ||
| 61 | + ${RUNTIME_DIR}/src/dfx/error_manager | ||
| 62 | + ${RUNTIME_DIR}/src/dfx/adump/inc/metadef/external | ||
| 63 | + ${RUNTIME_DIR}/include/dfx | ||
| 43 | ) | 64 | ) |
| 44 | 65 | ||
| 45 | target_compile_options(acl_rt_impl PRIVATE | 66 | target_compile_options(acl_rt_impl PRIVATE |
| @@ -52,8 +73,8 @@ target_compile_definitions(acl_rt_impl PRIVATE | |||
| 52 | FUNC_VISIBILITY | 73 | FUNC_VISIBILITY |
| 53 | ) | 74 | ) |
| 54 | 75 | ||
| 55 | -# Link options for the generated forwarding stub library. | ||
| 56 | target_link_options(acl_rt_impl PRIVATE | 76 | target_link_options(acl_rt_impl PRIVATE |
| 77 | + -rdynamic | ||
| 57 | -Wl,-Bsymbolic | 78 | -Wl,-Bsymbolic |
| 58 | -Wl,--exclude-libs,ALL | 79 | -Wl,--exclude-libs,ALL |
| 59 | -Wl,--no-undefined | 80 | -Wl,--no-undefined |
| @@ -61,6 +82,19 @@ target_link_options(acl_rt_impl PRIVATE | |||
| 61 | 82 | ||
| 62 | target_link_libraries(acl_rt_impl PRIVATE | 83 | target_link_libraries(acl_rt_impl PRIVATE |
| 63 | $<BUILD_INTERFACE:intf_pub> | 84 | $<BUILD_INTERFACE:intf_pub> |
| 85 | + $<BUILD_INTERFACE:c_sec_headers> | ||
| 86 | + $<BUILD_INTERFACE:mmpa_headers> | ||
| 87 | + $<BUILD_INTERFACE:msprof_headers> | ||
| 88 | + $<BUILD_INTERFACE:platform_headers> | ||
| 89 | + mmpa | ||
| 90 | + runtime | ||
| 91 | + c_sec | ||
| 92 | + unified_dlog | ||
| 93 | + profapi_share | ||
| 94 | + platform | ||
| 95 | + ascend_dump | ||
| 96 | + json | ||
| 97 | + error_manager | ||
| 64 | -Wl,--as-needed | 98 | -Wl,--as-needed |
| 65 | -ldl | 99 | -ldl |
| 66 | -lpthread | 100 | -lpthread |
| @@ -20,11 +20,11 @@ | |||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | + | ||
| 23 | 24 | ||
| 24 | 25 | ||
| 25 | 26 | ||
| 26 | 27 | ||
| 27 | - | ||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | 30 | ||
| @@ -563,12 +563,7 @@ aclError aclFinalizeInternal() | |||
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | if (acl::AclDump::GetInstance().GetAdxInitFromAclInitFlag()) { | 565 | if (acl::AclDump::GetInstance().GetAdxInitFromAclInitFlag()) { |
| 566 | - const auto& funcs = acl::GetAdumpCallbacks(); | 566 | + const int32_t adxRet = AdxDataDumpServerUnInit(); |
| 567 | - if (funcs.serverUnInit == nullptr) { | ||
| 568 | - ACL_LOG_INNER_ERROR("[Check][DumpCallback]Adump server uninit callback is not registered."); | ||
| 569 | - return ACL_ERROR_INTERNAL_ERROR; | ||
| 570 | - } | ||
| 571 | - const int32_t adxRet = funcs.serverUnInit(); | ||
| 572 | if (adxRet != 0) { | 567 | if (adxRet != 0) { |
| 573 | ACL_LOG_CALL_ERROR("[Generate][DumpFile]generate dump file failed in disk, adx errorCode = %d", adxRet); | 568 | ACL_LOG_CALL_ERROR("[Generate][DumpFile]generate dump file failed in disk, adx errorCode = %d", adxRet); |
| 574 | return ACL_ERROR_INTERNAL_ERROR; | 569 | return ACL_ERROR_INTERNAL_ERROR; |
| @@ -17,7 +17,6 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | - | ||
| 21 | 20 | ||
| 22 | 21 | ||
| 23 | 22 | ||
| @@ -44,12 +43,7 @@ namespace acl { | |||
| 44 | { | 43 | { |
| 45 | ACL_LOG_INFO("start to execute HandleDumpCommand."); | 44 | ACL_LOG_INFO("start to execute HandleDumpCommand."); |
| 46 | 45 | ||
| 47 | - const auto& funcs = acl::GetAdumpCallbacks(); | 46 | + int32_t adxRet = AdxDataDumpServerInit(); |
| 48 | - if (funcs.serverInit == nullptr) { | ||
| 49 | - ACL_LOG_INNER_ERROR("[Check][DumpCallback]Adump server init callback is not registered."); | ||
| 50 | - return ACL_ERROR_INTERNAL_ERROR; | ||
| 51 | - } | ||
| 52 | - int32_t adxRet = funcs.serverInit(); | ||
| 53 | if (adxRet != ADX_ERROR_NONE) { | 47 | if (adxRet != ADX_ERROR_NONE) { |
| 54 | ACL_LOG_INNER_ERROR("[AdxDataDumpServer][Init]dump server run failed, adx errorCode = %d", adxRet); | 48 | ACL_LOG_INNER_ERROR("[AdxDataDumpServer][Init]dump server run failed, adx errorCode = %d", adxRet); |
| 55 | return ACL_ERROR_INTERNAL_ERROR; | 49 | return ACL_ERROR_INTERNAL_ERROR; |
| @@ -57,15 +51,11 @@ namespace acl { | |||
| 57 | acl::AclDump::GetInstance().SetAdxInitFromAclInitFlag(true); | 51 | acl::AclDump::GetInstance().SetAdxInitFromAclInitFlag(true); |
| 58 | 52 | ||
| 59 | // base dump | 53 | // base dump |
| 60 | - acl::AdumpDumpConfigInfo configInfo; | 54 | + Adx::DumpConfigInfo configInfo; |
| 61 | configInfo.dumpConfigPath = configPath; | 55 | configInfo.dumpConfigPath = configPath; |
| 62 | configInfo.dumpConfigData = configStr; | 56 | configInfo.dumpConfigData = configStr; |
| 63 | configInfo.dumpConfigSize = size; | 57 | configInfo.dumpConfigSize = size; |
| 64 | - if (funcs.setDumpConfig == nullptr) { | 58 | + adxRet = Adx::AdumpSetDumpConfig(configInfo); |
| 65 | - ACL_LOG_INNER_ERROR("[Check][DumpCallback]Adump set dump config callback is not registered."); | ||
| 66 | - return ACL_ERROR_INTERNAL_ERROR; | ||
| 67 | - } | ||
| 68 | - adxRet = funcs.setDumpConfig(configInfo); | ||
| 69 | if (adxRet != ADX_ERROR_NONE) { | 59 | if (adxRet != ADX_ERROR_NONE) { |
| 70 | auto ret = | 60 | auto ret = |
| 71 | (adxRet == Adx::ADUMP_INPUT_FAILED) ? ACL_ERROR_INVALID_DUMP_CONFIG : ACL_ERROR_INTERNAL_ERROR; | 61 | (adxRet == Adx::ADUMP_INPUT_FAILED) ? ACL_ERROR_INVALID_DUMP_CONFIG : ACL_ERROR_INTERNAL_ERROR; |
| @@ -125,12 +115,7 @@ aclError aclmdlInitDumpImpl() | |||
| 125 | return ACL_ERROR_REPEAT_INITIALIZE; | 115 | return ACL_ERROR_REPEAT_INITIALIZE; |
| 126 | } | 116 | } |
| 127 | 117 | ||
| 128 | - const auto& funcs = acl::GetAdumpCallbacks(); | 118 | + const int32_t adxRet = AdxDataDumpServerInit(); |
| 129 | - if (funcs.serverInit == nullptr) { | ||
| 130 | - ACL_LOG_INNER_ERROR("[Check][DumpCallback]Adump server init callback is not registered."); | ||
| 131 | - return ACL_ERROR_INTERNAL_ERROR; | ||
| 132 | - } | ||
| 133 | - const int32_t adxRet = funcs.serverInit(); | ||
| 134 | if (adxRet != ADX_ERROR_NONE) { | 119 | if (adxRet != ADX_ERROR_NONE) { |
| 135 | ACL_LOG_CALL_ERROR("[AdxDataDumpServer][Init]dump server run failed, adx errorCode = %d", adxRet); | 120 | ACL_LOG_CALL_ERROR("[AdxDataDumpServer][Init]dump server run failed, adx errorCode = %d", adxRet); |
| 136 | return ACL_ERROR_INTERNAL_ERROR; | 121 | return ACL_ERROR_INTERNAL_ERROR; |
| @@ -175,16 +160,11 @@ aclError aclmdlSetDumpImpl(const char *dumpCfgPath) | |||
| 175 | // base dump | 160 | // base dump |
| 176 | if (!configStr.empty()) { | 161 | if (!configStr.empty()) { |
| 177 | ACL_LOG_INFO("Start to set dump."); | 162 | ACL_LOG_INFO("Start to set dump."); |
| 178 | - const auto& funcs = acl::GetAdumpCallbacks(); | 163 | + Adx::DumpConfigInfo configInfo; |
| 179 | - if (funcs.setDumpConfig == nullptr) { | ||
| 180 | - ACL_LOG_INNER_ERROR("[Check][DumpCallback]Adump set dump config callback is not registered."); | ||
| 181 | - return ACL_ERROR_INTERNAL_ERROR; | ||
| 182 | - } | ||
| 183 | - acl::AdumpDumpConfigInfo configInfo; | ||
| 184 | configInfo.dumpConfigPath = dumpCfgPath; | 164 | configInfo.dumpConfigPath = dumpCfgPath; |
| 185 | configInfo.dumpConfigData = configStr.c_str(); | 165 | configInfo.dumpConfigData = configStr.c_str(); |
| 186 | configInfo.dumpConfigSize = configStr.size(); | 166 | configInfo.dumpConfigSize = configStr.size(); |
| 187 | - const auto adxRet = funcs.setDumpConfig(configInfo); | 167 | + const auto adxRet = Adx::AdumpSetDumpConfig(configInfo); |
| 188 | if (adxRet != ADX_ERROR_NONE) { | 168 | if (adxRet != ADX_ERROR_NONE) { |
| 189 | ret = | 169 | ret = |
| 190 | (adxRet == Adx::ADUMP_INPUT_FAILED) ? ACL_ERROR_INVALID_DUMP_CONFIG : ACL_ERROR_INTERNAL_ERROR; | 170 | (adxRet == Adx::ADUMP_INPUT_FAILED) ? ACL_ERROR_INVALID_DUMP_CONFIG : ACL_ERROR_INTERNAL_ERROR; |
| @@ -219,23 +199,14 @@ aclError aclmdlFinalizeDumpImpl() | |||
| 219 | } | 199 | } |
| 220 | 200 | ||
| 221 | // close adump opened | 201 | // close adump opened |
| 222 | - const auto& funcs = acl::GetAdumpCallbacks(); | 202 | + int32_t adxRet = Adx::AdumpUnSetDump(); |
| 223 | - if (funcs.unsetDump == nullptr) { | ||
| 224 | - ACL_LOG_INNER_ERROR("[Check][DumpCallback]Adump unset dump callback is not registered."); | ||
| 225 | - return ACL_ERROR_INTERNAL_ERROR; | ||
| 226 | - } | ||
| 227 | - int32_t adxRet = funcs.unsetDump(); | ||
| 228 | if (adxRet != ADX_ERROR_NONE) { | 203 | if (adxRet != ADX_ERROR_NONE) { |
| 229 | ACL_LOG_INNER_ERROR("[Set][Dump]set dump off failed, adx errorCode = %d", adxRet); | 204 | ACL_LOG_INNER_ERROR("[Set][Dump]set dump off failed, adx errorCode = %d", adxRet); |
| 230 | return ACL_ERROR_INTERNAL_ERROR; | 205 | return ACL_ERROR_INTERNAL_ERROR; |
| 231 | } | 206 | } |
| 232 | 207 | ||
| 233 | // close dump server | 208 | // close dump server |
| 234 | - if (funcs.serverUnInit == nullptr) { | 209 | + adxRet = AdxDataDumpServerUnInit(); |
| 235 | - ACL_LOG_INNER_ERROR("[Check][DumpCallback]Adump server uninit callback is not registered."); | ||
| 236 | - return ACL_ERROR_INTERNAL_ERROR; | ||
| 237 | - } | ||
| 238 | - adxRet = funcs.serverUnInit(); | ||
| 239 | if (adxRet != ADX_ERROR_NONE) { | 210 | if (adxRet != ADX_ERROR_NONE) { |
| 240 | ACL_LOG_CALL_ERROR("[AdxDataDumpServer][UnInit]generate dump file failed in disk, adx errorCode = %d", adxRet); | 211 | ACL_LOG_CALL_ERROR("[AdxDataDumpServer][UnInit]generate dump file failed in disk, adx errorCode = %d", adxRet); |
| 241 | return ACL_ERROR_INTERNAL_ERROR; | 212 | return ACL_ERROR_INTERNAL_ERROR; |
| @@ -1,24 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Copyright (c) 2026 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 | - | ||
| 13 | - | ||
| 14 | -namespace acl { | ||
| 15 | -static AdumpCallbacks g_adumpCallbacks = {nullptr, nullptr, nullptr, nullptr}; | ||
| 16 | - | ||
| 17 | -void SetAdumpCallbacks(const AdumpCallbacks& callbacks) | ||
| 18 | -{ | ||
| 19 | - g_adumpCallbacks = callbacks; | ||
| 20 | - ACL_LOG_INFO("Adump callbacks registered."); | ||
| 21 | -} | ||
| 22 | - | ||
| 23 | -const AdumpCallbacks& GetAdumpCallbacks() { return g_adumpCallbacks; } | ||
| 24 | -} // namespace acl | ||
| @@ -1,40 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Copyright (c) 2026 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 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | -namespace acl { | ||
| 18 | -struct AdumpDumpConfigInfo { | ||
| 19 | - const char* dumpConfigPath; | ||
| 20 | - const char* dumpConfigData; | ||
| 21 | - size_t dumpConfigSize; | ||
| 22 | -}; | ||
| 23 | - | ||
| 24 | -typedef int32_t (*AdumpSetDumpConfigFunc)(const AdumpDumpConfigInfo& configInfo); | ||
| 25 | -typedef int32_t (*AdumpUnSetDumpFunc)(); | ||
| 26 | -typedef int (*AdxDataDumpServerInitFunc)(); | ||
| 27 | -typedef int (*AdxDataDumpServerUnInitFunc)(); | ||
| 28 | - | ||
| 29 | -struct AdumpCallbacks { | ||
| 30 | - AdumpSetDumpConfigFunc setDumpConfig; | ||
| 31 | - AdumpUnSetDumpFunc unsetDump; | ||
| 32 | - AdxDataDumpServerInitFunc serverInit; | ||
| 33 | - AdxDataDumpServerUnInitFunc serverUnInit; | ||
| 34 | -}; | ||
| 35 | - | ||
| 36 | -ACL_FUNC_VISIBILITY void SetAdumpCallbacks(const AdumpCallbacks& callbacks); | ||
| 37 | -const AdumpCallbacks& GetAdumpCallbacks(); | ||
| 38 | -} // namespace acl | ||
| 39 | - | ||
| 40 | - | ||
| @@ -11,7 +11,6 @@ | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | - | ||
| 15 | 14 | ||
| 16 | 15 | ||
| 17 | 16 | ||
| @@ -26,52 +25,6 @@ namespace acl { | |||
| 26 | constexpr const char_t *const RUNTIME_VERSION_PATH = "share/info/runtime/version.info"; | 25 | constexpr const char_t *const RUNTIME_VERSION_PATH = "share/info/runtime/version.info"; |
| 27 | 26 | ||
| 28 | constexpr const char_t *const VERSION_INFO_KEY = "Version="; | 27 | constexpr const char_t *const VERSION_INFO_KEY = "Version="; |
| 29 | - constexpr size_t MAX_INSTALL_PATH_SEARCH_DEPTH = 8U; | ||
| 30 | - | ||
| 31 | - std::string StripTrailingSlash(const std::string& path) | ||
| 32 | - { | ||
| 33 | - if ((path.size() > 1UL) && (path.back() == '/')) { | ||
| 34 | - return path.substr(0, path.size() - 1UL); | ||
| 35 | - } | ||
| 36 | - return path; | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - std::string GetParentDir(const std::string& path) | ||
| 40 | - { | ||
| 41 | - const std::string strippedPath = StripTrailingSlash(path); | ||
| 42 | - const size_t pos = strippedPath.rfind('/'); | ||
| 43 | - if (pos == std::string::npos) { | ||
| 44 | - return ""; | ||
| 45 | - } | ||
| 46 | - return strippedPath.substr(0, pos + 1UL); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - bool IsRegularFile(const std::string& path) | ||
| 50 | - { | ||
| 51 | - struct stat fileStat = {}; | ||
| 52 | - return (stat(path.c_str(), &fileStat) == 0) && ((fileStat.st_mode & S_IFMT) == S_IFREG); | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - bool FindFileFromCurrentToParents( | ||
| 56 | - const std::string& startDir, const std::string& relativePath, std::string& matchedDir) | ||
| 57 | - { | ||
| 58 | - std::string currentDir = startDir; | ||
| 59 | - for (size_t depth = 0U; depth < MAX_INSTALL_PATH_SEARCH_DEPTH; ++depth) { | ||
| 60 | - if (currentDir.empty()) { | ||
| 61 | - return false; | ||
| 62 | - } | ||
| 63 | - if (IsRegularFile(currentDir + relativePath)) { | ||
| 64 | - matchedDir = currentDir; | ||
| 65 | - return true; | ||
| 66 | - } | ||
| 67 | - const std::string parentDir = GetParentDir(currentDir); | ||
| 68 | - if ((parentDir.empty()) || (parentDir == currentDir)) { | ||
| 69 | - return false; | ||
| 70 | - } | ||
| 71 | - currentDir = parentDir; | ||
| 72 | - } | ||
| 73 | - return false; | ||
| 74 | - } | ||
| 75 | } // namespace | 28 | } // namespace |
| 76 | 29 | ||
| 77 | std::mutex CannInfoUtils::mutex_; | 30 | std::mutex CannInfoUtils::mutex_; |
| @@ -165,28 +118,12 @@ namespace acl { | |||
| 165 | return ret; | 118 | return ret; |
| 166 | } | 119 | } |
| 167 | ACL_LOG_DEBUG("current path = %s", path.c_str()); | 120 | ACL_LOG_DEBUG("current path = %s", path.c_str()); |
| 168 | - const std::string soDir = path; | ||
| 169 | path = path.substr(0, path.rfind('/')); | 121 | path = path.substr(0, path.rfind('/')); |
| 170 | path = path.substr(0, path.rfind('/') + 1UL); | 122 | path = path.substr(0, path.rfind('/') + 1UL); |
| 171 | swConfigPath_ = path + SW_CONFIG_FILE; | 123 | swConfigPath_ = path + SW_CONFIG_FILE; |
| 172 | - if (!IsRegularFile(swConfigPath_)) { | ||
| 173 | - std::string matchedDir; | ||
| 174 | - if (FindFileFromCurrentToParents(soDir, SW_CONFIG_FILE, matchedDir)) { | ||
| 175 | - swConfigPath_ = matchedDir + SW_CONFIG_FILE; | ||
| 176 | - path = matchedDir; | ||
| 177 | - ACL_LOG_INFO("fallback to swConfigPath = %s", swConfigPath_.c_str()); | ||
| 178 | - } | ||
| 179 | - } | ||
| 180 | ACL_LOG_DEBUG("swConfigPath = %s", swConfigPath_.c_str()); | 124 | ACL_LOG_DEBUG("swConfigPath = %s", swConfigPath_.c_str()); |
| 181 | path.pop_back(); | 125 | path.pop_back(); |
| 182 | defaultInstallPath_ = path.substr(0, path.rfind('/') + 1UL); | 126 | defaultInstallPath_ = path.substr(0, path.rfind('/') + 1UL); |
| 183 | - if (!IsRegularFile(defaultInstallPath_ + RUNTIME_VERSION_PATH)) { | ||
| 184 | - std::string matchedDir; | ||
| 185 | - if (FindFileFromCurrentToParents(soDir, RUNTIME_VERSION_PATH, matchedDir)) { | ||
| 186 | - defaultInstallPath_ = matchedDir; | ||
| 187 | - ACL_LOG_INFO("fallback to defaultInstallPath = %s", defaultInstallPath_.c_str()); | ||
| 188 | - } | ||
| 189 | - } | ||
| 190 | ACL_LOG_DEBUG("defaultInstallPath = %s", defaultInstallPath_.c_str()); | 127 | ACL_LOG_DEBUG("defaultInstallPath = %s", defaultInstallPath_.c_str()); |
| 191 | return ACL_SUCCESS; | 128 | return ACL_SUCCESS; |
| 192 | } | 129 | } |
| @@ -269,4 +206,4 @@ namespace acl { | |||
| 269 | } | 206 | } |
| 270 | } | 207 | } |
| 271 | } | 208 | } |
| 272 | -} // namespace acl | 209 | +} // namespace acl |
| @@ -207,49 +207,6 @@ set(libruntime_api_src_files_optional | |||
| 207 | ${RUNTIME_DIR}/src/runtime/api/api_c_uvm.cc | 207 | ${RUNTIME_DIR}/src/runtime/api/api_c_uvm.cc |
| 208 | ) | 208 | ) |
| 209 | 209 | ||
| 210 | -set(libruntime_api_aclrt_impl_src_files | ||
| 211 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/acl.cpp | ||
| 212 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/log.cpp | ||
| 213 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/device.cpp | ||
| 214 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/dfx.cpp | ||
| 215 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/event.cpp | ||
| 216 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/stream.cpp | ||
| 217 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/memory.cpp | ||
| 218 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/context.cpp | ||
| 219 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/callback.cpp | ||
| 220 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/group.cpp | ||
| 221 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/kernel.cpp | ||
| 222 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/notify.cpp | ||
| 223 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/label.cpp | ||
| 224 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/acl_rt_impl_base.cpp | ||
| 225 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/model_ri.cpp | ||
| 226 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/data_buffer.cpp | ||
| 227 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/allocator.cpp | ||
| 228 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/callback_api.cpp | ||
| 229 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/init_callback_manager.cpp | ||
| 230 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/snapshot.cpp | ||
| 231 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/types/fp16.cpp | ||
| 232 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/types/fp16_impl.cpp | ||
| 233 | - ${RUNTIME_DIR}/src/acl/common/log_inner.cpp | ||
| 234 | - ${RUNTIME_DIR}/src/acl/common/prof_reporter.cpp | ||
| 235 | - ${RUNTIME_DIR}/src/acl/common/resource_statistics.cpp | ||
| 236 | - ${RUNTIME_DIR}/src/acl/common/json_parser.cpp | ||
| 237 | - ${RUNTIME_DIR}/src/acl/utils/string_utils.cpp | ||
| 238 | - ${RUNTIME_DIR}/src/acl/utils/cann_info_utils.cpp | ||
| 239 | - ${RUNTIME_DIR}/src/acl/utils/hash_utils.cpp | ||
| 240 | - ${RUNTIME_DIR}/src/acl/utils/file_utils.cpp | ||
| 241 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/toolchain/dump.cpp | ||
| 242 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/toolchain/profiling.cpp | ||
| 243 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/toolchain/profiling_manager.cpp | ||
| 244 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/toolchain/dump_shim.cpp | ||
| 245 | -) | ||
| 246 | - | ||
| 247 | -set_source_files_properties(${libruntime_api_aclrt_impl_src_files} | ||
| 248 | - PROPERTIES | ||
| 249 | - COMPILE_OPTIONS "-ftrapv" | ||
| 250 | - COMPILE_DEFINITIONS "OS_TYPE=0;FUNC_VISIBILITY" | ||
| 251 | -) | ||
| 252 | - | ||
| 253 | #------------------------- runtime v100 ------------------------- | 210 | #------------------------- runtime v100 ------------------------- |
| 254 | set(xpu_tprt_api_file | 211 | set(xpu_tprt_api_file |
| 255 | ${RUNTIME_FEATURE_DIR}/xpu/api_error_xpu.cc | 212 | ${RUNTIME_FEATURE_DIR}/xpu/api_error_xpu.cc |
| @@ -577,7 +534,6 @@ macro(add_runtime_api_library target_name) | |||
| 577 | ${RUNTIME_DIR}/src/runtime/api/api.cc | 534 | ${RUNTIME_DIR}/src/runtime/api/api.cc |
| 578 | ${RUNTIME_CORE_DIR}/src/profiler/prof_map_ge_model_device.cc | 535 | ${RUNTIME_CORE_DIR}/src/profiler/prof_map_ge_model_device.cc |
| 579 | ${RUNTIME_CORE_DIR}/src/plugin_manage/runtime_keeper.cc | 536 | ${RUNTIME_CORE_DIR}/src/plugin_manage/runtime_keeper.cc |
| 580 | - ${libruntime_api_aclrt_impl_src_files} | ||
| 581 | $<TARGET_OBJECTS:runtime_platform_910B> | 537 | $<TARGET_OBJECTS:runtime_platform_910B> |
| 582 | $<TARGET_OBJECTS:runtime_platform_kirin> | 538 | $<TARGET_OBJECTS:runtime_platform_kirin> |
| 583 | $<TARGET_OBJECTS:runtime_platform_others> | 539 | $<TARGET_OBJECTS:runtime_platform_others> |
| @@ -610,18 +566,6 @@ macro(add_runtime_api_library target_name) | |||
| 610 | target_include_directories(${target_name} PRIVATE | 566 | target_include_directories(${target_name} PRIVATE |
| 611 | ${RUNTIME_INC_DIR_OPEN} | 567 | ${RUNTIME_INC_DIR_OPEN} |
| 612 | ${RUNTIME_DIR}/include | 568 | ${RUNTIME_DIR}/include |
| 613 | - ${RUNTIME_DIR}/src/acl/aclrt_impl | ||
| 614 | - ${RUNTIME_DIR}/src/acl/common | ||
| 615 | - ${RUNTIME_DIR}/src/acl/utils | ||
| 616 | - ${RUNTIME_DIR}/src/acl | ||
| 617 | - ${RUNTIME_DIR}/include/external | ||
| 618 | - ${RUNTIME_DIR}/pkg_inc | ||
| 619 | - ${RUNTIME_DIR}/pkg_inc/runtime | ||
| 620 | - ${RUNTIME_DIR}/pkg_inc/runtime/runtime | ||
| 621 | - ${RUNTIME_DIR}/pkg_inc/dump | ||
| 622 | - ${RUNTIME_DIR}/src/dfx/error_manager | ||
| 623 | - ${RUNTIME_DIR}/src/dfx/adump/inc/metadef/external | ||
| 624 | - ${RUNTIME_DIR}/include/dfx | ||
| 625 | ) | 569 | ) |
| 626 | 570 | ||
| 627 | target_link_libraries(${target_name} | 571 | target_link_libraries(${target_name} |
| @@ -303,49 +303,6 @@ set(libruntime_common_src_files | |||
| 303 | set(libruntime_dev_info_src_files | 303 | set(libruntime_dev_info_src_files |
| 304 | ) | 304 | ) |
| 305 | 305 | ||
| 306 | -set(libruntime_aclrt_impl_src_files | ||
| 307 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/acl.cpp | ||
| 308 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/log.cpp | ||
| 309 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/device.cpp | ||
| 310 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/dfx.cpp | ||
| 311 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/event.cpp | ||
| 312 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/stream.cpp | ||
| 313 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/memory.cpp | ||
| 314 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/context.cpp | ||
| 315 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/callback.cpp | ||
| 316 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/group.cpp | ||
| 317 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/kernel.cpp | ||
| 318 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/notify.cpp | ||
| 319 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/label.cpp | ||
| 320 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/acl_rt_impl_base.cpp | ||
| 321 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/model_ri.cpp | ||
| 322 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/data_buffer.cpp | ||
| 323 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/allocator.cpp | ||
| 324 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/callback_api.cpp | ||
| 325 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/init_callback_manager.cpp | ||
| 326 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/snapshot.cpp | ||
| 327 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/types/fp16.cpp | ||
| 328 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/types/fp16_impl.cpp | ||
| 329 | - ${RUNTIME_DIR}/src/acl/common/log_inner.cpp | ||
| 330 | - ${RUNTIME_DIR}/src/acl/common/prof_reporter.cpp | ||
| 331 | - ${RUNTIME_DIR}/src/acl/common/resource_statistics.cpp | ||
| 332 | - ${RUNTIME_DIR}/src/acl/common/json_parser.cpp | ||
| 333 | - ${RUNTIME_DIR}/src/acl/utils/string_utils.cpp | ||
| 334 | - ${RUNTIME_DIR}/src/acl/utils/cann_info_utils.cpp | ||
| 335 | - ${RUNTIME_DIR}/src/acl/utils/hash_utils.cpp | ||
| 336 | - ${RUNTIME_DIR}/src/acl/utils/file_utils.cpp | ||
| 337 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/toolchain/dump.cpp | ||
| 338 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/toolchain/profiling.cpp | ||
| 339 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/toolchain/profiling_manager.cpp | ||
| 340 | - ${RUNTIME_DIR}/src/acl/aclrt_impl/toolchain/dump_shim.cpp | ||
| 341 | -) | ||
| 342 | - | ||
| 343 | -set_source_files_properties(${libruntime_aclrt_impl_src_files} | ||
| 344 | - PROPERTIES | ||
| 345 | - COMPILE_OPTIONS "-O2;-ftrapv" | ||
| 346 | - COMPILE_DEFINITIONS "OS_TYPE=0;FUNC_VISIBILITY" | ||
| 347 | -) | ||
| 348 | - | ||
| 349 | #------------------------- runtime v100 ------------------------- | 306 | #------------------------- runtime v100 ------------------------- |
| 350 | set(libruntime_v100_src_files | 307 | set(libruntime_v100_src_files |
| 351 | ${RUNTIME_CORE_DIR}/src/common/inner_thread_local.cpp | 308 | ${RUNTIME_CORE_DIR}/src/common/inner_thread_local.cpp |
| @@ -627,7 +584,6 @@ macro(add_runtime_api_library target_name) | |||
| 627 | ${RUNTIME_DIR}/src/runtime/api/api.cc | 584 | ${RUNTIME_DIR}/src/runtime/api/api.cc |
| 628 | ${RUNTIME_CORE_DIR}/src/profiler/prof_map_ge_model_device.cc | 585 | ${RUNTIME_CORE_DIR}/src/profiler/prof_map_ge_model_device.cc |
| 629 | ${RUNTIME_CORE_DIR}/src/plugin_manage/runtime_keeper.cc | 586 | ${RUNTIME_CORE_DIR}/src/plugin_manage/runtime_keeper.cc |
| 630 | - ${libruntime_aclrt_impl_src_files} | ||
| 631 | $<TARGET_OBJECTS:profapi_stub> | 587 | $<TARGET_OBJECTS:profapi_stub> |
| 632 | $<$<STREQUAL:${PRODUCT},ascend031>:$<TARGET_OBJECTS:runtime_platform_tiny>> | 588 | $<$<STREQUAL:${PRODUCT},ascend031>:$<TARGET_OBJECTS:runtime_platform_tiny>> |
| 633 | ) | 589 | ) |
| @@ -639,7 +595,6 @@ macro(add_runtime_api_library target_name) | |||
| 639 | ${RUNTIME_DIR}/src/runtime/api/api.cc | 595 | ${RUNTIME_DIR}/src/runtime/api/api.cc |
| 640 | ${RUNTIME_CORE_DIR}/src/profiler/prof_map_ge_model_device.cc | 596 | ${RUNTIME_CORE_DIR}/src/profiler/prof_map_ge_model_device.cc |
| 641 | ${RUNTIME_CORE_DIR}/src/plugin_manage/runtime_keeper.cc | 597 | ${RUNTIME_CORE_DIR}/src/plugin_manage/runtime_keeper.cc |
| 642 | - ${libruntime_aclrt_impl_src_files} | ||
| 643 | $<$<STREQUAL:${PRODUCT},ascend031>:$<TARGET_OBJECTS:runtime_platform_tiny>> | 598 | $<$<STREQUAL:${PRODUCT},ascend031>:$<TARGET_OBJECTS:runtime_platform_tiny>> |
| 644 | ) | 599 | ) |
| 645 | endif() | 600 | endif() |
| @@ -669,18 +624,6 @@ macro(add_runtime_api_library target_name) | |||
| 669 | target_include_directories(${target_name} PRIVATE | 624 | target_include_directories(${target_name} PRIVATE |
| 670 | ${RUNTIME_INC_DIR_TINY} | 625 | ${RUNTIME_INC_DIR_TINY} |
| 671 | ${RUNTIME_DIR}/include | 626 | ${RUNTIME_DIR}/include |
| 672 | - ${RUNTIME_DIR}/src/acl/aclrt_impl | ||
| 673 | - ${RUNTIME_DIR}/src/acl/common | ||
| 674 | - ${RUNTIME_DIR}/src/acl/utils | ||
| 675 | - ${RUNTIME_DIR}/src/acl | ||
| 676 | - ${RUNTIME_DIR}/include/external | ||
| 677 | - ${RUNTIME_DIR}/pkg_inc | ||
| 678 | - ${RUNTIME_DIR}/pkg_inc/runtime | ||
| 679 | - ${RUNTIME_DIR}/pkg_inc/runtime/runtime | ||
| 680 | - ${RUNTIME_DIR}/pkg_inc/dump | ||
| 681 | - ${RUNTIME_DIR}/src/dfx/error_manager | ||
| 682 | - ${RUNTIME_DIR}/src/dfx/adump/inc/metadef/external | ||
| 683 | - ${RUNTIME_DIR}/include/dfx | ||
| 684 | ) | 627 | ) |
| 685 | 628 | ||
| 686 | target_link_libraries(${target_name} | 629 | target_link_libraries(${target_name} |
| @@ -96,9 +96,8 @@ CAMODEL_SO="${BUILD_LIB_DIR}/libruntime_camodel.so" | |||
| 96 | DRIVER_LIB_DIR="${ROOT_DIR}/build_runtime_cmodel_product/src/cmodel_driver/${PRODUCT_TYPE}" | 96 | DRIVER_LIB_DIR="${ROOT_DIR}/build_runtime_cmodel_product/src/cmodel_driver/${PRODUCT_TYPE}" |
| 97 | PVDRIVER_SO="${DRIVER_LIB_DIR}/libnpu_drv_pvmodel.so" | 97 | PVDRIVER_SO="${DRIVER_LIB_DIR}/libnpu_drv_pvmodel.so" |
| 98 | CADRIVER_SO="${DRIVER_LIB_DIR}/libnpu_drv_camodel.so" | 98 | CADRIVER_SO="${DRIVER_LIB_DIR}/libnpu_drv_camodel.so" |
| 99 | -ERROR_MANAGER_SO="${ROOT_DIR}/build_runtime_cmodel_product/src/dfx/error_manager/liberror_manager.so" | ||
| 100 | 99 | ||
| 101 | -if [ ! -f "${CMODEL_SO}" ] || [ ! -f "${CAMODEL_SO}" ] || [ ! -f "${PVDRIVER_SO}" ] || [ ! -f "${CADRIVER_SO}" ] || [ ! -f "${ERROR_MANAGER_SO}" ]; then | 100 | +if [ ! -f "${CMODEL_SO}" ] || [ ! -f "${CAMODEL_SO}" ] || [ ! -f "${PVDRIVER_SO}" ] || [ ! -f "${CADRIVER_SO}" ]; then |
| 102 | fail "Built runtime cmodel libraries not found under: ${BUILD_LIB_DIR}" | 101 | fail "Built runtime cmodel libraries not found under: ${BUILD_LIB_DIR}" |
| 103 | fi | 102 | fi |
| 104 | 103 | ||
| @@ -107,7 +106,6 @@ cp -f "${CMODEL_SO}" "${SIMULATOR_PRODUCT_DIR}/lib/" | |||
| 107 | cp -f "${CAMODEL_SO}" "${SIMULATOR_PRODUCT_DIR}/lib/" | 106 | cp -f "${CAMODEL_SO}" "${SIMULATOR_PRODUCT_DIR}/lib/" |
| 108 | cp -f "${PVDRIVER_SO}" "${SIMULATOR_PRODUCT_DIR}/lib/" | 107 | cp -f "${PVDRIVER_SO}" "${SIMULATOR_PRODUCT_DIR}/lib/" |
| 109 | cp -f "${CADRIVER_SO}" "${SIMULATOR_PRODUCT_DIR}/lib/" | 108 | cp -f "${CADRIVER_SO}" "${SIMULATOR_PRODUCT_DIR}/lib/" |
| 110 | -cp -f "${ERROR_MANAGER_SO}" "${SIMULATOR_PRODUCT_DIR}/lib/" | ||
| 111 | 109 | ||
| 112 | LIB_DIR="${SIMULATOR_PRODUCT_DIR}/lib" | 110 | LIB_DIR="${SIMULATOR_PRODUCT_DIR}/lib" |
| 113 | DRIVER_COMMON_LIB_DIR="/usr/local/Ascend/driver/lib64/common" | 111 | DRIVER_COMMON_LIB_DIR="/usr/local/Ascend/driver/lib64/common" |
| @@ -78,7 +78,6 @@ set(SRC_FILES | |||
| 78 | ${BASE_DIR}/src/acl/aclrt_impl/allocator.cpp | 78 | ${BASE_DIR}/src/acl/aclrt_impl/allocator.cpp |
| 79 | ${BASE_DIR}/src/acl/aclrt_impl/log.cpp | 79 | ${BASE_DIR}/src/acl/aclrt_impl/log.cpp |
| 80 | ${BASE_DIR}/src/acl/aclrt_impl/toolchain/dump.cpp | 80 | ${BASE_DIR}/src/acl/aclrt_impl/toolchain/dump.cpp |
| 81 | - ${BASE_DIR}/src/acl/aclrt_impl/toolchain/dump_shim.cpp | ||
| 82 | ${BASE_DIR}/src/acl/aclrt_impl/toolchain/profiling.cpp | 81 | ${BASE_DIR}/src/acl/aclrt_impl/toolchain/profiling.cpp |
| 83 | ${BASE_DIR}/src/acl/aclrt_impl/toolchain/profiling_manager.cpp | 82 | ${BASE_DIR}/src/acl/aclrt_impl/toolchain/profiling_manager.cpp |
| 84 | ${BASE_DIR}/src/acl/common/json_parser.cpp | 83 | ${BASE_DIR}/src/acl/common/json_parser.cpp |
| @@ -34,8 +34,6 @@ namespace { | |||
| 34 | (void)!system(("touch " + infoFile).c_str()); | 34 | (void)!system(("touch " + infoFile).c_str()); |
| 35 | (void)!system(("mkdir -p " + fakeConfigDir).c_str()); | 35 | (void)!system(("mkdir -p " + fakeConfigDir).c_str()); |
| 36 | (void)!system(("touch " + fakeConfigFile).c_str()); | 36 | (void)!system(("touch " + fakeConfigFile).c_str()); |
| 37 | - (void)!system(("mkdir -p " + camodelDir).c_str()); | ||
| 38 | - (void)!system(("touch " + camodelRuntimeFile).c_str()); | ||
| 39 | } | 37 | } |
| 40 | void RemoveTestDir() | 38 | void RemoveTestDir() |
| 41 | { | 39 | { |
| @@ -79,8 +77,6 @@ namespace { | |||
| 79 | const std::string failDir = testDir + "/tmp_fail"; | 77 | const std::string failDir = testDir + "/tmp_fail"; |
| 80 | const std::string fakeConfigDir = failDir + "/tmp_run_data/ascendcl_config"; | 78 | const std::string fakeConfigDir = failDir + "/tmp_run_data/ascendcl_config"; |
| 81 | const std::string fakeConfigFile = fakeConfigDir + "/swFeatureList.json"; | 79 | const std::string fakeConfigFile = fakeConfigDir + "/swFeatureList.json"; |
| 82 | - const std::string camodelDir = testDir + "/simulator/dav_3510/camodel"; | ||
| 83 | - const std::string camodelRuntimeFile = camodelDir + "/libruntime_camodel.so"; | ||
| 84 | }; | 80 | }; |
| 85 | 81 | ||
| 86 | bool MockGetPlatformResWithLock(const string &label, const string &key, string &val) | 82 | bool MockGetPlatformResWithLock(const string &label, const string &key, string &val) |
| @@ -118,13 +114,6 @@ namespace { | |||
| 118 | info->dli_fname = ACL_BASE_DIR"/tests/tmp_run_data/tmp_fail/tmp_run_data/ascendcl_config"; | 114 | info->dli_fname = ACL_BASE_DIR"/tests/tmp_run_data/tmp_fail/tmp_run_data/ascendcl_config"; |
| 119 | return 0; | 115 | return 0; |
| 120 | } | 116 | } |
| 121 | - | ||
| 122 | - static INT32 mmDladdrCamodel(VOID* addr, mmDlInfo* info) | ||
| 123 | - { | ||
| 124 | - (void)addr; | ||
| 125 | - info->dli_fname = ACL_BASE_DIR "/tests/tmp_run_data/simulator/dav_3510/camodel/libruntime_camodel.so"; | ||
| 126 | - return 0; | ||
| 127 | - } | ||
| 128 | }; | 117 | }; |
| 129 | 118 | ||
| 130 | class MockRuntime { | 119 | class MockRuntime { |
| @@ -321,18 +310,6 @@ TEST_F(UTEST_ACL_Capability, aclGetCannAttribute_Fail_CannInfoUtilsInitError) | |||
| 321 | } | 310 | } |
| 322 | 311 | ||
| 323 | // test cases bewlow will successfully initialize CannInfoUtils | 312 | // test cases bewlow will successfully initialize CannInfoUtils |
| 324 | -TEST_F(UTEST_ACL_Capability, aclGetCannAttribute_Ok_CamodelFallbackGetInfNan) | ||
| 325 | -{ | ||
| 326 | - dirUtils.MakeRuntimeVersionInfo(); | ||
| 327 | - aclCannAttr cannAttr = ACL_CANN_ATTR_INF_NAN; | ||
| 328 | - int32_t value; | ||
| 329 | - EXPECT_CALL(MockFunctionTest::aclStubInstance(), mmDladdr(_, _)).WillRepeatedly(Invoke(MockMmpa::mmDladdrCamodel)); | ||
| 330 | - | ||
| 331 | - aclError ret = aclGetCannAttribute(cannAttr, &value); | ||
| 332 | - EXPECT_EQ(ret, ACL_SUCCESS); | ||
| 333 | - EXPECT_EQ(value, 1); | ||
| 334 | -} | ||
| 335 | - | ||
| 336 | TEST_F(UTEST_ACL_Capability, aclGetCannAttribute_Fail_InvalidCannAttr) | 313 | TEST_F(UTEST_ACL_Capability, aclGetCannAttribute_Fail_InvalidCannAttr) |
| 337 | { | 314 | { |
| 338 | dirUtils.MakeRuntimeVersionInfo(); | 315 | dirUtils.MakeRuntimeVersionInfo(); |
| @@ -24,7 +24,6 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | - | ||
| 28 | 27 | ||
| 29 | 28 | ||
| 30 | 29 | ||
| @@ -357,110 +356,6 @@ TEST_F(UTEST_ACL_toolchain, HandleDumpConfig_EmptyConfigStr_Test) | |||
| 357 | EXPECT_EQ(ret, ACL_SUCCESS); | 356 | EXPECT_EQ(ret, ACL_SUCCESS); |
| 358 | } | 357 | } |
| 359 | 358 | ||
| 360 | -TEST_F(UTEST_ACL_toolchain, HandleDumpCommand_ServerInitNotRegistered) | ||
| 361 | -{ | ||
| 362 | - // Backup original callbacks | ||
| 363 | - auto originalCallbacks = acl::GetAdumpCallbacks(); | ||
| 364 | - acl::AdumpCallbacks mockCallbacks = originalCallbacks; | ||
| 365 | - | ||
| 366 | - // Set serverInit to nullptr | ||
| 367 | - mockCallbacks.serverInit = nullptr; | ||
| 368 | - acl::SetAdumpCallbacks(mockCallbacks); | ||
| 369 | - | ||
| 370 | - // Call HandleDumpCommand | ||
| 371 | - const char* config = "{}"; | ||
| 372 | - aclError ret = acl::AclDump::HandleDumpCommand(config, 2, nullptr); | ||
| 373 | - | ||
| 374 | - // Verify return value | ||
| 375 | - EXPECT_EQ(ret, ACL_ERROR_INTERNAL_ERROR); | ||
| 376 | - | ||
| 377 | - // Restore original callbacks | ||
| 378 | - acl::SetAdumpCallbacks(originalCallbacks); | ||
| 379 | -} | ||
| 380 | - | ||
| 381 | -TEST_F(UTEST_ACL_toolchain, HandleDumpCommand_SetDumpNotRegistered) | ||
| 382 | -{ | ||
| 383 | - auto originalCallbacks = acl::GetAdumpCallbacks(); | ||
| 384 | - acl::AdumpCallbacks mockCallbacks = originalCallbacks; | ||
| 385 | - | ||
| 386 | - mockCallbacks.setDumpConfig = nullptr; | ||
| 387 | - acl::SetAdumpCallbacks(mockCallbacks); | ||
| 388 | - | ||
| 389 | - const char* config = "{}"; | ||
| 390 | - aclError ret = acl::AclDump::HandleDumpCommand(config, 2, nullptr); | ||
| 391 | - EXPECT_EQ(ret, ACL_ERROR_INTERNAL_ERROR); | ||
| 392 | - | ||
| 393 | - acl::SetAdumpCallbacks(originalCallbacks); | ||
| 394 | -} | ||
| 395 | - | ||
| 396 | -TEST_F(UTEST_ACL_toolchain, aclmdlInitDump_ServerInitNotRegistered) | ||
| 397 | -{ | ||
| 398 | - auto originalCallbacks = acl::GetAdumpCallbacks(); | ||
| 399 | - acl::AdumpCallbacks mockCallbacks = originalCallbacks; | ||
| 400 | - | ||
| 401 | - mockCallbacks.serverInit = nullptr; | ||
| 402 | - acl::SetAdumpCallbacks(mockCallbacks); | ||
| 403 | - | ||
| 404 | - (void)aclmdlFinalizeDump(); | ||
| 405 | - aclError ret = aclmdlInitDump(); | ||
| 406 | - EXPECT_EQ(ret, ACL_ERROR_INTERNAL_ERROR); | ||
| 407 | - | ||
| 408 | - acl::SetAdumpCallbacks(originalCallbacks); | ||
| 409 | -} | ||
| 410 | - | ||
| 411 | -TEST_F(UTEST_ACL_toolchain, aclmdlSetDump_SetDumpNotRegistered) | ||
| 412 | -{ | ||
| 413 | - auto originalCallbacks = acl::GetAdumpCallbacks(); | ||
| 414 | - acl::AdumpCallbacks mockCallbacks = originalCallbacks; | ||
| 415 | - | ||
| 416 | - (void)aclmdlFinalizeDump(); | ||
| 417 | - ASSERT_EQ(aclmdlInitDump(), ACL_SUCCESS); | ||
| 418 | - | ||
| 419 | - mockCallbacks.setDumpConfig = nullptr; | ||
| 420 | - acl::SetAdumpCallbacks(mockCallbacks); | ||
| 421 | - | ||
| 422 | - aclError ret = aclmdlSetDump(ACL_BASE_DIR "/tests/ut/acl/json/testDump1.json"); | ||
| 423 | - EXPECT_EQ(ret, ACL_ERROR_INTERNAL_ERROR); | ||
| 424 | - | ||
| 425 | - acl::SetAdumpCallbacks(originalCallbacks); | ||
| 426 | - (void)aclmdlFinalizeDump(); | ||
| 427 | -} | ||
| 428 | - | ||
| 429 | -TEST_F(UTEST_ACL_toolchain, aclmdlFinalizeDump_UnsetDumpNotRegistered) | ||
| 430 | -{ | ||
| 431 | - auto originalCallbacks = acl::GetAdumpCallbacks(); | ||
| 432 | - acl::AdumpCallbacks mockCallbacks = originalCallbacks; | ||
| 433 | - | ||
| 434 | - (void)aclmdlFinalizeDump(); | ||
| 435 | - ASSERT_EQ(aclmdlInitDump(), ACL_SUCCESS); | ||
| 436 | - | ||
| 437 | - mockCallbacks.unsetDump = nullptr; | ||
| 438 | - acl::SetAdumpCallbacks(mockCallbacks); | ||
| 439 | - | ||
| 440 | - aclError ret = aclmdlFinalizeDump(); | ||
| 441 | - EXPECT_EQ(ret, ACL_ERROR_INTERNAL_ERROR); | ||
| 442 | - | ||
| 443 | - acl::SetAdumpCallbacks(originalCallbacks); | ||
| 444 | - (void)aclmdlFinalizeDump(); | ||
| 445 | -} | ||
| 446 | - | ||
| 447 | -TEST_F(UTEST_ACL_toolchain, aclmdlFinalizeDump_ServerUnInitNotRegistered) | ||
| 448 | -{ | ||
| 449 | - auto originalCallbacks = acl::GetAdumpCallbacks(); | ||
| 450 | - acl::AdumpCallbacks mockCallbacks = originalCallbacks; | ||
| 451 | - | ||
| 452 | - (void)aclmdlFinalizeDump(); | ||
| 453 | - ASSERT_EQ(aclmdlInitDump(), ACL_SUCCESS); | ||
| 454 | - | ||
| 455 | - mockCallbacks.serverUnInit = nullptr; | ||
| 456 | - acl::SetAdumpCallbacks(mockCallbacks); | ||
| 457 | - | ||
| 458 | - aclError ret = aclmdlFinalizeDump(); | ||
| 459 | - EXPECT_EQ(ret, ACL_ERROR_INTERNAL_ERROR); | ||
| 460 | - | ||
| 461 | - acl::SetAdumpCallbacks(originalCallbacks); | ||
| 462 | - (void)aclmdlFinalizeDump(); | ||
| 463 | -} | ||
| 464 | // ========================== profiling testcase ============================= | 359 | // ========================== profiling testcase ============================= |
| 465 | 360 | ||
| 466 | TEST_F(UTEST_ACL_toolchain, setDeviceSuccess) | 361 | TEST_F(UTEST_ACL_toolchain, setDeviceSuccess) |