From b23968868cf1d7cf2a2ad07af9f7768a181f5c77 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 5 Nov 2020 16:53:55 +0800 Subject: [PATCH 01/32] remove thirdparty register --- .../fwkacllib/inc/register/host_cpu_context.h | 39 ----- .../inc/register/op_kernel_registry.h | 49 ------- .../fwkacllib/inc/register/op_registry.h | 90 ------------ .../fwkacllib/inc/register/op_tiling.h | 135 ------------------ .../register/ops_kernel_builder_registry.h | 62 -------- third_party/fwkacllib/inc/register/register.h | 54 ------- .../inc/register/register_format_transfer.h | 79 ---------- 7 files changed, 508 deletions(-) delete mode 100644 third_party/fwkacllib/inc/register/host_cpu_context.h delete mode 100644 third_party/fwkacllib/inc/register/op_kernel_registry.h delete mode 100644 third_party/fwkacllib/inc/register/op_registry.h delete mode 100644 third_party/fwkacllib/inc/register/op_tiling.h delete mode 100644 third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h delete mode 100644 third_party/fwkacllib/inc/register/register.h delete mode 100644 third_party/fwkacllib/inc/register/register_format_transfer.h diff --git a/third_party/fwkacllib/inc/register/host_cpu_context.h b/third_party/fwkacllib/inc/register/host_cpu_context.h deleted file mode 100644 index 4d6d5855..00000000 --- a/third_party/fwkacllib/inc/register/host_cpu_context.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INC_REGISTER_HOST_CPU_CONTEXT_H_ -#define INC_REGISTER_HOST_CPU_CONTEXT_H_ - -#include "external/ge/ge_api_error_codes.h" -#include "register/register_types.h" - -namespace ge { -class HostCpuContext { - public: - HostCpuContext() = default; - ~HostCpuContext() = default; - private: - class Impl; - Impl *impl_; -}; -} // namespace ge - -extern "C" { -// Unified definition for registering host_cpu_kernel_wrapper when so is opened -FMK_FUNC_HOST_VISIBILITY ge::Status Initialize(const ge::HostCpuContext &ctx); -} - -#endif //INC_REGISTER_HOST_CPU_CONTEXT_H_ diff --git a/third_party/fwkacllib/inc/register/op_kernel_registry.h b/third_party/fwkacllib/inc/register/op_kernel_registry.h deleted file mode 100644 index 5fed8960..00000000 --- a/third_party/fwkacllib/inc/register/op_kernel_registry.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INC_REGISTER_OP_KERNEL_REGISTRY_H_ -#define INC_REGISTER_OP_KERNEL_REGISTRY_H_ -#include -#include -#include "register/register_types.h" -#include "register.h" - -namespace ge { -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpKernelRegistry { - public: - using CreateFn = HostCpuOp* (*)(); - ~OpKernelRegistry(); - - static OpKernelRegistry& GetInstance() { - static OpKernelRegistry instance; - return instance; - } - - bool IsRegistered(const std::string &op_type); - - void RegisterHostCpuOp(const std::string &op_type, CreateFn create_fn); - - std::unique_ptr CreateHostCpuOp(const std::string &op_type); - - private: - OpKernelRegistry(); - class OpKernelRegistryImpl; - /*lint -e148*/ - std::unique_ptr impl_; -}; -} // namespace ge - -#endif // INC_REGISTER_OP_KERNEL_REGISTRY_H_ diff --git a/third_party/fwkacllib/inc/register/op_registry.h b/third_party/fwkacllib/inc/register/op_registry.h deleted file mode 100644 index 3feea0df..00000000 --- a/third_party/fwkacllib/inc/register/op_registry.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INC_REGISTER_OP_REGISTRY_H_ -#define INC_REGISTER_OP_REGISTRY_H_ - -#include -#include -#include -#include -#include - -#include "register/register.h" - -namespace domi { -enum RemoveInputType { - OMG_MOVE_TYPE_DTYPE = 0, - OMG_MOVE_TYPE_VALUE, - OMG_MOVE_TYPE_SHAPE, - OMG_MOVE_TYPE_FORMAT, - OMG_MOVE_TYPE_AXIS, - OMG_MOVE_TYPE_SCALAR_VALUE, - OMG_REMOVE_TYPE_WITH_COND = 1000, - OMG_REMOVE_INPUT_WITH_ORIGINAL_TYPE, - OMG_INPUT_REORDER, -}; - -struct RemoveInputConfigure { - int inputIdx = INT_MAX; - std::string attrName; - RemoveInputType moveType; - bool attrValue = false; - std::string originalType; - std::vector input_order; -}; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistry { - public: - static OpRegistry *Instance(); - - std::vector registrationDatas; - - bool Register(const OpRegistrationData ®_data); - - domi::ImplyType GetImplyType(const std::string &op_type); - - void GetOpTypeByImplyType(std::vector &vec_op_type, const domi::ImplyType &imply_type); - - domi::ParseParamFunc GetParseParamFunc(const std::string &op_type, const std::string &ori_type); - - domi::ParseParamByOpFunc GetParseParamByOperatorFunc(const std::string &ori_type); - - domi::FusionParseParamFunc GetFusionParseParamFunc(const std::string &op_type, const std::string &ori_type); - - domi::FusionParseParamByOpFunc GetFusionParseParamByOpFunc(const std::string &op_type, - const std::string &ori_type); - - domi::ParseSubgraphFunc GetParseSubgraphPostFunc(const std::string &op_type); - - domi::ImplyType GetImplyTypeByOriOpType(const std::string &ori_optype); - - const std::vector &GetRemoveInputConfigure(const std::string &ori_optype) const; - - bool GetOmTypeByOriOpType(const std::string &ori_optype, std::string &om_type); - - private: - std::unordered_map op_run_mode_map_; - std::unordered_map op_parse_params_fn_map_; - std::unordered_map parse_params_by_op_func_map_; - std::unordered_map fusion_op_parse_params_fn_map_; - std::unordered_map fusion_parse_params_by_op_fn_map_; - std::unordered_map op_types_to_parse_subgraph_post_func_; - std::unordered_map> remove_input_configure_map_; - std::unordered_map origin_type_to_om_type_; -}; -} // namespace domi -#endif // INC_REGISTER_OP_REGISTRY_H_ diff --git a/third_party/fwkacllib/inc/register/op_tiling.h b/third_party/fwkacllib/inc/register/op_tiling.h deleted file mode 100644 index bcd4cd5e..00000000 --- a/third_party/fwkacllib/inc/register/op_tiling.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INC_OP_TILING_H_ -#define INC_OP_TILING_H_ - -#include "external/register/register_types.h" -#include "external/graph/tensor.h" -#include "graph/debug/ge_attr_define.h" -#include "graph/node.h" - -#include -#include -#include -#include -#include -#include -#include -#include "graph/node.h" - -#define REGISTER_OP_TILING_FUNC(optype, opfunc) \ - REGISTER_OP_TILING_FUNC_UNIQ_HELPER(optype, opfunc, __COUNTER__) - -#define REGISTER_OP_TILING_FUNC_UNIQ_HELPER(optype, opfunc, counter) \ - REGISTER_OP_TILING_FUNC_UNIQ(optype, opfunc, counter) - -#define REGISTER_OP_TILING_FUNC_UNIQ(optype, opfunc, counter) \ - static OpTilingInterf g_##optype##TilingInterf##counter(#optype, opfunc) - -namespace optiling { - -enum TensorArgType { - TA_NONE, - TA_SINGLE, - TA_LIST, -}; - - -using ByteBuffer = std::stringstream; - -struct TeOpTensor { - std::vector shape; - std::vector ori_shape; - std::string format; - std::string ori_format; - std::string dtype; - std::map attrs; -}; - - -struct TeOpTensorArg { - TensorArgType arg_type; - std::vector tensor; -}; - -struct OpRunInfo { - uint32_t block_dim; - std::vector workspaces; - ByteBuffer tiling_data; -}; - - -using TeOpAttrArgs = std::vector; -using TeConstTensorData = std::tuple; - -struct TeOpParas { - std::vector inputs; - std::vector outputs; - std::map const_inputs; - TeOpAttrArgs attrs; -}; - - -using OpTilingFunc = std::function; - -using OpTilingFuncPtr = bool(*)(const std::string&, const TeOpParas&, const nlohmann::json& , OpRunInfo&); - -class FMK_FUNC_HOST_VISIBILITY OpTilingInterf -{ -public: - OpTilingInterf(std::string op_type, OpTilingFunc func); - ~OpTilingInterf() = default; - static std::map &RegisteredOpInterf(); - static std::string OpTilingUuid; -}; - - -template -ByteBuffer& ByteBufferPut(ByteBuffer &buf, const T &value) -{ - buf.write(reinterpret_cast(&value), sizeof(value)); - buf.flush(); - return buf; -} - -template -ByteBuffer& ByteBufferGet(ByteBuffer &buf, T &value) -{ - buf.read(reinterpret_cast(&value), sizeof(value)); - return buf; -} - -inline size_t ByteBufferGetAll(ByteBuffer &buf, char *dest, size_t dest_len) -{ - size_t nread = 0; - size_t rn = 0; - do { - rn = buf.readsome(dest + nread, dest_len - nread); - nread += rn; - } while (rn > 0 && dest_len > nread); - - return nread; -} - - -extern "C" ge::graphStatus OpParaCalculate(const ge::Node &node, OpRunInfo &run_info); -extern "C" ge::graphStatus OpAtomicCalculate(const ge::Node &node, OpRunInfo &run_info); - -} - -#endif // INC_OP_TILING_H_ diff --git a/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h b/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h deleted file mode 100644 index 96ac931b..00000000 --- a/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ -#define INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ - -#include -#include "register/register_types.h" -#include "common/opskernel/ops_kernel_builder.h" - -namespace ge { -using OpsKernelBuilderPtr = std::shared_ptr; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpsKernelBuilderRegistry { - public: - static OpsKernelBuilderRegistry &GetInstance(); - - void Register(const std::string &lib_name, const OpsKernelBuilderPtr &instance); - - void UnregisterAll(); - - const std::map &GetAll() const; - - private: - std::map kernel_builders_; -}; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpsKernelBuilderRegistrar { - public: - using CreateFn = OpsKernelBuilder *(*)(); - OpsKernelBuilderRegistrar(const std::string &kernel_lib_name, CreateFn fn); - ~OpsKernelBuilderRegistrar() = default; -}; - -#define REGISTER_OPS_KERNEL_BUILDER(kernel_lib_name, builder) \ - REGISTER_OPS_KERNEL_BUILDER_UNIQ_HELPER(__COUNTER__, kernel_lib_name, builder) - -#define REGISTER_OPS_KERNEL_BUILDER_UNIQ_HELPER(ctr, kernel_lib_name, builder) \ - REGISTER_OPS_KERNEL_BUILDER_UNIQ(ctr, kernel_lib_name, builder) - -#define REGISTER_OPS_KERNEL_BUILDER_UNIQ(ctr, kernel_lib_name, builder) \ - static ::ge::OpsKernelBuilderRegistrar register_op_kernel_builder_##ctr \ - __attribute__((unused)) = \ - ::ge::OpsKernelBuilderRegistrar(kernel_lib_name, []()->::ge::OpsKernelBuilder* { \ - return new (std::nothrow) builder(); \ - }) -} // namespace ge - -#endif // INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ diff --git a/third_party/fwkacllib/inc/register/register.h b/third_party/fwkacllib/inc/register/register.h deleted file mode 100644 index d98edaa4..00000000 --- a/third_party/fwkacllib/inc/register/register.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INC_REGISTER_REGISTRY_H_ -#define INC_REGISTER_REGISTRY_H_ - -#include "external/register/register.h" -#include "external/ge/ge_api_error_codes.h" - -namespace ge { -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY HostCpuOp { - public: - HostCpuOp() = default; - virtual ~HostCpuOp() = default; - - virtual graphStatus Compute(Operator &op, - const std::map &inputs, - std::map &outputs) = 0; -}; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY HostCpuOpRegistrar { - public: - HostCpuOpRegistrar(const char *op_type, HostCpuOp *(*create_fn)()); - ~HostCpuOpRegistrar() = default; -}; - -#define REGISTER_HOST_CPU_OP_BUILDER(name, op) \ - REGISTER_HOST_CPU_OP_BUILDER_UNIQ_HELPER(__COUNTER__, name, op) - -#define REGISTER_HOST_CPU_OP_BUILDER_UNIQ_HELPER(ctr, name, op) \ - REGISTER_HOST_CPU_OP_BUILDER_UNIQ(ctr, name, op) - -#define REGISTER_HOST_CPU_OP_BUILDER_UNIQ(ctr, name, op) \ - static ::ge::HostCpuOpRegistrar register_host_cpu_op##ctr \ - __attribute__((unused)) = \ - ::ge::HostCpuOpRegistrar(name, []()->::ge::HostCpuOp* { \ - return new (std::nothrow) op(); \ - }) -} // namespace ge - -#endif //INC_REGISTER_REGISTRY_H_ diff --git a/third_party/fwkacllib/inc/register/register_format_transfer.h b/third_party/fwkacllib/inc/register/register_format_transfer.h deleted file mode 100644 index 72da94fc..00000000 --- a/third_party/fwkacllib/inc/register/register_format_transfer.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INC_REGISTER_REGISTER_FORMAT_TRANSFER_H_ -#define INC_REGISTER_REGISTER_FORMAT_TRANSFER_H_ - -#include -#include -#include - -#include "external/graph/types.h" -#include "ge/ge_api_error_codes.h" - -namespace ge { -namespace formats { -struct TransArgs { - const uint8_t *data; - Format src_format; - Format dst_format; - // For scenes that need to supplement the shape, for example, 5D to 4D - // It is not possible to convert the format normally if you only get the src_shape, - // and must get the shape before you mend the shape. - // So the parameters here need to be passed in both src_shape and dst_shape - std::vector src_shape; - std::vector dst_shape; - DataType src_data_type; -}; - -struct TransResult { - std::shared_ptr data; - // data length in bytes - size_t length; -}; - -class FormatTransfer { - public: - virtual ~FormatTransfer() = default; - virtual Status TransFormat(const TransArgs &args, TransResult &result) = 0; - virtual Status TransShape(Format src_format, const std::vector &src_shape, DataType data_type, - Format dst_format, std::vector &dst_shape) = 0; -}; - -using FormatTransferBuilder = std::function()>; - -class FormatTransferRegister { - public: - FormatTransferRegister(FormatTransferBuilder builder, Format src, Format dst); - ~FormatTransferRegister() = default; -}; - -#define REGISTER_FORMAT_TRANSFER(TransferClass, format1, format2) \ - namespace { \ - FormatTransferRegister format_transfer_register_##TransferClass##format1##format2( \ - []() { return std::make_shared(); }, format1, format2); \ - } - -/// Build a formattransfer according to 'args' -/// @param args -/// @param result -/// @return -std::shared_ptr BuildFormatTransfer(const TransArgs &args); - -bool FormatTransferExists(const TransArgs &args); -} // namespace formats -} // namespace ge -#endif // INC_REGISTER_REGISTER_FORMAT_TRANSFER_H_ \ No newline at end of file From 11851b69bf695ab211de92c65c2ce3fc523d3aa2 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Mon, 9 Nov 2020 20:10:58 +0800 Subject: [PATCH 02/32] ge executor support windows --- ge/client/ge_api.cc | 2 +- ge/common/auth/file_saver.cc | 12 ++- ge/common/debug/memory_dumper.cc | 17 ++-- .../format_transfer_nchw_fz_c04.cc | 16 ++-- ge/common/ge/op_tiling_manager.cc | 27 +++--- ge/common/ge/plugin_manager.cc | 67 +++++++++------ ge/common/ge/plugin_manager.h | 12 +-- ge/common/ge/tbe_plugin_manager.cc | 82 +++++++++--------- ge/common/ge/tbe_plugin_manager.h | 1 - ge/common/helper/model_cache_helper.cc | 6 +- ge/common/helper/model_helper.cc | 2 +- ge/common/model_parser/base.cc | 1 - ge/common/model_saver.cc | 14 ++- ge/common/profiling/profiling_manager.cc | 8 +- ge/common/properties_manager.h | 9 +- ge/common/util.cc | 85 ++++++++++++------- ge/engine_manager/dnnengine_manager.cc | 2 +- ge/graph/build/memory/block_mem_assigner.cc | 8 +- ge/graph/build/memory/graph_mem_assigner.cc | 2 +- .../new_model_manager/cpu_queue_schedule.cc | 2 +- .../load/new_model_manager/davinci_model.cc | 65 +++++++------- .../load/new_model_manager/model_manager.cc | 10 +-- .../load/new_model_manager/model_manager.h | 1 - .../load/new_model_manager/model_utils.cc | 6 +- .../task_info/kernel_ex_task_info.cc | 4 +- .../task_info/kernel_task_info.cc | 46 ++++++---- .../task_info/super_kernel/super_kernel.cc | 2 +- .../super_kernel/super_kernel_factory.cc | 14 +-- .../super_kernel/super_kernel_factory.h | 6 +- .../new_model_manager/zero_copy_offset.cc | 4 +- .../load/new_model_manager/zero_copy_task.cc | 3 +- ge/graph/manager/graph_var_manager.cc | 12 +-- ge/graph/manager/trans_var_data_utils.cc | 6 +- ge/graph/manager/util/debug.cc | 6 +- ge/graph/manager/util/debug.h | 2 - ge/hybrid/executor/hybrid_execution_context.h | 4 +- ge/init/gelib.cc | 10 +-- ge/omm/csa_interact.cc | 16 ++-- ge/opskernel_manager/ops_kernel_manager.cc | 2 +- ge/session/session_manager.cc | 26 +++--- ge/single_op/single_op.cc | 6 +- inc/framework/common/debug/ge_log.h | 70 ++++++++++++--- inc/framework/common/ge_compiler_options.h | 32 +++++++ inc/framework/common/string_util.h | 1 + inc/framework/common/types.h | 3 +- 45 files changed, 435 insertions(+), 297 deletions(-) create mode 100644 inc/framework/common/ge_compiler_options.h diff --git a/ge/client/ge_api.cc b/ge/client/ge_api.cc index 5619f137..ef8d5622 100644 --- a/ge/client/ge_api.cc +++ b/ge/client/ge_api.cc @@ -177,7 +177,7 @@ Session::Session(const std::map &options) { // check init status sessionId_ = 0; if (!g_ge_initialized) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized."); return; } // call Initialize diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index 60d99c0b..7b41397a 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -16,9 +16,7 @@ #include "common/auth/file_saver.h" -#include #include -#include #include #include #include @@ -39,12 +37,12 @@ Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { return FAILED; } - char real_path[PATH_MAX] = {0}; - GE_IF_BOOL_EXEC(realpath(file_path.c_str(), real_path) == nullptr, + char real_path[MMPA_MAX_PATH] = {0}; + GE_IF_BOOL_EXEC(mmRealPath(file_path.c_str(), real_path, MMPA_MAX_PATH) != EN_OK, GELOGI("File %s is not exist, it will be created.", file_path.c_str())); // Open file - mode_t mode = S_IRUSR | S_IWUSR; - fd = mmOpen2(real_path, O_RDWR | O_CREAT | O_TRUNC, mode); + mmMode_t mode = M_IRUSR | M_IWUSR; + fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode); if (fd == EN_INVALID_PARAM || fd == EN_ERROR) { // -1: Failed to open file; - 2: Illegal parameter GELOGE(FAILED, "Open file failed. mmpa_errno = %d, %s", fd, strerror(errno)); @@ -194,7 +192,7 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header, FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(const std::string &file_path) { // Determine file path length - if (file_path.size() >= PATH_MAX) { + if (file_path.size() >= MMPA_MAX_PATH) { GELOGE(FAILED, "Path is too long:%zu", file_path.size()); return FAILED; } diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index d2b8d674..e57c234f 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -16,9 +16,6 @@ #include "common/debug/memory_dumper.h" -#include - -#include #include #include "framework/common/debug/log.h" @@ -138,26 +135,26 @@ int MemoryDumper::OpenFile(const char *filename) { } // Get the absolute path string real_path; - char tmp_path[PATH_MAX] = {0}; + char tmp_path[MMPA_MAX_PATH] = {0}; GE_IF_BOOL_EXEC( -1 != path_split_pos, string prefix_path = std::string(filename).substr(0, path_split_pos); string last_path = std::string(filename).substr(path_split_pos, strlen(filename) - 1); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(prefix_path.length() >= PATH_MAX, return kInvalidFd, "Prefix path is too long!"); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(realpath(prefix_path.c_str(), tmp_path) == nullptr, return kInvalidFd, + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(prefix_path.length() >= MMPA_MAX_PATH, return kInvalidFd, "Prefix path is too long!"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(mmRealPath(prefix_path.c_str(), tmp_path, MMPA_MAX_PATH) != EN_OK, return kInvalidFd, "Dir %s does not exit.", prefix_path.c_str()); real_path = std::string(tmp_path) + last_path;) GE_IF_BOOL_EXEC( path_split_pos == -1 || path_split_pos == 0, - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(filename) >= PATH_MAX, return kInvalidFd, "Prefix path is too long!"); - GE_IF_BOOL_EXEC(realpath(filename, tmp_path) == nullptr, + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(filename) >= MMPA_MAX_PATH, return kInvalidFd, "Prefix path is too long!"); + GE_IF_BOOL_EXEC(mmRealPath(filename, tmp_path, MMPA_MAX_PATH) != EN_OK, GELOGI("File %s does not exit, it will be created.", filename)); real_path = std::string(tmp_path);) // Open file, only the current user can read and write, to avoid malicious application access // Using the O_EXCL, if the file already exists,return failed to avoid privilege escalation vulnerability. - mode_t mode = S_IRUSR | S_IWUSR; + mmMode_t mode = M_IRUSR | M_IWUSR; - int32_t fd = mmOpen2(real_path.c_str(), O_RDWR | O_CREAT | O_APPEND, mode); + int32_t fd = mmOpen2(real_path.c_str(), M_WRONLY | M_CREAT | O_TRUNC, mode); if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { GELOGE(kInvalidFd, "open file failed. errno = %d, %s", fd, strerror(errno)); return kInvalidFd; diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc index 275d9f10..a66aeeb4 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc @@ -118,19 +118,19 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { // data overflow check totally GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o), - GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", h_o, w_o); + GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", h_o, w_o); return INTERNAL_ERROR); GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o), - GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", n_o, c_o); + GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", n_o, c_o); return INTERNAL_ERROR); auto t1 = h_o * w_o; auto t2 = n_o * c_o; - GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", t1, t2); + GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2); return INTERNAL_ERROR); int64_t total_ele_cnt = n_o * c_o * h_o * w_o; GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size), - GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%lld], B[%lld]", total_ele_cnt, size); + GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size); return INTERNAL_ERROR); int64_t dst_size = total_ele_cnt * size; if (dst_size == 0) { @@ -205,20 +205,20 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr #include -#include #include #include #include @@ -38,8 +36,10 @@ const char *const kExt = ".so"; // supported extension of shared obje namespace ge { void PluginManager::ClearHandles_() noexcept { for (const auto &handle : handles_) { - if (dlclose(handle.second) != 0) { - GELOGW("Failed to close handle of %s: %s", handle.first.c_str(), dlerror()); + if (mmDlclose(handle.second) != 0) { + const char *error = mmDlerror(); + GE_IF_BOOL_EXEC(error == nullptr, error = ""); + GELOGW("Failed to close handle of %s: %s", handle.first.c_str(), error); } } handles_.clear(); @@ -48,18 +48,18 @@ void PluginManager::ClearHandles_() noexcept { PluginManager::~PluginManager() { ClearHandles_(); } string PluginManager::GetPath() { - Dl_info dl_info; - if (dladdr(reinterpret_cast(&PluginManager::GetPath), &dl_info) == 0) { + mmDlInfo dl_info; + if (mmDladdr(reinterpret_cast(&PluginManager::GetPath), &dl_info) != EN_OK) { GELOGW("Failed to read the shared library file path!"); return string(); } else { std::string so_path = dl_info.dli_fname; - char path[PATH_MAX] = {0}; - if (so_path.length() >= PATH_MAX) { + char path[MMPA_MAX_PATH] = {0}; + if (so_path.length() >= MMPA_MAX_PATH) { GELOGW("The shared library file path is too long!"); return string(); } - if (realpath(so_path.c_str(), path) == nullptr) { + if (mmRealPath(so_path.c_str(), path, MMPA_MAX_PATH) != EN_OK) { GELOGW("Failed to get realpath of %s", so_path.c_str()); return string(); } @@ -93,7 +93,7 @@ Status PluginManager::LoadSo(const string &path, const vector &func_chec std::vector path_vec; SplitPath(path, path_vec); for (const auto &single_path : path_vec) { - GE_IF_BOOL_EXEC(single_path.length() >= PATH_MAX, GELOGE(GE_PLGMGR_PATH_INVALID, + GE_IF_BOOL_EXEC(single_path.length() >= MMPA_MAX_PATH, GELOGE(GE_PLGMGR_PATH_INVALID, "The shared library file path is too long!"); continue); // load break when number of loaded so reach maximum @@ -119,16 +119,18 @@ Status PluginManager::LoadSo(const string &path, const vector &func_chec GELOGI("dlopen the shared library path name: %s.", file_path_dlopen.c_str()); // load continue when dlopen is failed - auto handle = dlopen(file_path_dlopen.c_str(), RTLD_NOW | RTLD_GLOBAL); + auto handle = mmDlopen(file_path_dlopen.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL); if (handle == nullptr) { - GELOGE(GE_PLGMGR_PATH_INVALID, "Failed to dlopen %s!", dlerror()); + const char *error = mmDlerror(); + GE_IF_BOOL_EXEC(error == nullptr, error = ""); + GELOGE(GE_PLGMGR_PATH_INVALID, "Failed to dlopen %s!", error); continue; } // load continue when so is invalid bool is_valid = true; for (const auto &func_name : func_check_list) { - auto real_fn = (void (*)())dlsym(handle, func_name.c_str()); + auto real_fn = (void (*)())mmDlsym(handle, const_cast(func_name.c_str())); if (real_fn == nullptr) { GELOGE(GE_PLGMGR_PATH_INVALID, "%s is skipped since function %s is not existed!", func_name.c_str(), func_name.c_str()); @@ -137,7 +139,7 @@ Status PluginManager::LoadSo(const string &path, const vector &func_chec } } if (!is_valid) { - GE_LOGE_IF(dlclose(handle), "Failed to dlclose."); + GE_LOGE_IF(mmDlclose(handle), "Failed to dlclose."); continue; } @@ -197,22 +199,29 @@ Status PluginManager::Load(const string &path, const vector &func_check_ so_list_.clear(); ClearHandles_(); - char canonical_path[PATH_MAX] = {0}; - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path.length() >= PATH_MAX, GELOGW("File path is too long!"); + char canonical_path[MMPA_MAX_PATH] = {0}; + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path.length() >= MMPA_MAX_PATH, GELOGW("File path is too long!"); return FAILED, "File path is too long!"); - if (realpath(path.c_str(), canonical_path) == nullptr) { + if (mmRealPath(path.c_str(), canonical_path, MMPA_MAX_PATH) != EN_OK) { GELOGW("Failed to get realpath of %s", path.c_str()); return SUCCESS; } - DIR *dir = opendir(canonical_path); - if (dir == nullptr) { - GELOGW("Invalid path for load: %s", path.c_str()); - return SUCCESS; + INT32 is_dir = mmIsDir(canonical_path); + // Lib plugin path not exist + if (is_dir != EN_OK) { + GELOGW("Invalid path for load: %s", path.c_str()); + return SUCCESS; } - struct dirent *entry = nullptr; - while ((entry = readdir(dir)) != nullptr) { + mmDirent **entries = nullptr; + auto ret = mmScandir(canonical_path, &entries, nullptr, nullptr); + if (ret < EN_OK) { + GELOGW("scan dir failed. path = %s, ret = %d", canonical_path, ret); + return FAILED; + } + for (int i = 0; i < ret; ++i) { + mmDirent *entry = entries[i]; // read fileName and fileType std::string file_name = entry->d_name; unsigned char file_type = entry->d_type; @@ -250,9 +259,11 @@ Status PluginManager::Load(const string &path, const vector &func_check_ GELOGI("Dlopen so path name: %s. ", file_path_dlopen.c_str()); // load continue when dlopen is failed - auto handle = dlopen(file_path_dlopen.c_str(), RTLD_NOW | RTLD_GLOBAL); + auto handle = mmDlopen(file_path_dlopen.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL); if (handle == nullptr) { - GELOGW("Failed in dlopen %s!", dlerror()); + const char *error = mmDlerror(); + GE_IF_BOOL_EXEC(error == nullptr, error = ""); + GELOGW("Failed in dlopen %s!", error); continue; } @@ -261,7 +272,7 @@ Status PluginManager::Load(const string &path, const vector &func_check_ // load continue when so is invalid bool is_valid = true; for (const auto &func_name : func_check_list) { - auto real_fn = (void (*)())dlsym(handle, func_name.c_str()); + auto real_fn = (void (*)())mmDlsym(handle, const_cast(func_name.c_str())); if (real_fn == nullptr) { GELOGW("The %s is skipped since function %s is not existed!", file_name.c_str(), func_name.c_str()); is_valid = false; @@ -269,7 +280,7 @@ Status PluginManager::Load(const string &path, const vector &func_check_ } } if (!is_valid) { - GE_LOGE_IF(dlclose(handle), "Failed to dlclose."); + GE_LOGE_IF(mmDlclose(handle), "Failed to dlclose."); continue; } @@ -279,7 +290,7 @@ Status PluginManager::Load(const string &path, const vector &func_check_ handles_[string(file_name)] = handle; num_of_loaded_so++; } - closedir(dir); + mmScandirFree(entries, ret); if (num_of_loaded_so == 0) { GELOGW("No loadable shared library found in the path: %s", path.c_str()); return SUCCESS; diff --git a/ge/common/ge/plugin_manager.h b/ge/common/ge/plugin_manager.h index 903367a3..7ef0f81a 100755 --- a/ge/common/ge/plugin_manager.h +++ b/ge/common/ge/plugin_manager.h @@ -17,7 +17,6 @@ #ifndef GE_COMMON_GE_PLUGIN_MANAGER_H_ #define GE_COMMON_GE_PLUGIN_MANAGER_H_ -#include #include #include #include @@ -30,6 +29,7 @@ #include "common/ge_inner_error_codes.h" #include "engine/dnnengine.h" #include "framework/common/debug/ge_log.h" +#include "mmpa/mmpa_api.h" namespace ge { using SoToHandleMap = std::map; @@ -57,7 +57,7 @@ class PluginManager { template Status GetAllFunctions(const string &func_name, map> &funcs) { for (const auto &handle : handles_) { - auto real_fn = (R(*)(Types...))dlsym(handle.second, func_name.c_str()); + auto real_fn = (R(*)(Types...))mmDlsym(handle.second, const_cast(func_name.c_str())); if (real_fn == nullptr) { GELOGW("Failed to get function %s in %s!", func_name.c_str(), handle.first.c_str()); return GE_PLGMGR_FUNC_NOT_EXIST; @@ -72,7 +72,7 @@ class PluginManager { Status InvokeAll(const string &func_name, Types... args) { for (const auto &handle : handles_) { // If the funcName is existed, signature of realFn can be casted to any type - auto real_fn = (void (*)(Types...))dlsym(handle.second, func_name.c_str()); + auto real_fn = (void (*)(Types...))mmDlsym(handle.second, const_cast(func_name.c_str())); if (real_fn == nullptr) { GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); return GE_PLGMGR_INVOKE_FAILED; @@ -87,7 +87,7 @@ class PluginManager { Status InvokeAll(const string &func_name, T arg) { for (const auto &handle : handles_) { // If the funcName is existed, signature of realFn can be casted to any type - auto real_fn = (void (*)(T))dlsym(handle.second, func_name.c_str()); + auto real_fn = (void (*)(T))mmDlsym(handle.second, const_cast(func_name.c_str())); if (real_fn == nullptr) { GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); return GE_PLGMGR_INVOKE_FAILED; @@ -112,7 +112,7 @@ class PluginManager { Status InvokeAll(const string &func_name, T1 arg) { for (const auto &handle : handles_) { // If the funcName is existed, signature of realFn can be casted to any type - auto real_fn = (T2(*)(T1))dlsym(handle.second, func_name.c_str()); + auto real_fn = (T2(*)(T1))mmDlsym(handle.second, const_cast(func_name.c_str())); if (real_fn == nullptr) { GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); return GE_PLGMGR_INVOKE_FAILED; @@ -130,7 +130,7 @@ class PluginManager { Status InvokeAll(const string &func_name) { for (const auto &handle : handles_) { // If the funcName is existed, signature of realFn can be casted to any type - auto real_fn = (T(*)())dlsym(handle.second, func_name.c_str()); + auto real_fn = (T(*)())mmDlsym(handle.second, const_cast(func_name.c_str())); if (real_fn == nullptr) { GELOGW("Failed to invoke function %s in %s!", func_name.c_str(), handle.first.c_str()); return GE_PLGMGR_INVOKE_FAILED; diff --git a/ge/common/ge/tbe_plugin_manager.cc b/ge/common/ge/tbe_plugin_manager.cc index 92da8e14..b91f1204 100755 --- a/ge/common/ge/tbe_plugin_manager.cc +++ b/ge/common/ge/tbe_plugin_manager.cc @@ -16,8 +16,6 @@ #include "common/ge/tbe_plugin_manager.h" -#include -#include #include #include #include @@ -50,9 +48,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY TBEPluginManager &TBEPluginMana Status TBEPluginManager::ClearHandles_() { Status ret = SUCCESS; for (const auto &handle : handles_vec_) { - if (dlclose(handle) != 0) { + if (mmDlclose(handle) != 0) { ret = FAILED; - GELOGW("Failed to close handle: %s", dlerror()); + const char *error = mmDlerror(); + GE_IF_BOOL_EXEC(error == nullptr, error = ""); + GELOGW("Failed to close handle: %s", error); } } handles_vec_.clear(); @@ -65,18 +65,18 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status TBEPluginManager::Finali } string TBEPluginManager::GetPath() { - Dl_info dl_info; - if (dladdr(reinterpret_cast(&TBEPluginManager::GetPath), &dl_info) == 0) { + mmDlInfo dl_info; + if (mmDladdr(reinterpret_cast(&TBEPluginManager::GetPath), &dl_info) != EN_OK) { GELOGW("Failed to read so path!"); return string(); } else { string so_path = dl_info.dli_fname; - char path[PATH_MAX] = {0}; - if (so_path.length() >= PATH_MAX) { + char path[MMPA_MAX_PATH] = {0}; + if (so_path.length() >= MMPA_MAX_PATH) { GELOGW("File path is too long!"); return string(); } - if (realpath(so_path.c_str(), path) == nullptr) { + if (mmRealPath(so_path.c_str(), path, MMPA_MAX_PATH) != EN_OK) { GELOGW("Failed to get realpath of %s", so_path.c_str()); return string(); } @@ -108,35 +108,36 @@ void TBEPluginManager::FindParserSo(const string &path, vector &file_lis GELOGW("RealPath is empty."); return; } - struct stat stat_buf; - if ((stat(real_path.c_str(), &stat_buf) != 0) || (!S_ISDIR(stat_buf.st_mode))) { - GELOGW("%s is not a dir.", real_path.c_str()); - return; - } - struct dirent *dent(0); - DIR *dir = opendir(real_path.c_str()); - // Plugin path does not exist - if (dir == nullptr) { - GELOGW("Open directory %s failed.", real_path.c_str()); - return; + INT32 is_dir = mmIsDir(real_path.c_str()); + // Lib plugin path not exist + if (is_dir != EN_OK) { + GELOGW("%s is not a dir.", real_path.c_str()); + return; } - while ((dent = readdir(dir)) != nullptr) { - if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; - string name = dent->d_name; - string full_name = real_path + "/" + name; - const string so_suff = ".so"; - const string caffe_parser_so_suff = "lib_caffe_parser.so"; - const string aicpu_so_suff = "_aicpu.so"; - const string aicpu_host_so_suff = "_online.so"; - if (name.size() >= so_suff.size() && name.compare(name.size() - so_suff.size(), so_suff.size(), so_suff) == 0) { - ProcessSoFullName(file_list, caffe_parser_path, full_name, caffe_parser_so_suff, aicpu_so_suff, - aicpu_host_so_suff); - } else { - FindParserSo(full_name, file_list, caffe_parser_path); - } + mmDirent **entries = nullptr; + auto ret = mmScandir(real_path.c_str(), &entries, nullptr, nullptr); + if (ret < EN_OK) { + GELOGW("scan dir failed. path = %s, ret = %d", real_path.c_str(), ret); + return; + } + for (int i = 0; i < ret; ++i) { + mmDirent *dent = entries[i]; + if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; + string name = dent->d_name; + string full_name = real_path + "/" + name; + const string so_suff = ".so"; + const string caffe_parser_so_suff = "lib_caffe_parser.so"; + const string aicpu_so_suff = "_aicpu.so"; + const string aicpu_host_so_suff = "_online.so"; + if (name.size() >= so_suff.size() && name.compare(name.size() - so_suff.size(), so_suff.size(), so_suff) == 0) { + ProcessSoFullName(file_list, caffe_parser_path, full_name, caffe_parser_so_suff, aicpu_so_suff, + aicpu_host_so_suff); + } else { + FindParserSo(full_name, file_list, caffe_parser_path); + } } - closedir(dir); + mmScandirFree(entries, ret); } void TBEPluginManager::GetPluginSoFileList(const string &path, vector &file_list, string &caffe_parser_path) { @@ -159,8 +160,9 @@ void TBEPluginManager::GetCustomOpPath(std::string &customop_path) { fmk_type = ge::TypeUtils::FmkTypeToSerialString(type); GELOGI("Framework type is %s.", fmk_type.c_str()); - const char *path_env = std::getenv("ASCEND_OPP_PATH"); - if (path_env != nullptr) { + char path_env[MMPA_MAX_PATH] = { 0x00 }; + INT32 res = mmGetEnv("ASCEND_OPP_PATH", path_env, MMPA_MAX_PATH); + if (res == EN_OK) { std::string path = path_env; customop_path = (path + "/framework/custom" + "/:") + (path + "/framework/built-in/" + fmk_type); GELOGI("Get custom so path from env : %s", path_env); @@ -210,9 +212,11 @@ void TBEPluginManager::LoadPluginSo(const std::map &options) { for (auto elem : file_list) { StringUtils::Trim(elem); - void *handle = dlopen(elem.c_str(), RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE); + void *handle = mmDlopen(elem.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL | MMPA_RTLD_NODELETE); if (handle == nullptr) { - GELOGW("dlopen failed, plugin name:%s. Message(%s).", elem.c_str(), dlerror()); + const char *error = mmDlerror(); + GE_IF_BOOL_EXEC(error == nullptr, error = ""); + GELOGW("dlopen failed, plugin name:%s. Message(%s).", elem.c_str(), error); } else if (find(handles_vec_.begin(), handles_vec_.end(), handle) == handles_vec_.end()) { // Close dl when the program exist, not close here GELOGI("Plugin load %s success.", elem.c_str()); diff --git a/ge/common/ge/tbe_plugin_manager.h b/ge/common/ge/tbe_plugin_manager.h index 41db8ef9..4bd8c6e3 100755 --- a/ge/common/ge/tbe_plugin_manager.h +++ b/ge/common/ge/tbe_plugin_manager.h @@ -17,7 +17,6 @@ #ifndef GE_COMMON_GE_TBE_PLUGIN_MANAGER_H_ #define GE_COMMON_GE_TBE_PLUGIN_MANAGER_H_ -#include #include #include #include diff --git a/ge/common/helper/model_cache_helper.cc b/ge/common/helper/model_cache_helper.cc index e84e0077..0b592e11 100755 --- a/ge/common/helper/model_cache_helper.cc +++ b/ge/common/helper/model_cache_helper.cc @@ -14,8 +14,6 @@ * limitations under the License. */ -#include -#include #include #include #include @@ -448,12 +446,12 @@ Status ModelCacheHelper::SaveJsonToFile(const string &file_name, const Json &jso } const string path = cache_path_ + file_name; const int FILE_AUTHORITY = 0600; - int fd = open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, FILE_AUTHORITY); + int fd = mmOpen2(path.c_str(), M_WRONLY | M_CREAT | O_TRUNC, FILE_AUTHORITY); if (fd < 0) { GELOGW("Fail to open the file: %s.", path.c_str()); return INTERNAL_ERROR; } - if (close(fd) != 0) { + if (mmClose(fd) != 0) { GELOGW("Fail to close the file: %s.", path.c_str()); return INTERNAL_ERROR; } diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index ab5075e1..65d5bb4b 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -393,7 +393,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadTask(Om GELOGE(INTERNAL_ERROR, "ReadProtoFromArray failed."); return INTERNAL_ERROR; } - GELOGI("TASK_INFO op_size:%zu, stream_num:%u", task->op().size(), task->stream_num()); + GELOGI("TASK_INFO op_size:%d, stream_num:%u", task->op().size(), task->stream_num()); } model_->SetModelTaskDef(task); return SUCCESS; diff --git a/ge/common/model_parser/base.cc b/ge/common/model_parser/base.cc index 25cc6645..bf7f70e4 100644 --- a/ge/common/model_parser/base.cc +++ b/ge/common/model_parser/base.cc @@ -17,7 +17,6 @@ #include "common/model_parser/base.h" #include "common/helper/model_helper.h" #include -#include #include #include #include diff --git a/ge/common/model_saver.cc b/ge/common/model_saver.cc index fb1cd0a7..b8442948 100755 --- a/ge/common/model_saver.cc +++ b/ge/common/model_saver.cc @@ -16,9 +16,7 @@ #include "common/model_saver.h" -#include #include -#include #include #include #include @@ -51,14 +49,14 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi return FAILED; } - char real_path[PATH_MAX] = {0}; - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path) >= PATH_MAX, return FAILED, "file path is too long!"); - GE_IF_BOOL_EXEC(realpath(file_path, real_path) == nullptr, + char real_path[MMPA_MAX_PATH] = {0}; + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path) >= MMPA_MAX_PATH, return FAILED, "file path is too long!"); + GE_IF_BOOL_EXEC(mmRealPath(file_path, real_path, MMPA_MAX_PATH) != EN_OK, GELOGI("File %s does not exit, it will be created.", file_path)); // Open file - mode_t mode = S_IRUSR | S_IWUSR; - int32_t fd = mmOpen2(real_path, O_RDWR | O_CREAT | O_TRUNC, mode); + mmMode_t mode = M_IRUSR | M_IWUSR; + int32_t fd = mmOpen2(real_path, M_RDWR | M_CREAT | O_TRUNC, mode); if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file_path, strerror(errno)}); GELOGE(FAILED, "Open file[%s] failed. %s", file_path, strerror(errno)); @@ -72,7 +70,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi ErrorManager::GetInstance().ATCReportErrMessage( "E19004", {"file", "errmsg"}, {file_path, strerror(errno)}); // Need to both print the error info of mmWrite and mmClose, so return ret after mmClose - GELOGE(FAILED, "Write to file failed. errno = %d, %s", mmpa_ret, strerror(errno)); + GELOGE(FAILED, "Write to file failed. errno = %ld, %s", mmpa_ret, strerror(errno)); ret = FAILED; } // Close file diff --git a/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc index 6e01ee87..81c583f2 100644 --- a/ge/common/profiling/profiling_manager.cc +++ b/ge/common/profiling/profiling_manager.cc @@ -214,8 +214,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Pa FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::InitFromOptions(const Options &options) { #ifdef DAVINCI_SUPPORT_PROFILING // enable profiling support two ways: env and front end - const char *profiling_mode = std::getenv("PROFILING_MODE"); - const char *prof_options = std::getenv("PROFILING_OPTIONS"); + char profiling_mode_temp[MMPA_MAX_PATH] = { 0x00 }; + char prof_options_temp[MMPA_MAX_PATH] = { 0x00 }; + (void)mmGetEnv("PROFILING_MODE", profiling_mode_temp, MMPA_MAX_PATH); + (void)mmGetEnv("PROFILING_OPTIONS", prof_options_temp, MMPA_MAX_PATH ); + const char *profiling_mode = profiling_mode_temp; + const char *prof_options = prof_options_temp; if ((profiling_mode == nullptr) || (strcmp("true", profiling_mode) != 0) || (prof_options == nullptr)) { is_load_profiling_ = false; is_execute_profiling_ = false; diff --git a/ge/common/properties_manager.h b/ge/common/properties_manager.h index 634113a8..b4c5aad1 100644 --- a/ge/common/properties_manager.h +++ b/ge/common/properties_manager.h @@ -25,13 +25,14 @@ #include "common/dump/dump_properties.h" #include "graph/op_desc.h" +#include "common/ge_compiler_options.h" namespace ge { // Configuration property management -static const char *SYSMODE __attribute__((unused)) = "FMK_SYSMODE"; -static const char *USE_FUSION __attribute__((unused)) = "FMK_USE_FUSION"; -static const char *TIMESTAT_ENABLE __attribute__((unused)) = "DAVINCI_TIMESTAT_ENABLE"; -static const char *ANNDROID_DEBUG __attribute__((unused)) = "ANNDROID_DEBUG"; +static const char *SYSMODE GE_ATTRIBUTE_UNUSED = "FMK_SYSMODE"; +static const char *USE_FUSION GE_ATTRIBUTE_UNUSED = "FMK_USE_FUSION"; +static const char *TIMESTAT_ENABLE GE_ATTRIBUTE_UNUSED = "DAVINCI_TIMESTAT_ENABLE"; +static const char *ANNDROID_DEBUG GE_ATTRIBUTE_UNUSED = "ANNDROID_DEBUG"; class PropertiesManager { public: diff --git a/ge/common/util.cc b/ge/common/util.cc index 2ddb4b2c..3c5954db 100644 --- a/ge/common/util.cc +++ b/ge/common/util.cc @@ -16,11 +16,12 @@ #include "framework/common/util.h" -#include #include - +#ifdef __GNUC__ #include -#include +#else +#include +#endif #include #include #include @@ -208,29 +209,30 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std::string &directory_path) { GE_CHK_BOOL_EXEC(!directory_path.empty(), return -1, "directory path is empty."); auto dir_path_len = directory_path.length(); - if (dir_path_len >= PATH_MAX) { - ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, - {directory_path, std::to_string(PATH_MAX)}); - GELOGW("Path[%s] len is too long, it must be less than %d", directory_path.c_str(), PATH_MAX); + if (dir_path_len >= MMPA_MAX_PATH) { + ErrorManager::GetInstance().ATCReportErrMessage( + "E19002", {"filepath", "size"}, {directory_path, std::to_string(MMPA_MAX_PATH)}); + GELOGW("Path[%s] len is too long, it must be less than %d", directory_path.c_str(), MMPA_MAX_PATH); return -1; } - char tmp_dir_path[PATH_MAX] = {0}; + char tmp_dir_path[MMPA_MAX_PATH] = {0}; for (size_t i = 0; i < dir_path_len; i++) { tmp_dir_path[i] = directory_path[i]; if ((tmp_dir_path[i] == '\\') || (tmp_dir_path[i] == '/')) { - if (access(tmp_dir_path, F_OK) != 0) { - int32_t ret = mmMkdir(tmp_dir_path, S_IRUSR | S_IWUSR | S_IXUSR); // 700 + if (mmAccess2(tmp_dir_path, M_F_OK) != EN_OK) { + int32_t ret = mmMkdir(tmp_dir_path, M_IRUSR | M_IWUSR | M_IXUSR); // 700 if (ret != 0) { if (errno != EEXIST) { ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path}); - GELOGW("Can not create directory %s. Make sure the directory exists and writable.", directory_path.c_str()); + GELOGW("Can not create directory %s. Make sure the directory exists and writable.", + directory_path.c_str()); return ret; } } } } } - int32_t ret = mmMkdir(const_cast(directory_path.c_str()), S_IRUSR | S_IWUSR | S_IXUSR); // 700 + int32_t ret = mmMkdir(const_cast(directory_path.c_str()), M_IRUSR | M_IWUSR | M_IXUSR); // 700 if (ret != 0) { if (errno != EEXIST) { ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path}); @@ -305,9 +307,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromMem(const cha } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() { - struct timeval tv {}; - int ret = gettimeofday(&tv, nullptr); - GE_LOGE_IF(ret != 0, "Func gettimeofday may failed: ret=%d", ret); + mmTimeval tv {}; + int ret = mmGetTimeOfDay(&tv, nullptr); + GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed: ret=%d", ret); auto total_use_time = tv.tv_usec + tv.tv_sec * 1000000; // 1000000: seconds to microseconds return static_cast(total_use_time); } @@ -347,16 +349,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInt64MulOverflow(int6 FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char *path) { GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL."); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - strlen(path) >= PATH_MAX, - ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(PATH_MAX)}); - return "", "Path[%s] len is too long, it must be less than %d", path, PATH_MAX); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(path) >= MMPA_MAX_PATH, + ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(MMPA_MAX_PATH)}); + return "", "Path[%s] len is too long, it must be less than %d", path, MMPA_MAX_PATH); // Nullptr is returned when the path does not exist or there is no permission // Return absolute path when path is accessible std::string res; - char resolved_path[PATH_MAX] = {0}; - if (realpath(path, resolved_path) != nullptr) { + char resolved_path[MMPA_MAX_PATH] = {0}; + if (mmRealPath(path, resolved_path, MMPA_MAX_PATH) == EN_OK) { res = resolved_path; } @@ -383,7 +384,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const // A regular matching expression to verify the validity of the input file path // Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores // File name section: Support upper and lower case letters, numbers, underscores chinese and dots(.) - std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; +#ifdef __GNUC__ + std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; +#else + std::string mode = "^[a-zA-Z]:([\\\\/][^\\s\\\\/:*?<>\"|][^\\\\/:*?<>\"|]*)*([/\\\\][^\\s\\\\/:*?<>\"|])?$"; +#endif GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( !ValidateStr(real_path, mode), @@ -392,7 +397,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason); // The absolute path points to a file that is not readable - if (access(real_path.c_str(), R_OK) != 0) { + if (mmAccess2(real_path.c_str(), M_R_OK) != EN_OK) { ErrorManager::GetInstance().ATCReportErrMessage("E19003", {"file", "errmsg"}, {file_path.c_str(), strerror(errno)}); GELOGW("Read file[%s] failed, errmsg[%s]", file_path.c_str(), strerror(errno)); return false; @@ -410,15 +415,19 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const return false; } - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - strlen(file_path.c_str()) >= PATH_MAX, ErrorManager::GetInstance().ATCReportErrMessage( - "E19002", {"filepath", "size"}, {file_path, std::to_string(PATH_MAX)}); - return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), PATH_MAX); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path.c_str()) >= MMPA_MAX_PATH, + ErrorManager::GetInstance().ATCReportErrMessage( + "E19002", {"filepath", "size"}, {file_path, std::to_string(MMPA_MAX_PATH)}); + return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), MMPA_MAX_PATH); // A regular matching expression to verify the validity of the input file path // Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores // File name section: Support upper and lower case letters, numbers, underscores chinese and dots(.) - std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; +#ifdef __GNUC__ + std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; +#else + std::string mode = "^[a-zA-Z]:([\\\\/][^\\s\\\\/:*?<>\"|][^\\\\/:*?<>\"|]*)*([/\\\\][^\\s\\\\/:*?<>\"|])?$"; +#endif GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( !ValidateStr(file_path, mode), @@ -430,7 +439,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const // Can get absolute path (file exists) if (!real_path.empty()) { // File is not readable or writable - if (access(real_path.c_str(), W_OK | F_OK) != 0) { + if (mmAccess2(real_path.c_str(), M_W_OK | M_F_OK) != EN_OK) { ErrorManager::GetInstance().ATCReportErrMessage("E19004", {"file", "errmsg"}, {real_path, strerror(errno)}); GELOGW("Write file[%s] failed, errmsg[%s]", real_path.c_str(), strerror(errno)); return false; @@ -461,6 +470,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const } FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::string &mode) { +#ifdef __GNUC__ char ebuff[kMaxBuffSize]; regex_t reg; int cflags = REG_EXTENDED | REG_NOSUB; @@ -482,6 +492,23 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str regfree(®); return true; +#else + std::wstring wstr(str.begin(), str.end()); + std::wstring wmode(mode.begin(), mode.end()); + std::wsmatch match; + bool res = false; + + try { + std::wregex reg(wmode, std::regex::icase); + // Matching string part + res = regex_match(wstr, match, reg); + res = regex_search(str, std::regex("[`!@#$%^&*()|{}';',<>?]")); + } catch (std::exception &ex) { + GELOGW("The directory %s is invalid, error: %s.", str.c_str(), ex.what()); + return false; + } + return !(res) && (str.size() == match.str().size()); +#endif } FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { diff --git a/ge/engine_manager/dnnengine_manager.cc b/ge/engine_manager/dnnengine_manager.cc index f8d58208..b23993b6 100644 --- a/ge/engine_manager/dnnengine_manager.cc +++ b/ge/engine_manager/dnnengine_manager.cc @@ -433,7 +433,7 @@ Status DNNEngineManager::ReadJsonFile(const std::string &file_path, JsonHandle h return FAILED; } const char *file = file_path.data(); - if ((access(file, F_OK)) == -1) { + if ((mmAccess2(file, M_F_OK)) != EN_OK) { if (engines_map_.size() != 0) { GELOGE(FAILED, "The json file %s is not exist, %s", file_path.c_str(), strerror(errno)); return FAILED; diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index ecf253e1..93d5a6e5 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -1102,7 +1102,7 @@ bool IsAtomicOutputMemory(const ge::NodePtr &node, uint32_t output_index, bool i if (static_cast(index) == output_index) { if (node->GetOwnerComputeGraph() != nullptr) { string graph_name = node->GetOwnerComputeGraph()->GetName(); - GELOGD("[IMAS]Atomic no assign %s name[%s] output[%d] streamid[%ld].", graph_name.c_str(), + GELOGD("[IMAS]Atomic no assign %s name[%s] output[%ld] streamid[%ld].", graph_name.c_str(), op_desc->GetName().c_str(), index, op_desc->GetStreamId()); } return true; @@ -1219,7 +1219,7 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector int64_t stream_id = op_desc->GetStreamId(); vector memorys_type; bool has_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, memorys_type); - GELOGI("Assign memory node[%s], output size[%d], output memory type size[%d]", op_desc->GetName().c_str(), + GELOGI("Assign memory node[%s], output size[%zu], output memory type size[%zu]", op_desc->GetName().c_str(), op_desc->GetOutputsSize(), memorys_type.size()); if (has_mem_type_attr && (memorys_type.size() != op_desc->GetOutputsSize())) { GELOGE(INTERNAL_ERROR, "fusion: node[%s], output memory size err[outputsize:%zu, memorysize:%zu]", @@ -1257,7 +1257,7 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector // fusion: other type's size not means malloc HBM memory bool l1_flag = has_mem_type_attr && memorys_type[i] == RT_MEMORY_L1; if (l1_flag) { - GELOGI("fusion: node[%s], output[%s], output memory type [%d]", + GELOGI("fusion: node[%s], output[%s], output memory type [%ld]", op_desc->GetName().c_str(), op_desc->GetOutputNameByIndex(i).c_str(), memorys_type[i]); size = 0; } @@ -1350,7 +1350,7 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector &ranges) { bool workspace_skip_flag = false; if (has_tvm_workspace_mem_type_attr && tvm_workspace_memory_type[i] == RT_MEMORY_L1) { GELOGI( - "fusion: node[%s]workspace index[%d] is not hbm type, add to zero_memory_list, workspace memory type [%ld]", + "fusion: node[%s]workspace index[%zu] is not hbm type, add to zero_memory_list, workspace memory type [%ld]", node_op_desc->GetName().c_str(), i, tvm_workspace_memory_type[i]); workspace_skip_flag = true; } diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index 7d35596c..4af411d5 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -456,7 +456,7 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, output_list.at(peer_out_data_anchor->GetIdx()) - continuous_mem_start + tensor_desc_size + MEM_ALIGN_SIZE; } GELOGI( - "[IMAS]Check Continuous input : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%zu] " + "[IMAS]Check Continuous input : Set %s name[%s] output[%d] offset to [%ld] stream_id[%ld] size[%u] " "real_size[%u].", node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), peer_out_data_anchor->GetIdx(), output_list.at(peer_out_data_anchor->GetIdx()), peer_op_desc->GetStreamId(), diff --git a/ge/graph/load/new_model_manager/cpu_queue_schedule.cc b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc index 7f406985..430321bd 100644 --- a/ge/graph/load/new_model_manager/cpu_queue_schedule.cc +++ b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc @@ -131,7 +131,7 @@ Status CpuTaskZeroCopy::Init(std::vector &mbuf_list, std::map(reinterpret_cast(virtual_args_addr.second.at(i)))); + dst_addrs.push_back(static_cast(reinterpret_cast(virtual_args_addr.second.at(i)))); } } index++; diff --git a/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc index 10e1c8b3..b6db50a7 100755 --- a/ge/graph/load/new_model_manager/davinci_model.cc +++ b/ge/graph/load/new_model_manager/davinci_model.cc @@ -17,11 +17,7 @@ #include "graph/load/new_model_manager/davinci_model.h" #include -#include #include -#include -#include -#include #include #include #include @@ -1459,7 +1455,7 @@ Status DavinciModel::InitLabelSet(const OpDescPtr &op_desc) { return INTERNAL_ERROR; } if (label_index >= LabelNum()) { - GELOGE(INTERNAL_ERROR, "InitLabelSet: label index: %u >= label size: %zu.", label_index, LabelNum()); + GELOGE(INTERNAL_ERROR, "InitLabelSet: label index: %u >= label size: %u.", label_index, LabelNum()); return INTERNAL_ERROR; } if (label_id_indication_.count(label_index) > 0) { @@ -2187,7 +2183,7 @@ Status DavinciModel::CopyInputData(const InputData &input_data, bool device_data void *mem_addr = data.second.GetBasicAddr(); void *data_buf_addr = reinterpret_cast(reinterpret_cast(data_buf.data)); uint64_t data_buf_length = data_buf.length; - GELOGI("[IMAS]CopyPlainData memcpy graph_%lu type[F] input[%lu] dst[%p] src[%p] mem_size[%lu] datasize[%lu]", + GELOGI("[IMAS]CopyPlainData memcpy graph_%u type[F] input[%u] dst[%p] src[%p] mem_size[%lu] datasize[%lu]", runtime_param_.graph_id, data.first, mem_addr, data_buf_addr, data_size, data_buf_length); GE_CHK_RT_RET(rtMemcpy(mem_addr, data_size, data_buf_addr, data_buf_length, kind)); } @@ -2552,10 +2548,10 @@ Status DavinciModel::CopyOutputData(uint32_t data_id, OutputData &output_data, r if (is_dynamic_) { GELOGI("No need to check output data size."); } else if (buffer.length < mem_size) { - GELOGE(FAILED, "Tensor data size=%lu, buffer size=%u", mem_size, buffer.length); + GELOGE(FAILED, "Tensor data size=%lu, buffer size=%lu", mem_size, buffer.length); return FAILED; } else if (buffer.length > mem_size) { - GELOGW("Tensor data size=%lu, buffer size=%u", mem_size, buffer.length); + GELOGW("Tensor data size=%lu, buffer size=%lu", mem_size, buffer.length); } int64_t data_size = output.second.GetDataSize(); @@ -2566,7 +2562,7 @@ Status DavinciModel::CopyOutputData(uint32_t data_id, OutputData &output_data, r uint64_t buffer_length = buffer.length; void *buffer_addr = reinterpret_cast(reinterpret_cast(buffer.data)); - GELOGI("[IMAS]CopyPlainData memcpy graph_%u type[F] output[%u] memaddr[%p] mem_size[%ld] datasize[%u]", + GELOGI("[IMAS]CopyPlainData memcpy graph_%u type[F] output[%u] memaddr[%p] mem_size[%lu] datasize[%lu]", runtime_param_.graph_id, output.first, output.second.GetBasicAddr(), data_size, buffer_length); GE_CHK_RT_RET(rtMemcpy(buffer_addr, buffer_length, output.second.GetBasicAddr(), data_size, kind)); idx++; @@ -2982,7 +2978,7 @@ void DavinciModel::UnbindTaskSinkStream() { Status DavinciModel::CreateKnownZeroCopyMap(const vector &inputs, const vector &outputs) { GELOGI("DavinciModel::CreateKnownZeroCopyMap in."); if (inputs.size() > data_op_list_.size()) { - GELOGE(FAILED, "input data addr %u should less than input op number %u.", inputs.size(), data_op_list_.size()); + GELOGE(FAILED, "input data addr %zu should less than input op number %zu.", inputs.size(), data_op_list_.size()); return FAILED; } // remove zero copy addr in last iteration @@ -2991,16 +2987,16 @@ Status DavinciModel::CreateKnownZeroCopyMap(const vector &inputs, const for (size_t i = 0; i < inputs.size(); ++i) { const vector addr_list = ModelUtils::GetOutputDataAddrs(runtime_param_, data_op_list_[i]); knonw_input_data_info_[addr_list[kDataIndex]] = inputs[i]; - GELOGI("DavinciModel::CreateKnownZeroCopyMap input %d,v addr %p,p addr %p .", i, addr_list[kDataIndex], inputs[i]); + GELOGI("DavinciModel::CreateKnownZeroCopyMap input %zu,v addr %p,p addr %p .", i, addr_list[kDataIndex], inputs[i]); } if (output_op_list_.size() < kOutputNum) { - GELOGW("output op num in graph is %u.", output_op_list_.size()); + GELOGW("output op num in graph is %zu.", output_op_list_.size()); return SUCCESS; } const vector addr_list = ModelUtils::GetInputDataAddrs(runtime_param_, output_op_list_[kDataIndex]); for (size_t i = 0; i < addr_list.size() && i < outputs.size(); ++i) { knonw_output_data_info_[addr_list[i]] = outputs[i]; - GELOGI("DavinciModel::CreateKnownZeroCopyMap output %d,v addr %p,p addr %p .", i, addr_list[i], outputs[i]); + GELOGI("DavinciModel::CreateKnownZeroCopyMap output %zu,v addr %p,p addr %p .", i, addr_list[i], outputs[i]); } GELOGI("DavinciModel::CreateKnownZeroCopyMap success."); return SUCCESS; @@ -3010,13 +3006,13 @@ Status DavinciModel::UpdateKnownZeroCopyAddr() { for (size_t i = 0; i < total_io_addrs_.size(); ++i) { auto it_in = knonw_input_data_info_.find(total_io_addrs_[i]); if (it_in != knonw_input_data_info_.end()) { - GELOGI("DavinciModel::UpdateKnownZeroCopyAddr input %d,v addr %p,p addr %p .", i, total_io_addrs_[i], + GELOGI("DavinciModel::UpdateKnownZeroCopyAddr input %zu,v addr %p,p addr %p .", i, total_io_addrs_[i], knonw_input_data_info_.at(total_io_addrs_[i])); total_io_addrs_[i] = knonw_input_data_info_.at(total_io_addrs_[i]); } auto it_out = knonw_output_data_info_.find(total_io_addrs_[i]); if (it_out != knonw_output_data_info_.end()) { - GELOGI("DavinciModel::UpdateKnownZeroCopyAddr output %d,v addr %p,p addr %p .", i, total_io_addrs_[i], + GELOGI("DavinciModel::UpdateKnownZeroCopyAddr output %zu,v addr %p,p addr %p .", i, total_io_addrs_[i], knonw_output_data_info_.at(total_io_addrs_[i])); total_io_addrs_[i] = knonw_output_data_info_.at(total_io_addrs_[i]); } @@ -3037,7 +3033,7 @@ Status DavinciModel::UpdateKnownNodeArgs(const vector &inputs, const vec if (task != nullptr) { Status ret = task->UpdateArgs(); if (ret != SUCCESS) { - GELOGE(FAILED, "task %d created by davinci model is nullptr.", task_index); + GELOGE(FAILED, "task %zu created by davinci model is nullptr.", task_index); return FAILED; } } @@ -3066,7 +3062,7 @@ Status DavinciModel::UpdateKnownNodeArgs(const vector &inputs, const vec } Status DavinciModel::InitTaskInfo(domi::ModelTaskDef &model_task_def) { - GELOGI("InitTaskInfo in, task size %zu", model_task_def.task().size()); + GELOGI("InitTaskInfo in, task size %d", model_task_def.task().size()); task_list_.resize(model_task_def.task_size()); for (int i = 0; i < model_task_def.task_size(); ++i) { // dynamic shape will create task_list_ before @@ -3142,8 +3138,9 @@ Status DavinciModel::DistributeTask() { task_desc_info_.clear(); bool flag = GetL1FusionEnableOption(); - char *skt_enable_env = std::getenv("SKT_ENABLE"); - int64_t env_flag = (skt_enable_env != nullptr) ? std::strtol(skt_enable_env, nullptr, kDecimal) : 0; + char skt_enable_env[MMPA_MAX_PATH] = { 0x00 }; + INT32 res = mmGetEnv("SKT_ENABLE", skt_enable_env, MMPA_MAX_PATH); + int64_t env_flag = (res == EN_OK) ? std::strtol(skt_enable_env, nullptr, kDecimal) : 0; if (env_flag != 0) { flag = true; } @@ -3331,7 +3328,7 @@ bool DavinciModel::CheckInputAndModelSize(const int64_t &input_size, const int64 if (input_size > op_size) { GELOGW( - "Input size [%u] is bigger than om size need [%u], " + "Input size [%ld] is bigger than om size need [%ld], " "MAY cause inference result ERROR, please check model input", input_size, op_size); } @@ -3413,7 +3410,7 @@ Status DavinciModel::UpdateIoTaskArgs(const std::map & for (const auto &data : data_info) { if (data.first >= blobs.size()) { // check data index. - GELOGE(FAILED, "Verify %s data num failed: can not find No.%zu data, because user only feeds %zu", + GELOGE(FAILED, "Verify %s data num failed: can not find No.%u data, because user only feeds %zu", input_or_output.c_str(), data.first, blobs.size()); return FAILED; } @@ -3522,7 +3519,7 @@ Status DavinciModel::InitConstant(const OpDescPtr &op_desc) { GeTensor *tensor = const_cast(v_weights[0].get()); GE_IF_BOOL_EXEC(static_cast(v_output_size[0]) < tensor->GetData().size(), - GELOGE(PARAM_INVALID, "output size:%u less than weight data size:%zu", v_output_size[0], + GELOGE(PARAM_INVALID, "output size:%ld less than weight data size:%zu", v_output_size[0], tensor->GetData().size()); return PARAM_INVALID;); @@ -3546,12 +3543,12 @@ Status DavinciModel::InitConstant(const OpDescPtr &op_desc) { uint64_t offset = static_cast(elem_num * kBytes); uint64_t hbm_raw_data_base_addr = - reinterpret_cast(reinterpret_cast(v_output_addr[0])) + offset; + static_cast(reinterpret_cast(v_output_addr[0])) + offset; for (int64_t i = elem_num - 1; i >= 0; --i) { buff[i] = hbm_raw_data_base_addr + (buff[i] - buff[0]); } } - GELOGI("[IMAS]InitConstant memcpy graph_%u type[V] name[%s] output[%d] memaddr[%p] mem_size[%u] datasize[%zu]", + GELOGI("[IMAS]InitConstant memcpy graph_%u type[V] name[%s] output[%d] memaddr[%p] mem_size[%lu] datasize[%zu]", runtime_param_.graph_id, op_desc->GetName().c_str(), 0, v_output_addr[0], v_output_size[0], tensor->GetData().size()); GE_CHK_RT_RET(rtMemcpy(v_output_addr[0], v_output_size[0], tensor->GetData().data(), tensor->GetData().size(), @@ -3906,7 +3903,9 @@ Status DavinciModel::InitEntryTask() { uint8_t *DavinciModel::MallocFeatureMapMem(size_t data_size) { uint8_t *mem_base = nullptr; const string purpose("feature map,used for op input and output."); - if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { + char ge_static_mem_env[MMPA_MAX_PATH] = { 0x00 }; + INT32 res = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH); + if (res == EN_OK) { data_size = static_cast(VarManager::Instance(session_id_)->GetGraphMemoryMaxSize()); string memory_key = std::to_string(0) + "_f"; mem_base = MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, memory_key, data_size, GetDeviceId()); @@ -3936,7 +3935,9 @@ uint8_t *DavinciModel::MallocP2PMem(size_t p2p_data_size) { uint8_t *DavinciModel::MallocWeightsMem(size_t weights_size) { uint8_t *weights_mem_base = nullptr; const string purpose("weights memory in inference network."); - if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { + char ge_static_mem_env[MMPA_MAX_PATH] = { 0x00 }; + INT32 res = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH); + if (res == EN_OK) { string weight_memory_key = std::to_string(0) + "_w"; weights_mem_base = MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, weight_memory_key, weights_size, GetDeviceId()); @@ -3947,7 +3948,9 @@ uint8_t *DavinciModel::MallocWeightsMem(size_t weights_size) { } void DavinciModel::FreeFeatureMapMem() { - if (std::getenv(kEnvGeuseStaticMemory) != nullptr && is_inner_mem_base_) { + char ge_static_mem_env[MMPA_MAX_PATH] = { 0x00 }; + INT32 res = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH); + if (res == EN_OK && is_inner_mem_base_) { string weight_memory_key = std::to_string(0) + "_f"; if (MemManager::Instance(RT_MEMORY_HBM)->GetMemoryAddr(weight_memory_key) != nullptr) { GE_CHK_STATUS(MemManager::Instance(RT_MEMORY_HBM)->FreeMemory(weight_memory_key, GetDeviceId()), @@ -3979,7 +3982,9 @@ void DavinciModel::FreeP2PMem() { } void DavinciModel::FreeWeightsMem() { - if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { + char ge_static_mem_env[MMPA_MAX_PATH] = { 0x00 }; + INT32 res = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH); + if (res == EN_OK) { string memory_key = std::to_string(0) + "_w"; if (MemManager::Instance(RT_MEMORY_HBM)->GetMemoryAddr(memory_key) != nullptr) { GE_CHK_STATUS(MemManager::Instance(RT_MEMORY_HBM)->FreeMemory(memory_key, GetDeviceId()), @@ -4160,7 +4165,7 @@ Status DavinciModel::GetAllAippInputOutputDims(uint32_t index, std::vector inputs; if (AttrUtils::GetListStr(data_op, ATTR_NAME_AIPP_INPUTS, inputs) && !inputs.empty()) { - GELOGI("GetAllAippInputOutputDims: Data: %s has %u related aippInfo.", data_op->GetName().c_str(), inputs.size()); + GELOGI("GetAllAippInputOutputDims: Data: %s has %zu related aippInfo.", data_op->GetName().c_str(), inputs.size()); for (auto it : inputs) { InputOutputDims input_info; ParseAIPPInfo(it, input_info); @@ -4171,7 +4176,7 @@ Status DavinciModel::GetAllAippInputOutputDims(uint32_t index, std::vectorGetInputDescPtr(kDataIndex)), data_input_size); GELOGD( - "GetAllAippInputOutputDims related Data[%d]: tensor_name is %s, dim_num is %u, tensor_size: %zu, format: " + "GetAllAippInputOutputDims related Data[%d]: tensor_name is %s, dim_num is %zu, tensor_size: %zu, format: " "%s, data_type: %s, shape: %s .", index, data_op->GetName().c_str(), data_input_desc->GetShape().GetDimNum(), data_input_size, TypeUtils::FormatToSerialString(data_input_desc->GetFormat()).c_str(), diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc index e51a205d..e4e0681d 100755 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -1019,8 +1019,8 @@ Status ModelManager::GetAippType(uint32_t model_id, uint32_t index, InputAippTyp Status ModelManager::GenSessionId(uint64_t &session_id) { std::lock_guard lock(session_id_create_mutex_); - struct timeval tv; - if (gettimeofday(&tv, nullptr) != 0) { + mmTimeval tv; + if (mmGetTimeOfDay(&tv, nullptr) != 0) { GELOGE(INTERNAL_ERROR, "Failed to get current time."); return INTERNAL_ERROR; } @@ -1037,8 +1037,8 @@ Status ModelManager::GenSessionId(uint64_t &session_id) { Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model, shared_ptr listener, void *dev_ptr, size_t mem_size, void *weight_ptr, size_t weight_size) { - GE_CHK_BOOL_RET_STATUS(model.key.empty() || access(model.key.c_str(), F_OK) == 0, - ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, + GE_CHK_BOOL_RET_STATUS(model.key.empty() || mmAccess2(model.key.c_str(), M_F_OK) == EN_OK, + ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, "input key file path %s is invalid, %s", model.key.c_str(), strerror(errno)); GenModelId(&model_id); @@ -1123,7 +1123,7 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model Status ModelManager::LoadModelWithQ(uint32_t &model_id, const ModelData &model_data, const std::vector &input_queue_ids, const std::vector &output_queue_ids) { - GE_CHK_BOOL_RET_STATUS(model_data.key.empty() || access(model_data.key.c_str(), F_OK) == 0, + GE_CHK_BOOL_RET_STATUS(model_data.key.empty() || mmAccess2(model_data.key.c_str(), M_F_OK) == EN_OK, ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, "input key file path %s is not valid, %s", model_data.key.c_str(), strerror(errno)); diff --git a/ge/graph/load/new_model_manager/model_manager.h b/ge/graph/load/new_model_manager/model_manager.h index 1179de43..ff2e3030 100755 --- a/ge/graph/load/new_model_manager/model_manager.h +++ b/ge/graph/load/new_model_manager/model_manager.h @@ -18,7 +18,6 @@ #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_MODEL_MANAGER_H_ #include -#include #include #include #include diff --git a/ge/graph/load/new_model_manager/model_utils.cc b/ge/graph/load/new_model_manager/model_utils.cc index 7ebdad8a..7d0fbf12 100755 --- a/ge/graph/load/new_model_manager/model_utils.cc +++ b/ge/graph/load/new_model_manager/model_utils.cc @@ -356,7 +356,7 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co // feature maps void *mem_addr = nullptr; if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion - mem_addr = reinterpret_cast(reinterpret_cast(input_offset)); + mem_addr = reinterpret_cast(static_cast(input_offset)); v_input_data_addr.push_back(mem_addr); } else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) { int64_t tensor_size = 0; @@ -424,7 +424,7 @@ vector ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C // feature maps void *mem_addr = nullptr; if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion - mem_addr = reinterpret_cast(reinterpret_cast(v_output_offset[i])); + mem_addr = reinterpret_cast(static_cast(v_output_offset[i])); v_output_data_addr.push_back(mem_addr); } else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) { const GeTensorDescPtr tensor_desc = op_desc->MutableOutputDesc(i); @@ -500,7 +500,7 @@ vector ModelUtils::GetWorkspaceDataAddrs(const RuntimeParam &model_param continue; } if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { - v_workspace_data_addr.push_back(reinterpret_cast(reinterpret_cast(v_workspace_offset[i]))); + v_workspace_data_addr.push_back(reinterpret_cast(static_cast(v_workspace_offset[i]))); GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[L1] name[%s], mem_addr[workspace index %zu]:0x%lx", model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i]); } else if (v_workspace_bytes[i] == 0) { diff --git a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc index 2a295915..e5574e47 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc @@ -149,7 +149,7 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin return FAILED; } - uint64_t workspace_base_addr = reinterpret_cast(reinterpret_cast(workspace_data_addrs[0])); + uint64_t workspace_base_addr = static_cast(reinterpret_cast(workspace_data_addrs[0])); const vector input_addrs = ModelUtils::GetInputDataAddrs(rts_param, op_desc); const vector output_addrs = ModelUtils::GetOutputDataAddrs(rts_param, op_desc); vector io_addrs; @@ -287,7 +287,7 @@ Status KernelExTaskInfo::CopyTaskInfo(const domi::KernelExDef &kernel_def, const } if (workspace_data_sizes[0] < static_cast(kernel_def.task_info_size())) { - GELOGE(FAILED, "Node:%s workspace size is %zu, task info size is %zu.", op_desc->GetName().c_str(), + GELOGE(FAILED, "Node:%s workspace size is %ld, task info size is %d.", op_desc->GetName().c_str(), workspace_data_sizes[0], kernel_def.task_info_size()); return FAILED; } diff --git a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc index b6b218cf..beef6933 100755 --- a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc @@ -73,7 +73,8 @@ Status KernelTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci GELOGD("node[%s] is_n_batch_spilt %d", op_desc_->GetName().c_str(), is_n_batch_spilt_); (void)AttrUtils::GetInt(*op_desc_, ATTR_NAME_FUSION_GROUP_KEY, group_key_); has_group_key_ = (group_key_ != kInvalidGroupKey); - GELOGD("node[%s] has_group_key_ %ld, group key is [%ld]", op_desc_->GetName().c_str(), has_group_key_, group_key_); + GELOGD("node[%s] has_group_key_ %d, group key is [%ld]", op_desc_->GetName().c_str(), has_group_key_, group_key_); + // fusion_op_info vector original_op_names; bool result = AttrUtils::GetListStr(op_desc_, ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, original_op_names); @@ -216,7 +217,7 @@ Status KernelTaskInfo::SuperKernelLaunch() { rtError_t rt_ret; auto &skt_kernel_list = skt_info_.kernel_list; auto &skt_arg_list = skt_info_.arg_list; - GELOGI("SuperKernelLaunch: Skt_kernel_list size[%d] skt_arg_list[%d]", skt_kernel_list.size(), skt_arg_list.size()); + GELOGI("SuperKernelLaunch: Skt_kernel_list size[%zu] skt_arg_list[%zu]", skt_kernel_list.size(), skt_arg_list.size()); if (skt_kernel_list.size() == kSKTSingleSize && skt_arg_list.size() == kSKTSingleSize) { rt_ret = rtKernelLaunchWithFlag(skt_info_.kernel_list[0], static_cast(skt_info_.last_block_dim), skt_info_.arg_list[0], skt_info_.last_args_size, @@ -367,8 +368,9 @@ Status KernelTaskInfo::Distribute() { GELOGI("Known node %s args addr %p, offset %u.", op_desc_->GetName().c_str(), args_, args_offset_); } rtError_t rt_ret = RT_ERROR_NONE; - char *skt_enable_env = getenv("SKT_ENABLE"); - int64_t env_flag = (skt_enable_env != nullptr) ? strtol(skt_enable_env, nullptr, 10) : 0; + char skt_enable_env[MMPA_MAX_PATH] = { 0x00 }; + INT32 res = mmGetEnv("SKT_ENABLE", skt_enable_env, MMPA_MAX_PATH); + int64_t env_flag = (res == EN_OK) ? strtol(skt_enable_env, nullptr, 10) : 0; bool call_skt = ((env_flag != 0) || is_l1_fusion_enable_); if (kernel_type_ == cce::ccKernelType::AI_CPU || kernel_type_ == cce::ccKernelType::CUST_AI_CPU) { GELOGI("distribute task info kernel_type %d, flag %d", kernel_type_, dump_flag_); @@ -747,15 +749,15 @@ Status KernelTaskInfo::InitAICPUCustomTask(uint32_t op_index, const domi::Kernel } } *(reinterpret_cast(args + ctx_.argsOffset[0])) = - reinterpret_cast(reinterpret_cast(custom_info_.input_descs)); // arg 0 + static_cast(reinterpret_cast(custom_info_.input_descs)); // arg 0 *(reinterpret_cast(args + ctx_.argsOffset[1])) = - reinterpret_cast(reinterpret_cast(custom_info_.input_addrs)); // arg 1 + static_cast(reinterpret_cast(custom_info_.input_addrs)); // arg 1 *(reinterpret_cast(args + ctx_.argsOffset[2])) = - reinterpret_cast(reinterpret_cast(custom_info_.output_descs)); // arg 2 + static_cast(reinterpret_cast(custom_info_.output_descs)); // arg 2 *(reinterpret_cast(args + ctx_.argsOffset[3])) = - reinterpret_cast(reinterpret_cast(custom_info_.output_addrs)); // arg 3 + static_cast(reinterpret_cast(custom_info_.output_addrs)); // arg 3 *(reinterpret_cast(args + ctx_.argsOffset[4])) = - reinterpret_cast(reinterpret_cast(custom_info_.attr_handle)); // arg 4 + static_cast(reinterpret_cast(custom_info_.attr_handle)); // arg 4 rt_ret = rtMalloc(&args_, args_size_, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { @@ -913,7 +915,7 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k op_desc_->GetType().c_str(), ext_info.size(), aicpu_ext_info_addr_); aicpu_param_head->extInfoAddr = reinterpret_cast(aicpu_ext_info_addr_); - aicpu_param_head->extInfoLength = reinterpret_cast(ext_info.size()); + aicpu_param_head->extInfoLength = static_cast(ext_info.size()); // malloc device memory for args rtError_t rt_ret = rtMalloc(static_cast(&args_), args_size_, RT_MEMORY_HBM); @@ -1122,18 +1124,24 @@ Status KernelTaskInfo::CceUpdateKernelArgs(const domi::KernelContext &context, u } GELOGI("FileName:%s, Path:%s.", file_name.c_str(), canonicalPath.c_str()); - auto handle = dlopen(canonicalPath.c_str(), RTLD_NOW | RTLD_GLOBAL); + auto handle = mmDlopen(canonicalPath.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL); + const char *error = ""; if (handle == nullptr) { - GELOGE(GE_PLGMGR_SO_NOT_EXIST, "Failed in dlopen %s! ", dlerror()); + error = mmDlerror(); + GE_IF_BOOL_EXEC(error == nullptr, error = ""); + GELOGE(GE_PLGMGR_SO_NOT_EXIST, "Failed in dlopen %s! ", error); return FAILED; } cce::ccStatus_t cc_ret; + std::string update_kernel_args = "ccUpdateKernelArgs"; auto cceUpdateKernelArgs = (cce::ccStatus_t(*)(cce::ccOpContext &, uint64_t, uint64_t, uint64_t, void *, uint64_t, - void *))dlsym(handle, "ccUpdateKernelArgs"); + void *))mmDlsym(handle, const_cast(update_kernel_args.c_str())); if (cceUpdateKernelArgs == nullptr) { GELOGE(FAILED, "Failed to invoke function ccUpdateKernelArgs"); - if (dlclose(handle) != 0) { - GELOGW("Failed to close handle %s", dlerror()); + if (mmDlclose(handle) != 0) { + error = mmDlerror(); + GE_IF_BOOL_EXEC(error == nullptr, error = ""); + GELOGW("Failed to close handle %s", error); } return FAILED; } else { @@ -1146,8 +1154,10 @@ Status KernelTaskInfo::CceUpdateKernelArgs(const domi::KernelContext &context, u const_cast(kernel_def.args().data()), args_size_, sm_contrl); } } - if (dlclose(handle) != 0) { - GELOGW("Failed to close handle %s", dlerror()); + if (mmDlclose(handle) != 0) { + error = mmDlerror(); + GE_IF_BOOL_EXEC(error == nullptr, error = ""); + GELOGW("Failed to close handle %s", error); return FAILED; } if (cc_ret != cce::CC_STATUS_SUCCESS) { @@ -1188,7 +1198,7 @@ Status KernelTaskInfo::SetFlowtable(std::string &flowtable, const domi::KernelDe *(reinterpret_cast( args + (reinterpret_cast(const_cast(context.args_offset().data())))[0])) = - reinterpret_cast(reinterpret_cast(flowtable_)); + static_cast(reinterpret_cast(flowtable_)); } return SUCCESS; } diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc index 09ed7458..63f29f84 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc @@ -23,7 +23,7 @@ Status SuperKernel::Launch(rtStream_t stream, uint32_t dump_flag) { const void *func_stub_ = this->GetFuncStub(); const void *args[] = {this->GetNavTablePtr(), - reinterpret_cast(reinterpret_cast(this->GetNavTableSize()))}; + reinterpret_cast(static_cast(this->GetNavTableSize()))}; rtError_t rt_ret = rtMalloc((void **)&(device_args_addr_), sizeof(args), RT_MEMORY_HBM); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc failied. error: 0x%X", rt_ret); return diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc index d237d56c..69f7b159 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc @@ -27,7 +27,7 @@ SuperKernelFactory &SuperKernelFactory::GetInstance() { Status SuperKernelFactory::Init() { if (!is_init_) { std::string skt_bin = "libcce_aicore.so"; - handle_ = dlopen(skt_bin.c_str(), RTLD_NOW | RTLD_GLOBAL); + handle_ = mmDlopen(skt_bin.c_str(), MMPA_RTLD_NOW | MMPA_RTLD_GLOBAL); if (handle_ == nullptr) { GELOGE(FAILED, "SKT: open skt lib failed, please check LD_LIBRARY_PATH."); } @@ -85,8 +85,10 @@ Status SuperKernelFactory::FuseKernels(const std::vector &stub_func_list "equal to 2"); return FAILED; } - GELOGI("SKT: superkernel start fuse, superkernel size %d.", stub_func_list.size()); - uint64_t nav_table[2 * stub_func_list.size()]; + GELOGI("SKT: superkernel start fuse, superkernel size %zu.", stub_func_list.size()); + const size_t nav_table_len = 2 * stub_func_list.size(); + std::unique_ptr nav_table(new(std::nothrow) uint64_t[nav_table_len]); + GE_CHECK_NOTNULL(nav_table); uint64_t nav_table_size = 2 * stub_func_list.size() * sizeof(int64_t); rtError_t rt_ret; @@ -99,16 +101,16 @@ Status SuperKernelFactory::FuseKernels(const std::vector &stub_func_list GELOGD("SKT: fuseKernels subFunc %p, device func address %p", stub_func_list[i], sub_device_func); // store two uint64_t address // address divided by 4 because of 32bits encoding, call offset will *4 when calculating - nav_table[i * 2] = reinterpret_cast(reinterpret_cast(sub_device_func)) / 4; + nav_table[i * 2] = static_cast(reinterpret_cast(sub_device_func)) / 4; GELOGD("SKT: CALL offet %lu", nav_table[i * 2]); - nav_table[i * 2 + 1] = reinterpret_cast(reinterpret_cast(args_addr_list[i])); + nav_table[i * 2 + 1] = static_cast(reinterpret_cast(args_addr_list[i])); GELOGD("SKT: fuseKernels args base address %lu", nav_table[i * 2 + 1]); } rt_ret = rtMalloc((void **)&hbm_nav_table_addr, nav_table_size, RT_MEMORY_HBM); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc failed. error: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret);) rt_ret = - rtMemcpy((void *)hbm_nav_table_addr, nav_table_size, (void *)nav_table, nav_table_size, RT_MEMCPY_HOST_TO_DEVICE); + rtMemcpy((void *)hbm_nav_table_addr, nav_table_size, (void *)nav_table.get(), nav_table_size, RT_MEMCPY_HOST_TO_DEVICE); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMemcpy failed. error: 0x%X", rt_ret); GE_CHK_RT(rtFree(hbm_nav_table_addr)); return RT_ERROR_TO_GE_STATUS(rt_ret);) // Create the necessary metadata for the super kernel diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h index efd61ef7..aeb5b49b 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h @@ -34,8 +34,10 @@ class SuperKernelFactory { ~SuperKernelFactory() { if (handle_ != nullptr) { GELOGI("SKT: SKT LIB PATH release."); - if (dlclose(handle_) != 0) { - GELOGW("failed to close handle, message: %s", dlerror()); + if (mmDlclose(handle_) != 0) { + const char *error = mmDlerror(); + GE_IF_BOOL_EXEC(error == nullptr, error = ""); + GELOGW("failed to close handle, message: %s", error); } } }; diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.cc b/ge/graph/load/new_model_manager/zero_copy_offset.cc index e93a7250..709db259 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.cc +++ b/ge/graph/load/new_model_manager/zero_copy_offset.cc @@ -69,7 +69,7 @@ Status ZeroCopyOffset::InitInputDataInfo(const vector &output_size_list uint64_t out_offset = reinterpret_cast(virtual_addr_list[kDataIndex]) + zero_copy_relative_offset_.at(index); int64_t real_data_size = ModelUtils::GetOutputSize(op_desc).at(kDataIndex); - data_info_.emplace_back(real_data_size, reinterpret_cast(reinterpret_cast(out_offset))); + data_info_.emplace_back(real_data_size, reinterpret_cast(static_cast(out_offset))); relative_offset_.emplace_back(zero_copy_relative_offset_.at(index)); GELOGI("[ZCPY] virtual_addr: %p has been l2-fusion to %lu, need copy data_size is %ld.", basic_addr_, out_offset, real_data_size); @@ -119,7 +119,7 @@ Status ZeroCopyOffset::InitOutputDataInfo(const vector &input_size_list in_count++; uint64_t in_offset = reinterpret_cast(virtual_addr_list[idx]) + zero_copy_relative_offset_.at(index); int64_t real_data_size = ModelUtils::GetInputSize(op_desc).at(idx); - data_info_.emplace_back(real_data_size, reinterpret_cast(reinterpret_cast(in_offset))); + data_info_.emplace_back(real_data_size, reinterpret_cast(static_cast(in_offset))); relative_offset_.emplace_back(zero_copy_relative_offset_.at(index)); GELOGI("[ZCPY] virtual_addr: %p has been l2-fusion from %lu, need copy data_size is %ld.", basic_addr_, in_offset, real_data_size); diff --git a/ge/graph/load/new_model_manager/zero_copy_task.cc b/ge/graph/load/new_model_manager/zero_copy_task.cc index 2079034e..e1be3701 100755 --- a/ge/graph/load/new_model_manager/zero_copy_task.cc +++ b/ge/graph/load/new_model_manager/zero_copy_task.cc @@ -19,6 +19,7 @@ #include "framework/common/debug/ge_log.h" #include "framework/common/util.h" #include "graph/load/new_model_manager/model_utils.h" +#inlcude "common/ge_compiler_options.h" namespace ge { const char *const kDefaultBatchLable = "Batch_default"; @@ -157,7 +158,7 @@ Status ZeroCopyTask::DistributeParam(bool async_mode, rtStream_t stream) { rt_err = rtMemcpyAsync(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE_EX, stream); } else { - __builtin_prefetch(args_addr_); + GE_BUILTIN_PREFETCH(args_addr_); rt_err = rtMemcpy(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE); } diff --git a/ge/graph/manager/graph_var_manager.cc b/ge/graph/manager/graph_var_manager.cc index 0b9f1ff9..fbe256b2 100755 --- a/ge/graph/manager/graph_var_manager.cc +++ b/ge/graph/manager/graph_var_manager.cc @@ -92,13 +92,13 @@ ge::Status VarResource::SaveVarAddr(const std::string &var_name, const ge::GeTen GELOGD("VarResource::SaveVarAddr, var_key = %s", var_key.c_str()); if (var_addr_mgr_map_.count(var_key) == 0) { uint64_t logic_address = VarManager::Instance(session_id_)->GetVarMemLogicBase() + - reinterpret_cast(reinterpret_cast(address)); + static_cast(reinterpret_cast(address)); GELOGI("SaveVarAddr node_name %s, tensor_desc format %s, type %s.", var_name.c_str(), TypeUtils::FormatToSerialString(tensor_desc.GetFormat()).c_str(), TypeUtils::DataTypeToSerialString(tensor_desc.GetDataType()).c_str()); VarAddrMgr var_addr_mgr; - var_addr_mgr.address = reinterpret_cast(reinterpret_cast(logic_address)); - var_addr_mgr.offset = reinterpret_cast(reinterpret_cast(address)); + var_addr_mgr.address = reinterpret_cast(static_cast(logic_address)); + var_addr_mgr.offset = static_cast(reinterpret_cast(address)); var_addr_mgr.tensor_desc = tensor_desc; var_addr_mgr.memory_type = memory_type; var_addr_mgr_map_[var_key] = var_addr_mgr; @@ -510,7 +510,7 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen } result = var_resource_->SaveVarAddr( - var_name, tensor_desc, reinterpret_cast(reinterpret_cast(mem_offset)), memory_type); + var_name, tensor_desc, reinterpret_cast(static_cast(mem_offset)), memory_type); if (result != SUCCESS) { GELOGE(ge::INTERNAL_ERROR, "AssignVarMem by offset failed."); return ge::INTERNAL_ERROR; @@ -527,7 +527,7 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen result = var_resource_->GetCurVarDesc(var_name, cur_tensor_desc); if (result != SUCCESS) { var_resource_->SetVarAddr(var_name, tensor_desc, - reinterpret_cast(reinterpret_cast(mem_offset)), memory_type); + reinterpret_cast(static_cast(mem_offset)), memory_type); return SUCCESS; } @@ -542,7 +542,7 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen ge::TypeUtils::FormatToSerialString(cur_tensor_desc.GetFormat()).c_str(), cur_tensor_desc.GetShape().GetDims().size()); var_resource_->SetVarAddr(var_name, tensor_desc, - reinterpret_cast(reinterpret_cast(mem_offset)), memory_type); + reinterpret_cast(static_cast(mem_offset)), memory_type); } return SUCCESS; diff --git a/ge/graph/manager/trans_var_data_utils.cc b/ge/graph/manager/trans_var_data_utils.cc index d6865716..94aeedb8 100644 --- a/ge/graph/manager/trans_var_data_utils.cc +++ b/ge/graph/manager/trans_var_data_utils.cc @@ -374,7 +374,7 @@ Status TransVarDataUtils::SyncVarData2BroadCast(const string &var_name, const ge GE_MAKE_GUARD_RTMEM(src_host_addr); GE_CHK_STATUS_RET(SyncTensorToHost(var_name, src_tensor_desc, &src_host_addr, src_addr_size, session_id)); - GELOGI("src_addr_size: %u, dst_addr_size: %u", src_addr_size, dst_addr_size); + GELOGI("src_addr_size: %ld, dst_addr_size: %ld", src_addr_size, dst_addr_size); GE_CHK_BOOL_RET_STATUS(src_addr_size == dst_addr_size, FAILED, "var data size is not equal broadcast "); GE_CHK_RT_RET(rtMemcpy(dst_addr, dst_addr_size, src_host_addr, src_addr_size, RT_MEMCPY_HOST_TO_DEVICE)); @@ -403,7 +403,7 @@ Status TransVarDataUtils::SyncTensorToHost(const string &var_name, const ge::GeT GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, src_tensor_desc, &src_addr)); uint8_t *mem_addr = src_addr - - static_cast(reinterpret_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + + static_cast(static_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + static_cast( reinterpret_cast(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); GE_CHK_RT_RET(rtMallocHost(reinterpret_cast(host_addr), src_tensor_size)); @@ -420,7 +420,7 @@ Status TransVarDataUtils::SyncTensorToDevice(const string &var_name, const uint8 GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, dst_tensor_desc, &dst_addr)); uint8_t *mem_addr = dst_addr - - static_cast(reinterpret_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + + static_cast(static_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + static_cast( reinterpret_cast(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); GE_CHK_RT_RET(rtMemcpy(mem_addr, addr_size, host_addr, addr_size, RT_MEMCPY_HOST_TO_DEVICE)); diff --git a/ge/graph/manager/util/debug.cc b/ge/graph/manager/util/debug.cc index b2ef1c92..45c070c6 100644 --- a/ge/graph/manager/util/debug.cc +++ b/ge/graph/manager/util/debug.cc @@ -32,7 +32,7 @@ Debug::~Debug() = default; void Debug::DumpProto(const Message &proto, const char *file) { std::string file_path = RealPath(file); - int fd = open(file_path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + int fd = mmOpen2(file_path.c_str(), M_WRONLY | M_CREAT | O_TRUNC, M_IRUSR | M_IWUSR | M_UMASK_GRPREAD | M_UMASK_OTHREAD); if (fd == -1) { GELOGW("Write %s failed", file_path.c_str()); return; @@ -40,7 +40,7 @@ void Debug::DumpProto(const Message &proto, const char *file) { auto output = ge::MakeShared(fd); if (output == nullptr) { GELOGW("create output failed."); - if (close(fd) != 0) { + if (mmClose(fd) != 0) { GELOGW("close fd failed."); } return; @@ -49,7 +49,7 @@ void Debug::DumpProto(const Message &proto, const char *file) { if (!ret) { GELOGW("dump proto failed."); } - if (close(fd) != 0) { + if (mmClose(fd) != 0) { GELOGW("close fd failed."); } } diff --git a/ge/graph/manager/util/debug.h b/ge/graph/manager/util/debug.h index 9cedb680..e1b13caf 100755 --- a/ge/graph/manager/util/debug.h +++ b/ge/graph/manager/util/debug.h @@ -17,7 +17,6 @@ #ifndef GE_GRAPH_MANAGER_UTIL_DEBUG_H_ #define GE_GRAPH_MANAGER_UTIL_DEBUG_H_ -#include #include #include #include @@ -25,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/ge/hybrid/executor/hybrid_execution_context.h b/ge/hybrid/executor/hybrid_execution_context.h index 05ed1157..0910d2c7 100644 --- a/ge/hybrid/executor/hybrid_execution_context.h +++ b/ge/hybrid/executor/hybrid_execution_context.h @@ -57,9 +57,9 @@ struct GraphExecutionContext { do { \ if ((context != nullptr) && (context)->profiler != nullptr) { \ if (node_name != nullptr) { \ - context->profiler->RecordEvent(evt_type, "tid:%lu [%s] [%s] " fmt, GetTid(), node_name, category, ##__VA_ARGS__);\ + context->profiler->RecordEvent(evt_type, "tid:%lu [%s] [%s] " fmt, GeLog::GetTid(), node_name, category, ##__VA_ARGS__);\ } else { \ - context->profiler->RecordEvent(evt_type, "tid:%lu [%s] " fmt, GetTid(), category, ##__VA_ARGS__); \ + context->profiler->RecordEvent(evt_type, "tid:%lu [%s] " fmt, GeLog::GetTid(), category, ##__VA_ARGS__); \ }\ } \ } while (0) diff --git a/ge/init/gelib.cc b/ge/init/gelib.cc index 8a5cb610..306a804a 100755 --- a/ge/init/gelib.cc +++ b/ge/init/gelib.cc @@ -110,7 +110,7 @@ Status GELib::InnerInitialize(const map &options) { Status initSystemStatus = SystemInitialize(options); GE_TIMESTAMP_END(SystemInitialize, "InnerInitialize::SystemInitialize"); if (initSystemStatus != SUCCESS) { - GELOGE(initSystemStatus); + GELOGE(initSystemStatus, "GE system initial failed."); RollbackInit(); return initSystemStatus; } @@ -120,7 +120,7 @@ Status GELib::InnerInitialize(const map &options) { Status initEmStatus = engineManager_.Initialize(options); GE_TIMESTAMP_END(EngineInitialize, "InnerInitialize::EngineInitialize"); if (initEmStatus != SUCCESS) { - GELOGE(initEmStatus); + GELOGE(initEmStatus, "GE engine manager initial failed."); RollbackInit(); return initEmStatus; } @@ -130,7 +130,7 @@ Status GELib::InnerInitialize(const map &options) { Status initOpsStatus = opsManager_.Initialize(options); GE_TIMESTAMP_END(OpsManagerInitialize, "InnerInitialize::OpsManagerInitialize"); if (initOpsStatus != SUCCESS) { - GELOGE(initOpsStatus); + GELOGE(initOpsStatus, "GE ops manager initial failed."); RollbackInit(); return initOpsStatus; } @@ -140,7 +140,7 @@ Status GELib::InnerInitialize(const map &options) { Status initOpsBuilderStatus = OpsKernelBuilderManager::Instance().Initialize(options); GE_TIMESTAMP_END(OpsKernelBuilderManagerInitialize, "InnerInitialize::OpsKernelBuilderManager"); if (initOpsBuilderStatus != SUCCESS) { - GELOGE(initOpsBuilderStatus); + GELOGE(initOpsBuilderStatus, "GE ops builder manager initial failed."); RollbackInit(); return initOpsBuilderStatus; } @@ -150,7 +150,7 @@ Status GELib::InnerInitialize(const map &options) { Status initSmStatus = sessionManager_.Initialize(options); GE_TIMESTAMP_END(SessionManagerInitialize, "InnerInitialize::SessionManagerInitialize"); if (initSmStatus != SUCCESS) { - GELOGE(initSmStatus); + GELOGE(initSmStatus, "GE session manager initial failed."); RollbackInit(); return initSmStatus; } diff --git a/ge/omm/csa_interact.cc b/ge/omm/csa_interact.cc index dd3f6240..1599af94 100644 --- a/ge/omm/csa_interact.cc +++ b/ge/omm/csa_interact.cc @@ -52,9 +52,11 @@ void CsaInteract::Init(int32_t dev_index, int64_t job_id) { if (!is_init_) { dev_index_ = dev_index; job_id_ = job_id; - char *file_dir_env = std::getenv(FMK_STATUS_FILE_DIR_ENV); + + char file_dir_env[MMPA_MAX_PATH] = { 0x00 }; + INT32 res = mmGetEnv(FMK_STATUS_FILE_DIR_ENV, file_dir_env, MMPA_MAX_PATH); string csa_path_prefix; - if (file_dir_env != nullptr) { + if (res == EN_OK) { csa_path_prefix = file_dir_env; } if (!csa_path_prefix.empty()) { @@ -186,21 +188,21 @@ Status CsaInteract::WriteHcomDetection(const std::string &content) { /// Status CsaInteract::WriteFile(const std::string &file_name, const std::string &content) { // if file path is not exist, then make path - INT32 flags = O_WRONLY | O_TRUNC | O_CREAT; - int32_t fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | S_IRGRP); + INT32 flags = M_WRONLY | O_TRUNC | M_CREAT; + int32_t fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | M_UMASK_GRPREAD); if (fd == EN_ERROR) { if (MakePath(file_name) != SUCCESS) { GELOGE(INTERNAL_ERROR, "csainteract create file path fail, errno is %d", errno); return INTERNAL_ERROR; } - fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | S_IRGRP); + fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | M_UMASK_GRPREAD); if (fd == EN_ERROR) { GELOGE(INTERNAL_ERROR, "open file fail, errno is %d", errno); return INTERNAL_ERROR; } } - ssize_t ret = write(fd, content.c_str(), content.length()); + mmSsize_t ret = mmWrite(fd, (void *)content.c_str(), content.length()); if (ret == EN_ERROR) { GELOGE(INTERNAL_ERROR, "write file fail, errno is %d", errno); ret = mmClose(fd); @@ -239,7 +241,7 @@ Status CsaInteract::MakePath(const std::string &file_name) { while (found != std::string::npos) { std::string pre_path = file_path.substr(0, found + 1); if (mmAccess(pre_path.c_str()) != EN_OK) { - if (mmMkdir(pre_path.c_str(), S_IRWXU) != EN_OK) { + if (mmMkdir(pre_path.c_str(), M_IRWXU) != EN_OK) { GELOGE(INTERNAL_ERROR, "csainteract mkdir fail, errno is %d", errno); return INTERNAL_ERROR; } diff --git a/ge/opskernel_manager/ops_kernel_manager.cc b/ge/opskernel_manager/ops_kernel_manager.cc index 12894292..c007d274 100644 --- a/ge/opskernel_manager/ops_kernel_manager.cc +++ b/ge/opskernel_manager/ops_kernel_manager.cc @@ -85,7 +85,7 @@ Status OpsKernelManager::Initialize(const map &options_const) { initialize_ = options; Status rst0 = plugin_manager_.InvokeAll &, Status>(kInitialize, initialize_); if (rst0 == FAILED) { - GELOGE(GE_OPS_GET_NO_VALID_SO); + GELOGE(GE_OPS_GET_NO_VALID_SO, "There is invalid so about OpsKernelInfoStore."); return GE_OPS_GET_NO_VALID_SO; } Status rst1 = diff --git a/ge/session/session_manager.cc b/ge/session/session_manager.cc index 81efb080..485b0bd0 100755 --- a/ge/session/session_manager.cc +++ b/ge/session/session_manager.cc @@ -61,7 +61,7 @@ Status SessionManager::SetRtContext(SessionId session_id, rtContext_t rt_context Status SessionManager::CreateSession(const std::map &options, SessionId &session_id) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } SessionId next_session_id = 0; @@ -92,7 +92,7 @@ Status SessionManager::CreateSession(const std::map &o Status SessionManager::DestroySession(SessionId session_id) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } std::lock_guard lock(mutex_); @@ -119,7 +119,7 @@ Status SessionManager::DestroySession(SessionId session_id) { Status SessionManager::GetVariable(SessionId session_id, const std::string &name, Tensor &val) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } SessionPtr innerSession = nullptr; @@ -143,7 +143,7 @@ Status SessionManager::AddGraph(SessionId session_id, uint32_t graph_id, const G Status SessionManager::AddGraph(SessionId session_id, uint32_t graph_id, const Graph &graph, const std::map &options) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } SessionPtr innerSession = nullptr; @@ -203,7 +203,7 @@ Status SessionManager::AddGraphWithCopy(SessionId session_id, uint32_t graph_id, Status SessionManager::RunGraph(SessionId session_id, uint32_t graph_id, const std::vector &inputs, std::vector &outputs) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } SessionPtr innerSession = nullptr; @@ -221,7 +221,7 @@ Status SessionManager::RunGraph(SessionId session_id, uint32_t graph_id, const s Status SessionManager::RemoveGraph(SessionId session_id, uint32_t graph_id) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } SessionPtr innerSession = nullptr; @@ -239,7 +239,7 @@ Status SessionManager::RemoveGraph(SessionId session_id, uint32_t graph_id) { bool SessionManager::HasSession(SessionId session_id) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return false; } return session_manager_map_.find(session_id) != session_manager_map_.end(); @@ -247,7 +247,7 @@ bool SessionManager::HasSession(SessionId session_id) { Status SessionManager::GetNextSessionId(SessionId &next_session_id) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } static SessionId session_id = 0; @@ -260,7 +260,7 @@ Status SessionManager::RegisterCallBackFunc( SessionId session_id, const std::string &key, const std::function &)> &callback) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } SessionPtr innerSession = nullptr; @@ -278,7 +278,7 @@ Status SessionManager::RegisterCallBackFunc( Status SessionManager::BuildGraph(SessionId session_id, uint32_t graph_id, const std::vector &inputs) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } SessionPtr innerSession = nullptr; @@ -297,7 +297,7 @@ Status SessionManager::BuildGraph(SessionId session_id, uint32_t graph_id, const Status SessionManager::RunGraphAsync(SessionId session_id, uint32_t graph_id, const std::vector &inputs, RunAsyncCallback callback) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } SessionPtr innerSession = nullptr; @@ -317,7 +317,7 @@ Status SessionManager::GetVariables(SessionId session_id, const std::vector &var_values) { // step 0: init session manager if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } SessionPtr innerSession = nullptr; @@ -383,7 +383,7 @@ Status SessionManager::GetVariables(SessionId session_id, const std::vector &inputs, const std:: for (size_t i = 0; i < num_inputs; ++i) { // preventing from read out of bound size_t aligned_size = GetAlignedSize(inputs[i].length); - GELOGI("Input [%zu], aligned_size:%zu, inputs.length:%lu, input_sizes_:%lu", + GELOGI("Input [%zu], aligned_size:%zu, inputs.length:%lu, input_sizes_:%zu", i, aligned_size, inputs[i].length, input_sizes_[i]); if (aligned_size < input_sizes_[i]) { GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Input size mismatch. index = %zu, model expect %zu," @@ -77,7 +77,7 @@ Status SingleOp::ValidateArgs(const std::vector &inputs, const std:: for (size_t i = 0; i < num_outputs; ++i) { // preventing from write out of bound size_t aligned_size = GetAlignedSize(outputs[i].length); - GELOGI("Output [%zu], aligned_size:%zu, outputs.length:%lu, output_sizes_:%lu", + GELOGI("Output [%zu], aligned_size:%zu, outputs.length:%lu, output_sizes_:%zu", i, aligned_size, outputs[i].length, output_sizes_[i]); if (aligned_size < output_sizes_[i]) { GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Output size mismatch. index = %zu, model expect %zu," @@ -143,7 +143,7 @@ Status SingleOp::UpdateArgs(const std::vector &inputs, const std::ve GE_CHECK_NOTNULL(task_io_addr); auto io_addr = reinterpret_cast(const_cast(task_io_addr)); for (size_t i = 0; i < io_addr_num; ++i) { - io_addr[i] = reinterpret_cast(args_[i]); + io_addr[i] = static_cast(args_[i]); } } else { GELOGW("Only TF_kernel aicpu and aicpu_CC are supported, but got %u", task->GetOpTaskType()); diff --git a/inc/framework/common/debug/ge_log.h b/inc/framework/common/debug/ge_log.h index 6ac00037..0ef21b34 100644 --- a/inc/framework/common/debug/ge_log.h +++ b/inc/framework/common/debug/ge_log.h @@ -18,11 +18,19 @@ #define INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_ #include -#include -#include #include "framework/common/ge_inner_error_codes.h" #include "toolchain/slog.h" +#ifdef __GNUC__ +#include +#include +#else +#include "mmpa/mmpa_api.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif #define GE_MODULE_NAME static_cast(GE) @@ -37,6 +45,21 @@ enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP }; #define GELOGO(...) GE_LOG_OPLOG(GE_MODULE_NAME, __VA_ARGS__) #define GELOGT(VALUE, ...) GE_LOG_TRACE(GE_MODULE_NAME, VALUE, __VA_ARGS__) +class GeLog { +public: +#ifdef __GNUC__ +static pid_t GetTid() { + thread_local static pid_t tid = syscall(__NR_gettid); + return tid; +} +#else +static int GetTid() { + thread_local static int tid = static_cast(GetCurrentThreadId()); + return tid; +} +#endif +}; + inline bool IsLogEnable(int module_name, int log_level) { int32_t enable = CheckLogLevel(module_name, log_level); // 1:enable, 0:disable @@ -46,23 +69,41 @@ inline bool IsLogEnable(int module_name, int log_level) { return false; } -inline pid_t GetTid() { - thread_local static pid_t tid = syscall(__NR_gettid); - return tid; -} +#define GELOGE(ERROR_CODE, fmt, ...) \ + dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \ + ((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__) +#define GELOGW(fmt, ...) \ + if (IsLogEnable(GE_MODULE_NAME, DLOG_WARN)) dlog_warn(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) +#define GELOGI(fmt, ...) \ + if (IsLogEnable(GE_MODULE_NAME, DLOG_INFO)) dlog_info(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) +#define GELOGD(fmt, ...) \ + if (IsLogEnable(GE_MODULE_NAME, DLOG_DEBUG)) dlog_debug(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) +#define GEEVENT(fmt, ...) dlog_event(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) +#define GELOGO(fmt, ...) \ + Dlog(GE_MODULE_NAME, DLOG_OPLOG, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) +#define GELOGT(VALUE, fmt, ...) \ + do { \ + TraceStatus stat = VALUE; \ + const char *const TraceStatStr[] = {"INIT", "RUNNING", "WAITING", "STOP"}; \ + int idx = static_cast(stat); \ + char *k = const_cast("status"); \ + char *v = const_cast(TraceStatStr[idx]); \ + KeyValue kv = {k, v}; \ + DlogWithKV(static_cast(GE_MODULE_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__); \ + } while (0) #define GE_LOG_ERROR(MOD_NAME, ERROR_CODE, fmt, ...) \ - dlog_error(MOD_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GetTid(), __FUNCTION__, ERROR_CODE, \ + dlog_error(MOD_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \ ((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__) #define GE_LOG_WARN(MOD_NAME, fmt, ...) \ - if (IsLogEnable(MOD_NAME, DLOG_WARN)) dlog_warn(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) + if (IsLogEnable(MOD_NAME, DLOG_WARN)) dlog_warn(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) #define GE_LOG_INFO(MOD_NAME, fmt, ...) \ - if (IsLogEnable(MOD_NAME, DLOG_INFO)) dlog_info(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) + if (IsLogEnable(MOD_NAME, DLOG_INFO)) dlog_info(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) #define GE_LOG_DEBUG(MOD_NAME, fmt, ...) \ - if (IsLogEnable(MOD_NAME, DLOG_DEBUG)) dlog_debug(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) -#define GE_LOG_EVENT(MOD_NAME, fmt, ...) dlog_event(MOD_NAME, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) + if (IsLogEnable(MOD_NAME, DLOG_DEBUG)) dlog_debug(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) +#define GE_LOG_EVENT(MOD_NAME, fmt, ...) dlog_event(MOD_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) #define GE_LOG_OPLOG(MOD_NAME, fmt, ...) \ - Dlog(MOD_NAME, DLOG_OPLOG, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__) + Dlog(MOD_NAME, DLOG_OPLOG, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) #define GE_LOG_TRACE(MOD_NAME, value, fmt, ...) \ do { \ @@ -72,7 +113,7 @@ inline pid_t GetTid() { char *k = const_cast("status"); \ char *v = const_cast(TraceStatStr[idx]); \ KeyValue kv = {k, v}; \ - DlogWithKV(static_cast(MOD_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GetTid(), __FUNCTION__, ##__VA_ARGS__); \ + DlogWithKV(static_cast(MOD_NAME), DLOG_TRACE, &kv, 1, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__); \ } while (0) // print memory when it is greater than 1KB. @@ -82,4 +123,7 @@ inline pid_t GetTid() { GELOGI("MallocMemory, func=%s, size=%zu, purpose=%s", (#FUNC), static_cast(SIZE), (PURPOSE)); \ } \ } while (0); +#ifdef __cplusplus +} +#endif #endif // INC_FRAMEWORK_COMMON_DEBUG_GE_LOG_H_ diff --git a/inc/framework/common/ge_compiler_options.h b/inc/framework/common/ge_compiler_options.h new file mode 100644 index 00000000..5c947346 --- /dev/null +++ b/inc/framework/common/ge_compiler_options.h @@ -0,0 +1,32 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_ +#define INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_ + +namespace ge { +#ifdef __GNUC__ +#define GE_ATTRIBUTE_UNUSED __attribute__((unused)) +#define GE_FUNCTION_IDENTIFIER __PRETTY_FUNCTION__ +#define GE_BUILTIN_PREFETCH(args_addr) __builtin_prefetch(args_addr) +#else +#define GE_ATTRIBUTE_UNUSED +#define GE_FUNCTION_IDENTIFIER __FUNCSIG__ +#define GE_BUILTIN_PREFETCH(args_addr) +#endif +} // namespace ge + +#endif // INC_FRAMEWORK_COMMON_GE_COMPILER_OPTIONS_H_ \ No newline at end of file diff --git a/inc/framework/common/string_util.h b/inc/framework/common/string_util.h index 47e80e75..de19807c 100644 --- a/inc/framework/common/string_util.h +++ b/inc/framework/common/string_util.h @@ -17,6 +17,7 @@ #ifndef INC_FRAMEWORK_COMMON_STRING_UTIL_H_ #define INC_FRAMEWORK_COMMON_STRING_UTIL_H_ +#include #include #include diff --git a/inc/framework/common/types.h b/inc/framework/common/types.h index 2a4f3ca3..22e85e0b 100644 --- a/inc/framework/common/types.h +++ b/inc/framework/common/types.h @@ -18,7 +18,6 @@ #define INC_FRAMEWORK_COMMON_TYPES_H_ #include -#include #include #include #include @@ -529,7 +528,7 @@ REGISTER_OPTYPE_DECLARE(HVDWAIT, "HorovodWait"); // aicpu op for online_infer dynamic_dims REGISTER_OPTYPE_DECLARE(GETDYNAMICDIMS, "GetDynamicDims"); -enum InputMode { INPUT = 0, CONST }; +enum InputMode { INPUT = 0, CONST_INPUT}; // Definition of the processing status enum of the process module enum ModelProcessState { From ce6b049eba49df0a77a72c918623cb3c5f494e6d Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 19 Nov 2020 21:24:24 +0800 Subject: [PATCH 03/32] update thirdparty includes --- third_party/fwkacllib/inc/hccl/base.h | 6 +- third_party/fwkacllib/inc/mmpa/mmpa_api.h | 13 + .../fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h | 352 +++++++++-------- .../fwkacllib/inc/mmpa/sub_inc/mmpa_win.h | 366 +++++++++--------- third_party/fwkacllib/inc/runtime/base.h | 16 +- third_party/fwkacllib/inc/runtime/context.h | 2 +- third_party/fwkacllib/inc/runtime/dev.h | 4 +- third_party/fwkacllib/inc/runtime/event.h | 28 +- third_party/fwkacllib/inc/runtime/kernel.h | 57 ++- third_party/fwkacllib/inc/runtime/mem.h | 6 +- third_party/fwkacllib/inc/runtime/rt_model.h | 3 +- third_party/fwkacllib/inc/runtime/stream.h | 16 +- .../fwkacllib/inc/tdt/index_transform.h | 29 ++ third_party/fwkacllib/inc/tdt/status.h | 3 + third_party/fwkacllib/inc/tdt/tsd_client.h | 22 +- third_party/fwkacllib/inc/toolchain/slog.h | 26 +- .../inc/toolchain/tuning_tool/tune_api.h | 72 ++++ 17 files changed, 627 insertions(+), 394 deletions(-) create mode 100644 third_party/fwkacllib/inc/tdt/index_transform.h create mode 100644 third_party/fwkacllib/inc/toolchain/tuning_tool/tune_api.h diff --git a/third_party/fwkacllib/inc/hccl/base.h b/third_party/fwkacllib/inc/hccl/base.h index 94253bf4..8194097e 100644 --- a/third_party/fwkacllib/inc/hccl/base.h +++ b/third_party/fwkacllib/inc/hccl/base.h @@ -68,8 +68,10 @@ struct MemRegisterAddr { u64 addr; u64 length; }; - -const u32 HCCL_MAX_MEM_REGISTER_NUM = 8; // The max number of memory register address. +/* + * @brief The max number of memory register address for remote access. + */ +const u32 HCCL_MAX_MEM_REGISTER_NUM = 32; enum GradSplitForceMode { FORCE_NONE, /**< no force */ diff --git a/third_party/fwkacllib/inc/mmpa/mmpa_api.h b/third_party/fwkacllib/inc/mmpa/mmpa_api.h index f5b80269..38a689ee 100644 --- a/third_party/fwkacllib/inc/mmpa/mmpa_api.h +++ b/third_party/fwkacllib/inc/mmpa/mmpa_api.h @@ -26,6 +26,12 @@ #define _GNU_SOURCE #endif +#ifdef FUNC_VISIBILITY +#define MMPA_FUNC_VISIBILITY __attribute__((visibility("default"))) +#else +#define MMPA_FUNC_VISIBILITY +#endif + #include #include #include @@ -86,6 +92,13 @@ #if(OS_TYPE == WIN) //lint !e553 + +#ifdef FUNC_VISIBILITY +#define MMPA_FUNC_VISIBILITY _declspec(dllexport) +#else +#define MMPA_FUNC_VISIBILITY +#endif + #include #include #include "Windows.h" diff --git a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h index aced4968..ea51f497 100644 --- a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h +++ b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h @@ -44,12 +44,16 @@ typedef VOID *mmExitCode; typedef key_t mmKey_t; typedef int mmMsgid; typedef struct dirent mmDirent; +typedef struct dirent mmDirent2; typedef struct shmid_ds mmshmId_ds; typedef int (*mmFilter)(const mmDirent *entry); +typedef int (*mmFilter2)(const mmDirent2 *entry); typedef int (*mmSort)(const mmDirent **a, const mmDirent **b); +typedef int (*mmSort2)(const mmDirent2 **a, const mmDirent2 **b); typedef size_t mmSize_t; typedef off_t mmOfft_t; typedef pid_t mmPid_t; +typedef long MM_LONG; typedef VOID *(*userProcFunc)(VOID *pulArg); @@ -113,6 +117,7 @@ typedef struct { } mmIoctlBuf; typedef int mmAtomicType; +typedef int mmAtomicType64; typedef enum { pollTypeRead = 1, // pipe read @@ -151,8 +156,8 @@ typedef struct { } mmTimeval; typedef struct { - LONG tv_sec; - LONG tv_nsec; + MM_LONG tv_sec; + MM_LONG tv_nsec; } mmTimespec; typedef struct { @@ -272,6 +277,9 @@ typedef struct { #define M_R_OK R_OK #define M_W_OK W_OK +#define MM_DT_DIR DT_DIR +#define MM_DT_REG DT_REG + #define MMPA_STDIN STDIN_FILENO #define MMPA_STDOUT STDOUT_FILENO #define MMPA_STDERR STDERR_FILENO @@ -283,182 +291,195 @@ typedef struct { #define MMPA_DL_EXT_NAME ".so" -extern INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock); -extern INT32 mmJoinTask(mmThread *threadHandle); -extern INT32 mmMutexInit(mmMutex_t *mutex); -extern INT32 mmMutexLock(mmMutex_t *mutex); -extern INT32 mmMutexTryLock(mmMutex_t *mutex); -extern INT32 mmMutexUnLock(mmMutex_t *mutex); -extern INT32 mmMutexDestroy(mmMutex_t *mutex); -extern INT32 mmCondInit(mmCond *cond); -extern INT32 mmCondLockInit(mmMutexFC *mutex); -extern INT32 mmCondLock(mmMutexFC *mutex); -extern INT32 mmCondUnLock(mmMutexFC *mutex); -extern INT32 mmCondLockDestroy(mmMutexFC *mutex); -extern INT32 mmRWLockInit(mmRWLock_t *rwLock); -extern INT32 mmRWLockRDLock(mmRWLock_t *rwLock); -extern INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock); -extern INT32 mmRWLockWRLock(mmRWLock_t *rwLock); -extern INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock); -extern INT32 mmRDLockUnLock(mmRWLock_t *rwLock); -extern INT32 mmWRLockUnLock(mmRWLock_t *rwLock); -extern INT32 mmRWLockDestroy(mmRWLock_t *rwLock); -extern INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex); -extern INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond); -extern INT32 mmCondNotify(mmCond *cond); -extern INT32 mmCondNotifyAll(mmCond *cond); -extern INT32 mmCondDestroy(mmCond *cond); -extern INT32 mmGetPid(); -extern INT32 mmGetTid(); -extern INT32 mmGetPidHandle(mmProcess *processHandle); -extern INT32 mmGetLocalTime(mmSystemTime_t *sysTime); -extern INT32 mmGetSystemTime(mmSystemTime_t *sysTime); - -extern INT32 mmSemInit(mmSem_t *sem, UINT32 value); -extern INT32 mmSemWait(mmSem_t *sem); -extern INT32 mmSemPost(mmSem_t *sem); -extern INT32 mmSemDestroy(mmSem_t *sem); -extern INT32 mmOpen(const CHAR *pathName, INT32 flags); -extern INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode); -extern FILE *mmPopen(CHAR *command, CHAR *type); -extern INT32 mmClose(INT32 fd); -extern INT32 mmPclose(FILE *stream); -extern mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen); -extern mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen); -extern mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol); -extern INT32 mmBind(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen); -extern INT32 mmListen(mmSockHandle sockFd, INT32 backLog); -extern mmSockHandle mmAccept(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t *addrLen); -extern INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen); -extern INT32 mmCloseSocket(mmSockHandle sockFd); -extern mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag); -extern mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag); -extern INT32 mmSocketSendTo(mmSockHandle sockFd, +MMPA_FUNC_VISIBILITY INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock); +MMPA_FUNC_VISIBILITY INT32 mmJoinTask(mmThread *threadHandle); +MMPA_FUNC_VISIBILITY INT32 mmMutexInit(mmMutex_t *mutex); +MMPA_FUNC_VISIBILITY INT32 mmMutexLock(mmMutex_t *mutex); +MMPA_FUNC_VISIBILITY INT32 mmMutexTryLock(mmMutex_t *mutex); +MMPA_FUNC_VISIBILITY INT32 mmMutexUnLock(mmMutex_t *mutex); +MMPA_FUNC_VISIBILITY INT32 mmMutexDestroy(mmMutex_t *mutex); +MMPA_FUNC_VISIBILITY INT32 mmCondInit(mmCond *cond); +MMPA_FUNC_VISIBILITY INT32 mmCondLockInit(mmMutexFC *mutex); +MMPA_FUNC_VISIBILITY INT32 mmCondLock(mmMutexFC *mutex); +MMPA_FUNC_VISIBILITY INT32 mmCondUnLock(mmMutexFC *mutex); +MMPA_FUNC_VISIBILITY INT32 mmCondLockDestroy(mmMutexFC *mutex); +MMPA_FUNC_VISIBILITY INT32 mmRWLockInit(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRWLockRDLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRWLockWRLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRDLockUnLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmWRLockUnLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRWLockDestroy(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex); +MMPA_FUNC_VISIBILITY INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond); +MMPA_FUNC_VISIBILITY INT32 mmCondNotify(mmCond *cond); +MMPA_FUNC_VISIBILITY INT32 mmCondNotifyAll(mmCond *cond); +MMPA_FUNC_VISIBILITY INT32 mmCondDestroy(mmCond *cond); +MMPA_FUNC_VISIBILITY INT32 mmGetPid(); +MMPA_FUNC_VISIBILITY INT32 mmGetTid(); +MMPA_FUNC_VISIBILITY INT32 mmGetPidHandle(mmProcess *processHandle); +MMPA_FUNC_VISIBILITY INT32 mmGetLocalTime(mmSystemTime_t *sysTime); +MMPA_FUNC_VISIBILITY INT32 mmGetSystemTime(mmSystemTime_t *sysTime); + +MMPA_FUNC_VISIBILITY INT32 mmSemInit(mmSem_t *sem, UINT32 value); +MMPA_FUNC_VISIBILITY INT32 mmSemWait(mmSem_t *sem); +MMPA_FUNC_VISIBILITY INT32 mmSemPost(mmSem_t *sem); +MMPA_FUNC_VISIBILITY INT32 mmSemDestroy(mmSem_t *sem); +MMPA_FUNC_VISIBILITY INT32 mmOpen(const CHAR *pathName, INT32 flags); +MMPA_FUNC_VISIBILITY INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode); +MMPA_FUNC_VISIBILITY FILE *mmPopen(CHAR *command, CHAR *type); +MMPA_FUNC_VISIBILITY INT32 mmClose(INT32 fd); +MMPA_FUNC_VISIBILITY INT32 mmPclose(FILE *stream); +MMPA_FUNC_VISIBILITY mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen); +MMPA_FUNC_VISIBILITY mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen); +MMPA_FUNC_VISIBILITY mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol); +MMPA_FUNC_VISIBILITY INT32 mmBind(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen); +MMPA_FUNC_VISIBILITY INT32 mmListen(mmSockHandle sockFd, INT32 backLog); +MMPA_FUNC_VISIBILITY mmSockHandle mmAccept(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t *addrLen); +MMPA_FUNC_VISIBILITY INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen); +MMPA_FUNC_VISIBILITY INT32 mmCloseSocket(mmSockHandle sockFd); +MMPA_FUNC_VISIBILITY mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag); +MMPA_FUNC_VISIBILITY mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag); +MMPA_FUNC_VISIBILITY INT32 mmSocketSendTo(mmSockHandle sockFd, VOID *sendMsg, INT32 sendLen, UINT32 sendFlag, const mmSockAddr* addr, INT32 tolen); -extern mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd, +MMPA_FUNC_VISIBILITY mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd, VOID *recvBuf, mmSize recvLen, UINT32 recvFlag, mmSockAddr* addr, mmSocklen_t *FromLen); -extern INT32 mmSAStartup(); -extern INT32 mmSACleanup(); -extern VOID *mmDlopen(const CHAR *fileName, INT32 mode); -extern INT32 mmDladdr(VOID *addr, mmDlInfo *info); -extern VOID *mmDlsym(VOID *handle, CHAR *funcName); -extern INT32 mmDlclose(VOID *handle); -extern CHAR *mmDlerror(); -extern INT32 mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock, UINT milliSecond, UINT period); -extern INT32 mmDeleteTimer(mmTimer timerHandle); -extern INT32 mmStatGet(const CHAR *path, mmStat_t *buffer); -extern INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer); -extern INT32 mmFStatGet(INT32 fd, mmStat_t *buffer); -extern INT32 mmMkdir(const CHAR *pathName, mmMode_t mode); -extern INT32 mmSleep(UINT32 milliSecond); - -extern INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock); -extern INT32 mmGetProcessPrio(mmProcess pid); -extern INT32 mmSetProcessPrio(mmProcess pid, INT32 processPrio); -extern INT32 mmGetThreadPrio(mmThread *threadHandle); -extern INT32 mmSetThreadPrio(mmThread *threadHandle, INT32 threadPrio); -extern INT32 mmAccess(const CHAR *pathName); -extern INT32 mmAccess2(const CHAR *pathName, INT32 mode); -extern INT32 mmRmdir(const CHAR *pathName); - -extern INT32 mmIoctl(mmProcess fd, INT32 ioctlCode, mmIoctlBuf *bufPtr); -extern INT32 mmSemTimedWait(mmSem_t *sem, INT32 timeout); -extern mmSsize_t mmWritev(mmProcess fd, mmIovSegment *iov, INT32 iovcnt); -extern VOID mmMb(); -extern INT32 mmInetAton(const CHAR *addrStr, mmInAddr *addr); - -extern mmProcess mmOpenFile(const CHAR *fileName, UINT32 access, mmCreateFlag fileFlag); -extern mmSsize_t mmReadFile(mmProcess fileId, VOID *buffer, INT32 len); -extern mmSsize_t mmWriteFile(mmProcess fileId, VOID *buffer, INT32 len); -extern INT32 mmCloseFile(mmProcess fileId); - -extern mmAtomicType mmSetData(mmAtomicType *ptr, mmAtomicType value); -extern mmAtomicType mmValueInc(mmAtomicType *ptr, mmAtomicType value); -extern mmAtomicType mmValueSub(mmAtomicType *ptr, mmAtomicType value); -extern INT32 mmCreateTaskWithDetach(mmThread *threadHandle, mmUserBlock_t *funcBlock); +MMPA_FUNC_VISIBILITY INT32 mmSAStartup(); +MMPA_FUNC_VISIBILITY INT32 mmSACleanup(); +MMPA_FUNC_VISIBILITY VOID *mmDlopen(const CHAR *fileName, INT32 mode); +MMPA_FUNC_VISIBILITY INT32 mmDladdr(VOID *addr, mmDlInfo *info); +MMPA_FUNC_VISIBILITY VOID *mmDlsym(VOID *handle, const CHAR *funcName); +MMPA_FUNC_VISIBILITY INT32 mmDlclose(VOID *handle); +MMPA_FUNC_VISIBILITY CHAR *mmDlerror(); +MMPA_FUNC_VISIBILITY INT32 mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock, UINT milliSecond, UINT period); +MMPA_FUNC_VISIBILITY INT32 mmDeleteTimer(mmTimer timerHandle); +MMPA_FUNC_VISIBILITY INT32 mmStatGet(const CHAR *path, mmStat_t *buffer); +MMPA_FUNC_VISIBILITY INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer); +MMPA_FUNC_VISIBILITY INT32 mmFStatGet(INT32 fd, mmStat_t *buffer); +MMPA_FUNC_VISIBILITY INT32 mmMkdir(const CHAR *pathName, mmMode_t mode); +MMPA_FUNC_VISIBILITY INT32 mmSleep(UINT32 milliSecond); + +MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock); +MMPA_FUNC_VISIBILITY INT32 mmGetProcessPrio(mmProcess pid); +MMPA_FUNC_VISIBILITY INT32 mmSetProcessPrio(mmProcess pid, INT32 processPrio); +MMPA_FUNC_VISIBILITY INT32 mmGetThreadPrio(mmThread *threadHandle); +MMPA_FUNC_VISIBILITY INT32 mmSetThreadPrio(mmThread *threadHandle, INT32 threadPrio); +MMPA_FUNC_VISIBILITY INT32 mmAccess(const CHAR *pathName); +MMPA_FUNC_VISIBILITY INT32 mmAccess2(const CHAR *pathName, INT32 mode); +MMPA_FUNC_VISIBILITY INT32 mmRmdir(const CHAR *pathName); + +MMPA_FUNC_VISIBILITY INT32 mmIoctl(mmProcess fd, INT32 ioctlCode, mmIoctlBuf *bufPtr); +MMPA_FUNC_VISIBILITY INT32 mmSemTimedWait(mmSem_t *sem, INT32 timeout); +MMPA_FUNC_VISIBILITY mmSsize_t mmWritev(mmProcess fd, mmIovSegment *iov, INT32 iovcnt); +MMPA_FUNC_VISIBILITY VOID mmMb(); +MMPA_FUNC_VISIBILITY INT32 mmInetAton(const CHAR *addrStr, mmInAddr *addr); + +MMPA_FUNC_VISIBILITY mmProcess mmOpenFile(const CHAR *fileName, UINT32 access, mmCreateFlag fileFlag); +MMPA_FUNC_VISIBILITY mmSsize_t mmReadFile(mmProcess fileId, VOID *buffer, INT32 len); +MMPA_FUNC_VISIBILITY mmSsize_t mmWriteFile(mmProcess fileId, VOID *buffer, INT32 len); +MMPA_FUNC_VISIBILITY INT32 mmCloseFile(mmProcess fileId); + +MMPA_FUNC_VISIBILITY mmAtomicType mmSetData(mmAtomicType *ptr, mmAtomicType value); +MMPA_FUNC_VISIBILITY mmAtomicType mmValueInc(mmAtomicType *ptr, mmAtomicType value); +MMPA_FUNC_VISIBILITY mmAtomicType mmValueSub(mmAtomicType *ptr, mmAtomicType value); +MMPA_FUNC_VISIBILITY mmAtomicType64 mmSetData64(mmAtomicType64 *ptr, mmAtomicType64 value); +MMPA_FUNC_VISIBILITY mmAtomicType64 mmValueInc64(mmAtomicType64 *ptr, mmAtomicType64 value); +MMPA_FUNC_VISIBILITY mmAtomicType64 mmValueSub64(mmAtomicType64 *ptr, mmAtomicType64 value); +MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithDetach(mmThread *threadHandle, mmUserBlock_t *funcBlock); // The following 3 interfaces are to be deleted -extern INT32 mmCreateNamedPipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode); -extern INT32 mmOpenNamePipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode); -extern VOID mmCloseNamedPipe(mmPipeHandle namedPipe[]); +MMPA_FUNC_VISIBILITY INT32 mmCreateNamedPipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode); +MMPA_FUNC_VISIBILITY INT32 mmOpenNamePipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode); +MMPA_FUNC_VISIBILITY VOID mmCloseNamedPipe(mmPipeHandle namedPipe[]); -extern INT32 mmCreatePipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode); -extern INT32 mmOpenPipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode); -extern VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount); +MMPA_FUNC_VISIBILITY INT32 mmCreatePipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode); +MMPA_FUNC_VISIBILITY INT32 mmOpenPipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode); +MMPA_FUNC_VISIBILITY VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount); // Poll related interface -extern mmCompletionHandle mmCreateCompletionPort(); -extern VOID mmCloseCompletionPort(mmCompletionHandle handle); -extern INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP, pmmPollData polledData, - mmPollBack pollBack); -extern INT32 mmGetErrorCode(); -extern CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size); -extern INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone); -extern mmTimespec mmGetTickCount(); -extern INT32 mmGetRealPath(CHAR *path, CHAR *realPath); -extern INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen); +MMPA_FUNC_VISIBILITY mmCompletionHandle mmCreateCompletionPort(); +MMPA_FUNC_VISIBILITY VOID mmCloseCompletionPort(mmCompletionHandle handle); +MMPA_FUNC_VISIBILITY INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP, + pmmPollData polledData, mmPollBack pollBack); +MMPA_FUNC_VISIBILITY INT32 mmGetErrorCode(); +MMPA_FUNC_VISIBILITY CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size); +MMPA_FUNC_VISIBILITY INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone); +MMPA_FUNC_VISIBILITY mmTimespec mmGetTickCount(); +MMPA_FUNC_VISIBILITY INT32 mmGetRealPath(CHAR *path, CHAR *realPath); +MMPA_FUNC_VISIBILITY INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen); -extern INT32 mmDup2(INT32 oldFd, INT32 newFd); +MMPA_FUNC_VISIBILITY INT32 mmDup2(INT32 oldFd, INT32 newFd); -extern INT32 mmDup(INT32 fd); +MMPA_FUNC_VISIBILITY INT32 mmDup(INT32 fd); -extern INT32 mmUnlink(const CHAR *filename); +MMPA_FUNC_VISIBILITY INT32 mmUnlink(const CHAR *filename); -extern INT32 mmChmod(const CHAR *filename, INT32 mode); +MMPA_FUNC_VISIBILITY INT32 mmChmod(const CHAR *filename, INT32 mode); -extern INT32 mmFileno(FILE *stream); +MMPA_FUNC_VISIBILITY INT32 mmFileno(FILE *stream); -extern INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort); +MMPA_FUNC_VISIBILITY INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort); +MMPA_FUNC_VISIBILITY INT32 mmScandir2(const CHAR *path, mmDirent2 ***entryList, mmFilter2 filterFunc, mmSort2 sort); -extern VOID mmScandirFree(mmDirent **entryList, INT32 count); +MMPA_FUNC_VISIBILITY VOID mmScandirFree(mmDirent **entryList, INT32 count); +MMPA_FUNC_VISIBILITY VOID mmScandirFree2(mmDirent2 **entryList, INT32 count); -extern mmMsgid mmMsgCreate(mmKey_t key, INT32 msgFlag); +MMPA_FUNC_VISIBILITY mmMsgid mmMsgCreate(mmKey_t key, INT32 msgFlag); -extern mmMsgid mmMsgOpen(mmKey_t key, INT32 msgFlag); +MMPA_FUNC_VISIBILITY mmMsgid mmMsgOpen(mmKey_t key, INT32 msgFlag); -extern INT32 mmMsgSnd(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag); +MMPA_FUNC_VISIBILITY INT32 mmMsgSnd(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag); -extern INT32 mmMsgRcv(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag); +MMPA_FUNC_VISIBILITY INT32 mmMsgRcv(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag); -extern INT32 mmMsgClose(mmMsgid msqid); +MMPA_FUNC_VISIBILITY INT32 mmMsgClose(mmMsgid msqid); -extern INT32 mmLocalTimeR(const time_t *timep, struct tm *result); +MMPA_FUNC_VISIBILITY INT32 mmLocalTimeR(const time_t *timep, struct tm *result); -extern INT32 mmGetOpt(INT32 argc, char *const *argv, const char *opts); -extern INT32 mmGetOptLong(INT32 argc, char *const *argv, const char *opts, const mmStructOption *longOpts, - INT32 *longIndex); +MMPA_FUNC_VISIBILITY INT32 mmGetOptErr(); +MMPA_FUNC_VISIBILITY VOID mmSetOptErr(INT32 mmOptErr); +MMPA_FUNC_VISIBILITY INT32 mmGetOptInd(); +MMPA_FUNC_VISIBILITY VOID mmSetOptInd(INT32 mmOptInd); +MMPA_FUNC_VISIBILITY INT32 mmGetOptOpt(); +MMPA_FUNC_VISIBILITY VOID mmSetOpOpt(INT32 mmOptOpt); +MMPA_FUNC_VISIBILITY CHAR *mmGetOptArg(); +MMPA_FUNC_VISIBILITY VOID mmSetOptArg(CHAR *mmOptArg); +MMPA_FUNC_VISIBILITY INT32 mmGetOpt(INT32 argc, char *const *argv, const char *opts); +MMPA_FUNC_VISIBILITY INT32 mmGetOptLong(INT32 argc, char *const *argv, const char *opts, const mmStructOption *longOpts, + INT32 *longIndex); -extern LONG mmLseek(INT32 fd, INT64 offset, INT32 seekFlag); -extern INT32 mmFtruncate(mmProcess fd, UINT32 length); +MMPA_FUNC_VISIBILITY LONG mmLseek(INT32 fd, INT64 offset, INT32 seekFlag); +MMPA_FUNC_VISIBILITY INT32 mmFtruncate(mmProcess fd, UINT32 length); -extern INT32 mmTlsCreate(mmThreadKey *key, VOID (*destructor)(VOID *)); -extern INT32 mmTlsSet(mmThreadKey key, const VOID *value); -extern VOID *mmTlsGet(mmThreadKey key); -extern INT32 mmTlsDelete(mmThreadKey key); -extern INT32 mmGetOsType(); +MMPA_FUNC_VISIBILITY INT32 mmTlsCreate(mmThreadKey *key, VOID (*destructor)(VOID *)); +MMPA_FUNC_VISIBILITY INT32 mmTlsSet(mmThreadKey key, const VOID *value); +MMPA_FUNC_VISIBILITY VOID *mmTlsGet(mmThreadKey key); +MMPA_FUNC_VISIBILITY INT32 mmTlsDelete(mmThreadKey key); +MMPA_FUNC_VISIBILITY INT32 mmGetOsType(); -extern INT32 mmFsync(mmProcess fd); -extern INT32 mmFsync2(INT32 fd); -extern INT32 mmChdir(const CHAR *path); -extern INT32 mmUmask(INT32 pmode); -extern INT32 mmThreadKill(mmThread id); -extern INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options); +MMPA_FUNC_VISIBILITY INT32 mmFsync(mmProcess fd); +MMPA_FUNC_VISIBILITY INT32 mmFsync2(INT32 fd); +MMPA_FUNC_VISIBILITY INT32 mmChdir(const CHAR *path); +MMPA_FUNC_VISIBILITY INT32 mmUmask(INT32 pmode); +MMPA_FUNC_VISIBILITY INT32 mmThreadKill(mmThread id); +MMPA_FUNC_VISIBILITY INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options); -extern INT32 mmGetCwd(CHAR *buffer, INT32 maxLen); -extern INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len); -extern INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite); -extern CHAR *mmStrTokR(CHAR *str, const CHAR *delim, CHAR **saveptr); -extern CHAR *mmDirName(CHAR *path); -extern CHAR *mmBaseName(CHAR *path); -extern INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize); +MMPA_FUNC_VISIBILITY INT32 mmGetCwd(CHAR *buffer, INT32 maxLen); +MMPA_FUNC_VISIBILITY INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len); +MMPA_FUNC_VISIBILITY INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite); +MMPA_FUNC_VISIBILITY CHAR *mmStrTokR(CHAR *str, const CHAR *delim, CHAR **saveptr); +MMPA_FUNC_VISIBILITY CHAR *mmDirName(CHAR *path); +MMPA_FUNC_VISIBILITY CHAR *mmBaseName(CHAR *path); +MMPA_FUNC_VISIBILITY INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize); /* * Function: set the thread name created by mmcreatetask @@ -467,7 +488,7 @@ extern INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize); * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the * execution failure returns EN_ERROR */ -extern INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name); +MMPA_FUNC_VISIBILITY INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name); /* * Function: get thread name @@ -477,37 +498,38 @@ extern INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name); * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the * execution failure returns EN_ERROR */ -extern INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, INT32 size); +MMPA_FUNC_VISIBILITY INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, INT32 size); /* * Function:Set the thread name of the currently executing thread - call inside the thread body * Input:name:Thread name to be set * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the * execution failure returns EN_ERROR */ -extern INT32 mmSetCurrentThreadName(const CHAR *name); +MMPA_FUNC_VISIBILITY INT32 mmSetCurrentThreadName(const CHAR *name); /* * Function:Get the thread name of the currently executing thread - in body call * Input:name:The name of the thread to get, and the cache is allocated by the user,size>=MMPA_THREADNAME_SIZE * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the * execution failure returns EN_ERROR */ -extern INT32 mmGetCurrentThreadName(CHAR *name, INT32 size); -extern INT32 mmGetFileSize(const CHAR *fileName, ULONGLONG *length); -extern INT32 mmIsDir(const CHAR *fileName); -extern INT32 mmGetOsName(CHAR *name, INT32 nameSize); -extern INT32 mmGetOsVersion(CHAR *versionInfo, INT32 versionLength); -extern INT32 mmGetMac(mmMacInfo **list, INT32 *count); -extern INT32 mmGetMacFree(mmMacInfo *list, INT32 count); -extern INT32 mmGetCpuInfo(mmCpuDesc **cpuInfo, INT32 *count); -extern INT32 mmCpuInfoFree(mmCpuDesc *cpuInfo, INT32 count); -extern INT32 mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const char *stdoutRedirectFile, mmProcess *id); - -extern INT32 mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, - const mmThreadAttr *threadAttr); -extern mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode); -extern INT32 mmShmUnlink(const CHAR *name); -extern VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags); -extern INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra); +MMPA_FUNC_VISIBILITY INT32 mmGetCurrentThreadName(CHAR *name, INT32 size); +MMPA_FUNC_VISIBILITY INT32 mmGetFileSize(const CHAR *fileName, ULONGLONG *length); +MMPA_FUNC_VISIBILITY INT32 mmIsDir(const CHAR *fileName); +MMPA_FUNC_VISIBILITY INT32 mmGetOsName(CHAR *name, INT32 nameSize); +MMPA_FUNC_VISIBILITY INT32 mmGetOsVersion(CHAR *versionInfo, INT32 versionLength); +MMPA_FUNC_VISIBILITY INT32 mmGetMac(mmMacInfo **list, INT32 *count); +MMPA_FUNC_VISIBILITY INT32 mmGetMacFree(mmMacInfo *list, INT32 count); +MMPA_FUNC_VISIBILITY INT32 mmGetCpuInfo(mmCpuDesc **cpuInfo, INT32 *count); +MMPA_FUNC_VISIBILITY INT32 mmCpuInfoFree(mmCpuDesc *cpuInfo, INT32 count); +MMPA_FUNC_VISIBILITY INT32 mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const char *stdoutRedirectFile, + mmProcess *id); + +MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, + const mmThreadAttr *threadAttr); +MMPA_FUNC_VISIBILITY mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode); +MMPA_FUNC_VISIBILITY INT32 mmShmUnlink(const CHAR *name); +MMPA_FUNC_VISIBILITY VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags); +MMPA_FUNC_VISIBILITY INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra); #define MMPA_DLL_API #ifdef __cplusplus diff --git a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h index 6adc1426..5db6bbf8 100644 --- a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h +++ b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h @@ -30,11 +30,6 @@ extern "C" { #define MMPA_MACINFO_DEFAULT_SIZE 18 #define MMPA_CPUDESC_DEFAULT_SIZE 64 -MMPA_DLL_API extern char *optarg; -MMPA_DLL_API extern int opterr; -MMPA_DLL_API extern int optind; -MMPA_DLL_API extern int optopt; - #pragma section(".CRT$XCU", long, read) #pragma section(".CRT$XPU", long, read) @@ -65,6 +60,7 @@ typedef struct sockaddr mmSockAddr; typedef int mmSocklen_t; typedef int mmSemTimeout_t; typedef long mmAtomicType; +typedef long long mmAtomicType64; typedef DWORD mmExitCode; typedef DWORD mmErrorMsg; typedef int mmKey_t; @@ -76,6 +72,7 @@ typedef INT32 mmSsize_t; typedef int mmSize; // size typedef size_t mmSize_t; typedef VOID mmshmId_ds; +typedef long long MM_LONG; typedef enum { DT_DIR = FILE_ATTRIBUTE_DIRECTORY, @@ -86,8 +83,15 @@ typedef struct { char d_name[MAX_PATH]; // file name } mmDirent; +typedef struct { + unsigned long d_type; + char d_name[MAX_PATH]; // file name +} mmDirent2; + typedef int (*mmFilter)(const mmDirent *entry); +typedef int (*mmFilter2)(const mmDirent2 *entry); typedef int (*mmSort)(const mmDirent **a, const mmDirent **b); +typedef int (*mmSort2)(const mmDirent2 **a, const mmDirent2 **b); typedef struct { VOID *sendBuf; @@ -162,8 +166,8 @@ typedef struct { } mmTimezone; typedef struct { - LONG tv_sec; - LONG tv_nsec; + MM_LONG tv_sec; + MM_LONG tv_nsec; } mmTimespec; typedef mmTimerHandle mmTimer; @@ -283,12 +287,13 @@ typedef VOID (*mmPf)(VOID); #define DT_UNKNOWN 0 #define DT_FIFO 1 #define DT_CHR 2 -#define DT_DIR 4 #define DT_BLK 6 #define DT_REG 8 #define DT_LNK 10 #define DT_SOCK 12 #define DT_WHT 14 +#define MM_DT_DIR 16 +#define MM_DT_REG 32 #define mmConstructor(x) __declspec(allocate(".CRT$XCU")) mmPf con = x #define mmDestructor(x) __declspec(allocate(".CRT$XPU")) mmPf de = x @@ -327,175 +332,188 @@ typedef VOID (*mmPf)(VOID); #define __attribute__(v) -_declspec(dllexport) INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock); -_declspec(dllexport) INT32 mmJoinTask(mmThread *threadHandle); -_declspec(dllexport) INT32 mmMutexInit(mmMutex_t *mutex); -_declspec(dllexport) INT32 mmMutexLock(mmMutex_t *mutex); -_declspec(dllexport) INT32 mmMutexTryLock(mmMutex_t *mutex); -_declspec(dllexport) INT32 mmMutexUnLock(mmMutex_t *mutex); -_declspec(dllexport) INT32 mmMutexDestroy(mmMutex_t *mutex); -_declspec(dllexport) INT32 mmCondInit(mmCond *cond); -_declspec(dllexport) INT32 mmCondLockInit(mmMutexFC *mutex); -_declspec(dllexport) INT32 mmCondLock(mmMutexFC *mutex); -_declspec(dllexport) INT32 mmCondUnLock(mmMutexFC *mutex); -_declspec(dllexport) INT32 mmCondLockDestroy(mmMutexFC *mutex); -_declspec(dllexport) INT32 mmRWLockInit(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRWLockRDLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRWLockWRLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRDLockUnLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmWRLockUnLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRWLockDestroy(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex); -_declspec(dllexport) INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond); - -_declspec(dllexport) INT32 mmCondNotify(mmCond *cond); -_declspec(dllexport) INT32 mmCondNotifyAll(mmCond *cond); -_declspec(dllexport) INT32 mmCondDestroy(mmCond *cond); -_declspec(dllexport) INT32 mmGetPid(VOID); -_declspec(dllexport) INT32 mmGetTid(VOID); -_declspec(dllexport) INT32 mmGetPidHandle(mmProcess *processHandle); -_declspec(dllexport) INT32 mmGetLocalTime(mmSystemTime_t *sysTime); -_declspec(dllexport) INT32 mmGetSystemTime(mmSystemTime_t *sysTime); -_declspec(dllexport) INT32 mmSemInit(mmSem_t *sem, UINT32 value); -_declspec(dllexport) INT32 mmSemWait(mmSem_t *sem); -_declspec(dllexport) INT32 mmSemPost(mmSem_t *sem); -_declspec(dllexport) INT32 mmSemDestroy(mmSem_t *sem); -_declspec(dllexport) INT32 mmOpen(const CHAR *pathName, INT32 flags); -_declspec(dllexport) INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode); -_declspec(dllexport) FILE *mmPopen(CHAR *command, CHAR *type); -_declspec(dllexport) INT32 mmClose(INT32 fd); -_declspec(dllexport) INT32 mmPclose(FILE *stream); -_declspec(dllexport) mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen); -_declspec(dllexport) mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen); -_declspec(dllexport) mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol); -_declspec(dllexport) INT32 mmBind(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen); -_declspec(dllexport) INT32 mmListen(mmSockHandle sockFd, INT32 backLog); -_declspec(dllexport) mmSockHandle mmAccept(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t *addrLen); -_declspec(dllexport) INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen); -_declspec(dllexport) INT32 mmCloseSocket(mmSockHandle sockFd); -_declspec(dllexport) mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag); -_declspec(dllexport) mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag); -_declspec(dllexport) INT32 mmSocketSendTo(mmSockHandle sockFd, +MMPA_FUNC_VISIBILITY INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock); +MMPA_FUNC_VISIBILITY INT32 mmJoinTask(mmThread *threadHandle); +MMPA_FUNC_VISIBILITY INT32 mmMutexInit(mmMutex_t *mutex); +MMPA_FUNC_VISIBILITY INT32 mmMutexLock(mmMutex_t *mutex); +MMPA_FUNC_VISIBILITY INT32 mmMutexTryLock(mmMutex_t *mutex); +MMPA_FUNC_VISIBILITY INT32 mmMutexUnLock(mmMutex_t *mutex); +MMPA_FUNC_VISIBILITY INT32 mmMutexDestroy(mmMutex_t *mutex); +MMPA_FUNC_VISIBILITY INT32 mmCondInit(mmCond *cond); +MMPA_FUNC_VISIBILITY INT32 mmCondLockInit(mmMutexFC *mutex); +MMPA_FUNC_VISIBILITY INT32 mmCondLock(mmMutexFC *mutex); +MMPA_FUNC_VISIBILITY INT32 mmCondUnLock(mmMutexFC *mutex); +MMPA_FUNC_VISIBILITY INT32 mmCondLockDestroy(mmMutexFC *mutex); +MMPA_FUNC_VISIBILITY INT32 mmRWLockInit(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRWLockRDLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRWLockWRLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRDLockUnLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmWRLockUnLock(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmRWLockDestroy(mmRWLock_t *rwLock); +MMPA_FUNC_VISIBILITY INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex); +MMPA_FUNC_VISIBILITY INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond); + +MMPA_FUNC_VISIBILITY INT32 mmCondNotify(mmCond *cond); +MMPA_FUNC_VISIBILITY INT32 mmCondNotifyAll(mmCond *cond); +MMPA_FUNC_VISIBILITY INT32 mmCondDestroy(mmCond *cond); +MMPA_FUNC_VISIBILITY INT32 mmGetPid(VOID); +MMPA_FUNC_VISIBILITY INT32 mmGetTid(VOID); +MMPA_FUNC_VISIBILITY INT32 mmGetPidHandle(mmProcess *processHandle); +MMPA_FUNC_VISIBILITY INT32 mmGetLocalTime(mmSystemTime_t *sysTime); +MMPA_FUNC_VISIBILITY INT32 mmGetSystemTime(mmSystemTime_t *sysTime); +MMPA_FUNC_VISIBILITY INT32 mmSemInit(mmSem_t *sem, UINT32 value); +MMPA_FUNC_VISIBILITY INT32 mmSemWait(mmSem_t *sem); +MMPA_FUNC_VISIBILITY INT32 mmSemPost(mmSem_t *sem); +MMPA_FUNC_VISIBILITY INT32 mmSemDestroy(mmSem_t *sem); +MMPA_FUNC_VISIBILITY INT32 mmOpen(const CHAR *pathName, INT32 flags); +MMPA_FUNC_VISIBILITY INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode); +MMPA_FUNC_VISIBILITY FILE *mmPopen(CHAR *command, CHAR *type); +MMPA_FUNC_VISIBILITY INT32 mmClose(INT32 fd); +MMPA_FUNC_VISIBILITY INT32 mmPclose(FILE *stream); +MMPA_FUNC_VISIBILITY mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen); +MMPA_FUNC_VISIBILITY mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen); +MMPA_FUNC_VISIBILITY mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol); +MMPA_FUNC_VISIBILITY INT32 mmBind(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen); +MMPA_FUNC_VISIBILITY INT32 mmListen(mmSockHandle sockFd, INT32 backLog); +MMPA_FUNC_VISIBILITY mmSockHandle mmAccept(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t *addrLen); +MMPA_FUNC_VISIBILITY INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLen); +MMPA_FUNC_VISIBILITY INT32 mmCloseSocket(mmSockHandle sockFd); +MMPA_FUNC_VISIBILITY mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag); +MMPA_FUNC_VISIBILITY mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag); +MMPA_FUNC_VISIBILITY INT32 mmSocketSendTo(mmSockHandle sockFd, VOID *sendMsg, INT32 sendLen, UINT32 sendFlag, const mmSockAddr* addr, INT32 tolen); -_declspec(dllexport) mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd, +MMPA_FUNC_VISIBILITY mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd, VOID *recvBuf, mmSize recvLen, UINT32 recvFlag, mmSockAddr* addr, mmSocklen_t *FromLen); -_declspec(dllexport) INT32 mmSAStartup(VOID); -_declspec(dllexport) INT32 mmSACleanup(VOID); -_declspec(dllexport) VOID *mmDlopen(const CHAR *fileName, INT mode); -_declspec(dllexport) INT32 mmDladdr(VOID *addr, mmDlInfo *info); -_declspec(dllexport) VOID *mmDlsym(VOID *handle, CHAR *fileName); -_declspec(dllexport) INT32 mmDlclose(VOID *handle); -_declspec(dllexport) CHAR *mmDlerror(VOID); -_declspec(dllexport) INT32 +MMPA_FUNC_VISIBILITY INT32 mmSAStartup(VOID); +MMPA_FUNC_VISIBILITY INT32 mmSACleanup(VOID); +MMPA_FUNC_VISIBILITY VOID *mmDlopen(const CHAR *fileName, INT mode); +MMPA_FUNC_VISIBILITY INT32 mmDladdr(VOID *addr, mmDlInfo *info); +MMPA_FUNC_VISIBILITY VOID *mmDlsym(VOID *handle, const CHAR *fileName); +MMPA_FUNC_VISIBILITY INT32 mmDlclose(VOID *handle); +MMPA_FUNC_VISIBILITY CHAR *mmDlerror(VOID); +MMPA_FUNC_VISIBILITY INT32 mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock, UINT milliSecond, UINT period); -_declspec(dllexport) INT32 mmDeleteTimer(mmTimer timerHandle); -_declspec(dllexport) INT32 mmStatGet(const CHAR *path, mmStat_t *buffer); -_declspec(dllexport) INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer); -_declspec(dllexport) INT32 mmFStatGet(INT32 fd, mmStat_t *buffer); -_declspec(dllexport) INT32 mmMkdir(const CHAR *pathName, mmMode_t mode); -_declspec(dllexport) INT32 mmSleep(UINT32 milliSecond); -_declspec(dllexport) INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock); -_declspec(dllexport) INT32 mmGetProcessPrio(mmProcess pid); -_declspec(dllexport) INT32 mmSetProcessPrio(mmProcess pid, INT32 processPrio); -_declspec(dllexport) INT32 mmGetThreadPrio(mmThread *threadHandle); -_declspec(dllexport) INT32 mmSetThreadPrio(mmThread *threadHandle, INT32 threadPrio); -_declspec(dllexport) INT32 mmAccess(const CHAR *pathName); -_declspec(dllexport) INT32 mmAccess2(const CHAR *pathName, INT32 mode); -_declspec(dllexport) INT32 mmRmdir(const CHAR *pathName); - -_declspec(dllexport) INT32 mmIoctl(mmProcess fd, INT32 ioctlCode, mmIoctlBuf *bufPtr); -_declspec(dllexport) INT32 mmSemTimedWait(mmSem_t *sem, INT32 timeout); -_declspec(dllexport) mmSsize_t mmWritev(mmSockHandle fd, mmIovSegment *iov, INT32 iovcnt); -_declspec(dllexport) VOID mmMb(); -_declspec(dllexport) INT32 mmInetAton(const CHAR *addrStr, mmInAddr *addr); - -_declspec(dllexport) mmProcess mmOpenFile(const CHAR *fileName, UINT32 access, mmCreateFlag fileFlag); -_declspec(dllexport) mmSsize_t mmReadFile(mmProcess fileId, VOID *buffer, INT32 len); -_declspec(dllexport) mmSsize_t mmWriteFile(mmProcess fileId, VOID *buffer, INT32 len); -_declspec(dllexport) INT32 mmCloseFile(mmProcess fileId); - -_declspec(dllexport) mmAtomicType mmSetData(mmAtomicType *ptr, mmAtomicType value); -_declspec(dllexport) mmAtomicType mmValueInc(mmAtomicType *ptr, mmAtomicType value); -_declspec(dllexport) mmAtomicType mmValueSub(mmAtomicType *ptr, mmAtomicType value); -_declspec(dllexport) INT32 mmCreateTaskWithDetach(mmThread *threadHandle, mmUserBlock_t *funcBlock); - -_declspec(dllexport) INT32 mmCreateNamedPipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode); -_declspec(dllexport) INT32 mmOpenNamePipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode); -_declspec(dllexport) VOID mmCloseNamedPipe(mmPipeHandle namedPipe[]); - -_declspec(dllexport) INT32 mmCreatePipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode); -_declspec(dllexport) INT32 mmOpenPipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode); -_declspec(dllexport) VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount); - -_declspec(dllexport) mmCompletionHandle mmCreateCompletionPort(); -_declspec(dllexport) VOID mmCloseCompletionPort(mmCompletionHandle handle); -_declspec(dllexport) INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP, +MMPA_FUNC_VISIBILITY INT32 mmDeleteTimer(mmTimer timerHandle); +MMPA_FUNC_VISIBILITY INT32 mmStatGet(const CHAR *path, mmStat_t *buffer); +MMPA_FUNC_VISIBILITY INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer); +MMPA_FUNC_VISIBILITY INT32 mmFStatGet(INT32 fd, mmStat_t *buffer); +MMPA_FUNC_VISIBILITY INT32 mmMkdir(const CHAR *pathName, mmMode_t mode); +MMPA_FUNC_VISIBILITY INT32 mmSleep(UINT32 milliSecond); +MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock); +MMPA_FUNC_VISIBILITY INT32 mmGetProcessPrio(mmProcess pid); +MMPA_FUNC_VISIBILITY INT32 mmSetProcessPrio(mmProcess pid, INT32 processPrio); +MMPA_FUNC_VISIBILITY INT32 mmGetThreadPrio(mmThread *threadHandle); +MMPA_FUNC_VISIBILITY INT32 mmSetThreadPrio(mmThread *threadHandle, INT32 threadPrio); +MMPA_FUNC_VISIBILITY INT32 mmAccess(const CHAR *pathName); +MMPA_FUNC_VISIBILITY INT32 mmAccess2(const CHAR *pathName, INT32 mode); +MMPA_FUNC_VISIBILITY INT32 mmRmdir(const CHAR *pathName); + +MMPA_FUNC_VISIBILITY INT32 mmIoctl(mmProcess fd, INT32 ioctlCode, mmIoctlBuf *bufPtr); +MMPA_FUNC_VISIBILITY INT32 mmSemTimedWait(mmSem_t *sem, INT32 timeout); +MMPA_FUNC_VISIBILITY mmSsize_t mmWritev(mmSockHandle fd, mmIovSegment *iov, INT32 iovcnt); +MMPA_FUNC_VISIBILITY VOID mmMb(); +MMPA_FUNC_VISIBILITY INT32 mmInetAton(const CHAR *addrStr, mmInAddr *addr); + +MMPA_FUNC_VISIBILITY mmProcess mmOpenFile(const CHAR *fileName, UINT32 access, mmCreateFlag fileFlag); +MMPA_FUNC_VISIBILITY mmSsize_t mmReadFile(mmProcess fileId, VOID *buffer, INT32 len); +MMPA_FUNC_VISIBILITY mmSsize_t mmWriteFile(mmProcess fileId, VOID *buffer, INT32 len); +MMPA_FUNC_VISIBILITY INT32 mmCloseFile(mmProcess fileId); + +MMPA_FUNC_VISIBILITY mmAtomicType mmSetData(mmAtomicType *ptr, mmAtomicType value); +MMPA_FUNC_VISIBILITY mmAtomicType mmValueInc(mmAtomicType *ptr, mmAtomicType value); +MMPA_FUNC_VISIBILITY mmAtomicType mmValueSub(mmAtomicType *ptr, mmAtomicType value); +MMPA_FUNC_VISIBILITY mmAtomicType64 mmSetData64(mmAtomicType64 *ptr, mmAtomicType64 value); +MMPA_FUNC_VISIBILITY mmAtomicType64 mmValueInc64(mmAtomicType64 *ptr, mmAtomicType64 value); +MMPA_FUNC_VISIBILITY mmAtomicType64 mmValueSub64(mmAtomicType64 *ptr, mmAtomicType64 value); +MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithDetach(mmThread *threadHandle, mmUserBlock_t *funcBlock); + +MMPA_FUNC_VISIBILITY INT32 mmCreateNamedPipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode); +MMPA_FUNC_VISIBILITY INT32 mmOpenNamePipe(mmPipeHandle pipe[], CHAR *pipeName[], INT32 waitMode); +MMPA_FUNC_VISIBILITY VOID mmCloseNamedPipe(mmPipeHandle namedPipe[]); + +MMPA_FUNC_VISIBILITY INT32 mmCreatePipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode); +MMPA_FUNC_VISIBILITY INT32 mmOpenPipe(mmPipeHandle pipe[], CHAR *pipeName[], UINT32 pipeCount, INT32 waitMode); +MMPA_FUNC_VISIBILITY VOID mmClosePipe(mmPipeHandle pipe[], UINT32 pipeCount); + +MMPA_FUNC_VISIBILITY mmCompletionHandle mmCreateCompletionPort(); +MMPA_FUNC_VISIBILITY VOID mmCloseCompletionPort(mmCompletionHandle handle); +MMPA_FUNC_VISIBILITY INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP, pmmPollData polledData, mmPollBack pollBack); -_declspec(dllexport) INT32 mmGetErrorCode(); -_declspec(dllexport) CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size); -_declspec(dllexport) INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone); -_declspec(dllexport) mmTimespec mmGetTickCount(); -_declspec(dllexport) INT32 mmGetRealPath(CHAR *path, CHAR *realPath); - -_declspec(dllexport) INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen); - -_declspec(dllexport) INT32 mmDup2(INT32 oldFd, INT32 newFd); -_declspec(dllexport) INT32 mmDup(INT32 fd); -_declspec(dllexport) INT32 mmUnlink(const CHAR *filename); -_declspec(dllexport) INT32 mmChmod(const CHAR *filename, INT32 mode); -_declspec(dllexport) INT32 mmFileno(FILE *stream); -_declspec(dllexport) INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort); -_declspec(dllexport) VOID mmScandirFree(mmDirent **entryList, INT32 count); - -_declspec(dllexport) mmMsgid mmMsgCreate(mmKey_t key, INT32 msgFlag); -_declspec(dllexport) mmMsgid mmMsgOpen(mmKey_t key, INT32 msgFlag); -_declspec(dllexport) INT32 mmMsgRcv(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag); -_declspec(dllexport) INT32 mmMsgSnd(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag); - -_declspec(dllexport) INT32 mmMsgClose(mmMsgid msqid); - -_declspec(dllexport) INT32 mmLocalTimeR(const time_t *timep, struct tm *result); -_declspec(dllexport) INT32 mmGetOpt(INT32 argc, char *const *argv, const char *opts); -_declspec(dllexport) INT32 +MMPA_FUNC_VISIBILITY INT32 mmGetErrorCode(); +MMPA_FUNC_VISIBILITY CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size); +MMPA_FUNC_VISIBILITY INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone); +MMPA_FUNC_VISIBILITY mmTimespec mmGetTickCount(); +MMPA_FUNC_VISIBILITY INT32 mmGetRealPath(CHAR *path, CHAR *realPath); + +MMPA_FUNC_VISIBILITY INT32 mmRealPath(const CHAR *path, CHAR *realPath, INT32 realPathLen); + +MMPA_FUNC_VISIBILITY INT32 mmDup2(INT32 oldFd, INT32 newFd); +MMPA_FUNC_VISIBILITY INT32 mmDup(INT32 fd); +MMPA_FUNC_VISIBILITY INT32 mmUnlink(const CHAR *filename); +MMPA_FUNC_VISIBILITY INT32 mmChmod(const CHAR *filename, INT32 mode); +MMPA_FUNC_VISIBILITY INT32 mmFileno(FILE *stream); +MMPA_FUNC_VISIBILITY INT32 mmScandir(const CHAR *path, mmDirent ***entryList, mmFilter filterFunc, mmSort sort); +MMPA_FUNC_VISIBILITY INT32 mmScandir2(const CHAR *path, mmDirent2 ***entryList, mmFilter2 filterFunc, mmSort2 sort); +MMPA_FUNC_VISIBILITY VOID mmScandirFree(mmDirent **entryList, INT32 count); +MMPA_FUNC_VISIBILITY VOID mmScandirFree2(mmDirent2 **entryList, INT32 count); + +MMPA_FUNC_VISIBILITY mmMsgid mmMsgCreate(mmKey_t key, INT32 msgFlag); +MMPA_FUNC_VISIBILITY mmMsgid mmMsgOpen(mmKey_t key, INT32 msgFlag); +MMPA_FUNC_VISIBILITY INT32 mmMsgRcv(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag); +MMPA_FUNC_VISIBILITY INT32 mmMsgSnd(mmMsgid msqid, VOID *buf, INT32 bufLen, INT32 msgFlag); + +MMPA_FUNC_VISIBILITY INT32 mmMsgClose(mmMsgid msqid); + +MMPA_FUNC_VISIBILITY INT32 mmLocalTimeR(const time_t *timep, struct tm *result); +MMPA_FUNC_VISIBILITY INT32 mmGetOptErr(); +MMPA_FUNC_VISIBILITY VOID mmSetOptErr(INT32 mmOptErr); +MMPA_FUNC_VISIBILITY INT32 mmGetOptInd(); +MMPA_FUNC_VISIBILITY VOID mmSetOptInd(INT32 mmOptInd); +MMPA_FUNC_VISIBILITY INT32 mmGetOptOpt(); +MMPA_FUNC_VISIBILITY VOID mmSetOpOpt(INT32 mmOptOpt); +MMPA_FUNC_VISIBILITY CHAR *mmGetOptArg(); +MMPA_FUNC_VISIBILITY VOID mmSetOptArg(CHAR *mmOptArg); +MMPA_FUNC_VISIBILITY INT32 mmGetOpt(INT32 argc, char *const *argv, const char *opts); +MMPA_FUNC_VISIBILITY INT32 mmGetOptLong(INT32 argc, CHAR *const *argv, const CHAR *opts, const mmStructOption *longopts, INT32 *longindex); -_declspec(dllexport) LONG mmLseek(INT32 fd, INT64 offset, INT32 seekFlag); -_declspec(dllexport) INT32 mmFtruncate(mmProcess fd, UINT32 length); +MMPA_FUNC_VISIBILITY LONG mmLseek(INT32 fd, INT64 offset, INT32 seekFlag); +MMPA_FUNC_VISIBILITY INT32 mmFtruncate(mmProcess fd, UINT32 length); -_declspec(dllexport) INT32 mmTlsCreate(mmThreadKey *key, VOID (*destructor)(VOID *)); -_declspec(dllexport) INT32 mmTlsSet(mmThreadKey key, const VOID *value); -_declspec(dllexport) VOID *mmTlsGet(mmThreadKey key); -_declspec(dllexport) INT32 mmTlsDelete(mmThreadKey key); -_declspec(dllexport) INT32 mmGetOsType(); +MMPA_FUNC_VISIBILITY INT32 mmTlsCreate(mmThreadKey *key, VOID (*destructor)(VOID *)); +MMPA_FUNC_VISIBILITY INT32 mmTlsSet(mmThreadKey key, const VOID *value); +MMPA_FUNC_VISIBILITY VOID *mmTlsGet(mmThreadKey key); +MMPA_FUNC_VISIBILITY INT32 mmTlsDelete(mmThreadKey key); +MMPA_FUNC_VISIBILITY INT32 mmGetOsType(); -_declspec(dllexport) INT32 mmFsync(mmProcess fd); -_declspec(dllexport) INT32 mmFsync2(INT32 fd); -_declspec(dllexport) INT32 mmChdir(const CHAR *path); -_declspec(dllexport) INT32 mmUmask(INT32 pmode); -_declspec(dllexport) INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options); +MMPA_FUNC_VISIBILITY INT32 mmFsync(mmProcess fd); +MMPA_FUNC_VISIBILITY INT32 mmFsync2(INT32 fd); +MMPA_FUNC_VISIBILITY INT32 mmChdir(const CHAR *path); +MMPA_FUNC_VISIBILITY INT32 mmUmask(INT32 pmode); +MMPA_FUNC_VISIBILITY INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options); -_declspec(dllexport) INT32 mmGetCwd(CHAR *buffer, INT32 maxLen); -_declspec(dllexport) CHAR *mmStrTokR(CHAR *str, const CHAR *delim, CHAR **saveptr); +MMPA_FUNC_VISIBILITY INT32 mmGetCwd(CHAR *buffer, INT32 maxLen); +MMPA_FUNC_VISIBILITY CHAR *mmStrTokR(CHAR *str, const CHAR *delim, CHAR **saveptr); -_declspec(dllexport) INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len); -_declspec(dllexport) INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite); -_declspec(dllexport) CHAR *mmDirName(CHAR *path); -_declspec(dllexport) CHAR *mmBaseName(CHAR *path); -_declspec(dllexport) INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize); +MMPA_FUNC_VISIBILITY INT32 mmGetEnv(const CHAR *name, CHAR *value, UINT32 len); +MMPA_FUNC_VISIBILITY INT32 mmSetEnv(const CHAR *name, const CHAR *value, INT32 overwrite); +MMPA_FUNC_VISIBILITY CHAR *mmDirName(CHAR *path); +MMPA_FUNC_VISIBILITY CHAR *mmBaseName(CHAR *path); +MMPA_FUNC_VISIBILITY INT32 mmGetDiskFreeSpace(const char *path, mmDiskSize *diskSize); -_declspec(dllexport) INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name); -_declspec(dllexport) INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, INT32 size); +MMPA_FUNC_VISIBILITY INT32 mmSetThreadName(mmThread *threadHandle, const CHAR *name); +MMPA_FUNC_VISIBILITY INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, INT32 size); /* * Function: set the thread name of the currently executing thread - internal call of thread, which is not supported @@ -504,7 +522,7 @@ _declspec(dllexport) INT32 mmGetThreadName(mmThread *threadHandle, CHAR *name, I * The input parameter error returns EN_INVALID_PARAM, the execution success returns EN_OK, and the * execution failure returns EN_ERROR */ -_declspec(dllexport) INT32 mmSetCurrentThreadName(const CHAR *name); +MMPA_FUNC_VISIBILITY INT32 mmSetCurrentThreadName(const CHAR *name); /* * Function: Get the thread name of the currently executing thread - thread body call, not supported under windows, null @@ -513,25 +531,25 @@ _declspec(dllexport) INT32 mmSetCurrentThreadName(const CHAR *name); * The input parameter error returns EN_INVALID_PARAM, the execution success returns * EN_OK, and the execution failure returns EN_ERROR */ -_declspec(dllexport) INT32 mmGetCurrentThreadName(CHAR *name, INT32 size); - -_declspec(dllexport) INT32 mmGetFileSize(const CHAR *fileName, ULONGLONG *length); -_declspec(dllexport) INT32 mmIsDir(const CHAR *fileName); -_declspec(dllexport) INT32 mmGetOsName(CHAR *name, INT32 nameSize); -_declspec(dllexport) INT32 mmGetOsVersion(CHAR *versionInfo, INT32 versionLength); -_declspec(dllexport) INT32 mmGetMac(mmMacInfo **list, INT32 *count); -_declspec(dllexport) INT32 mmGetMacFree(mmMacInfo *list, INT32 count); -_declspec(dllexport) INT32 mmGetCpuInfo(mmCpuDesc **cpuInfo, INT32 *count); -_declspec(dllexport) INT32 mmCpuInfoFree(mmCpuDesc *cpuInfo, INT32 count); -_declspec(dllexport) INT32 +MMPA_FUNC_VISIBILITY INT32 mmGetCurrentThreadName(CHAR *name, INT32 size); + +MMPA_FUNC_VISIBILITY INT32 mmGetFileSize(const CHAR *fileName, ULONGLONG *length); +MMPA_FUNC_VISIBILITY INT32 mmIsDir(const CHAR *fileName); +MMPA_FUNC_VISIBILITY INT32 mmGetOsName(CHAR *name, INT32 nameSize); +MMPA_FUNC_VISIBILITY INT32 mmGetOsVersion(CHAR *versionInfo, INT32 versionLength); +MMPA_FUNC_VISIBILITY INT32 mmGetMac(mmMacInfo **list, INT32 *count); +MMPA_FUNC_VISIBILITY INT32 mmGetMacFree(mmMacInfo *list, INT32 count); +MMPA_FUNC_VISIBILITY INT32 mmGetCpuInfo(mmCpuDesc **cpuInfo, INT32 *count); +MMPA_FUNC_VISIBILITY INT32 mmCpuInfoFree(mmCpuDesc *cpuInfo, INT32 count); +MMPA_FUNC_VISIBILITY INT32 mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const char *stdoutRedirectFile, mmProcess *id); -_declspec(dllexport) INT32 +MMPA_FUNC_VISIBILITY INT32 mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, const mmThreadAttr *threadAttr); -_declspec(dllexport) mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode); -_declspec(dllexport) INT32 mmShmUnlink(const CHAR *name); -_declspec(dllexport) VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags); -_declspec(dllexport) INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra); +MMPA_FUNC_VISIBILITY mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode); +MMPA_FUNC_VISIBILITY INT32 mmShmUnlink(const CHAR *name); +MMPA_FUNC_VISIBILITY VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags); +MMPA_FUNC_VISIBILITY INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra); #ifdef __cplusplus #if __cplusplus } diff --git a/third_party/fwkacllib/inc/runtime/base.h b/third_party/fwkacllib/inc/runtime/base.h index fcb7a627..4e735438 100644 --- a/third_party/fwkacllib/inc/runtime/base.h +++ b/third_party/fwkacllib/inc/runtime/base.h @@ -391,6 +391,8 @@ typedef void (*rtErrorCallback)(rtExceptionType); typedef void (*rtTaskFailCallback)(rtExceptionInfo *exceptionInfo); +typedef void (*rtDeviceStateCallback)(uint32_t devId, bool isOpen); + /** * @ingroup dvrt_base * @brief stream handle. @@ -419,7 +421,7 @@ RTS_API rtError_t rtSetProfDirEx(const char *profDir, const char *address, const * @ingroup profiling_base * @brief init profiler object. */ -RTS_API rtError_t rtProfilerInit(const char *profdir, const char *address, const char *job_ctx); +RTS_API rtError_t rtProfilerInit(const char *profDir, const char *address, const char *jobCtx); /** * @ingroup profiling_base @@ -473,6 +475,16 @@ RTS_API rtError_t rtSetExceptCallback(rtErrorCallback callback); */ RTS_API rtError_t rtSetTaskFailCallback(rtTaskFailCallback callback); +/** + * @ingroup dvrt_base + * @brief register callback for deviceid + * @param [in] uniName unique register name, can't be null + * @param [in] callback Device state callback function + * @param [out] NA + * @return RT_ERROR_NONE for ok + */ +RTS_API rtError_t rtRegDeviceStateCallback(const char *regName, rtDeviceStateCallback callback); + /** * @ingroup dvrt_base * @brief notify handle. @@ -593,7 +605,7 @@ RTS_API rtError_t rtLabelCreateEx(rtLabel_t *label, rtStream_t stream); * @return RT_ERROR_NONE for ok * @return RT_ERROR_INVALID_VALUE for input null ptr */ -RTS_API rtError_t rtGetTaskIdAndStreamID(uint32_t *taskid, uint32_t *streamid); +RTS_API rtError_t rtGetTaskIdAndStreamID(uint32_t *taskId, uint32_t *streamId); #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } diff --git a/third_party/fwkacllib/inc/runtime/context.h b/third_party/fwkacllib/inc/runtime/context.h index ffcf7e4b..4be49a8c 100644 --- a/third_party/fwkacllib/inc/runtime/context.h +++ b/third_party/fwkacllib/inc/runtime/context.h @@ -139,7 +139,7 @@ RTS_API rtError_t rtSetGroup(int32_t groupId); * @param [in] groupid count * @return RT_ERROR_NONE for ok, errno for failed */ -RTS_API rtError_t rtGetGroupInfo(int32_t groupId, rtGroupInfo_t* groupInfo, uint32_t count); +RTS_API rtError_t rtGetGroupInfo(int32_t groupId, rtGroupInfo_t *groupInfo, uint32_t count); /** * @ingroup diff --git a/third_party/fwkacllib/inc/runtime/dev.h b/third_party/fwkacllib/inc/runtime/dev.h index f3f2937c..b378e3b0 100644 --- a/third_party/fwkacllib/inc/runtime/dev.h +++ b/third_party/fwkacllib/inc/runtime/dev.h @@ -295,7 +295,7 @@ RTS_API rtError_t rtGetRunMode(rtRunMode *mode); * @return RT_ERROR_NONE for ok * @return RT_ERROR_DRV_ERR for can not get aicpu deploy */ -RTS_API rtError_t rtGetAicpuDeploy(rtAicpuDeployType_t *deplyType); +RTS_API rtError_t rtGetAicpuDeploy(rtAicpuDeployType_t *deployType); /** * @ingroup dvrt_dev @@ -309,7 +309,7 @@ RTS_API rtError_t rtSetSocVersion(const char *version); * @brief get chipType * @return RT_ERROR_NONE for ok */ -rtError_t rtGetSocVersion(char *version, const uint32_t maxLen); +RTS_API rtError_t rtGetSocVersion(char *version, const uint32_t maxLen); /** * @ingroup dvrt_dev diff --git a/third_party/fwkacllib/inc/runtime/event.h b/third_party/fwkacllib/inc/runtime/event.h index c8a227e8..41e611ea 100644 --- a/third_party/fwkacllib/inc/runtime/event.h +++ b/third_party/fwkacllib/inc/runtime/event.h @@ -57,6 +57,16 @@ RTS_API rtError_t rtEventCreateWithFlag(rtEvent_t *event, uint32_t flag); */ RTS_API rtError_t rtEventDestroy(rtEvent_t event); +/** + * @ingroup dvrt_event + * @brief get event id + * @param [in] event_ event to be get + * @param [in|out] event_id event_id id + * @return RT_ERROR_NONE for ok + * @return RT_ERROR_INVALID_VALUE for error input + */ +RTS_API rtError_t rtGetEventID(rtEvent_t event, uint32_t *eventId); + /** * @ingroup dvrt_event * @brief event record @@ -116,13 +126,13 @@ RTS_API rtError_t rtEventGetTimeStamp(uint64_t *time, rtEvent_t event); /** * @ingroup dvrt_event * @brief name an event - * @param [in] event_ event to be named + * @param [in] event event to be named * @param [in] name identification name * @return RT_ERROR_NONE for ok * @return RT_ERROR_INVALID_VALUE for error input of event, name * @return RT_ERROR_DRV_ERR for driver error */ -RTS_API rtError_t rtNameEvent(rtEvent_t event_, const char *name); +RTS_API rtError_t rtNameEvent(rtEvent_t event, const char *name); /** * @ingroup dvrt_event @@ -132,7 +142,7 @@ RTS_API rtError_t rtNameEvent(rtEvent_t event_, const char *name); * @return RT_ERROR_NONE for ok * @return RT_ERROR_INVALID_VALUE for error input */ -RTS_API rtError_t rtNotifyCreate(int32_t device_id, rtNotify_t *notify_); +RTS_API rtError_t rtNotifyCreate(int32_t deviceId, rtNotify_t *notify); /** * @ingroup dvrt_event @@ -142,7 +152,7 @@ RTS_API rtError_t rtNotifyCreate(int32_t device_id, rtNotify_t *notify_); * @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_DRV_ERR for driver error */ -RTS_API rtError_t rtNotifyDestroy(rtNotify_t notify_); +RTS_API rtError_t rtNotifyDestroy(rtNotify_t notify); /** * @ingroup dvrt_event @@ -153,7 +163,7 @@ RTS_API rtError_t rtNotifyDestroy(rtNotify_t notify_); * @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_STREAM_CONTEXT for stream is not in current ctx */ -RTS_API rtError_t rtNotifyRecord(rtNotify_t notify_, rtStream_t stream_); +RTS_API rtError_t rtNotifyRecord(rtNotify_t notify, rtStream_t stream); /** * @ingroup dvrt_event @@ -164,7 +174,7 @@ RTS_API rtError_t rtNotifyRecord(rtNotify_t notify_, rtStream_t stream_); * @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_STREAM_CONTEXT for stream is not in current ctx */ -RTS_API rtError_t rtNotifyWait(rtNotify_t notify_, rtStream_t stream_); +RTS_API rtError_t rtNotifyWait(rtNotify_t notify, rtStream_t stream); /** * @ingroup dvrt_event @@ -174,7 +184,7 @@ RTS_API rtError_t rtNotifyWait(rtNotify_t notify_, rtStream_t stream_); * @return RT_ERROR_NONE for ok * @return RT_ERROR_INVALID_VALUE for error input */ -RTS_API rtError_t rtNameNotify(rtNotify_t notify_, const char *name); +RTS_API rtError_t rtNameNotify(rtNotify_t notify, const char *name); /** * @ingroup dvrt_event @@ -184,7 +194,7 @@ RTS_API rtError_t rtNameNotify(rtNotify_t notify_, const char *name); * @return RT_ERROR_NONE for ok * @return RT_ERROR_INVALID_VALUE for error input */ -RTS_API rtError_t rtGetNotifyID(rtNotify_t notify_, uint32_t *notify_id); +RTS_API rtError_t rtGetNotifyID(rtNotify_t notify, uint32_t *notifyId); /** * @ingroup dvrt_event @@ -199,7 +209,7 @@ RTS_API rtError_t rtIpcSetNotifyName(rtNotify_t notify, char *name, uint32_t len /** * @ingroup dvrt_event * @brief Open IPC notify - * @param [in] notify notify to be opened + * @param [out] notify the opened notify * @param [in] name identification name * @return RT_ERROR_NONE for ok * @return RT_ERROR_INVALID_VALUE for error input diff --git a/third_party/fwkacllib/inc/runtime/kernel.h b/third_party/fwkacllib/inc/runtime/kernel.h index de806a9e..5f519442 100644 --- a/third_party/fwkacllib/inc/runtime/kernel.h +++ b/third_party/fwkacllib/inc/runtime/kernel.h @@ -169,6 +169,18 @@ typedef void (*rtCallback_t)(void *fnData); */ #define RT_DEV_BINARY_MAGIC_ELF_AIVEC 0x41415246 +/** + * @ingroup rt_kernel + * @brief magic number of elf binary for aicube + */ +#define RT_DEV_BINARY_MAGIC_ELF_AICUBE 0x41415247 + +/** + * @ingroup rt_kernel + * @brief magic number of elf binary for aivector + */ +#define RT_DEV_BINARY_MAGIC_ELF_AIVECTOR 0x41415248 + /** * @ingroup rt_kernel_flags * @brief kernel op bit flags @@ -285,7 +297,7 @@ RTS_API rtError_t rtQueryFunctionRegistered(const char *stubName); * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtKernelConfigDump(uint32_t kind, uint32_t dumpSizePerBlock, uint32_t blockDim, void **dumpBaseAddr, - rtStream_t stream_); + rtStream_t stream); /** * @ingroup rt_kernel @@ -297,7 +309,7 @@ RTS_API rtError_t rtKernelConfigDump(uint32_t kind, uint32_t dumpSizePerBlock, u * @param [in] smDesc shared memory description * @param [in] stream associated stream * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtKernelLaunch(const void *stubFunc, uint32_t blockDim, void *args, uint32_t argsSize, rtSmDesc_t *smDesc, rtStream_t stream); @@ -313,7 +325,7 @@ RTS_API rtError_t rtKernelLaunch(const void *stubFunc, uint32_t blockDim, void * * @param [in] stream associated stream * @param [in] flag dump flag * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtKernelLaunchWithFlag(const void *stubFunc, uint32_t blockDim, void *args, uint32_t argsSize, rtSmDesc_t *smDesc, rtStream_t stream, uint32_t flags); @@ -375,7 +387,7 @@ typedef void *rtModel_t; * @return RT_ERROR_NONE for ok * @return RT_ERROR_INVALID_VALUE for error input */ - RTS_API rtError_t rtDumpAddrSet(rtModel_t model, void *addr , uint32_t dumpSize, uint32_t flag); + RTS_API rtError_t rtDumpAddrSet(rtModel_t model, void *addr, uint32_t dumpSize, uint32_t flag); /** * @ingroup rt_kernel @@ -444,7 +456,7 @@ RTS_API rtError_t rtKernelConfigTransArg(const void *ptr, uint64_t size, uint32_ * @brief start fusion kernels. * @param [in] stream stream for fusion kernels * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtKernelFusionStart(rtStream_t stream); @@ -453,7 +465,7 @@ RTS_API rtError_t rtKernelFusionStart(rtStream_t stream); * @brief end fusion kernels. * @param [in] stream stream for fusion kernels * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtKernelFusionEnd(rtStream_t stream); @@ -462,7 +474,7 @@ RTS_API rtError_t rtKernelFusionEnd(rtStream_t stream); * @brief set kernelinfo callback * @param [in] callback * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtSetKernelReportCallback(rtKernelReportCallback callBack); @@ -472,7 +484,7 @@ RTS_API rtError_t rtSetKernelReportCallback(rtKernelReportCallback callBack); * @param [in] threadId thread id for stream * @param [in] stream stream for subscribe * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtSubscribeReport(uint64_t threadId, rtStream_t stream); @@ -483,7 +495,7 @@ RTS_API rtError_t rtSubscribeReport(uint64_t threadId, rtStream_t stream); * @param [in] fnData user data * @param [in] stream subscribed stream * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtCallbackLaunch(rtCallback_t callBackFunc, void *fnData, rtStream_t stream, bool isBlock); @@ -492,7 +504,7 @@ RTS_API rtError_t rtCallbackLaunch(rtCallback_t callBackFunc, void *fnData, rtSt * @brief process callback report. * @param [in] timeout if timeout=-1, while(1); else timeout * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtProcessReport(int32_t timeout); @@ -502,7 +514,7 @@ RTS_API rtError_t rtProcessReport(int32_t timeout); * @param [in] threadId thread id for stream * @param [in] stream stream for subscribe * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtUnSubscribeReport(uint64_t threadId, rtStream_t stream); @@ -510,7 +522,7 @@ RTS_API rtError_t rtUnSubscribeReport(uint64_t threadId, rtStream_t stream); * @ingroup profiling_base * @brief start online prof. * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtStartOnlineProf(rtStream_t stream, uint32_t sampleNum); @@ -518,7 +530,7 @@ RTS_API rtError_t rtStartOnlineProf(rtStream_t stream, uint32_t sampleNum); * @ingroup profiling_base * @brief stop online prof. * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtStopOnlineProf(rtStream_t stream); @@ -526,9 +538,26 @@ RTS_API rtError_t rtStopOnlineProf(rtStream_t stream); * @ingroup profiling_base * @brief get online prof. * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input + * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtGetOnlineProfData(rtStream_t stream, rtProfDataInfo_t *pProfData, uint32_t profDataNum); + +/** + * @ingroup profiling_base + * @brief start mdc profiler. + * @return RT_ERROR_NONE for ok + * @return RT_ERROR_INVALID_VALUE for error input + */ +RTS_API rtError_t rtStartMDCProfiler(void **addr, uint32_t length); + +/** + * @ingroup profiling_base + * @brief stop mdc profiler. + * @return RT_ERROR_NONE for ok + * @return RT_ERROR_INVALID_VALUE for error input + */ +RTS_API rtError_t rtStopMDCProfiler(void *addr); + #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/mem.h b/third_party/fwkacllib/inc/runtime/mem.h index 22a00ac6..e65d8604 100644 --- a/third_party/fwkacllib/inc/runtime/mem.h +++ b/third_party/fwkacllib/inc/runtime/mem.h @@ -475,7 +475,7 @@ RTS_API rtError_t rtIpcSetMemoryName(const void *ptr, uint64_t byteCount, char * * @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_DRV_ERR for driver error */ -rtError_t rtIpcDestroyMemoryName(const char *name); +RTS_API rtError_t rtIpcDestroyMemoryName(const char *name); /** * @ingroup dvrt_mem @@ -503,13 +503,13 @@ RTS_API rtError_t rtIpcCloseMemory(const void *ptr); * @ingroup dvrt_mem * @brief HCCL Async memory cpy * @param [in] index sq index - * @param [in] wqe_index moudle index + * @param [in] wqeIndex moudle index * @param [in] stream asynchronized task stream * @return RT_ERROR_NONE for ok * @return RT_ERROR_INVALID_VALUE for error input * @return RT_ERROR_DRV_ERR for driver error */ -RTS_API rtError_t rtRDMASend(uint32_t index, uint32_t wqe_index, rtStream_t stream); +RTS_API rtError_t rtRDMASend(uint32_t index, uint32_t wqeIndex, rtStream_t stream); /** * @ingroup dvrt_mem diff --git a/third_party/fwkacllib/inc/runtime/rt_model.h b/third_party/fwkacllib/inc/runtime/rt_model.h index 78bb2321..b72b142d 100644 --- a/third_party/fwkacllib/inc/runtime/rt_model.h +++ b/third_party/fwkacllib/inc/runtime/rt_model.h @@ -438,7 +438,8 @@ RTS_API rtError_t rtModelGetId(rtModel_t model, uint32_t *modelId); * @return RT_ERROR_NONE for ok * @return RT_ERROR_INVALID_VALUE for error input */ -rtError_t rtDebugRegister(rtModel_t model, uint32_t flag, const void *addr, uint32_t *streamId, uint32_t *taskId); +RTS_API rtError_t rtDebugRegister(rtModel_t model, uint32_t flag, const void *addr, + uint32_t *streamId, uint32_t *taskId); /* * @ingroup rt_model diff --git a/third_party/fwkacllib/inc/runtime/stream.h b/third_party/fwkacllib/inc/runtime/stream.h index 81810a21..388fd3c2 100644 --- a/third_party/fwkacllib/inc/runtime/stream.h +++ b/third_party/fwkacllib/inc/runtime/stream.h @@ -126,17 +126,17 @@ RTS_API rtError_t rtGetStreamId(rtStream_t stream, int32_t *streamId); * @return RT_ERROR_NONE for complete * @return RT_ERROR_INVALID_VALUE for error input */ -RTS_API rtError_t rtGetMaxStreamAndTask(uint32_t streamType, uint32_t *MaxStrCount, uint32_t *MaxTaskCount); +RTS_API rtError_t rtGetMaxStreamAndTask(uint32_t streamType, uint32_t *maxStrCount, uint32_t *maxTaskCount); /** * @ingroup dvrt_stream * @brief Name a stream - * @param [in] stream_ stream to be named + * @param [in] stream stream to be named * @param [in] name identification name * @return RT_ERROR_NONE for complete * @return RT_ERROR_INVALID_VALUE for error input */ -RTS_API rtError_t rtNameStream(rtStream_t stream_, const char *name); +RTS_API rtError_t rtNameStream(rtStream_t stream, const char *name); /** * @ingroup dvrt_stream @@ -144,12 +144,12 @@ RTS_API rtError_t rtNameStream(rtStream_t stream_, const char *name); * @param [in] ptr Determine the address where the value of the true and false branches is located * @param [in] condition switch condition * @param [in] value switch value - * @param [in] true_stream Stream that needs to be activated when the value is non-zero + * @param [in] trueStream Stream that needs to be activated when the value is non-zero * @param [in] stream input stream to init task * @return RT_ERROR_NONE for complete * @return RT_ERROR_INVALID_VALUE for error input */ -RTS_API rtError_t rtStreamSwitch(void *ptr, rtCondition_t condition, int64_t value, rtStream_t true_stream, +RTS_API rtError_t rtStreamSwitch(void *ptr, rtCondition_t condition, int64_t value, rtStream_t trueStream, rtStream_t stream); /** @@ -162,18 +162,18 @@ RTS_API rtError_t rtStreamSwitch(void *ptr, rtCondition_t condition, int64_t val * @param [in] dataType data type of target value * @return RT_ERROR_NONE for complete */ -RTS_API rtError_t rtStreamSwitchEx(void *ptr, rtCondition_t condition, void *value_ptr, rtStream_t true_stream, +RTS_API rtError_t rtStreamSwitchEx(void *ptr, rtCondition_t condition, void *valuePtr, rtStream_t trueStream, rtStream_t stream, rtSwitchDataType_t dataType); /** * @ingroup dvrt_stream * @brief Active a stream - * @param [in] active_stream stream to be activated + * @param [in] activeStream stream to be activated * @param [in] stream input stream to init task * @return RT_ERROR_NONE for complete * @return RT_ERROR_INVALID_VALUE for error input */ -RTS_API rtError_t rtStreamActive(rtStream_t active_stream, rtStream_t stream); +RTS_API rtError_t rtStreamActive(rtStream_t activeStream, rtStream_t stream); /** * @brief execute extensible stream case switch task diff --git a/third_party/fwkacllib/inc/tdt/index_transform.h b/third_party/fwkacllib/inc/tdt/index_transform.h new file mode 100644 index 00000000..a5af2c83 --- /dev/null +++ b/third_party/fwkacllib/inc/tdt/index_transform.h @@ -0,0 +1,29 @@ +/** +* @file index_transform.h +* +* Copyright (C) Huawei Technologies Co., Ltd. 2018-2019. All Rights Reserved. +* +* This program is used to get logical device id by phy device id. +*/ + +#ifndef INC_TDT_INDEX_TRANSFORM_H +#define INC_TDT_INDEX_TRANSFORM_H + +#include "stdint.h" +/** +* @ingroup IndexTransform +* @brief get logical device id by phy device id. +* +* @par Function get logical device id by phy device id. +* +* @param phyId [IN] physical device id +* @param logicalId [OUT] logical device id +* @retval 0 Success +* @retval OtherValues Fail +* +* @par Dependency +* @li libruntime.so: Library to which the interface belongs. +*/ + +int32_t IndexTransform(const uint32_t phyId, uint32_t &logicId); +#endif diff --git a/third_party/fwkacllib/inc/tdt/status.h b/third_party/fwkacllib/inc/tdt/status.h index a42f38a5..d30564b8 100644 --- a/third_party/fwkacllib/inc/tdt/status.h +++ b/third_party/fwkacllib/inc/tdt/status.h @@ -193,6 +193,7 @@ enum { TDT_HDC_SRV_TYPE_ERROR_CODE, TDT_TSD_CLT_OPEN_FAILED_CODE, TDT_TSD_CLT_CLOSE_FAILED_CODE, + TDT_TSD_CLT_UPDATE_PROFILING_FAILED_CODE, TDT_TSD_CLT_INTERFACE_NOT_SUPPORT_CODE, TDT_SUPERVISOR_ILLEGAL_HEARTBEAT_TIME_CODE, TDT_SUPERVISOR_INOTIFY_READ_SIZE_ERROR_CODE, @@ -697,6 +698,8 @@ TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_BIND_CPUCORE_FAILED, "thread TDT_DEF_ERROR_CODE(MODID_HDC_SERVER, TDT_ERROR, TDT_HDC_SRV_CLOSED, "hdc server has been closed"); TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_OPEN_FAILED, "tsd client open failed"); TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_CLOSE_FAILED, "tsd client close failed"); +TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_UPDATE_PROFILING_FAILED, + "tsd client update profiling failed"); TDT_DEF_ERROR_CODE(MODID_TSD_CLIENT, TDT_ERROR, TDT_TSD_CLT_INTERFACE_NOT_SUPPORT, "tsd client func not support"); TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_FILELIST_NOT_EXIST, "tdt filelist open failed"); TDT_DEF_ERROR_CODE(MODID_TDT_PREFETCH, TDT_ERROR, TDT_PREFETCH_SAMPLE_FILE_NOT_FOUND, "tdt sample file is empty"); diff --git a/third_party/fwkacllib/inc/tdt/tsd_client.h b/third_party/fwkacllib/inc/tdt/tsd_client.h index 7886488e..6066a12e 100644 --- a/third_party/fwkacllib/inc/tdt/tsd_client.h +++ b/third_party/fwkacllib/inc/tdt/tsd_client.h @@ -49,7 +49,7 @@ extern "C" { * @li tsd_client.h: Header file where the interface declaration is located. * @li data_common.h: Header file where 'TDT_StatusT' defined */ -TDT_StatusT TsdOpen(const uint32_t phyDeviceId, const uint32_t rankSize); +TDT_LIB_EXPORT TDT_StatusT TsdOpen(const uint32_t phyDeviceId, const uint32_t rankSize); /** * @ingroup Close @@ -67,7 +67,25 @@ TDT_StatusT TsdOpen(const uint32_t phyDeviceId, const uint32_t rankSize); * @li tsd_client.h: Header file where the interface declaration is located. * @li data_common.h: Header file where 'TDT_StatusT' defined */ -TDT_StatusT TsdClose(const uint32_t phyDeviceId); +TDT_LIB_EXPORT TDT_StatusT TsdClose(const uint32_t phyDeviceId); + +/** +* @ingroup UpdateProfilingMode +* @brief notify TSDClient update profiling mode +* +* @par Function +* notify TSDClient update profiling mode +* +* @param NA +* @retval TDT_OK Success +* @retval OtherValues Failure +* +* @par Dependency +* @li libtsdclient.so: Library to which the interface belongs. +* @li tsd_client.h: Header file where the interface declaration is located. +* @li data_common.h: Header file where 'TDT_StatusT' defined +*/ +TDT_LIB_EXPORT TDT_StatusT UpdateProfilingMode(const uint32_t phyDeviceId, const uint32_t flag); /** * @ingroup CreateCmdParameterObj diff --git a/third_party/fwkacllib/inc/toolchain/slog.h b/third_party/fwkacllib/inc/toolchain/slog.h index 2cb00a05..bce58f32 100644 --- a/third_party/fwkacllib/inc/toolchain/slog.h +++ b/third_party/fwkacllib/inc/toolchain/slog.h @@ -25,10 +25,20 @@ extern "C" { #define LINUX 0 #endif // LINUX +#ifndef WIN +#define WIN 1 +#endif + #ifndef OS_TYPE #define OS_TYPE 0 #endif // OS_TYPE +#if (OS_TYPE == LINUX) +#define DLL_EXPORT __attribute__((visibility("default"))) +#else +#define DLL_EXPORT _declspec(dllexport) +#endif + /** * @ingroup slog * @@ -180,12 +190,11 @@ enum { INVLID_MOUDLE_ID }; -#if (OS_TYPE == LINUX) /** * @ingroup slog * @brief External log interface, which called by modules */ -extern void dlog_init(void); +DLL_EXPORT void dlog_init(void); /** * @ingroup slog @@ -195,7 +204,7 @@ extern void dlog_init(void); * @param [out]enableEvent: 1: enable; 0: disable * @return: module level(0: debug, 1: info, 2: warning, 3: error, 4: null output) */ -extern int dlog_getlevel(int moduleId, int *enableEvent); +DLL_EXPORT int dlog_getlevel(int moduleId, int *enableEvent); /** * @ingroup slog @@ -206,7 +215,7 @@ extern int dlog_getlevel(int moduleId, int *enableEvent); * @param [in]enableEvent: 1: enable; 0: disable, others:invalid * @return: 0: SUCCEED, others: FAILED */ -extern int dlog_setlevel(int moduleId, int level, int enableEvent); +DLL_EXPORT int dlog_setlevel(int moduleId, int level, int enableEvent); /** * @ingroup slog @@ -217,7 +226,7 @@ extern int dlog_setlevel(int moduleId, int level, int enableEvent); * @param [in]logLevel: eg: DLOG_EVENT/DLOG_ERROR/DLOG_WARN/DLOG_INFO/DLOG_DEBUG * @return: 1:enable, 0:disable */ -extern int CheckLogLevel(int moduleId, int logLevel); +DLL_EXPORT int CheckLogLevel(int moduleId, int logLevel); /** * @ingroup slog @@ -343,7 +352,7 @@ extern int CheckLogLevel(int moduleId, int logLevel); * @ingroup slog * @brief DlogFlush: flush log buffer to file */ -void DlogFlush(void); +DLL_EXPORT void DlogFlush(void); /** * @ingroup slog @@ -357,11 +366,6 @@ void DlogEventInner(int moduleId, const char *fmt, ...); void DlogInner(int moduleId, int level, const char *fmt, ...); void DlogWithKVInner(int moduleId, int level, KeyValue *pstKVArray, int kvNum, const char *fmt, ...); -#else -_declspec(dllexport) void dlog_init(void); -_declspec(dllexport) int dlog_getlevel(int moduleId, int *enableEvent); -#endif // OS_TYPE - #ifdef __cplusplus } #endif // __cplusplus diff --git a/third_party/fwkacllib/inc/toolchain/tuning_tool/tune_api.h b/third_party/fwkacllib/inc/toolchain/tuning_tool/tune_api.h new file mode 100644 index 00000000..12b6aa1e --- /dev/null +++ b/third_party/fwkacllib/inc/toolchain/tuning_tool/tune_api.h @@ -0,0 +1,72 @@ +/** + * @file tune_api.h + * + * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.\n + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n + * 描述:mstune调优接口头文件 + */ +/** @defgroup mstune mstune调优接口 */ +#ifndef TUNE_API_H +#define TUNE_API_H +#include +#include +#include +#include "graph/graph.h" +#include "ge/ge_api.h" + +/** + * @ingroup mstune + * + * mstune status + */ +enum MsTuneStatus { + MSTUNE_SUCCESS, /** tune success */ + MSTUNE_FAILED, /** tune failed */ +}; + +// Option key: for train options sets +const std::string MSTUNE_SELF_KEY = "mstune"; +const std::string MSTUNE_GEINIT_KEY = "initialize"; +const std::string MSTUNE_GESESS_KEY = "session"; + +/** + * @ingroup mstune + * @par 描述: 命令行调优 + * + * @attention 无 + * @param option [IN] 调优参数 + * @param msg [OUT] 调优异常下返回信息 + * @retval #MSTUNE_SUCCESS 执行成功 + * @retval #MSTUNE_FAILED 执行失败 + * @par 依赖: + * @li tune_api.cpp:该接口所属的开发包。 + * @li tune_api.h:该接口声明所在的头文件。 + * @see 无 + * @since + */ +MsTuneStatus MsTuning(const std::map &option, std::string &msg); + +/** + * @ingroup mstune + * @par 描述: 梯度调优 + * + * @attention 无 + * @param tuningGraph [IN] 调优图 + * @param dependGraph [IN] 调优依赖图 + * @param session [IN] ge连接会话 + * @param option [IN] 参数集. 包含调优参数及ge参数 + * @retval #MSTUNE_SUCCESS 执行成功 + * @retval #MSTUNE_FAILED 执行失败 + * @par 依赖: + * @li tune_api.cpp:该接口所属的开发包。 + * @li tune_api.h:该接口声明所在的头文件。 + * @see 无 + * @since + */ +extern "C" MsTuneStatus MsTrainTuning(ge::Graph &tuningGraph, std::vector &dependGraph, + ge::Session *session, const std::map> &option); + +#endif From 2b34789c3dea73f2a313b7abc4934bbfb41eec7d Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 19 Nov 2020 21:56:23 +0800 Subject: [PATCH 04/32] update cmakelist find libmmpa.a --- CMakeLists.txt | 8 ++++---- ge/CMakeLists.txt | 7 ++++--- ge/common/CMakeLists.txt | 2 +- ge/common/ge_common.mk | 6 ++++-- ge/ge_inference.mk | 4 ++-- ge/ge_runner.mk | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index baf05030..e67ecb1f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ if (ENABLE_OPEN_SRC) set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) set(STATIC_ACL_LIB ${GE_LIB_PATH}) find_module(slog libslog.so ${GE_LIB_PATH}) - find_module(mmpa libmmpa.so ${GE_LIB_PATH}) + find_module(mmpa libmmpa.a ${GE_LIB_PATH}) find_module(msprof libmsprof.so ${GE_LIB_PATH}) find_module(hccl libhccl.so ${GE_LIB_PATH}) find_module(adump_server libadump_server.a ${GE_LIB_PATH}) @@ -67,10 +67,10 @@ if (ENABLE_OPEN_SRC) find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH}) find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH}) - #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) + #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) else() find_module(slog libslog.so ${ASCEND_ATC_DIR}) - find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) + find_module(mmpa libmmpa.a ${ASCEND_ATC_DIR}) if(PLATFORM STREQUAL "train") find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) @@ -114,7 +114,7 @@ if (ENABLE_OPEN_SRC) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) - #find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) + #find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) else() message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated") endif() diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index 6eba7bc4..c895e7ce 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -648,6 +648,7 @@ target_link_libraries(ge_runner ge_memory adump_server msprofiler + static_mmpa -Wl,--no-as-needed graph ge_common @@ -655,7 +656,6 @@ target_link_libraries(ge_runner register c_sec slog - mmpa msprof runtime resource @@ -712,6 +712,7 @@ target_include_directories(ge_compiler PRIVATE target_link_libraries(ge_compiler $ ge_memory + static_mmpa -Wl,--no-as-needed graph ge_common @@ -720,7 +721,6 @@ target_link_libraries(ge_compiler c_sec error_manager slog - mmpa runtime_compile resource -Wl,--as-needed @@ -770,6 +770,7 @@ target_link_libraries(opensrc_ascendcl PRIVATE ge_executor ge_common_static graph_static + static_mmpa ascend_protobuf_static register_static error_manager_static @@ -779,11 +780,11 @@ target_link_libraries(opensrc_ascendcl PRIVATE -Wl,--no-as-needed c_sec runtime - mmpa slog msprof ascend_hal_stub -Wl,--as-needed + -lrt -ldl json ) diff --git a/ge/common/CMakeLists.txt b/ge/common/CMakeLists.txt index 444f93a2..117b7f86 100755 --- a/ge/common/CMakeLists.txt +++ b/ge/common/CMakeLists.txt @@ -105,6 +105,7 @@ target_include_directories(ge_common PRIVATE target_link_libraries(ge_common PRIVATE $ + static_mmpa -Wl,--no-as-needed graph ascend_protobuf @@ -112,7 +113,6 @@ target_link_libraries(ge_common PRIVATE c_sec error_manager slog - mmpa -Wl,--as-needed json -lrt diff --git a/ge/common/ge_common.mk b/ge/common/ge_common.mk index 0e3fc972..3fffd203 100755 --- a/ge/common/ge_common.mk +++ b/ge/common/ge_common.mk @@ -110,11 +110,12 @@ LOCAL_SHARED_LIBRARIES := \ libascend_protobuf \ libc_sec \ libslog \ - libmmpa \ libgraph \ libregister \ liberror_manager \ +LOCAL_STATIC_LIBRARIES += libmmpa + LOCAL_LDFLAGS := -lrt -ldl include $(BUILD_HOST_SHARED_LIBRARY) @@ -152,11 +153,12 @@ LOCAL_SHARED_LIBRARIES := \ libascend_protobuf \ libc_sec \ libslog \ - libmmpa \ libgraph \ libregister \ liberror_manager \ +LOCAL_STATIC_LIBRARIES += libmmpa + ifeq ($(device_os),android) LOCAL_LDFLAGS += -ldl LOCAL_LDLIBS += -L$(PWD)/prebuilts/clang/linux-x86/aarch64/android-ndk-r21/sysroot/usr/lib/aarch64-linux-android/29 -llog diff --git a/ge/ge_inference.mk b/ge/ge_inference.mk index 3b1dba01..0987f148 100755 --- a/ge/ge_inference.mk +++ b/ge/ge_inference.mk @@ -387,12 +387,12 @@ LOCAL_SRC_FILES += $(BUILER_SRC_FILES) LOCAL_SRC_FILES += $(ANALYZER_SRC_FILES) LOCAL_STATIC_LIBRARIES := libge_memory \ + libmmpa \ LOCAL_SHARED_LIBRARIES := \ libc_sec \ libascend_protobuf \ libslog \ - libmmpa \ libgraph \ libregister \ libge_common \ @@ -451,12 +451,12 @@ LOCAL_C_INCLUDES := $(DEVICE_LOCAL_C_INCLUDES) LOCAL_C_INCLUDES += $(ANALYZER_LOCAL_INCLUDES) LOCAL_STATIC_LIBRARIES := libge_memory \ + libmmpa \ LOCAL_SHARED_LIBRARIES := \ libc_sec \ libascend_protobuf \ libslog \ - libmmpa \ libgraph \ libregister \ libresource \ diff --git a/ge/ge_runner.mk b/ge/ge_runner.mk index c9be823f..a2679ed1 100644 --- a/ge/ge_runner.mk +++ b/ge/ge_runner.mk @@ -372,12 +372,12 @@ LOCAL_SRC_FILES += $(LIBCLIENT_LOCAL_SRC_FILES) LOCAL_STATIC_LIBRARIES := libge_memory \ libadump_server \ libmsprofiler \ + libmmpa \ LOCAL_SHARED_LIBRARIES := \ libc_sec \ libascend_protobuf \ libslog \ - libmmpa \ libgraph \ libregister \ libge_common \ From acddf53306ec2327a1726928954c79ddffb97124 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 20 Nov 2020 11:44:32 +0800 Subject: [PATCH 05/32] update GELOGX redefine --- CMakeLists.txt | 4 ++-- inc/framework/common/debug/ge_log.h | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e67ecb1f..0a553f55 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ if (ENABLE_OPEN_SRC) find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH}) find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH}) - #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) + #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) else() find_module(slog libslog.so ${ASCEND_ATC_DIR}) find_module(mmpa libmmpa.a ${ASCEND_ATC_DIR}) @@ -114,7 +114,7 @@ if (ENABLE_OPEN_SRC) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) - #find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) + #find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) else() message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated") endif() diff --git a/inc/framework/common/debug/ge_log.h b/inc/framework/common/debug/ge_log.h index 0ef21b34..4a32af36 100644 --- a/inc/framework/common/debug/ge_log.h +++ b/inc/framework/common/debug/ge_log.h @@ -37,14 +37,6 @@ extern "C" { // trace status of log enum TraceStatus { TRACE_INIT = 0, TRACE_RUNNING, TRACE_WAITING, TRACE_STOP }; -#define GELOGE(ERROR_CODE, ...) GE_LOG_ERROR(GE_MODULE_NAME, ERROR_CODE, __VA_ARGS__) -#define GELOGW(...) GE_LOG_WARN(GE_MODULE_NAME, __VA_ARGS__) -#define GELOGI(...) GE_LOG_INFO(GE_MODULE_NAME, __VA_ARGS__) -#define GELOGD(...) GE_LOG_DEBUG(GE_MODULE_NAME, __VA_ARGS__) -#define GEEVENT(...) GE_LOG_EVENT(GE_MODULE_NAME, __VA_ARGS__) -#define GELOGO(...) GE_LOG_OPLOG(GE_MODULE_NAME, __VA_ARGS__) -#define GELOGT(VALUE, ...) GE_LOG_TRACE(GE_MODULE_NAME, VALUE, __VA_ARGS__) - class GeLog { public: #ifdef __GNUC__ From 5c692bf337476f28c66f2b4d926f202b0580397c Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 20 Nov 2020 14:19:33 +0800 Subject: [PATCH 06/32] update static_mmpa --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a553f55..936d85d7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ if (ENABLE_OPEN_SRC) set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) set(STATIC_ACL_LIB ${GE_LIB_PATH}) find_module(slog libslog.so ${GE_LIB_PATH}) - find_module(mmpa libmmpa.a ${GE_LIB_PATH}) + find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) find_module(msprof libmsprof.so ${GE_LIB_PATH}) find_module(hccl libhccl.so ${GE_LIB_PATH}) find_module(adump_server libadump_server.a ${GE_LIB_PATH}) @@ -70,7 +70,7 @@ if (ENABLE_OPEN_SRC) #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) else() find_module(slog libslog.so ${ASCEND_ATC_DIR}) - find_module(mmpa libmmpa.a ${ASCEND_ATC_DIR}) + find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR}) if(PLATFORM STREQUAL "train") find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) @@ -91,7 +91,7 @@ if (ENABLE_OPEN_SRC) find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) - #find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) + #find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) if(PRODUCT STREQUAL "flr3") find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) elseif(PRODUCT STREQUAL "flr1") From 5c4b3b1b9e9f7c83774193d2c89cc8aa5aa8d69c Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 24 Nov 2020 15:32:02 +0800 Subject: [PATCH 07/32] update metadef parser metadef --- metadef | 2 +- parser | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadef b/metadef index 1b09ed04..6bdf2e30 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 1b09ed04b6dd22d1aed1bee92fd42736c0fafc65 +Subproject commit 6bdf2e3011150b200fdcd2acd18b7186902534b6 diff --git a/parser b/parser index 3d49906d..af06fc02 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 3d49906d119b1cc01f4256d7992759ce9f3dcfcd +Subproject commit af06fc022551f154574efd5b68f96d13bce9193f From 149aa0703496e19be8309e565b16c36004957d2a Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 24 Nov 2020 15:52:29 +0800 Subject: [PATCH 08/32] update session manage --- ge/common/debug/memory_dumper.cc | 2 +- ge/session/session_manager.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index e57c234f..872fe1da 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -154,7 +154,7 @@ int MemoryDumper::OpenFile(const char *filename) { // Using the O_EXCL, if the file already exists,return failed to avoid privilege escalation vulnerability. mmMode_t mode = M_IRUSR | M_IWUSR; - int32_t fd = mmOpen2(real_path.c_str(), M_WRONLY | M_CREAT | O_TRUNC, mode); + int32_t fd = mmOpen2(real_path.c_str(), M_RDWR | M_CREAT | O_TRUNC, mode); if (fd == EN_ERROR || fd == EN_INVALID_PARAM) { GELOGE(kInvalidFd, "open file failed. errno = %d, %s", fd, strerror(errno)); return kInvalidFd; diff --git a/ge/session/session_manager.cc b/ge/session/session_manager.cc index 485b0bd0..69a62923 100755 --- a/ge/session/session_manager.cc +++ b/ge/session/session_manager.cc @@ -173,7 +173,7 @@ Status SessionManager::AddGraph(SessionId session_id, uint32_t graph_id, const G Status SessionManager::AddGraphWithCopy(SessionId session_id, uint32_t graph_id, const Graph &graph, const std::map &options) { if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT); + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); return GE_SESSION_MANAGER_NOT_INIT; } SessionPtr innerSession = nullptr; From 2b89cf934a0940c5f10a794f93ddf1d9abc4d721 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 24 Nov 2020 16:03:29 +0800 Subject: [PATCH 09/32] update compiler options --- ge/graph/load/new_model_manager/zero_copy_task.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/load/new_model_manager/zero_copy_task.cc b/ge/graph/load/new_model_manager/zero_copy_task.cc index e1be3701..fe19ea1d 100755 --- a/ge/graph/load/new_model_manager/zero_copy_task.cc +++ b/ge/graph/load/new_model_manager/zero_copy_task.cc @@ -19,7 +19,7 @@ #include "framework/common/debug/ge_log.h" #include "framework/common/util.h" #include "graph/load/new_model_manager/model_utils.h" -#inlcude "common/ge_compiler_options.h" +#include "common/ge_compiler_options.h" namespace ge { const char *const kDefaultBatchLable = "Batch_default"; From 8ea2a10c662e1cf91f3723ef11348c2431549b36 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 24 Nov 2020 16:20:10 +0800 Subject: [PATCH 10/32] update atc depend on static_mmpa --- ge/offline/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/offline/CMakeLists.txt b/ge/offline/CMakeLists.txt index e8e91327..49af37c0 100644 --- a/ge/offline/CMakeLists.txt +++ b/ge/offline/CMakeLists.txt @@ -69,7 +69,7 @@ target_link_libraries(atc PRIVATE json runtime_compile slog - mmpa + static_mmpa -lrt -ldl ) From 0c111a4da685e332c4dc1e56da5134dc43e5d100 Mon Sep 17 00:00:00 2001 From: zhou_chao1993 Date: Tue, 24 Nov 2020 11:33:28 +0800 Subject: [PATCH 11/32] add mark agnostic pass --- ge/graph/passes/mark_agnostic_pass.cc | 11 +++++++++++ ge/graph/preprocess/graph_preprocess.cc | 2 ++ 2 files changed, 13 insertions(+) diff --git a/ge/graph/passes/mark_agnostic_pass.cc b/ge/graph/passes/mark_agnostic_pass.cc index 00a3dad9..4fdc8e1b 100644 --- a/ge/graph/passes/mark_agnostic_pass.cc +++ b/ge/graph/passes/mark_agnostic_pass.cc @@ -16,6 +16,7 @@ #include "graph/passes/mark_agnostic_pass.h" #include "graph/utils/node_utils.h" +#include "graph/utils/tensor_utils.h" namespace ge { Status MarkAgnosticPass::Run(ComputeGraphPtr graph) { @@ -47,6 +48,16 @@ Status MarkAgnosticPass::Run(ComputeGraphPtr graph) { } if (node_type == MERGE) { GELOGD("Mark format agnostic and continuous for merge node %s", node->GetName().c_str()); + auto in_nodes = node->GetInAllNodes(); + vector input_nodes(in_nodes.begin(), in_nodes.end()); + /// Enter-----------+ + /// +-> Merge + /// NextIteration---+ + if (input_nodes.size() == 2) { + if (input_nodes[0]->GetType() == ENTER && input_nodes[1]->GetType() == NEXTITERATION) { + continue; + } + } const OpDescPtr op_desc = node->GetOpDesc(); const GeTensorDescPtr op_tensor = op_desc->MutableOutputDesc(0); if (op_tensor == nullptr) { diff --git a/ge/graph/preprocess/graph_preprocess.cc b/ge/graph/preprocess/graph_preprocess.cc index 58718c9f..b899ee83 100644 --- a/ge/graph/preprocess/graph_preprocess.cc +++ b/ge/graph/preprocess/graph_preprocess.cc @@ -117,6 +117,7 @@ #include "graph/passes/variable_op_pass.h" #include "graph/passes/variable_prepare_op_pass.h" #include "graph/passes/variable_ref_delete_op_pass.h" +#include "graph/passes/mark_agnostic_pass.h" namespace ge { @@ -1700,6 +1701,7 @@ Status GraphPrepare::PrepareOptimize() { try { (void)original_graph_passes.AddPass("PrepareOptimize::ShapeOperateOpRemovePass", new ShapeOperateOpRemovePass); (void)original_graph_passes.AddPass("PrepareOptimize::ReplaceTransShapePass", new ReplaceTransShapePass); + (void)original_graph_passes.AddPass("PrepareOptimize::MarkAgnosticPass" , new MarkAgnosticPass); } catch (std::bad_alloc &e) { GELOGE(INTERNAL_ERROR, "Add pass failed, bad memory allocation occurs."); return INTERNAL_ERROR; From 9477cdeb4e8cfe30f7bab28db0c416dff17191bd Mon Sep 17 00:00:00 2001 From: zhou_lili Date: Tue, 24 Nov 2020 17:16:51 +0800 Subject: [PATCH 12/32] delete check when adapter has checked --- ge/graph/manager/graph_manager.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index f00c477f..c874abcd 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -1540,16 +1540,6 @@ Status GraphManager::ParseOptions(const std::map &opti ParseOption(options, DYNAMIC_NODE_TYPE, options_.dynamic_node_type); GELOGD("Dynamic dims params: input shape is %s, dynamic dims is %s, dynamic node type is %d.", options_.input_shape.c_str(), options_.dynamic_dims.c_str(), options_.dynamic_node_type); - if ((!options_.input_shape.empty() && options_.dynamic_dims.empty()) || - (options_.input_shape.empty() && !options_.dynamic_dims.empty())) { - GELOGE(GRAPH_PARAM_INVALID, "Should set input shape and dynamic dims at the same time"); - return GRAPH_PARAM_INVALID; - } - if ((!options_.input_shape.empty() && options_.dynamic_node_type == kInvalidDynaimcDimsType) || - (!options_.dynamic_dims.empty() && options_.dynamic_node_type == kInvalidDynaimcDimsType)) { - GELOGE(GRAPH_PARAM_INVALID, "Should set valid dynamic node type"); - return GRAPH_PARAM_INVALID; - } // Set Build model and step ParseOption(options, BUILD_MODE, options_.build_mode); From 82be3ef3eea13a2772a9647c253df5695b70a2ea Mon Sep 17 00:00:00 2001 From: zhaoxinxin Date: Tue, 24 Nov 2020 19:55:33 +0800 Subject: [PATCH 13/32] deleted: ge/graph/optimize/optimizer/allreduce_fusion_pass.cc deleted: ge/graph/optimize/optimizer/allreduce_fusion_pass.h --- .../optimizer/allreduce_fusion_pass.cc | 397 ------------------ .../optimizer/allreduce_fusion_pass.h | 56 --- 2 files changed, 453 deletions(-) delete mode 100644 ge/graph/optimize/optimizer/allreduce_fusion_pass.cc delete mode 100644 ge/graph/optimize/optimizer/allreduce_fusion_pass.h diff --git a/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc b/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc deleted file mode 100644 index 34c3a0de..00000000 --- a/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc +++ /dev/null @@ -1,397 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "graph/optimize/optimizer/allreduce_fusion_pass.h" -#include -#include "common/debug/log.h" -#include "framework/common/debug/ge_log.h" -#include "common/types.h" -#include "common/util.h" -#include "graph/anchor.h" -#include "graph/node.h" -#include "graph/op_desc.h" -#include "graph/utils/attr_utils.h" -#include "graph/utils/graph_utils.h" -#include "graph/utils/tensor_utils.h" -#include "graph/debug/ge_attr_define.h" -#include "hccl/base.h" -#include "hccl/hcom.h" - -namespace ge { -Status AllReducePass::Run(ge::ComputeGraphPtr graph) { - GELOGI("FusionAllReducePass: start"); - std::vector fusionOps; - std::vector inputGradientSize; - std::vector inputGradientTime; - - static const float inputGradientSizeTemp = 0.0; - static const float inputGradientTimeTemp = 0.0; - - // Get all nodes - for (auto nodePtr : graph->GetDirectNode()) { - GE_IF_BOOL_EXEC(nullptr == nodePtr, GELOGW("FusionAllReducePass: null node exists"); continue;); - - ge::OpDescPtr opDescPtr = nodePtr->GetOpDesc(); - GE_IF_BOOL_EXEC(nullptr == opDescPtr, - GELOGW("FusionAllReducePass: desc of node %s is null", nodePtr->GetName().c_str()); - continue;) - GE_IF_BOOL_EXEC(HCOMALLREDUCE == opDescPtr->GetType(), - // the op is allreduce and fusion > 0, then run fusion - std::int64_t hcom_fusion = 1; - GE_IF_BOOL_EXEC(!ge::AttrUtils::GetInt(opDescPtr, HCOM_ATTR_FUSION, hcom_fusion), - GELOGW("FusionAllReducePass: not get hcom_fusion from opDescPtr " - "by HCOM_ATTR_FUSION")); - GELOGI("after GetInt, hcom_fusion is :%ld", hcom_fusion); GE_IF_BOOL_EXEC( - hcom_fusion > 0, fusionOps.push_back(nodePtr); inputGradientSize.push_back(inputGradientSizeTemp); - inputGradientTime.push_back(inputGradientTimeTemp);)) - } - // The number of allredecue operator must be more than 1 - GE_IF_BOOL_EXEC(1 >= fusionOps.size(), GELOGW("FusionAllReducePass NOT_CHANGED: the graph has " - "%lu allreduce operator", - fusionOps.size()); - return NOT_CHANGED;); - - string group = "group"; - u32 gradientNum = fusionOps.size(); - string model_name_str = graph->GetName(); - const char *model_name = model_name_str.c_str(); - model_feature modelFeature{model_name, gradientNum, inputGradientSize.data(), inputGradientTime.data()}; - - u32 segmentNum = 0; - u32 segmentIndex[HCCL_MAX_SEGMENT_NUM] = {}; - - // Call HCCL function: hcom_gradient_segment - GELOGI("FusionAllReducePass: invoking hcom_get_split_strategy"); - GE_IF_BOOL_EXEC(HCCL_SUCCESS != hcom_get_split_strategy(group.c_str(), &modelFeature, HCCL_MAX_SEGMENT_NUM, - &segmentNum, segmentIndex), - GELOGE(FAILED, "FusionAllReducePass FAILED: the graph has %lu allreduce operator", fusionOps.size()); - return FAILED;) - GELOGI("FusionAllReducePass: invoke hcom_get_split_strategy successfully"); - - // check whether segmentNum is legal or not - GE_IF_BOOL_EXEC((HCCL_MAX_SEGMENT_NUM < segmentNum || 1 > segmentNum || segmentNum > gradientNum), - GELOGE(FAILED, - "FusionAllReducePass FAILED: illegal segmentNum=%u, " - "HCCL_MAX_SEGMENT_NUM=%u, gradientNum=%u", - segmentNum, HCCL_MAX_SEGMENT_NUM, gradientNum); - return FAILED;); - - // check whether segmentIndex is legal or not - GE_IF_BOOL_EXEC((segmentIndex[segmentNum - 1] != gradientNum - 1), - GELOGE(FAILED, - "FusionAllReducePass FAILED: illegal segmentIndex[0]=%u, " - "segmentIndex[segmentNum-1]=%u, gradientNum=%u", - segmentIndex[0], segmentIndex[(segmentNum)-1], gradientNum); - return FAILED;); - - for (uint32_t i = 0; i < segmentNum - 1; i++) { - GE_IF_BOOL_EXEC(segmentIndex[i] >= segmentIndex[i + 1], GELOGE(FAILED, - "FusionAllReducePass FAILED: illegal " - "segmentIndex[%u]=%u, segmentIndex[%u]=%u", - i, segmentIndex[i], i + 1, segmentIndex[i + 1]); - return FAILED;); - } - - // check whether fusion is needed or not - GE_IF_BOOL_EXEC( - segmentNum == gradientNum, - GELOGE(NOT_CHANGED, "FusionAllReducePass NOT_CHANGED: segmentNum=%u, gradientNum=%u", segmentNum, gradientNum); - return NOT_CHANGED;) - - std::unordered_set anchorPtrSet; - std::vector fusionOpPeerOutDataAnchor; - std::vector fusionOpPeerOutDataToInControl; - std::vector fusionOpPeerOutControlAnchor; - std::vector> fusionOpPeerInDataAnchor; - std::vector> fusionOpPeerInControlFromOutData; - std::vector fusionOpPeerInControlAnchor; - ge::OutControlAnchorPtr previousNewAllreduceOutControlAnchor = nullptr; - - // Traversing the segmentNum - uint32_t start = 0; - uint32_t end = 0; - for (uint32_t segmentIdx = 0; segmentIdx < segmentNum; segmentIdx++) { - end = segmentIndex[segmentIdx]; - GE_IF_BOOL_EXEC(end - start < 1, - GELOGI("FusionAllReducePass: segmentIndex[%u]=%u", segmentIdx, segmentIndex[segmentIdx]); - start = end + 1; continue;); - - ge::OpDescPtr originDescPtr = fusionOps[start]->GetOpDesc(); - GE_CHECK_NOTNULL(originDescPtr); - ge::OpDescPtr newAllreduceDesc = AttrUtils::CloneOpDesc(originDescPtr); - GE_CHECK_NOTNULL(newAllreduceDesc); - - // Cleat buffer - anchorPtrSet.clear(); - fusionOpPeerOutDataAnchor.clear(); - fusionOpPeerOutDataToInControl.clear(); - fusionOpPeerOutControlAnchor.clear(); - fusionOpPeerInDataAnchor.clear(); - fusionOpPeerInControlFromOutData.clear(); - fusionOpPeerInControlAnchor.clear(); - - // Traversing the Allreduce operators of each group - int outDataAnchorIndex = 0; - GE_CHK_STATUS_RET(GetPeerOutDataToInData(anchorPtrSet, fusionOpPeerOutDataAnchor, fusionOps[start]), - "Get peer outDataAnchor to inDataAnchor failed"); - - GE_CHK_STATUS_RET(GetPeerInAnchorToOutData(anchorPtrSet, fusionOpPeerInDataAnchor, fusionOpPeerInControlFromOutData, - fusionOps[start]), - "Get peer inDataAnchor and inControlAnchor to outDataAnchor failed"); - - GE_CHK_STATUS_RET(GetPeerOutDataToInControl(anchorPtrSet, fusionOpPeerOutDataToInControl, fusionOps[start]), - "Get peer outDataAnchor to inControlAnchor failed"); - GE_CHK_STATUS_RET(GetPeerOutControlToInControl(anchorPtrSet, fusionOpPeerOutControlAnchor, fusionOps[start]), - "Get peer outControlAnchor to inControlAnchor failed"); - GE_CHK_STATUS_RET(GetPeerInControlFromOutControl(anchorPtrSet, fusionOpPeerInControlAnchor, fusionOps[start]), - "Get peer outControlAnchor from inControlAnchor failed"); - GE_CHK_STATUS_RET(graph->RemoveNode(fusionOps[start]), "FusionAllReducePass FAILED: remove node %s\n.", - fusionOps[start]->GetName().c_str()); - - for (uint32_t idx = start + 1; idx <= end; idx++) { - GE_CHK_STATUS_RET( - GetPeerOutDataToInData(anchorPtrSet, fusionOpPeerOutDataAnchor, fusionOps[idx], newAllreduceDesc), - "Get peer outDataAnchor to inDataAnchor failed"); - GE_CHK_STATUS_RET(GetPeerOutDataToInControl(anchorPtrSet, fusionOpPeerOutDataToInControl, fusionOps[idx]), - "Get peer outDataAnchor to inControlAnchor failed"); - GE_CHK_STATUS_RET(GetPeerOutControlToInControl(anchorPtrSet, fusionOpPeerOutControlAnchor, fusionOps[idx]), - "Get peer outControlAnchor to inControlAnchor failed"); - GE_CHK_STATUS_RET( - GetPeerAnchorFromOutData(anchorPtrSet, fusionOpPeerInDataAnchor, fusionOpPeerInControlFromOutData, - fusionOps[idx], newAllreduceDesc, outDataAnchorIndex), - "Get peerAnchor from outDataAnchor failed"); - GE_CHK_STATUS_RET(GetPeerInControlFromOutControl(anchorPtrSet, fusionOpPeerInControlAnchor, fusionOps[idx]), - "Get peer outControlAnchor from inControlAnchor failed"); - - // Delete the node - GE_CHK_STATUS_RET(graph->RemoveNode(fusionOps[idx]), "FusionAllReducePass FAILED: remove node %s\n.", - fusionOps[idx]->GetName().c_str()); - } - - NodePtr newAllReducePtr = graph->AddNode(newAllreduceDesc); - GE_CHECK_NOTNULL(newAllReducePtr); - // Link the inputDataAnchor - for (uint32_t i = 0; i < fusionOpPeerOutDataAnchor.size(); i++) { - GE_CHK_STATUS_RET( - GraphUtils::AddEdge(fusionOpPeerOutDataAnchor[i], newAllReducePtr->GetInDataAnchor(static_cast(i))), - "FusionAllReducePass FAILED: add input data edge failed"); - } - - // Link the inputControlAnchor - for (uint32_t i = 0; i < fusionOpPeerOutControlAnchor.size(); i++) { - GE_CHK_STATUS_RET(GraphUtils::AddEdge(fusionOpPeerOutControlAnchor[i], newAllReducePtr->GetInControlAnchor()), - "FusionAllReducePass FAILED: add input control edge failed"); - } - - for (uint32_t i = 0; i < fusionOpPeerOutDataToInControl.size(); i++) { - GE_CHK_STATUS_RET(GraphUtils::AddEdge(fusionOpPeerOutDataToInControl[i], newAllReducePtr->GetInControlAnchor()), - "FusionAllReducePass FAILED: add edge from out data to incontrol " - "failed"); - } - - // Link the outputDataAnchor - for (uint32_t i = 0; i < fusionOpPeerInDataAnchor.size(); i++) { - auto peerInDataAnchor = fusionOpPeerInDataAnchor[i].second; - GE_CHK_STATUS_RET( - GraphUtils::AddEdge(newAllReducePtr->GetOutDataAnchor(fusionOpPeerInDataAnchor[i].first), peerInDataAnchor), - "FusionAllReducePass FAILED: add output data edge failed"); - } - for (uint32_t i = 0; i < fusionOpPeerInControlFromOutData.size(); i++) { - auto peerInControlAnchor = fusionOpPeerInControlFromOutData[i].second; - GE_CHK_STATUS_RET( - GraphUtils::AddEdge(newAllReducePtr->GetOutDataAnchor(fusionOpPeerInControlFromOutData[i].first), - peerInControlAnchor), - "FusionAllReducePass FAILED: add edge from out data to in control " - "failed"); - } - - // Link the outputControlAnchor - for (uint32_t i = 0; i < fusionOpPeerInControlAnchor.size(); i++) { - GE_CHK_STATUS_RET(GraphUtils::AddEdge(newAllReducePtr->GetOutControlAnchor(), fusionOpPeerInControlAnchor[i]), - "FusionAllReducePass FAILED: add output control edge failed"); - } - - // Link the newAllreduce - if (segmentIdx > 0 && previousNewAllreduceOutControlAnchor != nullptr) { - GE_CHK_STATUS_RET( - GraphUtils::AddEdge(previousNewAllreduceOutControlAnchor, newAllReducePtr->GetInControlAnchor()), - "FusionAllReducePass FAILED: add input previous control edge failed"); - } - - previousNewAllreduceOutControlAnchor = newAllReducePtr->GetOutControlAnchor(); - start = end + 1; - } - - return SUCCESS; -} - -Status AllReducePass::GetPeerOutDataToInData(std::unordered_set &anchorSet, - vector &peerOutDataAnchorVec, - ge::NodePtr &srcNodePtr) { - for (auto inDataAnchor : srcNodePtr->GetAllInDataAnchors()) { - GE_IF_BOOL_EXEC(inDataAnchor == nullptr, continue;); - OutDataAnchorPtr peerOutDataAnchor = inDataAnchor->GetPeerOutAnchor(); - GE_IF_BOOL_EXEC(peerOutDataAnchor == nullptr, continue;); - if (anchorSet.count(peerOutDataAnchor.get()) == 0) { - peerOutDataAnchorVec.push_back(peerOutDataAnchor); - anchorSet.insert(peerOutDataAnchor.get()); - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(peerOutDataAnchor, inDataAnchor)); - } - } - return SUCCESS; -} - -Status AllReducePass::GetPeerInAnchorToOutData( - std::unordered_set &anchorSet, std::vector> &fusionOpPeerInDataAnchor, - std::vector> &fusionOpPeerInControlFromOutData, ge::NodePtr &srcNodePtr) { - for (auto outDataAnchor : srcNodePtr->GetAllOutDataAnchors()) { - GE_IF_BOOL_EXEC(outDataAnchor == nullptr, continue;); - for (auto peerInDataAnchor : outDataAnchor->GetPeerInDataAnchors()) { - GE_IF_BOOL_EXEC(peerInDataAnchor == nullptr, continue;); - if (anchorSet.count(peerInDataAnchor.get()) == 0) { - std::pair pairPeerInDataAnchor; - pairPeerInDataAnchor.first = 0; - pairPeerInDataAnchor.second = peerInDataAnchor; - fusionOpPeerInDataAnchor.push_back(pairPeerInDataAnchor); - anchorSet.insert(peerInDataAnchor.get()); - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(outDataAnchor, peerInDataAnchor)); - } - } - - for (auto peerInControlAnchorFromData : outDataAnchor->GetPeerInControlAnchors()) { - GE_IF_BOOL_EXEC(peerInControlAnchorFromData == nullptr, continue;); - if (anchorSet.count(peerInControlAnchorFromData.get()) == 0) { - std::pair pairPeerInControlAnchorFromData; - pairPeerInControlAnchorFromData.first = 0; - pairPeerInControlAnchorFromData.second = peerInControlAnchorFromData; - fusionOpPeerInControlFromOutData.push_back(pairPeerInControlAnchorFromData); - anchorSet.insert(peerInControlAnchorFromData.get()); - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(outDataAnchor, peerInControlAnchorFromData)); - } - } - } - return SUCCESS; -} - -Status AllReducePass::GetPeerOutDataToInData(std::unordered_set &anchorSet, - vector &peerOutDataAnchorVec, - ge::NodePtr &srcNodePtr, ge::OpDescPtr &dstOpDescPtr) { - for (auto inDataAnchor : srcNodePtr->GetAllInDataAnchors()) { - GE_IF_BOOL_EXEC(inDataAnchor == nullptr, continue;); - OutDataAnchorPtr peerOutDataAnchor = inDataAnchor->GetPeerOutAnchor(); - GE_IF_BOOL_EXEC(peerOutDataAnchor == nullptr, continue;); - if (anchorSet.count(peerOutDataAnchor.get()) == 0) { - peerOutDataAnchorVec.push_back(peerOutDataAnchor); - anchorSet.insert(peerOutDataAnchor.get()); - if (dstOpDescPtr->AddInputDesc(inDataAnchor->GetOwnerNode()->GetOpDesc()->GetInputDesc(inDataAnchor->GetIdx())) != - ge::GRAPH_SUCCESS) { - GELOGW("GetPeerOutDataToInData: AddInputDesc failed"); - } - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(peerOutDataAnchor, inDataAnchor)); - } - } - return SUCCESS; -} - -Status AllReducePass::GetPeerOutDataToInControl(std::unordered_set &anchorSet, - vector &peerOutDataToInControlVec, - ge::NodePtr &srcNodePtr) { - InControlAnchorPtr inControlAnchor = srcNodePtr->GetInControlAnchor(); - GE_CHECK_NOTNULL(inControlAnchor); - for (auto peerOutDataToInControl : inControlAnchor->GetPeerOutDataAnchors()) { - GE_IF_BOOL_EXEC(peerOutDataToInControl == nullptr, continue;); - if (anchorSet.count(peerOutDataToInControl.get()) == 0) { - peerOutDataToInControlVec.push_back(peerOutDataToInControl); - anchorSet.insert(peerOutDataToInControl.get()); - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(peerOutDataToInControl, inControlAnchor)); - } - } - return SUCCESS; -} - -Status AllReducePass::GetPeerOutControlToInControl(std::unordered_set &anchorSet, - vector &peerOutControlToInControlVec, - ge::NodePtr &srcNodePtr) { - InControlAnchorPtr inControlAnchor = srcNodePtr->GetInControlAnchor(); - GE_CHECK_NOTNULL(inControlAnchor); - for (auto peerOutControlAnchor : inControlAnchor->GetPeerOutControlAnchors()) { - GE_IF_BOOL_EXEC(peerOutControlAnchor == nullptr, continue;); - if (anchorSet.count(peerOutControlAnchor.get()) == 0) { - peerOutControlToInControlVec.push_back(peerOutControlAnchor); - anchorSet.insert(peerOutControlAnchor.get()); - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(peerOutControlAnchor, inControlAnchor)); - } - } - return SUCCESS; -} - -Status AllReducePass::GetPeerAnchorFromOutData( - std::unordered_set &anchorSet, vector> &peerInDataFromOutDataVec, - vector> &peerInControlFromOutDataVec, ge::NodePtr &srcNodePtr, - ge::OpDescPtr &dstOpDescPtr, int &index) { - for (auto outDataAnchor : srcNodePtr->GetAllOutDataAnchors()) { - GE_IF_BOOL_EXEC(outDataAnchor == nullptr, continue;) - if (outDataAnchor->GetPeerInDataAnchors().size() > 0 || outDataAnchor->GetPeerInControlAnchors().size() > 0) { - if (dstOpDescPtr->AddOutputDesc( - outDataAnchor->GetOwnerNode()->GetOpDesc()->GetOutputDesc(outDataAnchor->GetIdx())) != ge::GRAPH_SUCCESS) { - GELOGW("GetPeerAnchorFromOutData: AddOutputDesc failed"); - } - index++; - } - - for (auto peerInDataAnchor : outDataAnchor->GetPeerInDataAnchors()) { - GE_IF_BOOL_EXEC(peerInDataAnchor == nullptr, continue;) - if (anchorSet.count(peerInDataAnchor.get()) == 0) { - std::pair pairPeerInDataAnchor; - pairPeerInDataAnchor.first = index; - pairPeerInDataAnchor.second = peerInDataAnchor; - peerInDataFromOutDataVec.push_back(pairPeerInDataAnchor); - anchorSet.insert(peerInDataAnchor.get()); - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(outDataAnchor, peerInDataAnchor)) - } - } - - for (auto peerInControlAnchorFromData : outDataAnchor->GetPeerInControlAnchors()) { - GE_IF_BOOL_EXEC(peerInControlAnchorFromData == nullptr, continue;) - if (anchorSet.count(peerInControlAnchorFromData.get()) == 0) { - std::pair pairPeerInControlAnchorFromData; - pairPeerInControlAnchorFromData.first = index; - pairPeerInControlAnchorFromData.second = peerInControlAnchorFromData; - peerInControlFromOutDataVec.push_back(pairPeerInControlAnchorFromData); - anchorSet.insert(peerInControlAnchorFromData.get()); - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(outDataAnchor, peerInControlAnchorFromData)) - } - } - } - return SUCCESS; -} - -Status AllReducePass::GetPeerInControlFromOutControl(std::unordered_set &anchorSet, - vector &peerInControlFromOutControlVec, - ge::NodePtr &srcNodePtr) { - OutControlAnchorPtr outControlAnchor = srcNodePtr->GetOutControlAnchor(); - GE_CHECK_NOTNULL(outControlAnchor); - for (auto peerInControlAnchor : outControlAnchor->GetPeerInControlAnchors()) { - GE_IF_BOOL_EXEC(peerInControlAnchor == nullptr, continue;) - if (anchorSet.count(peerInControlAnchor.get()) == 0) { - peerInControlFromOutControlVec.push_back(peerInControlAnchor); - anchorSet.insert(peerInControlAnchor.get()); - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(outControlAnchor, peerInControlAnchor)) - } - } - return SUCCESS; -} -} // namespace ge diff --git a/ge/graph/optimize/optimizer/allreduce_fusion_pass.h b/ge/graph/optimize/optimizer/allreduce_fusion_pass.h deleted file mode 100644 index 8b2168d9..00000000 --- a/ge/graph/optimize/optimizer/allreduce_fusion_pass.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GE_GRAPH_OPTIMIZE_OPTIMIZER_ALLREDUCE_FUSION_PASS_H_ -#define GE_GRAPH_OPTIMIZE_OPTIMIZER_ALLREDUCE_FUSION_PASS_H_ - -#include -#include -#include -#include "inc/graph_pass.h" - -namespace ge { -// -class AllReducePass : public GraphPass { - public: - Status Run(ge::ComputeGraphPtr graph) override; - - private: - Status GetPeerOutDataToInData(std::unordered_set &anchorSet, - vector &peerOutDataAnchorVec, ge::NodePtr &srcNodePtr, - ge::OpDescPtr &dstOpDescPtr); - Status GetPeerOutDataToInControl(std::unordered_set &anchorSet, - vector &peerOutDataToInControlVec, ge::NodePtr &srcNodePtr); - Status GetPeerOutControlToInControl(std::unordered_set &anchorSet, - vector &peerOutControlToInControlVec, - ge::NodePtr &srcNodePtr); - Status GetPeerAnchorFromOutData(std::unordered_set &anchorSet, - vector> &peerInDataFromOutDataVec, - vector> &peerInControlFromOutDataVec, - ge::NodePtr &srcNodePtr, ge::OpDescPtr &dstOpDescPtr, int &index); - Status GetPeerInControlFromOutControl(std::unordered_set &anchorSet, - vector &peerInControlFromOutControlVec, - ge::NodePtr &srcNodePtr); - Status GetPeerOutDataToInData(std::unordered_set &anchorSet, - std::vector &peerOutDataAnchorVec, - ge::NodePtr &srcNodePtr); - Status GetPeerInAnchorToOutData(std::unordered_set &anchorSet, - std::vector> &fusionOpPeerInDataAnchor, - std::vector>&fusionOpPeerInControlFromOutData, - ge::NodePtr &srcNodePtr); -}; -} // namespace ge -#endif // GE_GRAPH_OPTIMIZE_OPTIMIZER_ALLREDUCE_FUSION_PASS_H_ From 328b3c767581f1822f652228368ad9433823b4ee Mon Sep 17 00:00:00 2001 From: zhengyuanhua Date: Tue, 24 Nov 2020 20:31:53 +0800 Subject: [PATCH 14/32] external interface modify: string change to ascendstring --- ge/client/ge_api.cc | 121 +++++++++++++++++++++- ge/graph/manager/graph_manager.cc | 27 +++++ ge/graph/manager/graph_manager.h | 6 ++ ge/graph/passes/multi_batch_clone_pass.cc | 15 ++- ge/ir_build/ge_ir_build.cc | 53 +++++++++- ge/session/inner_session.cc | 19 ++++ ge/session/inner_session.h | 4 + ge/session/session_manager.cc | 20 ++++ ge/session/session_manager.h | 3 + inc/external/ge/ge_api.h | 34 ++++++ inc/external/ge/ge_api_error_codes.h | 26 +++++ inc/external/ge/ge_api_types.h | 42 +++++++- inc/external/ge/ge_ir_build.h | 27 +++-- metadef | 2 +- parser | 2 +- 15 files changed, 386 insertions(+), 15 deletions(-) diff --git a/ge/client/ge_api.cc b/ge/client/ge_api.cc index ef8d5622..9ecc3016 100644 --- a/ge/client/ge_api.cc +++ b/ge/client/ge_api.cc @@ -76,7 +76,7 @@ Status CheckOptionsValid(const std::map &options) { } // Initialize GE, prepare for execution, call GELib::Initialize -Status GEInitialize(const std::map &options) { +Status GEInitializeImpl(const std::map &options) { GELOGT(TRACE_INIT, "GEInitialize start"); // 0.check init status if (g_ge_initialized) { @@ -127,6 +127,26 @@ Status GEInitialize(const std::map &options) { return ret; } +// Initialize GE, prepare for execution, call GELib::Initialize +Status GEInitialize(const std::map &options) { + return GEInitializeImpl(options); +} + +Status GEInitialize(const std::map &options) { + std::map str_options; + for (auto & option : options) { + if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { + GELOGE(FAILED, "GEInitialize options is nullptr."); + return FAILED; + } + std::string key = option.first.GetString(); + std::string val = option.second.GetString(); + str_options[key] = val; + } + return GEInitializeImpl(str_options); +} + + // GE finalize, releasing all resources Status GEFinalize() { GELOGT(TRACE_INIT, "GEFinalize start"); @@ -202,6 +222,46 @@ Session::Session(const std::map &options) { GELOGT(TRACE_STOP, "Session Constructor finished"); } +Session::Session(const std::map &options) { + GELOGT(TRACE_INIT, "Session Constructor start"); + // check init status + sessionId_ = 0; + if (!g_ge_initialized) { + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized."); + return; + } + // call Initialize + std::shared_ptr instance_ptr = ge::GELib::GetInstance(); + if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session Constructor failed"); + return; + } + + GELOGT(TRACE_RUNNING, "Creating session"); + std::map str_options; + for (auto &option : options) { + if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { + GELOGE(FAILED, "Session options is nullptr."); + return; + } + std::string key = option.first.GetString(); + std::string val = option.second.GetString(); + str_options[key] = val; + } + uint64_t session_id = 0; + Status ret = instance_ptr->SessionManagerObj().CreateSession(str_options, session_id); + GELOGT(TRACE_RUNNING, "Session id is %lu", session_id); + + // check return status, return, update session id if success + if (ret == SUCCESS) { + sessionId_ = session_id; + } else { + GELOGE(ret, "Session constructor failed, session Id not initialized"); + return; + } + GELOGT(TRACE_STOP, "Session Constructor finished"); +} + // session destructor Session::~Session() { GELOGT(TRACE_INIT, "Session Destructor start"); @@ -260,6 +320,34 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map &options) { + GELOGT(TRACE_INIT, "Start to add graph in Session. graph_id: %u, session_id: %lu.", graph_id, sessionId_); + std::shared_ptr instance_ptr = ge::GELib::GetInstance(); + if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "AddGraph failed in Session."); + return FAILED; + } + GELOGD("Adding graph to session"); + std::map str_options; + for (auto &option : options) { + if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { + GELOGE(FAILED, "AddGraph options is nullptr."); + return FAILED; + } + std::string key = option.first.GetString(); + std::string val = option.second.GetString(); + str_options[key] = val; + } + Status ret = instance_ptr->SessionManagerObj().AddGraph(sessionId_, graph_id, graph, str_options); + if (ret != SUCCESS) { + GELOGE(ret, "AddGraph failed in Session."); + return FAILED; + } + GELOGD("AddGraph finished in Session."); + return ret; +} + Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph) { std::map options; return AddGraphWithCopy(graph_id, graph, options); @@ -387,6 +475,14 @@ Status Session::RegisterCallBackFunc(const std::string &key, const pCallBackFunc return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, key, callback); } +Status Session::RegisterCallBackFunc(const char *key, const session::pCallBackFunc &callback) { + std::string str_key; + if (key != nullptr) { + str_key = key; + } + return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, str_key, callback); +} + Status Session::BuildGraph(uint32_t graph_id, const std::vector &inputs) { std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { @@ -436,6 +532,29 @@ Status Session::GetVariables(const std::vector &var_names, std::vec return SUCCESS; } +Status Session::GetVariables(const std::vector &var_names, std::vector &var_values) { + auto instance_ptr = ge::GELib::GetInstance(); + if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); + return FAILED; + } + GELOGT(TRACE_RUNNING, "Get Variables"); + std::vector str_var_names; + for (auto &var_name : var_names) { + if (var_name.GetString() == nullptr) { + GELOGE(FAILED, "GetVariables name is nullptr."); + return FAILED; + } + str_var_names.emplace_back(var_name.GetString()); + } + Status ret = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, str_var_names, var_values); + if (ret != SUCCESS) { + GELOGE(ret, "SessionManager RunGraphAsync failed"); + return FAILED; + } + return SUCCESS; +} + bool Session::IsGraphNeedRebuild(uint32_t graph_id) { return ge::GELib::GetInstance()->SessionManagerObj().IsGraphNeedRebuild(sessionId_, graph_id); } diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index c874abcd..654bea16 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -1870,12 +1870,30 @@ Status GraphManager::RegisterCallBackFunc( return SUCCESS; } +Status GraphManager::RegisterCallBackFunc( + const std::string &key, + const std::function &)> &callback) { + std::lock_guard lock(member_mutex_); + GELOGI("[GraphManager] RegisterCallBackFunc, key=%s.", key.c_str()); + callback_map_[key] = callback; + return SUCCESS; +} + Status GraphManager::PushSummaryData2ME(const GraphId &graph_id, const std::map &summary_data) { std::lock_guard lock(member_mutex_); GELOGI("[GraphManager] PushSummaryData2ME, dataSize=%zu.", summary_data.size()); auto itr = me_callback_map_.find(kSummary); if (itr == me_callback_map_.end()) { + auto iter = callback_map_.find(kSummary); + if (iter != callback_map_.end()) { + std::map tmp_summary_data; + for (auto &data : summary_data) { + AscendString tmp(data.first.c_str()); + tmp_summary_data[tmp] = data.second; + } + return iter->second(graph_id, tmp_summary_data); + } GELOGE(FAILED, "[GraphManager] PushSummaryData2ME failed, not found summary callback."); return FAILED; } @@ -1887,6 +1905,15 @@ Status GraphManager::PushSaveData2ME(const GraphId &graph_id, const std::map tmp_save_data; + for (auto &data : save_data) { + AscendString tmp(data.first.c_str()); + tmp_save_data[tmp] = data.second; + } + return iter->second(graph_id, tmp_save_data); + } GELOGE(FAILED, "[GraphManager] PushSaveData2ME failed, not found checkpoint callback."); return FAILED; } diff --git a/ge/graph/manager/graph_manager.h b/ge/graph/manager/graph_manager.h index 897ebf92..b0dde0c0 100644 --- a/ge/graph/manager/graph_manager.h +++ b/ge/graph/manager/graph_manager.h @@ -163,6 +163,10 @@ class GraphManager { const std::string &key, const std::function &)> &callback); + Status RegisterCallBackFunc( + const std::string &key, + const std::function &)> &callback); + const bool GetTrainFlag() const { return options_.train_graph_flag; } bool IsGraphNeedRebuild(uint32_t graph_id); @@ -390,6 +394,8 @@ class GraphManager { // summary and checkpoint callback function list for ME, key is summary or checkpoint std::map &)>> me_callback_map_; + std::map &)>> callback_map_; + bool init_flag_; GraphManagerOptions options_; diff --git a/ge/graph/passes/multi_batch_clone_pass.cc b/ge/graph/passes/multi_batch_clone_pass.cc index 732844e5..87d9749a 100755 --- a/ge/graph/passes/multi_batch_clone_pass.cc +++ b/ge/graph/passes/multi_batch_clone_pass.cc @@ -610,11 +610,17 @@ Status MultiBatchClonePass::CreateSubgraphs(const ComputeGraphPtr &graph, const /// Status MultiBatchClonePass::PostProcSubgraph(const ComputeGraphPtr &graph) { auto func_desc = case_node_->GetOpDesc(); + domi::ParseSubgraphFuncV2 parse_func_v2 = nullptr; auto post_func = domi::OpRegistry::Instance()->GetParseSubgraphPostFunc(func_desc->GetType()); if (post_func == nullptr) { GELOGW("The subgraph post func for node %s type %s is null.", case_node_->GetName().c_str(), case_node_->GetType().c_str()); - return FAILED; + if (domi::OpRegistry::Instance()->GetParseSubgraphPostFunc(func_desc->GetType(), parse_func_v2) != SUCCESS || + parse_func_v2 == nullptr) { + GELOGW("The subgraph new post func v2 for node %s type %s is null", case_node_->GetName().c_str(), + case_node_->GetType().c_str()); + return FAILED; + } } for (const auto &name : func_desc->GetSubgraphInstanceNames()) { @@ -629,7 +635,12 @@ Status MultiBatchClonePass::PostProcSubgraph(const ComputeGraphPtr &graph) { "Subgraph: %s get subgraph name failed.", subgraph->GetName().c_str()); auto graph = GraphUtils::CreateGraphFromComputeGraph(subgraph); - auto ret = post_func(subgraph_name, graph); + Status ret = FAILED; + if (post_func != nullptr) { + ret = post_func(subgraph_name, graph); + } else if (parse_func_v2 != nullptr) { + ret = parse_func_v2(subgraph_name.c_str(), graph); + } if (ret != SUCCESS) { GELOGE(FAILED, "Failed to post-process subgraph %s on node %s type %s", graph.GetName().c_str(), case_node_->GetName().c_str(), case_node_->GetType().c_str()); diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index ccf3b24e..242b38a0 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -141,7 +141,7 @@ static void LoadOpsProto() { (void)manager->Initialize(option_tmp); } -graphStatus aclgrphBuildInitialize(std::map global_options) { +graphStatus aclgrphBuildInitializeImpl(std::map &global_options) { GELOGD("Enter aclgrphInitialize start!"); // check global options if (CheckGlobalOptions(global_options) != GRAPH_SUCCESS) { @@ -167,6 +167,24 @@ graphStatus aclgrphBuildInitialize(std::map global_opt return GRAPH_SUCCESS; } +graphStatus aclgrphBuildInitialize(std::map global_options) { + return aclgrphBuildInitializeImpl(global_options); +} + +graphStatus aclgrphBuildInitialize(std::map &global_options) { + std::map tmp_global_options; + for (auto &option : global_options) { + if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { + GELOGE(GRAPH_FAILED, "AclgrphBuildInitialize option is nullptr."); + return GRAPH_FAILED; + } + std::string key = option.first.GetString(); + std::string val = option.second.GetString(); + tmp_global_options[key] = val; + } + return aclgrphBuildInitializeImpl(tmp_global_options); +} + void aclgrphBuildFinalize() { if (ge::GELib::GetInstance() != nullptr && ge::GELib::GetInstance()->InitFlag()) { (void)ge::GELib::GetInstance()->Finalize(); @@ -453,6 +471,24 @@ graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, + ModelBufferData &model) { + GELOGD("Enter aclmdlBuildModel process!"); + std::map tmp_build_options; + for (auto &option : build_options) { + if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { + GELOGE(GRAPH_FAILED, "AclgrphBuildInitialize option is nullptr."); + return GRAPH_FAILED; + } + std::string key = option.first.GetString(); + std::string val = option.second.GetString(); + tmp_build_options[key] = val; + } + + Impl builder; + return builder.BuildModel(graph, tmp_build_options, model); +} + graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &model) { GELOGD("Enter aclmdlSaveModel process!"); if (model.data.get() == nullptr || model.length == 0) { @@ -463,6 +499,21 @@ graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &m static_cast(model.length)); } +graphStatus aclgrphSaveModel(const char *output_file, const ModelBufferData &model) { + GELOGD("Enter aclmdlSaveModel process!"); + if (model.data.get() == nullptr || model.length == 0) { + GELOGE(GRAPH_PARAM_INVALID, "Input model is illegal"); + return GRAPH_PARAM_INVALID; + } + if (output_file == nullptr) { + GELOGE(GRAPH_PARAM_INVALID, "Output file is nullptr."); + return GRAPH_PARAM_INVALID; + } + std::string str_output_file = output_file; + return FileSaver::SaveToFile((str_output_file + ".om"), reinterpret_cast(model.data.get()), + static_cast(model.length)); +} + graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *patch_version) { GELOGD("Enter aclgrphGetIRVersion process!"); GE_CHECK_NOTNULL(major_version); diff --git a/ge/session/inner_session.cc b/ge/session/inner_session.cc index ec85d9ac..c4f8a53b 100755 --- a/ge/session/inner_session.cc +++ b/ge/session/inner_session.cc @@ -254,6 +254,25 @@ Status InnerSession::RegisterCallBackFunc( return SUCCESS; } +Status InnerSession::RegisterCallBackFunc( + const std::string &key, + const std::function &)> &callback) { + std::lock_guard lock(resource_mutex_); + if (!init_flag_) { + GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); + return GE_SESS_INIT_FAILED; + } + UpdateThreadContext(std::map{}); + Status ret = graph_manager_.RegisterCallBackFunc(key, callback); + if (ret != SUCCESS) { + GELOGE(ret, "[InnerSession:%lu] register %s callback function failed.", session_id_, key.c_str()); + return ret; + } + + GELOGI("[InnerSession:%lu] register %s callback function success.", session_id_, key.c_str()); + return SUCCESS; +} + Status InnerSession::BuildGraph(uint32_t graph_id, const std::vector &inputs) { UpdateThreadContext(graph_id); GELOGI("[InnerSession:%lu] build graph on session, graph_id=%u.", session_id_, graph_id); diff --git a/ge/session/inner_session.h b/ge/session/inner_session.h index db7a2c92..5cab43d8 100644 --- a/ge/session/inner_session.h +++ b/ge/session/inner_session.h @@ -62,6 +62,10 @@ class InnerSession { const std::string &key, const std::function &)> &callback); + Status RegisterCallBackFunc( + const std::string &key, + const std::function &)> &callback); + const GraphManager &getGraphManagerObj() const; bool IsGraphNeedRebuild(uint32_t graph_id); diff --git a/ge/session/session_manager.cc b/ge/session/session_manager.cc index 69a62923..5d5a299a 100755 --- a/ge/session/session_manager.cc +++ b/ge/session/session_manager.cc @@ -276,6 +276,26 @@ Status SessionManager::RegisterCallBackFunc( return innerSession->RegisterCallBackFunc(key, callback); } +Status SessionManager::RegisterCallBackFunc( + SessionId session_id, const std::string &key, + const std::function &)> &callback) { + if (!init_flag_) { + GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); + return GE_SESSION_MANAGER_NOT_INIT; + } + SessionPtr innerSession = nullptr; + { + std::lock_guard lock(mutex_); + std::map::iterator it = session_manager_map_.find(session_id); + if (it == session_manager_map_.end()) { + return GE_SESSION_NOT_EXIST; + } else { + innerSession = it->second; + } + } + return innerSession->RegisterCallBackFunc(key, callback); +} + Status SessionManager::BuildGraph(SessionId session_id, uint32_t graph_id, const std::vector &inputs) { if (!init_flag_) { GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); diff --git a/ge/session/session_manager.h b/ge/session/session_manager.h index ac901c3a..da23219c 100644 --- a/ge/session/session_manager.h +++ b/ge/session/session_manager.h @@ -158,6 +158,9 @@ class SessionManager { Status RegisterCallBackFunc( SessionId session_id, const std::string &key, const std::function &)> &callback); + Status RegisterCallBackFunc( + SessionId session_id, const std::string &key, + const std::function &)> &callback); bool IsGraphNeedRebuild(SessionId session_id, uint32_t graph_id); diff --git a/inc/external/ge/ge_api.h b/inc/external/ge/ge_api.h index 8fd4b944..9c26ebf8 100644 --- a/inc/external/ge/ge_api.h +++ b/inc/external/ge/ge_api.h @@ -29,16 +29,26 @@ namespace ge { typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map ¶ms_list); +namespace session { +typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map ¶ms_list); +} + // Initialize GE +ATTRIBUTED_DEPRECATED(Status GEInitialize(const std::map &)) Status GEInitialize(const std::map &options); +Status GEInitialize(const std::map &options); + // Finalize GE, release all resources Status GEFinalize(); class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { public: + ATTRIBUTED_DEPRECATED(Session(const std::map &)) explicit Session(const std::map &options); + explicit Session(const std::map &options); + ~Session(); /// @@ -57,8 +67,19 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { /// @param [in] options graph options /// @return Status result of function /// + ATTRIBUTED_DEPRECATED(Status AddGraph(uint32_t, const Graph &, const std::map &)) Status AddGraph(uint32_t graphId, const Graph &graph, const std::map &options); + /// + /// @ingroup client + /// @brief add a graph with a specific graphId and graphOptions + /// @param [in] graphId graph id + /// @param [in] graph the graph + /// @param [in] options graph options + /// @return Status result of function + /// + Status AddGraph(uint32_t graphId, const Graph &graph, const std::map &options); + /// /// @ingroup client /// @brief add a copy graph with a specific graphId @@ -124,8 +145,18 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { /// @param [out] var_values: variable values /// @return Status result of function /// + ATTRIBUTED_DEPRECATED(Status GetVariables(const std::vector &, std::vector &)) Status GetVariables(const std::vector &var_names, std::vector &var_values); + /// + /// @ingroup ge_graph + /// @brief get variables in the session with specific session id + /// @param [in] var_names: variable names + /// @param [out] var_values: variable values + /// @return Status result of function + /// + Status GetVariables(const std::vector &var_names, std::vector &var_values); + /// /// @ingroup ge_graph /// @brief register callback func with specific summary or checkpoint by users @@ -135,8 +166,11 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { /// Please ensure that the implementation of the function is trusted. /// @return Status result of function /// + ATTRIBUTED_DEPRECATED(Status RegisterCallBackFunc(const char *, const session::pCallBackFunc &)) Status RegisterCallBackFunc(const std::string &key, const pCallBackFunc &callback); + Status RegisterCallBackFunc(const char *key, const session::pCallBackFunc &callback); + bool IsGraphNeedRebuild(uint32_t graphId); private: diff --git a/inc/external/ge/ge_api_error_codes.h b/inc/external/ge/ge_api_error_codes.h index 1a25b86d..92b82a09 100644 --- a/inc/external/ge/ge_api_error_codes.h +++ b/inc/external/ge/ge_api_error_codes.h @@ -20,8 +20,15 @@ #include #include #include "ge_error_codes.h" +#include "graph/ascend_string.h" namespace ge { +#ifdef __GNUC__ +#define ATTRIBUTED_DEPRECATED(replacement) __attribute__((deprecated("Please use " #replacement " instead."))) +#else +#define ATTRIBUTED_DEPRECATED(replacement) __declspec(deprecated("Please use " #replacement " instead.")) +#endif + class StatusFactory { public: static StatusFactory *Instance() { @@ -37,6 +44,17 @@ class StatusFactory { err_desc_[err] = desc; } + void RegisterErrorNo(uint32_t err, const char *desc) { + if (desc == nullptr) { + return; + } + std::string error_desc = desc; + if (err_desc_.find(err) != err_desc_.end()) { + return; + } + err_desc_[err] = error_desc; + } + std::string GetErrDesc(uint32_t err) { auto iter_find = err_desc_.find(err); if (iter_find == err_desc_.end()) { @@ -45,6 +63,13 @@ class StatusFactory { return iter_find->second; } + void GetErrDesc(uint32_t err, AscendString &err_desc) { + auto iter_find = err_desc_.find(err); + if (iter_find != err_desc_.end()) { + err_desc = AscendString((iter_find->second).c_str()); + } + } + protected: StatusFactory() {} ~StatusFactory() {} @@ -56,6 +81,7 @@ class StatusFactory { class ErrorNoRegisterar { public: ErrorNoRegisterar(uint32_t err, const std::string &desc) { StatusFactory::Instance()->RegisterErrorNo(err, desc); } + ErrorNoRegisterar(uint32_t err, const char *desc) { StatusFactory::Instance()->RegisterErrorNo(err, desc); } ~ErrorNoRegisterar() {} }; diff --git a/inc/external/ge/ge_api_types.h b/inc/external/ge/ge_api_types.h index 28de4307..c439a8bf 100644 --- a/inc/external/ge/ge_api_types.h +++ b/inc/external/ge/ge_api_types.h @@ -65,7 +65,47 @@ const char *const OPTION_EXEC_ENABLE_TAILING_OPTIMIZATION = "ge.exec.isTailingOp // Option key: memory init const char *const GRAPH_MEMORY_MAX_SIZE = "ge.graphMemoryMaxSize"; const char *const VARIABLE_MEMORY_MAX_SIZE = "ge.variableMemoryMaxSize"; - +namespace configure_option { +const char *const STREAM_NUM = "ge.streamNum"; +const char *const HEAD_STREAM = "ge.headStream"; +const char *const PERF_LEVEL = "ge.perfLevel"; +const char *const ENCRYPT_MODE = "ge.encryptMode"; +const char *const EK_FILE = "ge.ekFile"; +const char *const CERT_FILE = "ge.certFile"; +const char *const HW_KEY_FILE = "ge.hwKeyFile"; +const char *const PRIVATE_KEY_FILE = "ge.privateKeyFile"; +const char *const FRAMEWORK_TYPE = "ge.frameworkType"; +const char *const CALIBRATION_CONF_FILE = "ge.calibrationConfFile"; +const char *const INSERT_OP_FILE = "ge.insertOpFile"; +const char *const OUTPUT_NODE_NAME = "ge.outputNodeName"; +const char *const COMPRESS_FLAG = "ge.compressFlag"; +const char *const PRECISION_MODE = "ge.exec.precision_mode"; +const char *const SINGLE_OP_FLAG = "ge.exec.single_op"; +const char *const TRAIN_FLAG = "ge.trainFlag"; +const char *const RUN_FLAG = "ge.runFlag"; +const char *const LOCAL_FMKOP_FLAG = "ge.enabledLocalFmkop"; +const char *const TBE_PLUGIN_PATH_FLAG = "ge.TBE_plugin_path"; +const char *const DDK_VERSION_FLAG = "ge.DDK_version"; +const char *const GE_FE_FLAG = "ge.feFlag"; +const char *const STREAM_MAX_PARALLEL_NUM = "ge.streamMaxParallelNum"; +const char *const OUTPUT_DATATYPE = "ge.outputDatatype"; +const char *const OP_SELECT_IMPL_MODE = "ge.opSelectImplmode"; +const char *const OPTYPELIST_FOR_IMPLMODE = "ge.optypelistForImplmode"; +const char *const HCOM_PARALLEL = "ge.hcomParallel"; +const char *const AUTO_TUNE_MODE = "ge.autoTuneMode"; +const char *const SOC_VERSION = "ge.socVersion"; +const char *const CORE_TYPE = "ge.engineType"; +const char *const AICORE_NUM = "ge.aicoreNum"; +const char *const L1_FUSION = "ge.l1Fusion"; +const char *const BUFFER_OPTIMIZE = "ge.bufferOptimize"; +const char *const ENABLE_SMALL_CHANNEL = "ge.enableSmallChannel"; +const char *const ENABLE_COMPRESS_WEIGHT = "ge.enableCompressWeight"; +const char *const FUSION_SWITCH_FILE = "ge.fusionSwitchFile"; +const char *const SAVE_ORIGINAL_MODEL = "ge.saveOriginalModel"; +const char *const ORIGINAL_MODEL_FILE = "ge.originalModelFile"; +const char *const INPUT_FP16_NODES = "ge.INPUT_NODES_SET_FP16"; +const char *const OP_DEBUG_LEVEL = "ge.opDebugLevel"; +} // namespace configure_option // Configure stream num by Session constructor options param, // its value should be int32_t type, default value is "1" const std::string STREAM_NUM = "ge.streamNum"; diff --git a/inc/external/ge/ge_ir_build.h b/inc/external/ge/ge_ir_build.h index e6401093..778ec21d 100644 --- a/inc/external/ge/ge_ir_build.h +++ b/inc/external/ge/ge_ir_build.h @@ -27,12 +27,11 @@ namespace { #define IR_MAJOR_VERSION (int(1)) #define IR_MINOR_VERSION (int(0)) #define IR_PATCH_VERSION (int(0)) -} +} // namespace -namespace ge{ +namespace ge { -struct ModelBufferData -{ +struct ModelBufferData { std::shared_ptr data = nullptr; uint64_t length; }; @@ -45,8 +44,11 @@ struct ModelBufferData * @retval GRAPH_SUCCESS The function is successfully executed. * @retval OtherValues Failure */ +ATTRIBUTED_DEPRECATED(graphStatus aclgrphBuildInitialize(std::map &)) graphStatus aclgrphBuildInitialize(std::map global_options); +graphStatus aclgrphBuildInitialize(std::map &global_options); + /** * @ingroup AscendCL * @brief build model.Notice the model is stored in buffer @@ -64,7 +66,13 @@ void aclgrphBuildFinalize(); * @retval GRAPH_SUCCESS The function is successfully executed. * @retval OtherValues Failure */ -graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, ModelBufferData& model); +ATTRIBUTED_DEPRECATED(graphStatus aclgrphBuildModel(const ge::Graph &, const std::map &, + ModelBufferData &)) +graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, + ModelBufferData &model); + +graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, + ModelBufferData &model); /** * @ingroup AscendCL @@ -75,7 +83,10 @@ graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map Date: Tue, 24 Nov 2020 23:20:33 +0800 Subject: [PATCH 15/32] No session in tf_singleop_task and add cpu kernels cache. --- .../task_info/kernel_task_info.cc | 31 ++++++++++++- .../node_executor/aicpu/aicpu_ext_info.cc | 36 ++++++++++++++++ .../node_executor/aicpu/aicpu_ext_info.h | 8 ++++ .../aicpu/aicpu_node_executor.cc | 43 +++++++++++-------- .../node_executor/aicpu/aicpu_node_executor.h | 2 +- ge/single_op/single_op.cc | 12 ------ ge/single_op/single_op.h | 4 -- ge/single_op/single_op_model.cc | 32 +++++++------- ge/single_op/single_op_model.h | 4 +- .../task/aicpu_kernel_task_builder.cc | 4 +- ge/single_op/task/aicpu_kernel_task_builder.h | 2 +- ge/single_op/task/aicpu_task_builder.cc | 14 +++--- ge/single_op/task/aicpu_task_builder.h | 2 +- ge/single_op/task/op_task.cc | 12 ++++-- ge/single_op/task/op_task.h | 2 +- 15 files changed, 138 insertions(+), 70 deletions(-) diff --git a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc index beef6933..010f90a8 100755 --- a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc @@ -31,6 +31,7 @@ #include "runtime/kernel.h" #include "super_kernel/super_kernel.h" #include "super_kernel/super_kernel_factory.h" +#include "cce/aicpu_engine_struct.h" namespace { const uint8_t kL2LoadToDdr = 1; @@ -958,12 +959,40 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) { if (ext_info.empty()) { return SUCCESS; } + + std::unique_ptr copy_ext_info; + copy_ext_info.reset(new(std::nothrow)uint8_t[ext_info.size()]); + GE_CHECK_NOTNULL(copy_ext_info); + auto sec_ret = memcpy_s(copy_ext_info.get(), ext_info.size(), ext_info.c_str(), ext_info.size()); + if (sec_ret != EOK) { + GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); + return FAILED; + } + + auto ext_info_data = copy_ext_info.get(); + size_t offset = 0; + while (offset + sizeof(aicpu::FWKAdapter::ExtInfo) <= ext_info.size()) { + auto aicpu_ext_info = reinterpret_cast(ext_info_data + offset); + GELOGD("Ext infoType=%d, infoLen=%u.", aicpu_ext_info->infoType, aicpu_ext_info->infoLen); + if (aicpu_ext_info->infoType == aicpu::FWKAdapter::FWK_ADPT_EXT_SESSION_INFO) { + GE_CHK_BOOL_RET_STATUS(aicpu_ext_info->infoLen == sizeof(SessionInfo), PARAM_INVALID, + "Parse ext session info failed as infoLen must be %zu but %u.", + sizeof(SessionInfo), aicpu_ext_info->infoLen); + SessionInfo *session_info = reinterpret_cast(aicpu_ext_info->infoMsg); + session_info->sessionId = davinci_model_->GetSessionId(); + session_info->sessFlag = true; + GELOGD("Update aicpu_task ext_info session_info session_id is %lu", session_info->sessionId); + } + offset += sizeof(aicpu::FWKAdapter::ExtInfo); + offset += aicpu_ext_info->infoLen; + } + auto rt_ret = rtMalloc(&aicpu_ext_info_addr_, ext_info.size(), RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "rtMalloc ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size()); return RT_ERROR_TO_GE_STATUS(rt_ret); } - rt_ret = rtMemcpy(aicpu_ext_info_addr_, ext_info.size(), ext_info.c_str(), ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE); + rt_ret = rtMemcpy(aicpu_ext_info_addr_, ext_info.size(), ext_info_data, ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "rtMemcpy ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size()); return RT_ERROR_TO_GE_STATUS(rt_ret); diff --git a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc index 3974e29b..d7837144 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc +++ b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc @@ -57,6 +57,9 @@ Status AicpuExtInfoHandler::Parse(const std::string &ext_info) { case aicpu::FWKAdapter::FWK_ADPT_EXT_OUTPUT_SHAPE: GE_CHK_STATUS_RET(ParseExtOutputShape(aicpu_ext_info), "Parse ext output shape failed."); break; + case aicpu::FWKAdapter::FWK_ADPT_EXT_SESSION_INFO: + GE_CHK_STATUS_RET(ParseExtSessionInfo(aicpu_ext_info), "Parse ext session info failed."); + break; default: GELOGD("Node[%s] ignore infoType=%d, infoLen=%u.", node_name_.c_str(), aicpu_ext_info->infoType, aicpu_ext_info->infoLen); @@ -123,6 +126,39 @@ Status AicpuExtInfoHandler::ParseExtOutputShape(AicpuExtInfo *aicpu_ext_info) { return SUCCESS; } +Status AicpuExtInfoHandler::ParseExtSessionInfo(AicpuExtInfo *aicpu_ext_info) { + GE_CHK_BOOL_RET_STATUS(aicpu_ext_info->infoLen == sizeof(AicpuSessionInfo), PARAM_INVALID, + "Node[%s] parse ext session info failed as infoLen must be %zu but %u.", + node_name_.c_str(), sizeof(SessionInfo), aicpu_ext_info->infoLen); + + session_info_ = reinterpret_cast(aicpu_ext_info->infoMsg); + GELOGI("Node[%s] parse session info success infoLen=%u.", node_name_.c_str(), aicpu_ext_info->infoLen); + return SUCCESS; +} + +Status AicpuExtInfoHandler::UpdateSessionInfo(uint64_t session_id, uint64_t kernel_id, bool sess_flag) { + if (session_info_ == nullptr) { + GELOGD("There is no session info in ext_info, no need update."); + return SUCCESS; + } + + session_info_->sessionId = session_id; + session_info_->kernelId = kernel_id; + session_info_->sessFlag = sess_flag; + return SUCCESS; +} + +Status AicpuExtInfoHandler::UpdateSessionInfoSessionId(uint64_t session_id) { + if (session_info_ == nullptr) { + GELOGD("There is no session info in ext_info, no need update."); + return SUCCESS; + } + + session_info_->sessionId = session_id; + session_info_->sessFlag = true; + return SUCCESS; +} + Status AicpuExtInfoHandler::UpdateInputShapeAndType(uint32_t input_index, const GeTensorDesc &input_desc) { GE_CHECK_LE(input_index, input_num_); const auto &shape = input_desc.GetShape(); diff --git a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h index 9c867cdc..2defba8f 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h +++ b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h @@ -19,6 +19,7 @@ #include "external/ge/ge_api_error_codes.h" #include "cce/fwk_adpt_struct.h" +#include "cce/aicpu_engine_struct.h" #include "graph/op_desc.h" #include "graph/ge_tensor.h" @@ -26,6 +27,7 @@ namespace ge { namespace hybrid { using AicpuShapeAndType = aicpu::FWKAdapter::ShapeAndType; using AicpuExtInfo = aicpu::FWKAdapter::ExtInfo; +using AicpuSessionInfo = SessionInfo; class AicpuExtInfoHandler { public: @@ -51,6 +53,10 @@ class AicpuExtInfoHandler { Status UpdateOutputShapeAndType(uint32_t output_index, const GeTensorDesc &output_desc); + Status UpdateSessionInfo(uint64_t session_id, uint64_t kernel_id, bool sess_flag); + + Status UpdateSessionInfoSessionId(uint64_t session_id); + Status GetOutputShapeAndType(uint32_t output_index, GeShape &shape, DataType &data_type); private: @@ -58,6 +64,7 @@ class AicpuExtInfoHandler { Status ParseExtShapeType(AicpuExtInfo *aicpu_ext_info); Status ParseExtInputShape(AicpuExtInfo *aicpu_ext_info); Status ParseExtOutputShape(AicpuExtInfo *aicpu_ext_info); + Status ParseExtSessionInfo(AicpuExtInfo *aicpu_ext_info); static Status UpdateShapeAndType(const GeShape &shape, DataType data_type, @@ -72,6 +79,7 @@ class AicpuExtInfoHandler { const uint32_t input_num_; const uint32_t output_num_; UnknowShapeOpType unknown_type_; + AicpuSessionInfo *session_info_ = nullptr; std::unique_ptr ext_info_; size_t ext_info_len_ = 0; diff --git a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc index 61af55dd..d921c57c 100755 --- a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc +++ b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc @@ -40,29 +40,36 @@ Status AicpuNodeTaskBase::AllocTensorBuffer(size_t size, std::unique_ptris_dynamic) { - // dynamic node must have ext info - GE_CHK_STATUS_RET(aicpu_ext_handle_.Parse(kernel_ext_info), - "Node[%s] parse kernel ext info failed, kernel_ext_info_size=%zu.", - node_name_.c_str(), kernel_ext_info.size()); - } - - // if no ext info no need copy to device. +Status AicpuNodeTaskBase::InitExtInfo(const std::string &kernel_ext_info, int64_t session_id) { if (kernel_ext_info.empty()) { - GELOGI("Node[%s] kernel_ext_info is empty, no need copy to device, is_dynamic=%s.", - node_name_.c_str(), node_item_->is_dynamic ? "true" : "false"); - return SUCCESS; + if (node_item_->is_dynamic) { + // dynamic node must have ext info + GELOGE(PARAM_INVALID, "Node[%s] parse ext info failed as ext info is empty.", node_name_.c_str()); + return PARAM_INVALID; + } else { + // if no ext info no need copy to device. + GELOGI("Node[%s] kernel_ext_info is empty, no need copy to device, is_dynamic=%s.", + node_name_.c_str(), node_item_->is_dynamic ? "true" : "false"); + return SUCCESS; + } } + GE_CHK_STATUS_RET(aicpu_ext_handle_.Parse(kernel_ext_info), + "Node[%s] parse kernel ext info failed, kernel_ext_info_size=%zu.", + node_name_.c_str(), kernel_ext_info.size()); + GELOGD("To update aicpu_task ext_info session_info session_id to %lu", session_id); + GE_CHK_STATUS_RET(aicpu_ext_handle_.UpdateSessionInfoSessionId(session_id), + "UpdateSessionInfoSessionId failed."); + // copy task args buf - GE_CHK_STATUS_RET(AllocTensorBuffer(kernel_ext_info.size(), ext_info_addr_dev_), + GE_CHK_STATUS_RET(AllocTensorBuffer(aicpu_ext_handle_.GetExtInfoLen(), ext_info_addr_dev_), "Node[%s] alloc kernel_ext_info buf failed, size=%zu", - node_name_.c_str(), kernel_ext_info.size()); + node_name_.c_str(), aicpu_ext_handle_.GetExtInfoLen()); // copy default ext info to device GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_->GetData(), ext_info_addr_dev_->GetSize(), - kernel_ext_info.data(), kernel_ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE)); + aicpu_ext_handle_.GetExtInfo(), aicpu_ext_handle_.GetExtInfoLen(), + RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } @@ -290,7 +297,8 @@ Status AicpuTfNodeTask::Init(const HybridModel &model) { node_name_.c_str(), kernel_ext_info.size(), kernel_ext_info_size); // init ext info - GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info), "Node[%s] init ext info failed.", node_name_.c_str()); + uint64_t ext_session_id = model.GetSessionId(); + GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info, ext_session_id), "Node[%s] init ext info failed.", node_name_.c_str()); GE_CHK_STATUS_RET(InitForDependComputeTask(), "Node[%s] init for depend compute task failed.", node_name_.c_str()); // build fwk_op_kernel. @@ -679,7 +687,8 @@ Status AicpuNodeTask::Init(const HybridModel &model) { "Node[%s] task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", node_name.c_str(), kernel_ext_info.size(), kernel_ext_info_size); - GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info), "Node[%s] init ext info failed.", node_name.c_str()); + uint64_t ext_session_id = model.GetSessionId(); + GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info, ext_session_id), "Node[%s] init ext info failed.", node_name.c_str()); if (ext_info_addr_dev_ == nullptr) { aicpu_param_head->extInfoLength = 0; diff --git a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h index 7caabd66..b984cc86 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h +++ b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h @@ -43,7 +43,7 @@ class AicpuNodeTaskBase : public NodeTask { Status ExecuteAsync(TaskContext &context, std::function done_callback) override; protected: - virtual Status InitExtInfo(const std::string &kernel_ext_info); + virtual Status InitExtInfo(const std::string &kernel_ext_info, int64_t session_id); virtual Status UpdateExtInfo(); diff --git a/ge/single_op/single_op.cc b/ge/single_op/single_op.cc index 7a199eac..371d7110 100755 --- a/ge/single_op/single_op.cc +++ b/ge/single_op/single_op.cc @@ -44,8 +44,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY SingleOp::~SingleOp() { delete task; task = nullptr; } - GELOGI("SingleOp destory sessionId = %lu", aicpu_session_id_); - ModelManager::GetInstance()->DestroyAicpuSession(aicpu_session_id_); } Status SingleOp::ValidateArgs(const std::vector &inputs, const std::vector &outputs) { @@ -180,17 +178,11 @@ void SingleOp::SetStream(rtStream_t stream) { stream_ = stream; } -void SingleOp::SetSessionID(uint64_t session_id) { - aicpu_session_id_ = session_id; -} - DynamicSingleOp::DynamicSingleOp(uintptr_t resource_id, std::mutex *stream_mutex, rtStream_t stream) : resource_id_(resource_id), stream_mutex_(stream_mutex), stream_(stream) { } DynamicSingleOp::~DynamicSingleOp() { - GELOGI("DynamicSingleOp destory sessionId = %lu", aicpu_session_id_); - ModelManager::GetInstance()->DestroyAicpuSession(aicpu_session_id_); } Status DynamicSingleOp::ValidateParams(const vector &input_desc, @@ -299,8 +291,4 @@ Status DynamicSingleOp::ExecuteAsync(const vector &input_desc, return ACL_ERROR_GE_OP_TASK_TYPE_INVALID; } } - -void DynamicSingleOp::SetSessionID(uint64_t session_id) { - aicpu_session_id_ = session_id; -} } // namespace ge diff --git a/ge/single_op/single_op.h b/ge/single_op/single_op.h index bd671017..14ef8ce1 100755 --- a/ge/single_op/single_op.h +++ b/ge/single_op/single_op.h @@ -37,7 +37,6 @@ class SingleOp { Status ExecuteAsync(const std::vector &inputs, const std::vector &outputs); void SetStream(rtStream_t stream); - void SetSessionID(uint64_t session_id); private: Status ValidateArgs(const std::vector &inputs, const std::vector &outputs); @@ -52,7 +51,6 @@ class SingleOp { std::vector output_addr_list_; std::vector output_sizes_; std::vector args_; - uint64_t aicpu_session_id_ = 0; std::vector tasks_; std::vector> arg_table_; @@ -66,7 +64,6 @@ class DynamicSingleOp { const std::vector &inputs, std::vector &output_desc, std::vector &outputs); - void SetSessionID(uint64_t session_id); private: friend class SingleOpModel; @@ -89,7 +86,6 @@ class DynamicSingleOp { rtStream_t stream_ = nullptr; size_t num_inputs_ = 0; size_t num_outputs_ = 0; - uint64_t aicpu_session_id_ = 0; }; } // namespace ge #endif // GE_SINGLE_OP_SINGLE_OP_H_ diff --git a/ge/single_op/single_op_model.cc b/ge/single_op/single_op_model.cc index 65eb58be..49968f4f 100755 --- a/ge/single_op/single_op_model.cc +++ b/ge/single_op/single_op_model.cc @@ -32,7 +32,7 @@ #include "task/aicpu_kernel_task_builder.h" #include "task/tbe_task_builder.h" -static std::atomic aicpu_sessionid(0); +static std::atomic aicpu_kernel_id(0); using domi::TaskDef; using std::unique_ptr; @@ -252,7 +252,9 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) { } else if (kernel_type == cce::ccKernelType::AI_CPU || kernel_type == cce::ccKernelType::CUST_AI_CPU) { GELOGD("Building AICPU_CC task"); OpTask *task = nullptr; - auto ret = BuildCpuKernelTask(task_def.kernel(), &task); + uint64_t singleop_kernel_id = aicpu_kernel_id++; + GELOGI("Build singleOp CCTask, kernel_id = %lu", singleop_kernel_id); + auto ret = BuildCpuKernelTask(task_def.kernel(), &task, singleop_kernel_id); if (ret != SUCCESS) { return ret; } @@ -265,14 +267,13 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) { GELOGD("Building AICPU_TF task"); AiCpuTask *aicpu_task = nullptr; bool depend_compute_flag = false; - uint64_t singleop_sessionid = aicpu_sessionid++; - GELOGI("Build singleOp, sessionId = %lu", singleop_sessionid); - auto ret = BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, false, depend_compute_flag, singleop_sessionid); + uint64_t singleop_kernel_id = aicpu_kernel_id++; + GELOGI("Build singleOp TfTask, kernel_id = %lu", singleop_kernel_id); + auto ret = BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, false, depend_compute_flag, singleop_kernel_id); if (ret != SUCCESS) { return ret; } single_op.tasks_.emplace_back(aicpu_task); - single_op.SetSessionID(singleop_sessionid); } else { // skip GELOGD("Skip task type: %d", static_cast(task_type)); @@ -329,7 +330,7 @@ Status SingleOpModel::BuildKernelTask(const domi::KernelDef &kernel_def, TbeOpTa } Status SingleOpModel::BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task, - bool dynamic_flag, bool& depend_compute_flag, uint64_t session_id) { + bool dynamic_flag, bool& depend_compute_flag, uint64_t kernel_id) { auto iter = op_list_.find(kernel_def.op_index()); if (iter == op_list_.end()) { GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "op desc not found. op index = %u", kernel_def.op_index()); @@ -342,7 +343,7 @@ Status SingleOpModel::BuildKernelExTask(const domi::KernelExDef &kernel_def, AiC return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto builder = AiCpuTaskBuilder(iter->second->GetOpDesc(), kernel_def); - auto ret = builder.BuildTask(*aicpu_task, model_params_, dynamic_flag, session_id); + auto ret = builder.BuildTask(*aicpu_task, model_params_, dynamic_flag, kernel_id); if (ret != SUCCESS) { GELOGE(ret, "build aicpu_TF op task failed"); return ret; @@ -353,7 +354,7 @@ Status SingleOpModel::BuildKernelExTask(const domi::KernelExDef &kernel_def, AiC return SUCCESS; } -Status SingleOpModel::BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTask **task) { +Status SingleOpModel::BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTask **task, uint64_t kernel_id) { const auto &context = kernel_def.context(); auto iter = op_list_.find(context.op_index()); if (iter == op_list_.end()) { @@ -367,7 +368,7 @@ Status SingleOpModel::BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTa } auto builder = AiCpuCCTaskBuilder(iter->second->GetOpDesc(), kernel_def); - auto ret = builder.BuildTask(*aicpucc_task); + auto ret = builder.BuildTask(*aicpucc_task, kernel_id); if (ret != SUCCESS) { GELOGE(ret, "build aicpu_CC op task failed"); return ret; @@ -396,7 +397,9 @@ Status SingleOpModel::BuildModelTaskKernel(const TaskDef &task_def, DynamicSingl } else if (kernel_type == cce::ccKernelType::AI_CPU || kernel_type == cce::ccKernelType::CUST_AI_CPU) { GELOGD("Building AICPU_CC task"); OpTask *task = nullptr; - GE_CHK_STATUS_RET_NOLOG(BuildCpuKernelTask(task_def.kernel(), &task)); + uint64_t dynamic_singleop_kernel_id = aicpu_kernel_id++; + GELOGI("Build dynamic singleOp CCTask, kernel_id = %lu", dynamic_singleop_kernel_id); + GE_CHK_STATUS_RET_NOLOG(BuildCpuKernelTask(task_def.kernel(), &task, dynamic_singleop_kernel_id)); single_op.op_task_.reset(task); } else { GELOGE(ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID, @@ -430,10 +433,10 @@ Status SingleOpModel::BuildTaskListForDynamicOp(DynamicSingleOp &single_op) { GELOGD("Building AICPU_TF task"); AiCpuTask *aicpu_task = nullptr; bool depend_compute_flag = false; - uint64_t dynamic_singleop_sessionid = aicpu_sessionid++; - GELOGI("Build dynamic singleOp, sessionId = %lu", dynamic_singleop_sessionid); + uint64_t dynamic_singleop_kernel_id = aicpu_kernel_id++; + GELOGI("Build dynamic singleOp TfTask, kernel_id = %lu", dynamic_singleop_kernel_id); GE_CHK_STATUS_RET_NOLOG(BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, true, - depend_compute_flag, dynamic_singleop_sessionid)); + depend_compute_flag, dynamic_singleop_kernel_id)); if (depend_compute_flag) { if (i >= tasks.size() - 1) { GELOGE(ACL_ERROR_GE_PARAM_INVALID, "The copy task of the fourth operator was not found."); @@ -444,7 +447,6 @@ Status SingleOpModel::BuildTaskListForDynamicOp(DynamicSingleOp &single_op) { GE_CHK_STATUS_RET_NOLOG(aicpu_task->SetMemCopyTask(copy_task_def.kernel_ex())); } single_op.op_task_.reset(aicpu_task); - single_op.SetSessionID(dynamic_singleop_sessionid); } else { // skip GELOGD("Skip task type: %d", static_cast(task_type)); diff --git a/ge/single_op/single_op_model.h b/ge/single_op/single_op_model.h index 2e6b37dc..50aeb7ab 100755 --- a/ge/single_op/single_op_model.h +++ b/ge/single_op/single_op_model.h @@ -69,8 +69,8 @@ class SingleOpModel { Status BuildTaskListForDynamicOp(DynamicSingleOp &dynamic_single_op); Status BuildKernelTask(const domi::KernelDef &kernel_def, TbeOpTask **task); Status BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task, - bool dynamic_flag, bool& depend_compute_flag, uint64_t session_id); - Status BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTask **task); + bool dynamic_flag, bool& depend_compute_flag, uint64_t kernel_id); + Status BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTask **task, uint64_t kernel_id); Status BuildModelTaskKernel(const domi::TaskDef &task_def, DynamicSingleOp &single_op); static void ParseOpModelParams(ModelHelper &model_helper, SingleOpModelParam ¶m); diff --git a/ge/single_op/task/aicpu_kernel_task_builder.cc b/ge/single_op/task/aicpu_kernel_task_builder.cc index 8e140a6f..26f6a166 100755 --- a/ge/single_op/task/aicpu_kernel_task_builder.cc +++ b/ge/single_op/task/aicpu_kernel_task_builder.cc @@ -46,7 +46,7 @@ Status AiCpuCCTaskBuilder::SetKernelArgs(AiCpuCCTask &task) { return SUCCESS; } -Status AiCpuCCTaskBuilder::BuildTask(AiCpuCCTask &task) { +Status AiCpuCCTaskBuilder::BuildTask(AiCpuCCTask &task, uint64_t kernel_id) { auto ret = SetKernelArgs(task); if (ret != SUCCESS) { return ret; @@ -76,7 +76,7 @@ Status AiCpuCCTaskBuilder::BuildTask(AiCpuCCTask &task) { "task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", kernel_ext_info.size(), kernel_ext_info_size); - ret = task.SetExtInfoAndType(kernel_ext_info); + ret = task.SetExtInfoAndType(kernel_ext_info, kernel_id); if (ret != SUCCESS) { GELOGE(ret, "Init ext info failed."); return ret; diff --git a/ge/single_op/task/aicpu_kernel_task_builder.h b/ge/single_op/task/aicpu_kernel_task_builder.h index f9ca0530..e77e3c10 100755 --- a/ge/single_op/task/aicpu_kernel_task_builder.h +++ b/ge/single_op/task/aicpu_kernel_task_builder.h @@ -30,7 +30,7 @@ class AiCpuCCTaskBuilder { explicit AiCpuCCTaskBuilder(const OpDescPtr &op_desc, const domi::KernelDef &kernel_def); ~AiCpuCCTaskBuilder() = default; - Status BuildTask(AiCpuCCTask &task); + Status BuildTask(AiCpuCCTask &task, uint64_t kernel_id); private: Status SetKernelArgs(AiCpuCCTask &task); diff --git a/ge/single_op/task/aicpu_task_builder.cc b/ge/single_op/task/aicpu_task_builder.cc index 468fee86..d91bba17 100755 --- a/ge/single_op/task/aicpu_task_builder.cc +++ b/ge/single_op/task/aicpu_task_builder.cc @@ -111,7 +111,7 @@ namespace ge { } Status AiCpuTaskBuilder::BuildTask(ge::AiCpuTask &task, const SingleOpModelParam ¶m, - bool dynamic_flag, uint64_t session_id) { + bool dynamic_flag, uint64_t kernel_id) { GE_CHK_STATUS_RET_NOLOG(InitWorkspaceAndIO(&task.io_addr_, &task.workspace_addr_, param, dynamic_flag)); STR_FWK_OP_KERNEL fwk_op_kernel = {0}; @@ -130,7 +130,7 @@ namespace ge { GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, "task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", kernel_ext_info.size(), kernel_ext_info_size); - GE_CHK_STATUS_RET(task.SetExtInfoAndType(kernel_ext_info), "Init ext info failed."); + GE_CHK_STATUS_RET(task.SetExtInfoAndType(kernel_ext_info, kernel_id), "Init ext info failed."); if (task.ext_info_addr_dev_ != nullptr) { fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoAddr = reinterpret_cast(task.ext_info_addr_dev_); @@ -138,13 +138,9 @@ namespace ge { } GE_CHK_STATUS_RET(task.InitForSummaryAndCopy(), "AiCpuTask init for summary and copy task failed."); - // Create session - fwk_op_kernel.fwkKernelBase.fwk_kernel.sessionID = session_id; - GELOGI("Begin to CreateAicpuSession, session id: %lu", session_id); - GE_CHECK_NOTNULL(ModelManager::GetInstance()); - GE_IF_BOOL_EXEC(ModelManager::GetInstance()->CreateAicpuSession(session_id) != SUCCESS, - GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "CreateAicpuSession error. session id: %lu", session_id); - return ACL_ERROR_GE_INTERNAL_ERROR;) + fwk_op_kernel.fwkKernelBase.fwk_kernel.sessionID = ULLONG_MAX; + fwk_op_kernel.fwkKernelBase.fwk_kernel.kernelID = kernel_id; + fwk_op_kernel.fwkKernelBase.fwk_kernel.opType = aicpu::FWKAdapter::FWKOperateType::FWK_ADPT_KERNEL_RUN_NO_SESS; ret = SetKernelArgs(&task.args_, fwk_op_kernel); if (ret != SUCCESS) { return ret; diff --git a/ge/single_op/task/aicpu_task_builder.h b/ge/single_op/task/aicpu_task_builder.h index 6dcd7a0f..4669e118 100755 --- a/ge/single_op/task/aicpu_task_builder.h +++ b/ge/single_op/task/aicpu_task_builder.h @@ -29,7 +29,7 @@ namespace ge { AiCpuTaskBuilder(const OpDescPtr &op_desc, const domi::KernelExDef &kernel_def); ~AiCpuTaskBuilder() = default; - Status BuildTask(AiCpuTask &task, const SingleOpModelParam ¶m, bool dynamic_flag, uint64_t session_id); + Status BuildTask(AiCpuTask &task, const SingleOpModelParam ¶m, bool dynamic_flag, uint64_t kernel_id); private: static Status SetKernelArgs(void **args, STR_FWK_OP_KERNEL &kernel); diff --git a/ge/single_op/task/op_task.cc b/ge/single_op/task/op_task.cc index 30d4d311..1b4b23ff 100755 --- a/ge/single_op/task/op_task.cc +++ b/ge/single_op/task/op_task.cc @@ -245,7 +245,7 @@ AiCpuBaseTask::~AiCpuBaseTask() { } } -Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info) { +Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info, uint64_t kernel_id) { if (kernel_ext_info.empty()) { GELOGI("Kernel_ext_info is empty, no need copy to device."); return SUCCESS; @@ -268,9 +268,13 @@ Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info) { return ret; } - GE_CHK_RT_RET(rtMalloc(&ext_info_addr_dev_, kernel_ext_info.size(), RT_MEMORY_HBM)); - GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, kernel_ext_info.size(), - kernel_ext_info.data(), kernel_ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_STATUS_RET(aicpu_ext_handle_->UpdateSessionInfo(ULLONG_MAX, kernel_id, false), + "UpdateSessionInfo failed."); + + GE_CHK_RT_RET(rtMalloc(&ext_info_addr_dev_, aicpu_ext_handle_->GetExtInfoLen(), RT_MEMORY_HBM)); + GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, aicpu_ext_handle_->GetExtInfoLen(), + aicpu_ext_handle_->GetExtInfo(), aicpu_ext_handle_->GetExtInfoLen(), + RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } diff --git a/ge/single_op/task/op_task.h b/ge/single_op/task/op_task.h index 1b4d9c02..bf8316f6 100644 --- a/ge/single_op/task/op_task.h +++ b/ge/single_op/task/op_task.h @@ -132,7 +132,7 @@ class AiCpuBaseTask : public OpTask { const UnknowShapeOpType GetUnknownType() const { return unknown_type_; } protected: - Status SetExtInfoAndType(const std::string &kernel_ext_info); + Status SetExtInfoAndType(const std::string &kernel_ext_info, uint64_t kernel_id); Status UpdateExtInfo(const std::vector &input_desc, std::vector &output_desc, From 77f6792ee91182bc10dc2c0b96c1a2970fb59aae Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 Nov 2020 23:44:45 +0800 Subject: [PATCH 16/32] add metadef. --- metadef | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadef b/metadef index a464149d..89590b34 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit a464149d95257e7514859b198444fb341dc40786 +Subproject commit 89590b3405f6c5714997c07f81470764ac66635b From f4cedd32d7b26709185bb1593e0bdc63e7d62dea Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Nov 2020 00:32:08 +0800 Subject: [PATCH 17/32] add head file. --- third_party/fwkacllib/inc/cce/aicpu_engine_struct.h | 6 ++++++ third_party/fwkacllib/inc/cce/fwk_adpt_struct.h | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/third_party/fwkacllib/inc/cce/aicpu_engine_struct.h b/third_party/fwkacllib/inc/cce/aicpu_engine_struct.h index d61c981d..a5f43be9 100644 --- a/third_party/fwkacllib/inc/cce/aicpu_engine_struct.h +++ b/third_party/fwkacllib/inc/cce/aicpu_engine_struct.h @@ -40,6 +40,12 @@ typedef struct { } fwkKernelBase; } __attribute__((packed)) STR_FWK_OP_KERNEL; +struct SessionInfo { + uint64_t sessionId; + uint64_t kernelId; + bool sessFlag; +} __attribute__((packed)); + #ifdef __cplusplus } #endif diff --git a/third_party/fwkacllib/inc/cce/fwk_adpt_struct.h b/third_party/fwkacllib/inc/cce/fwk_adpt_struct.h index 957117cc..79d94023 100644 --- a/third_party/fwkacllib/inc/cce/fwk_adpt_struct.h +++ b/third_party/fwkacllib/inc/cce/fwk_adpt_struct.h @@ -48,7 +48,8 @@ enum FWKOperateType { FWK_ADPT_KERNEL_RUN, FWK_ADPT_KERNEL_DESTROY, FWK_ADPT_SESSION_DESTROY, - FWK_ADPT_SINGLE_OP_RUN + FWK_ADPT_SINGLE_OP_RUN, + FWK_ADPT_KERNEL_RUN_NO_SESS, }; // Extend Info type for task @@ -58,6 +59,7 @@ enum FWKTaskExtInfoType { FWK_ADPT_EXT_OUTPUT_SHAPE, FWK_ADPT_EXT_UPDATE_ADDR, FWK_ADPT_EXT_OP_NAME, + FWK_ADPT_EXT_SESSION_INFO, FWK_ADPT_EXT_INVALID }; From 15763e5f3956b26c340a965528fbf58372fc4813 Mon Sep 17 00:00:00 2001 From: zhou_lili Date: Wed, 25 Nov 2020 09:20:31 +0800 Subject: [PATCH 18/32] fix some bug find by zhouli --- .../load/new_model_manager/davinci_model.cc | 40 +++++++++++-------- .../load/new_model_manager/model_manager.cc | 18 ++++++--- .../load/new_model_manager/model_manager.h | 1 - ge/graph/manager/graph_manager.cc | 14 ++++--- ge/graph/preprocess/multi_batch_copy_graph.cc | 7 ++-- ge/graph/preprocess/multi_batch_options.cc | 6 +++ 6 files changed, 54 insertions(+), 32 deletions(-) diff --git a/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc index b6db50a7..f15c0c5f 100755 --- a/ge/graph/load/new_model_manager/davinci_model.cc +++ b/ge/graph/load/new_model_manager/davinci_model.cc @@ -2556,8 +2556,10 @@ Status DavinciModel::CopyOutputData(uint32_t data_id, OutputData &output_data, r int64_t data_size = output.second.GetDataSize(); if (is_online_infer_dynamic_) { - auto gear_and_real_out_size_info = merge_nodes_gear_and_real_out_size_info_[idx]; - data_size = gear_and_real_out_size_info[cur_dynamic_dims_]; + if (merge_nodes_gear_and_real_out_size_info_.find(idx) != merge_nodes_gear_and_real_out_size_info_.end()) { + auto gear_and_real_out_size_info = merge_nodes_gear_and_real_out_size_info_[idx]; + data_size = gear_and_real_out_size_info[cur_dynamic_dims_]; + } } uint64_t buffer_length = buffer.length; void *buffer_addr = reinterpret_cast(reinterpret_cast(buffer.data)); @@ -2594,11 +2596,13 @@ Status DavinciModel::GenOutputTensorInfo(const OpDescPtr &op_desc, uint32_t data return ret); std::vector output_shape = input_desc->GetShape().GetDims(); if (is_online_infer_dynamic_) { - auto gear_and_real_out_size_info = merge_nodes_gear_and_real_out_size_info_[i]; - size = gear_and_real_out_size_info[cur_dynamic_dims_]; - auto gear_and_real_out_shape_info = merge_nodes_gear_and_real_out_shape_info_[i]; - output_shape = gear_and_real_out_shape_info[cur_dynamic_dims_]; - is_dynamic_ = true; + if (merge_nodes_gear_and_real_out_size_info_.find(i) != merge_nodes_gear_and_real_out_size_info_.end()) { + auto gear_and_real_out_size_info = merge_nodes_gear_and_real_out_size_info_[i]; + size = gear_and_real_out_size_info[cur_dynamic_dims_]; + auto gear_and_real_out_shape_info = merge_nodes_gear_and_real_out_shape_info_[i]; + output_shape = gear_and_real_out_shape_info[cur_dynamic_dims_]; + is_dynamic_ = true; + } } GELOGI("Output size is %ld, output shape is %s.", size, formats::JoinToString(output_shape).c_str()); out_buffer_size_vec.push_back(size); @@ -2755,16 +2759,6 @@ void *DavinciModel::Run(DavinciModel *model) { InputData current_data = data_wrapper->GetInput(); GELOGI("Model thread Run begin, model id:%u, data index:%u.", model_id, current_data.index); - if (model->is_online_infer_dynamic_ && !model->is_getnext_sink_dynamic_) { - model->cur_dynamic_dims_.clear(); - GE_IF_BOOL_EXEC(current_data.blobs.empty(), break); - auto shape_data_buffer_data = current_data.blobs.back().data; - auto shape_data_buffer_length = current_data.blobs.back().length; - model->cur_dynamic_dims_.assign(reinterpret_cast(shape_data_buffer_data), - reinterpret_cast(shape_data_buffer_data) + - shape_data_buffer_length / sizeof(int64_t)); - GELOGD("Data: cur dynamic dims is %s", formats::JoinToString(model->cur_dynamic_dims_).c_str()); - } GE_TIMESTAMP_START(Model_SyncVarData); ret = model->SyncVarData(); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( @@ -2781,6 +2775,18 @@ void *DavinciModel::Run(DavinciModel *model) { ret != SUCCESS, (void)model->ReturnResult(current_data.index, false, false, data_wrapper->GetOutput()); CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); continue, "Copy input data to model failed."); // [No need to check value] + if (model->is_online_infer_dynamic_ && !model->is_getnext_sink_dynamic_) { + model->cur_dynamic_dims_.clear(); + GE_IF_BOOL_EXEC(current_data.blobs.empty(), break); + auto shape_data_buffer_data = current_data.blobs.back().data; + auto shape_data_buffer_length = current_data.blobs.back().length; + model->cur_dynamic_dims_.assign(reinterpret_cast(shape_data_buffer_data), + reinterpret_cast(shape_data_buffer_data) + + shape_data_buffer_length / sizeof(int64_t)); + GELOGD("Data: cur dynamic dims is %s", formats::JoinToString(model->cur_dynamic_dims_).c_str()); + delete[] (int64_t *)current_data.blobs.back().data; + current_data.blobs.pop_back(); + } GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), model->SetProfileTime(MODEL_PRE_PROC_END)); GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), model->SetProfileTime(MODEL_INFER_START)); if (ProfilingManager::Instance().ProfilingOpTraceOn()) { diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc index e4e0681d..3ebd1daf 100755 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -407,10 +407,6 @@ Status ModelManager::Unload(uint32_t model_id) { } std::lock_guard lock(exeception_infos_mutex_); exception_infos_.clear(); - for (auto addr : shape_data_addrs_[model_id]) { - delete[] addr; - } - shape_data_addrs_.erase(model_id); return SUCCESS; } @@ -475,6 +471,19 @@ Status ModelManager::GetCurDynamicDims(const vector> &user_real_ } } GELOGD("Cur dynamic dims is %s.", formats::JoinToString(cur_dynamic_dims).c_str()); + bool cur_dynamic_dims_valid = false; + std::vector shape_strs = ge::StringUtils::Split(GetLocalOmgContext().dynamic_dims, ';'); + for (auto dynamic_dim : shape_strs) { + if (dynamic_dim == formats::JoinToString(cur_dynamic_dims)) { + cur_dynamic_dims_valid = true; + break; + } + } + if (!cur_dynamic_dims_valid) { + GELOGE(INTERNAL_ERROR, "Cur dynamic dims is %s, not exist in options.", + formats::JoinToString(cur_dynamic_dims).c_str()); + return INTERNAL_ERROR; + } return SUCCESS; } @@ -517,7 +526,6 @@ Status ModelManager::DataInputTensor(uint32_t model_id, const std::vector(data.data)); } } diff --git a/ge/graph/load/new_model_manager/model_manager.h b/ge/graph/load/new_model_manager/model_manager.h index ff2e3030..b2bb4564 100755 --- a/ge/graph/load/new_model_manager/model_manager.h +++ b/ge/graph/load/new_model_manager/model_manager.h @@ -363,7 +363,6 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { std::map> cust_aicpu_so_; static DumpProperties dump_properties_; - std::map> shape_data_addrs_; }; } // namespace ge diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index 654bea16..0b6f6d8a 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -2866,13 +2866,15 @@ void GraphManager::RunThread(GraphManager *graph_manager) { if (args.graph_node->graph_run_async_listener_ != nullptr) { args.graph_node->graph_run_async_listener_->SetCallback(args.callback); } + Status ret; // parse inputs.dims to vector> dynamic_dims - if (graph_manager->ParseInputsDims(args.input_tensor) != SUCCESS) { - GELOGE(PARAM_INVALID, "Parse input dims failed."); + ret = graph_manager->ParseInputsDims(args.input_tensor); + if (ret != SUCCESS) { + ReturnError(graph_manager, args.callback, ret, "ParseInputsDims failed, thread exit."); + args.graph_node->Unlock(); return; } - Status ret; if (!args.graph_node->GetLoadFlag()) { ret = graph_manager->LoadGraphAsync(args.ge_root_model, args.graph_node); if (ret != SUCCESS || args.ge_root_model == nullptr) { @@ -2897,12 +2899,12 @@ void GraphManager::RunThread(GraphManager *graph_manager) { ret = graph_manager->graph_executor_.ExecuteGraphAsync(args.graph_id, args.graph_node->GetGeRootModel(), args.input_tensor); args.graph_node->SetRunFlag(false); - args.graph_node->Unlock(); if (ret != SUCCESS) { - GELOGE(ret, "[GraphManager] Run graph async failed, graph_id=%u.", args.graph_id); - StopQueue(graph_manager); + ReturnError(graph_manager, args.callback, ret, "ExecuteGraphAsync failed, thread exit."); + args.graph_node->Unlock(); return; } + args.graph_node->Unlock(); GELOGI("[GraphManager] Run graph async success, graph_id=%u.", args.graph_id); } } diff --git a/ge/graph/preprocess/multi_batch_copy_graph.cc b/ge/graph/preprocess/multi_batch_copy_graph.cc index c3647b93..9ab74d70 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.cc +++ b/ge/graph/preprocess/multi_batch_copy_graph.cc @@ -1571,6 +1571,10 @@ void GetDynamicShapeByMerge(const ComputeGraphPtr &graph, const NodePtr &node, // Connect NetOutput directly void GetDirectOutputShape(const ComputeGraphPtr &graph, const NodePtr &node, const set &dynamic_output_index, vector &dynamic_output_dims) { + if (!GetLocalOmgContext().dynamic_node_type.empty()) { + GELOGD("No need to get directly shape info of %s when train.", node->GetName().c_str()); + return; + } GELOGD("Try get directly shape info, Graph: %s, Node: %s", graph->GetName().c_str(), node->GetName().c_str()); const auto &netoutput_desc = node->GetOpDesc(); const auto &inputnode_to_netoutput = node->GetInAllNodes(); @@ -1578,9 +1582,6 @@ void GetDirectOutputShape(const ComputeGraphPtr &graph, const NodePtr &node, if (dynamic_output_index.count(i) > 0) { continue; } - if (inputnode_to_netoutput.at(i)->GetType() == GETDYNAMICDIMS) { - continue; - } auto tensor_desc = netoutput_desc->GetInputDesc(i); auto shape = tensor_desc.GetShape().ToString(); diff --git a/ge/graph/preprocess/multi_batch_options.cc b/ge/graph/preprocess/multi_batch_options.cc index c168e077..f33c2983 100644 --- a/ge/graph/preprocess/multi_batch_options.cc +++ b/ge/graph/preprocess/multi_batch_options.cc @@ -84,8 +84,10 @@ Status DistinguishGetNextAndData(ComputeGraphPtr &graph, vector &data_n if (op_desc->GetType() == DATA && op_desc->GetName() != kShapeDataName) { if (op_desc->GetName().find(kSubstrOfGetNextNosinkName) == string::npos) { data_nodes.emplace_back(input_node); + GELOGD("Name of data node is %s.", op_desc->GetName().c_str()); } else { getnext_nosink_nodes.emplace_back(input_node); + GELOGD("Name of getnext nosink is %s.", op_desc->GetName().c_str()); } } if (IsGetNextType(input_node)) { @@ -111,6 +113,8 @@ Status CheckSequenceOfData(ComputeGraphPtr &graph, const vector &data_n GE_CHECK_NOTNULL(data_node->GetOpDesc()); auto output_shape = data_node->GetOpDesc()->GetOutputDesc(0).GetShape().GetDims(); auto dynamic_dims = GetLocalOmgContext().user_input_dims.at(i).second; + GELOGD("The %zu data node is %s, node shape is %s, dynamic dim is %s.", i, data_node->GetName().c_str(), + formats::JoinToString(output_shape).c_str(), formats::JoinToString(dynamic_dims).c_str()); if (output_shape.empty() && dynamic_dims.size() == 1 && dynamic_dims.at(0) == 0) { GELOGI("No need to check sequence for constant."); continue; @@ -151,6 +155,8 @@ Status CheckSequenceOfGetnext(ComputeGraphPtr &graph, const vector &get for (size_t i = 0; i < data_count; ++i) { auto output_shape = data_node->GetOpDesc()->GetOutputDesc(i).GetShape().GetDims(); auto dynamic_dims = GetLocalOmgContext().user_input_dims.at(i).second; + GELOGD("The %zu getnext node is %s, node shape is %s, dynamic dim is %s.", i, data_node->GetName().c_str(), + formats::JoinToString(output_shape).c_str(), formats::JoinToString(dynamic_dims).c_str()); if (output_shape.empty() && dynamic_dims.size() == 1 && dynamic_dims.at(0) == 0) { GELOGI("No need to check sequence for constant."); continue; From bf3be54322381b9a674c220ddd98d9f580c87b5a Mon Sep 17 00:00:00 2001 From: yanghaoran Date: Tue, 24 Nov 2020 17:27:19 +0800 Subject: [PATCH 19/32] mindspore mode support static mmpa --- CMakeLists.txt | 2 +- ge/common/CMakeLists.txt | 2 +- metadef | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 936d85d7..4134678f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,10 +148,10 @@ elseif (ENABLE_D OR ENABLE_ACL) # common libraries find_module(slog libslog.so ${ASCEND_MS_DRIVER_PATH}) find_module(error_manager liberror_manager.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH}) + find_module(static_mmpa libmmpa.a ${ASCEND_MS_DRIVER_PATH}) if (ENABLE_D) # training - find_module(mmpa libmmpa.so ${ASCEND_MS_DRIVER_PATH}) find_module(runtime libruntime.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH}) find_module(register libregister.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH}) endif () diff --git a/ge/common/CMakeLists.txt b/ge/common/CMakeLists.txt index 117b7f86..728971b6 100755 --- a/ge/common/CMakeLists.txt +++ b/ge/common/CMakeLists.txt @@ -210,7 +210,7 @@ target_link_libraries(ge_common PRIVATE c_sec error_manager slog - mmpa + static_mmpa -Wl,--as-needed json -lrt diff --git a/metadef b/metadef index 6bdf2e30..89590b34 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 6bdf2e3011150b200fdcd2acd18b7186902534b6 +Subproject commit 89590b3405f6c5714997c07f81470764ac66635b From fa2165896519a0c2f73e3c171c4bcd356f1f55f5 Mon Sep 17 00:00:00 2001 From: yanghaoran Date: Wed, 25 Nov 2020 10:27:24 +0800 Subject: [PATCH 20/32] Delete deprecated hccl calling methods --- ge/ge_runtime/task/hccl_task.cc | 223 ++++++++++++++++++++------- ge/ge_runtime/task/hccl_task.h | 30 +++- inc/framework/ge_runtime/task_info.h | 31 +--- 3 files changed, 197 insertions(+), 87 deletions(-) diff --git a/ge/ge_runtime/task/hccl_task.cc b/ge/ge_runtime/task/hccl_task.cc index 3d5f8504..dfeda94b 100644 --- a/ge/ge_runtime/task/hccl_task.cc +++ b/ge/ge_runtime/task/hccl_task.cc @@ -15,83 +15,56 @@ */ #include "ge_runtime/task/hccl_task.h" +#include #include "ge_runtime/task/task_factory.h" #include "common/opskernel/ops_kernel_info_store.h" #include "common/opskernel/ge_task_info.h" namespace ge { namespace model_runner { +std::map>>> + HcclTask::model_stream_mapping_; +std::mutex HcclTask::model_stream_mapping_mutex_; + HcclTask::HcclTask(const ModelContext &model_context, const std::shared_ptr &task_info) : TaskRepeater(model_context, task_info), task_info_(task_info), stream_(nullptr), + workspace_mem_(nullptr), rt_model_handle_(nullptr), priority_(0), - slave_stream_list_(), - hcom_bind_model_(nullptr), - hcom_unbind_model_(nullptr), - hcom_distribute_task_(nullptr) { + secondary_stream_list_() { if (task_info_ == nullptr) { GELOGW("task_info_ is null!"); } - hcom_bind_model_ = task_info->hcom_bind_model(); - hcom_unbind_model_ = task_info->hcom_unbind_model(); - priority_ = model_context.priority(); rt_model_handle_ = model_context.rt_model_handle(); auto stream_list = model_context.stream_list(); - if (hcom_bind_model_ != nullptr) { - if (rt_model_handle_list_.insert(rt_model_handle_).second) { - for (auto stream : stream_list) { - (void)hcom_bind_model_(rt_model_handle_, stream); - } - } - } - if (stream_list.size() == 1) { stream_ = stream_list[0]; } else if (stream_list.size() > task_info->stream_id()) { stream_ = stream_list[task_info->stream_id()]; } else { - GELOGW("index: %u >= stream_list.size(): %zu.", task_info->stream_id(), stream_list.size()); + GELOGW("Index: %u >= stream_list.size(): %zu.", task_info->stream_id(), stream_list.size()); } } HcclTask::~HcclTask() { - for (size_t i = 0; i < slave_stream_list_.size(); ++i) { - rtError_t rt_ret = rtModelUnbindStream(rt_model_handle_, slave_stream_list_[i]); + if (workspace_mem_ != nullptr) { + rtError_t rt_ret = rtFree(workspace_mem_); if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Unbind stream from model failed! Index: %zu", i); - } - } - - for (size_t i = 0; i < slave_stream_list_.size(); ++i) { - rtError_t rt_ret = rtStreamDestroy(slave_stream_list_[i]); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Destroy stream failed! Index: %zu", i); - } - } - - if (hcom_unbind_model_ != nullptr) { - if (rt_model_handle_list_.find(rt_model_handle_) != rt_model_handle_list_.end()) { - (void)hcom_unbind_model_(rt_model_handle_); - (void)rt_model_handle_list_.erase(rt_model_handle_); + GELOGE(RT_FAILED, "rtFree workspace_mem_ failed! ret: 0x%X.", rt_ret); } + workspace_mem_ = nullptr; } } bool HcclTask::Distribute() { - // No ops kernel info store - hcom_distribute_task_ = task_info_->hcom_distribute_task(); - if (hcom_distribute_task_ != nullptr) { - return hcom_distribute_task_(task_info_, stream_); - } - // Ops kernel info store // Get privateDef and opsKernelStorePtr - GELOGI("get custom info in modelTaskDef"); + GELOGI("Get custom info in modelTaskDef"); void *ops_kernel_store = task_info_->ops_kernel_store(); OpsKernelInfoStore *ops_kernel_info_store = reinterpret_cast(ops_kernel_store); if (ops_kernel_store == nullptr) { @@ -101,25 +74,15 @@ bool HcclTask::Distribute() { char *private_def = reinterpret_cast(const_cast(task_info_->private_def().data())); auto private_def_len = static_cast(task_info_->private_def().size()); - GELOGI("the first address of the custom info, privateDef=%p", private_def); - - GELOGI("hcclStreamNum =%ld", task_info_->hccl_stream_num()); - for (int64_t i = 0; i < task_info_->hccl_stream_num(); ++i) { - rtStream_t stream = nullptr; - rtError_t rt_ret = rtStreamCreateWithFlags(&stream, priority_, RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } + GELOGI("The first address of the custom info, privateDef=%p", private_def); + SetSecondaryStream(); - rt_ret = rtModelBindStream(rt_model_handle_, stream, RT_HEAD_STREAM); + if (task_info_->workspace_size() > 0) { + rtError_t rt_ret = rtMalloc(&workspace_mem_, task_info_->workspace_size(), RT_MEMORYINFO_HBM); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return false; } - - GELOGI("hccl_stream addr is=%p", stream); - slave_stream_list_.push_back(stream); } GELOGI("HcclTaskInfo Distribute Start. begin to call function LoadTask in hccl."); @@ -128,17 +91,22 @@ bool HcclTask::Distribute() { ge_task.type = static_cast(RT_MODEL_TASK_HCCL); ge_task.stream = stream_; + ge_task.kernelHcclInfo = std::vector(1); ge_task.kernelHcclInfo[0].hccl_type = task_info_->hccl_type(); ge_task.kernelHcclInfo[0].inputDataAddr = task_info_->input_data_addr(); ge_task.kernelHcclInfo[0].outputDataAddr = task_info_->output_data_addr(); - ge_task.kernelHcclInfo[0].workSpaceAddr = task_info_->workspace_addr(); + ge_task.kernelHcclInfo[0].workSpaceAddr = workspace_mem_; ge_task.kernelHcclInfo[0].workSpaceMemSize = task_info_->workspace_size(); ge_task.kernelHcclInfo[0].count = task_info_->count(); ge_task.kernelHcclInfo[0].dataType = static_cast(task_info_->data_type()); ge_task.kernelHcclInfo[0].opType = static_cast(task_info_->op_type()); ge_task.kernelHcclInfo[0].rootId = task_info_->root_id(); - ge_task.kernelHcclInfo[0].hcclStreamList = slave_stream_list_; + std::vector secondary_stream_list; + std::transform(secondary_stream_list_.begin(), secondary_stream_list_.end(), + std::back_inserter(secondary_stream_list), + [](const std::shared_ptr &stream) -> rtStream_t { return stream->GetStream(); }); + ge_task.kernelHcclInfo[0].hcclStreamList = secondary_stream_list; ge_task.privateDef = private_def; ge_task.privateDefLen = private_def_len; @@ -151,10 +119,151 @@ bool HcclTask::Distribute() { return false; } - GELOGI("call function LoadTask end."); + GELOGI("Call function LoadTask end."); return true; } +bool HcclTask::SetSecondaryStream() { + const uint32_t master_stream_id = task_info_->stream_id(); + const int64_t hccl_secondary_stream_num = task_info_->hccl_stream_num(); + Status ret; + std::lock_guard lock(model_stream_mapping_mutex_); + if (model_stream_mapping_.find(rt_model_handle_) == model_stream_mapping_.end()) { + GELOGI("Need to create map for rt_model_handle_:%p with new mainstream %ld.", rt_model_handle_, master_stream_id); + ret = CreateStream(hccl_secondary_stream_num, master_stream_id); + if (!ret) { + GELOGE(RT_FAILED, "Create hccl stream failed."); + return false; + } + return true; + } + + std::map>> &master_secondary_stream_map = + model_stream_mapping_.at(rt_model_handle_); + if (auto iter = master_secondary_stream_map.find(master_stream_id); iter != master_secondary_stream_map.end()) { + std::vector> &secondary_stream_vec = iter->second; + auto lock_weak_ptr = [&secondary_stream_vec, this](int64_t index) -> bool { + auto stream = secondary_stream_vec[index].lock(); + if (stream == nullptr) { + rtStream_t new_stream = nullptr; + bool ret = CreateStream(rt_model_handle_, &new_stream); + if (!ret) { + GELOGE(FAILED, "CreateStream failed."); + return false; + } + stream = std::make_shared(rt_model_handle_, new_stream); + if (stream == nullptr) { + GELOGE(FAILED, "MakeShared failed."); + return false; + } + secondary_stream_vec[index] = stream; + } + secondary_stream_list_.push_back(stream); + return true; + }; + + if (static_cast(hccl_secondary_stream_num) <= secondary_stream_vec.size()) { + GELOGI("Number of secondary stream is enough to be reused."); + for (int64_t i = 0; i < hccl_secondary_stream_num; ++i) { + if (!lock_weak_ptr(i)) { + GELOGE(FAILED, "Lock weak ptr failed."); + return false; + } + } + } else { + GELOGI("Need to reuse secondary stream and create new secondary stream."); + size_t created_stream_num = secondary_stream_vec.size(); + for (size_t i = 0; i < secondary_stream_vec.size(); ++i) { + if (!lock_weak_ptr(i)) { + GELOGE(FAILED, "Lock weak ptr failed."); + return false; + } + } + ret = CreateStream(hccl_secondary_stream_num - created_stream_num, master_stream_id); + if (ret != SUCCESS) { + GELOGE(RT_FAILED, "Create hccl stream failed."); + return false; + } + } + GELOGI("Initialize hccl secondary stream success, hccl_secondary_stream_num =%ld", hccl_secondary_stream_num); + } else { + GELOGI("Need to create secondary stream for %s with new mainstream %ld.", task_info_->op_name().c_str(), + master_stream_id); + ret = CreateStream(hccl_secondary_stream_num, master_stream_id); + if (!ret) { + GELOGE(RT_FAILED, "Create hccl stream failed."); + return false; + } + } + return true; +} + +bool HcclTask::CreateStream(int64_t stream_num, int64_t master_stream_id) { + GELOGI("Start to create %ld hccl secondary stream.", stream_num); + for (int64_t i = 0; i < stream_num; ++i) { + rtStream_t stream = nullptr; + bool ret = CreateStream(rt_model_handle_, &stream); + if (!ret) { + GELOGE(FAILED, "CreateStream failed."); + return false; + } + + GELOGD("hccl_stream addr is=%p", stream); + auto shared_stream = std::make_shared(rt_model_handle_, stream); + if (shared_stream == nullptr) { + GELOGE(FAILED, "MakeShared failed."); + return false; + } + SaveHcclSecondaryStream(master_stream_id, shared_stream); + secondary_stream_list_.push_back(shared_stream); + } + GELOGI("CreateStream success."); + return true; +} + +bool HcclTask::CreateStream(rtModel_t model, rtStream_t *stream) const { + if (stream == nullptr) { + GELOGE(FAILED, "Output param stream is null."); + return false; + } + + rtError_t rt_ret = rtStreamCreateWithFlags(stream, priority_, RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + // Create secondary stream, inactive by default, activated by hccl + rt_ret = rtModelBindStream(model, *stream, RT_MODEL_WAIT_ACTIVE_STREAM); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + return true; +} + +void HcclTask::SaveHcclSecondaryStream(int64_t master_stream_id, const std::shared_ptr &stream) { + if (model_stream_mapping_.find(rt_model_handle_) == model_stream_mapping_.end()) { + model_stream_mapping_.emplace(rt_model_handle_, std::map>>()); + } + std::map>> &master_secondary_stream_map = + model_stream_mapping_.at(rt_model_handle_); + master_secondary_stream_map[master_stream_id].emplace_back(stream); +} + +HcclTask::StreamGuard::~StreamGuard() { + rtError_t rt_ret = rtModelUnbindStream(model_, stream_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Unbind stream from model failed!"); + return; + } + + rt_ret = rtStreamDestroy(stream_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Destroy stream failed!"); + return; + } +} + REGISTER_TASK(TaskInfoType::HCCL, HcclTask, HcclTaskInfo); } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/hccl_task.h b/ge/ge_runtime/task/hccl_task.h index 1649a8bd..11d88944 100644 --- a/ge/ge_runtime/task/hccl_task.h +++ b/ge/ge_runtime/task/hccl_task.h @@ -19,7 +19,9 @@ #include #include +#include #include +#include #include "ge_runtime/task/task.h" namespace ge { @@ -33,18 +35,34 @@ class HcclTask : public TaskRepeater { bool Distribute() override; private: + class StreamGuard; + bool SetSecondaryStream(); + bool CreateStream(int64_t stream_num, int64_t master_stream_id); + bool CreateStream(rtModel_t model, rtStream_t *stream) const; + void SaveHcclSecondaryStream(int64_t master_stream_id, const std::shared_ptr &stream); + std::shared_ptr task_info_; void *stream_; + void *workspace_mem_; rtModel_t rt_model_handle_; int32_t priority_; - std::vector slave_stream_list_; - std::function hcom_bind_model_; - std::function hcom_unbind_model_; - std::function, void *)> hcom_distribute_task_; - static std::set rt_model_handle_list_; + std::vector> secondary_stream_list_; + + // map>> + static std::map>>> model_stream_mapping_; + static std::mutex model_stream_mapping_mutex_; }; -std::set HcclTask::rt_model_handle_list_{}; +class HcclTask::StreamGuard { + public: + StreamGuard(rtModel_t model, rtStream_t stream) : model_(model), stream_(stream) {} + ~StreamGuard(); + rtStream_t GetStream() const { return stream_; } + + private: + rtModel_t model_; + rtStream_t stream_; +}; } // namespace model_runner } // namespace ge diff --git a/inc/framework/ge_runtime/task_info.h b/inc/framework/ge_runtime/task_info.h index e36c4333..f59c6454 100644 --- a/inc/framework/ge_runtime/task_info.h +++ b/inc/framework/ge_runtime/task_info.h @@ -18,7 +18,6 @@ #define INC_FRAMEWORK_GE_RUNTIME_TASK_INFO_H_ #include -#include #include #include #include @@ -219,9 +218,9 @@ class LabelSwitchTaskInfo : public TaskInfo { label_list_(label_list), cond_(cond) {} ~LabelSwitchTaskInfo() override {} - uint32_t label_size() { return label_size_; }; - const std::vector &label_list() { return label_list_; }; - void *cond() { return cond_; }; + uint32_t label_size() const { return label_size_; } + const std::vector &label_list() const { return label_list_; } + void *cond() const { return cond_; } private: uint32_t label_size_; @@ -236,7 +235,7 @@ class EventTaskInfo : public TaskInfo { protected: EventTaskInfo(const std::string &op_name, uint32_t stream_id, TaskInfoType type, uint32_t event_id) : TaskInfo(op_name, stream_id, type, false), event_id_(event_id) {} - virtual ~EventTaskInfo() override {} + ~EventTaskInfo() override {} uint32_t event_id_; }; @@ -272,16 +271,13 @@ class FusionEndTaskInfo : public TaskInfo { class HcclTaskInfo : public TaskInfo { public: HcclTaskInfo(const std::string &op_name, uint32_t stream_id, const std::string hccl_type, void *input_data_addr, - void *output_data_addr, void *workspace_addr, int64_t workspace_size, int64_t hccl_stream_num, + void *output_data_addr, int64_t workspace_size, int64_t hccl_stream_num, const std::vector &private_def, void *ops_kernel_store, int32_t count, int64_t root_id, - int64_t op_type, int64_t data_type, const std::string &group, - std::function hcom_bind_model, std::function hcom_unbind_model, - std::function, void *)> hcom_distribute_task, bool dump_flag) + int64_t op_type, int64_t data_type, const std::string &group, bool dump_flag) : TaskInfo(op_name, stream_id, TaskInfoType::HCCL, dump_flag), hccl_type_(hccl_type), input_data_addr_(input_data_addr), output_data_addr_(output_data_addr), - workspace_addr_(workspace_addr), workspace_size_(workspace_size), hccl_stream_num_(hccl_stream_num), private_def_(private_def), @@ -290,16 +286,12 @@ class HcclTaskInfo : public TaskInfo { root_id_(root_id), op_type_(op_type), data_type_(data_type), - group_(group), - hcom_bind_model_(hcom_bind_model), - hcom_unbind_model_(hcom_unbind_model), - hcom_distribute_task_(hcom_distribute_task) {} + group_(group) {} ~HcclTaskInfo() override {} const std::string &hccl_type() const { return hccl_type_; } void *input_data_addr() const { return input_data_addr_; } void *output_data_addr() const { return output_data_addr_; } - void *workspace_addr() const { return workspace_addr_; } int64_t workspace_size() const { return workspace_size_; } int64_t hccl_stream_num() const { return hccl_stream_num_; } const std::vector &private_def() const { return private_def_; } @@ -309,17 +301,11 @@ class HcclTaskInfo : public TaskInfo { int64_t op_type() const { return op_type_; } int64_t data_type() const { return data_type_; } const std::string &group() const { return group_; } - std::function hcom_bind_model() const { return hcom_bind_model_; } - std::function hcom_unbind_model() const { return hcom_unbind_model_; } - std::function, void *)> hcom_distribute_task() const { - return hcom_distribute_task_; - } private: std::string hccl_type_; void *input_data_addr_; void *output_data_addr_; - void *workspace_addr_; int64_t workspace_size_; int64_t hccl_stream_num_; std::vector private_def_; @@ -329,9 +315,6 @@ class HcclTaskInfo : public TaskInfo { int64_t op_type_; int64_t data_type_; std::string group_; - std::function hcom_bind_model_; - std::function hcom_unbind_model_; - std::function, void *)> hcom_distribute_task_; }; class ProfilerTraceTaskInfo : public TaskInfo { From d94eb178701b4633d2b842ec60abc2db4675fab5 Mon Sep 17 00:00:00 2001 From: zhengyuanhua Date: Wed, 25 Nov 2020 11:14:12 +0800 Subject: [PATCH 21/32] delete ascend string.h --- inc/external/ge/ge_api_error_codes.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/inc/external/ge/ge_api_error_codes.h b/inc/external/ge/ge_api_error_codes.h index 92b82a09..0ea2d064 100644 --- a/inc/external/ge/ge_api_error_codes.h +++ b/inc/external/ge/ge_api_error_codes.h @@ -20,7 +20,6 @@ #include #include #include "ge_error_codes.h" -#include "graph/ascend_string.h" namespace ge { #ifdef __GNUC__ @@ -63,13 +62,6 @@ class StatusFactory { return iter_find->second; } - void GetErrDesc(uint32_t err, AscendString &err_desc) { - auto iter_find = err_desc_.find(err); - if (iter_find != err_desc_.end()) { - err_desc = AscendString((iter_find->second).c_str()); - } - } - protected: StatusFactory() {} ~StatusFactory() {} From 009920c7d1cbd4bdae5c516799d0b449af8b330e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=A1=E6=99=A8?= Date: Wed, 25 Nov 2020 13:51:54 +0800 Subject: [PATCH 22/32] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!4?= =?UTF-8?q?18=20:=20ge=5Fapi=5Ferror=5Fcodes.h=20delete=20ascend=5Fstring.?= =?UTF-8?q?h'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/external/ge/ge_api_error_codes.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/inc/external/ge/ge_api_error_codes.h b/inc/external/ge/ge_api_error_codes.h index 0ea2d064..92b82a09 100644 --- a/inc/external/ge/ge_api_error_codes.h +++ b/inc/external/ge/ge_api_error_codes.h @@ -20,6 +20,7 @@ #include #include #include "ge_error_codes.h" +#include "graph/ascend_string.h" namespace ge { #ifdef __GNUC__ @@ -62,6 +63,13 @@ class StatusFactory { return iter_find->second; } + void GetErrDesc(uint32_t err, AscendString &err_desc) { + auto iter_find = err_desc_.find(err); + if (iter_find != err_desc_.end()) { + err_desc = AscendString((iter_find->second).c_str()); + } + } + protected: StatusFactory() {} ~StatusFactory() {} From 8b666aa28ef16dedb8736fb26a6496ce51ff6e84 Mon Sep 17 00:00:00 2001 From: zhengyuanhua Date: Wed, 25 Nov 2020 14:34:25 +0800 Subject: [PATCH 23/32] revet :external interface --- ge/client/ge_api.cc | 121 +--------------------- ge/graph/manager/graph_manager.cc | 27 ----- ge/graph/manager/graph_manager.h | 6 -- ge/graph/passes/multi_batch_clone_pass.cc | 15 +-- ge/ir_build/ge_ir_build.cc | 53 +--------- ge/session/inner_session.cc | 19 ---- ge/session/inner_session.h | 4 - ge/session/session_manager.cc | 20 ---- ge/session/session_manager.h | 3 - inc/external/ge/ge_api.h | 34 ------ inc/external/ge/ge_api_error_codes.h | 26 ----- inc/external/ge/ge_api_types.h | 42 +------- inc/external/ge/ge_ir_build.h | 14 +-- 13 files changed, 7 insertions(+), 377 deletions(-) diff --git a/ge/client/ge_api.cc b/ge/client/ge_api.cc index 9ecc3016..ef8d5622 100644 --- a/ge/client/ge_api.cc +++ b/ge/client/ge_api.cc @@ -76,7 +76,7 @@ Status CheckOptionsValid(const std::map &options) { } // Initialize GE, prepare for execution, call GELib::Initialize -Status GEInitializeImpl(const std::map &options) { +Status GEInitialize(const std::map &options) { GELOGT(TRACE_INIT, "GEInitialize start"); // 0.check init status if (g_ge_initialized) { @@ -127,26 +127,6 @@ Status GEInitializeImpl(const std::map &options) { return ret; } -// Initialize GE, prepare for execution, call GELib::Initialize -Status GEInitialize(const std::map &options) { - return GEInitializeImpl(options); -} - -Status GEInitialize(const std::map &options) { - std::map str_options; - for (auto & option : options) { - if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(FAILED, "GEInitialize options is nullptr."); - return FAILED; - } - std::string key = option.first.GetString(); - std::string val = option.second.GetString(); - str_options[key] = val; - } - return GEInitializeImpl(str_options); -} - - // GE finalize, releasing all resources Status GEFinalize() { GELOGT(TRACE_INIT, "GEFinalize start"); @@ -222,46 +202,6 @@ Session::Session(const std::map &options) { GELOGT(TRACE_STOP, "Session Constructor finished"); } -Session::Session(const std::map &options) { - GELOGT(TRACE_INIT, "Session Constructor start"); - // check init status - sessionId_ = 0; - if (!g_ge_initialized) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized."); - return; - } - // call Initialize - std::shared_ptr instance_ptr = ge::GELib::GetInstance(); - if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session Constructor failed"); - return; - } - - GELOGT(TRACE_RUNNING, "Creating session"); - std::map str_options; - for (auto &option : options) { - if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(FAILED, "Session options is nullptr."); - return; - } - std::string key = option.first.GetString(); - std::string val = option.second.GetString(); - str_options[key] = val; - } - uint64_t session_id = 0; - Status ret = instance_ptr->SessionManagerObj().CreateSession(str_options, session_id); - GELOGT(TRACE_RUNNING, "Session id is %lu", session_id); - - // check return status, return, update session id if success - if (ret == SUCCESS) { - sessionId_ = session_id; - } else { - GELOGE(ret, "Session constructor failed, session Id not initialized"); - return; - } - GELOGT(TRACE_STOP, "Session Constructor finished"); -} - // session destructor Session::~Session() { GELOGT(TRACE_INIT, "Session Destructor start"); @@ -320,34 +260,6 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map &options) { - GELOGT(TRACE_INIT, "Start to add graph in Session. graph_id: %u, session_id: %lu.", graph_id, sessionId_); - std::shared_ptr instance_ptr = ge::GELib::GetInstance(); - if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "AddGraph failed in Session."); - return FAILED; - } - GELOGD("Adding graph to session"); - std::map str_options; - for (auto &option : options) { - if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(FAILED, "AddGraph options is nullptr."); - return FAILED; - } - std::string key = option.first.GetString(); - std::string val = option.second.GetString(); - str_options[key] = val; - } - Status ret = instance_ptr->SessionManagerObj().AddGraph(sessionId_, graph_id, graph, str_options); - if (ret != SUCCESS) { - GELOGE(ret, "AddGraph failed in Session."); - return FAILED; - } - GELOGD("AddGraph finished in Session."); - return ret; -} - Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph) { std::map options; return AddGraphWithCopy(graph_id, graph, options); @@ -475,14 +387,6 @@ Status Session::RegisterCallBackFunc(const std::string &key, const pCallBackFunc return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, key, callback); } -Status Session::RegisterCallBackFunc(const char *key, const session::pCallBackFunc &callback) { - std::string str_key; - if (key != nullptr) { - str_key = key; - } - return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, str_key, callback); -} - Status Session::BuildGraph(uint32_t graph_id, const std::vector &inputs) { std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { @@ -532,29 +436,6 @@ Status Session::GetVariables(const std::vector &var_names, std::vec return SUCCESS; } -Status Session::GetVariables(const std::vector &var_names, std::vector &var_values) { - auto instance_ptr = ge::GELib::GetInstance(); - if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); - return FAILED; - } - GELOGT(TRACE_RUNNING, "Get Variables"); - std::vector str_var_names; - for (auto &var_name : var_names) { - if (var_name.GetString() == nullptr) { - GELOGE(FAILED, "GetVariables name is nullptr."); - return FAILED; - } - str_var_names.emplace_back(var_name.GetString()); - } - Status ret = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, str_var_names, var_values); - if (ret != SUCCESS) { - GELOGE(ret, "SessionManager RunGraphAsync failed"); - return FAILED; - } - return SUCCESS; -} - bool Session::IsGraphNeedRebuild(uint32_t graph_id) { return ge::GELib::GetInstance()->SessionManagerObj().IsGraphNeedRebuild(sessionId_, graph_id); } diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index 0b6f6d8a..091579bd 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -1870,30 +1870,12 @@ Status GraphManager::RegisterCallBackFunc( return SUCCESS; } -Status GraphManager::RegisterCallBackFunc( - const std::string &key, - const std::function &)> &callback) { - std::lock_guard lock(member_mutex_); - GELOGI("[GraphManager] RegisterCallBackFunc, key=%s.", key.c_str()); - callback_map_[key] = callback; - return SUCCESS; -} - Status GraphManager::PushSummaryData2ME(const GraphId &graph_id, const std::map &summary_data) { std::lock_guard lock(member_mutex_); GELOGI("[GraphManager] PushSummaryData2ME, dataSize=%zu.", summary_data.size()); auto itr = me_callback_map_.find(kSummary); if (itr == me_callback_map_.end()) { - auto iter = callback_map_.find(kSummary); - if (iter != callback_map_.end()) { - std::map tmp_summary_data; - for (auto &data : summary_data) { - AscendString tmp(data.first.c_str()); - tmp_summary_data[tmp] = data.second; - } - return iter->second(graph_id, tmp_summary_data); - } GELOGE(FAILED, "[GraphManager] PushSummaryData2ME failed, not found summary callback."); return FAILED; } @@ -1905,15 +1887,6 @@ Status GraphManager::PushSaveData2ME(const GraphId &graph_id, const std::map tmp_save_data; - for (auto &data : save_data) { - AscendString tmp(data.first.c_str()); - tmp_save_data[tmp] = data.second; - } - return iter->second(graph_id, tmp_save_data); - } GELOGE(FAILED, "[GraphManager] PushSaveData2ME failed, not found checkpoint callback."); return FAILED; } diff --git a/ge/graph/manager/graph_manager.h b/ge/graph/manager/graph_manager.h index b0dde0c0..897ebf92 100644 --- a/ge/graph/manager/graph_manager.h +++ b/ge/graph/manager/graph_manager.h @@ -163,10 +163,6 @@ class GraphManager { const std::string &key, const std::function &)> &callback); - Status RegisterCallBackFunc( - const std::string &key, - const std::function &)> &callback); - const bool GetTrainFlag() const { return options_.train_graph_flag; } bool IsGraphNeedRebuild(uint32_t graph_id); @@ -394,8 +390,6 @@ class GraphManager { // summary and checkpoint callback function list for ME, key is summary or checkpoint std::map &)>> me_callback_map_; - std::map &)>> callback_map_; - bool init_flag_; GraphManagerOptions options_; diff --git a/ge/graph/passes/multi_batch_clone_pass.cc b/ge/graph/passes/multi_batch_clone_pass.cc index 87d9749a..732844e5 100755 --- a/ge/graph/passes/multi_batch_clone_pass.cc +++ b/ge/graph/passes/multi_batch_clone_pass.cc @@ -610,17 +610,11 @@ Status MultiBatchClonePass::CreateSubgraphs(const ComputeGraphPtr &graph, const /// Status MultiBatchClonePass::PostProcSubgraph(const ComputeGraphPtr &graph) { auto func_desc = case_node_->GetOpDesc(); - domi::ParseSubgraphFuncV2 parse_func_v2 = nullptr; auto post_func = domi::OpRegistry::Instance()->GetParseSubgraphPostFunc(func_desc->GetType()); if (post_func == nullptr) { GELOGW("The subgraph post func for node %s type %s is null.", case_node_->GetName().c_str(), case_node_->GetType().c_str()); - if (domi::OpRegistry::Instance()->GetParseSubgraphPostFunc(func_desc->GetType(), parse_func_v2) != SUCCESS || - parse_func_v2 == nullptr) { - GELOGW("The subgraph new post func v2 for node %s type %s is null", case_node_->GetName().c_str(), - case_node_->GetType().c_str()); - return FAILED; - } + return FAILED; } for (const auto &name : func_desc->GetSubgraphInstanceNames()) { @@ -635,12 +629,7 @@ Status MultiBatchClonePass::PostProcSubgraph(const ComputeGraphPtr &graph) { "Subgraph: %s get subgraph name failed.", subgraph->GetName().c_str()); auto graph = GraphUtils::CreateGraphFromComputeGraph(subgraph); - Status ret = FAILED; - if (post_func != nullptr) { - ret = post_func(subgraph_name, graph); - } else if (parse_func_v2 != nullptr) { - ret = parse_func_v2(subgraph_name.c_str(), graph); - } + auto ret = post_func(subgraph_name, graph); if (ret != SUCCESS) { GELOGE(FAILED, "Failed to post-process subgraph %s on node %s type %s", graph.GetName().c_str(), case_node_->GetName().c_str(), case_node_->GetType().c_str()); diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index 242b38a0..ccf3b24e 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -141,7 +141,7 @@ static void LoadOpsProto() { (void)manager->Initialize(option_tmp); } -graphStatus aclgrphBuildInitializeImpl(std::map &global_options) { +graphStatus aclgrphBuildInitialize(std::map global_options) { GELOGD("Enter aclgrphInitialize start!"); // check global options if (CheckGlobalOptions(global_options) != GRAPH_SUCCESS) { @@ -167,24 +167,6 @@ graphStatus aclgrphBuildInitializeImpl(std::map &globa return GRAPH_SUCCESS; } -graphStatus aclgrphBuildInitialize(std::map global_options) { - return aclgrphBuildInitializeImpl(global_options); -} - -graphStatus aclgrphBuildInitialize(std::map &global_options) { - std::map tmp_global_options; - for (auto &option : global_options) { - if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(GRAPH_FAILED, "AclgrphBuildInitialize option is nullptr."); - return GRAPH_FAILED; - } - std::string key = option.first.GetString(); - std::string val = option.second.GetString(); - tmp_global_options[key] = val; - } - return aclgrphBuildInitializeImpl(tmp_global_options); -} - void aclgrphBuildFinalize() { if (ge::GELib::GetInstance() != nullptr && ge::GELib::GetInstance()->InitFlag()) { (void)ge::GELib::GetInstance()->Finalize(); @@ -471,24 +453,6 @@ graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, - ModelBufferData &model) { - GELOGD("Enter aclmdlBuildModel process!"); - std::map tmp_build_options; - for (auto &option : build_options) { - if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(GRAPH_FAILED, "AclgrphBuildInitialize option is nullptr."); - return GRAPH_FAILED; - } - std::string key = option.first.GetString(); - std::string val = option.second.GetString(); - tmp_build_options[key] = val; - } - - Impl builder; - return builder.BuildModel(graph, tmp_build_options, model); -} - graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &model) { GELOGD("Enter aclmdlSaveModel process!"); if (model.data.get() == nullptr || model.length == 0) { @@ -499,21 +463,6 @@ graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &m static_cast(model.length)); } -graphStatus aclgrphSaveModel(const char *output_file, const ModelBufferData &model) { - GELOGD("Enter aclmdlSaveModel process!"); - if (model.data.get() == nullptr || model.length == 0) { - GELOGE(GRAPH_PARAM_INVALID, "Input model is illegal"); - return GRAPH_PARAM_INVALID; - } - if (output_file == nullptr) { - GELOGE(GRAPH_PARAM_INVALID, "Output file is nullptr."); - return GRAPH_PARAM_INVALID; - } - std::string str_output_file = output_file; - return FileSaver::SaveToFile((str_output_file + ".om"), reinterpret_cast(model.data.get()), - static_cast(model.length)); -} - graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *patch_version) { GELOGD("Enter aclgrphGetIRVersion process!"); GE_CHECK_NOTNULL(major_version); diff --git a/ge/session/inner_session.cc b/ge/session/inner_session.cc index c4f8a53b..ec85d9ac 100755 --- a/ge/session/inner_session.cc +++ b/ge/session/inner_session.cc @@ -254,25 +254,6 @@ Status InnerSession::RegisterCallBackFunc( return SUCCESS; } -Status InnerSession::RegisterCallBackFunc( - const std::string &key, - const std::function &)> &callback) { - std::lock_guard lock(resource_mutex_); - if (!init_flag_) { - GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); - return GE_SESS_INIT_FAILED; - } - UpdateThreadContext(std::map{}); - Status ret = graph_manager_.RegisterCallBackFunc(key, callback); - if (ret != SUCCESS) { - GELOGE(ret, "[InnerSession:%lu] register %s callback function failed.", session_id_, key.c_str()); - return ret; - } - - GELOGI("[InnerSession:%lu] register %s callback function success.", session_id_, key.c_str()); - return SUCCESS; -} - Status InnerSession::BuildGraph(uint32_t graph_id, const std::vector &inputs) { UpdateThreadContext(graph_id); GELOGI("[InnerSession:%lu] build graph on session, graph_id=%u.", session_id_, graph_id); diff --git a/ge/session/inner_session.h b/ge/session/inner_session.h index 5cab43d8..db7a2c92 100644 --- a/ge/session/inner_session.h +++ b/ge/session/inner_session.h @@ -62,10 +62,6 @@ class InnerSession { const std::string &key, const std::function &)> &callback); - Status RegisterCallBackFunc( - const std::string &key, - const std::function &)> &callback); - const GraphManager &getGraphManagerObj() const; bool IsGraphNeedRebuild(uint32_t graph_id); diff --git a/ge/session/session_manager.cc b/ge/session/session_manager.cc index 5d5a299a..69a62923 100755 --- a/ge/session/session_manager.cc +++ b/ge/session/session_manager.cc @@ -276,26 +276,6 @@ Status SessionManager::RegisterCallBackFunc( return innerSession->RegisterCallBackFunc(key, callback); } -Status SessionManager::RegisterCallBackFunc( - SessionId session_id, const std::string &key, - const std::function &)> &callback) { - if (!init_flag_) { - GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); - return GE_SESSION_MANAGER_NOT_INIT; - } - SessionPtr innerSession = nullptr; - { - std::lock_guard lock(mutex_); - std::map::iterator it = session_manager_map_.find(session_id); - if (it == session_manager_map_.end()) { - return GE_SESSION_NOT_EXIST; - } else { - innerSession = it->second; - } - } - return innerSession->RegisterCallBackFunc(key, callback); -} - Status SessionManager::BuildGraph(SessionId session_id, uint32_t graph_id, const std::vector &inputs) { if (!init_flag_) { GELOGE(GE_SESSION_MANAGER_NOT_INIT, "Session manager is not initialized."); diff --git a/ge/session/session_manager.h b/ge/session/session_manager.h index da23219c..ac901c3a 100644 --- a/ge/session/session_manager.h +++ b/ge/session/session_manager.h @@ -158,9 +158,6 @@ class SessionManager { Status RegisterCallBackFunc( SessionId session_id, const std::string &key, const std::function &)> &callback); - Status RegisterCallBackFunc( - SessionId session_id, const std::string &key, - const std::function &)> &callback); bool IsGraphNeedRebuild(SessionId session_id, uint32_t graph_id); diff --git a/inc/external/ge/ge_api.h b/inc/external/ge/ge_api.h index 9c26ebf8..8fd4b944 100644 --- a/inc/external/ge/ge_api.h +++ b/inc/external/ge/ge_api.h @@ -29,26 +29,16 @@ namespace ge { typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map ¶ms_list); -namespace session { -typedef uint32_t (*pCallBackFunc)(uint32_t graph_id, const std::map ¶ms_list); -} - // Initialize GE -ATTRIBUTED_DEPRECATED(Status GEInitialize(const std::map &)) Status GEInitialize(const std::map &options); -Status GEInitialize(const std::map &options); - // Finalize GE, release all resources Status GEFinalize(); class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { public: - ATTRIBUTED_DEPRECATED(Session(const std::map &)) explicit Session(const std::map &options); - explicit Session(const std::map &options); - ~Session(); /// @@ -67,19 +57,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { /// @param [in] options graph options /// @return Status result of function /// - ATTRIBUTED_DEPRECATED(Status AddGraph(uint32_t, const Graph &, const std::map &)) Status AddGraph(uint32_t graphId, const Graph &graph, const std::map &options); - /// - /// @ingroup client - /// @brief add a graph with a specific graphId and graphOptions - /// @param [in] graphId graph id - /// @param [in] graph the graph - /// @param [in] options graph options - /// @return Status result of function - /// - Status AddGraph(uint32_t graphId, const Graph &graph, const std::map &options); - /// /// @ingroup client /// @brief add a copy graph with a specific graphId @@ -145,18 +124,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { /// @param [out] var_values: variable values /// @return Status result of function /// - ATTRIBUTED_DEPRECATED(Status GetVariables(const std::vector &, std::vector &)) Status GetVariables(const std::vector &var_names, std::vector &var_values); - /// - /// @ingroup ge_graph - /// @brief get variables in the session with specific session id - /// @param [in] var_names: variable names - /// @param [out] var_values: variable values - /// @return Status result of function - /// - Status GetVariables(const std::vector &var_names, std::vector &var_values); - /// /// @ingroup ge_graph /// @brief register callback func with specific summary or checkpoint by users @@ -166,11 +135,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Session { /// Please ensure that the implementation of the function is trusted. /// @return Status result of function /// - ATTRIBUTED_DEPRECATED(Status RegisterCallBackFunc(const char *, const session::pCallBackFunc &)) Status RegisterCallBackFunc(const std::string &key, const pCallBackFunc &callback); - Status RegisterCallBackFunc(const char *key, const session::pCallBackFunc &callback); - bool IsGraphNeedRebuild(uint32_t graphId); private: diff --git a/inc/external/ge/ge_api_error_codes.h b/inc/external/ge/ge_api_error_codes.h index 92b82a09..1a25b86d 100644 --- a/inc/external/ge/ge_api_error_codes.h +++ b/inc/external/ge/ge_api_error_codes.h @@ -20,15 +20,8 @@ #include #include #include "ge_error_codes.h" -#include "graph/ascend_string.h" namespace ge { -#ifdef __GNUC__ -#define ATTRIBUTED_DEPRECATED(replacement) __attribute__((deprecated("Please use " #replacement " instead."))) -#else -#define ATTRIBUTED_DEPRECATED(replacement) __declspec(deprecated("Please use " #replacement " instead.")) -#endif - class StatusFactory { public: static StatusFactory *Instance() { @@ -44,17 +37,6 @@ class StatusFactory { err_desc_[err] = desc; } - void RegisterErrorNo(uint32_t err, const char *desc) { - if (desc == nullptr) { - return; - } - std::string error_desc = desc; - if (err_desc_.find(err) != err_desc_.end()) { - return; - } - err_desc_[err] = error_desc; - } - std::string GetErrDesc(uint32_t err) { auto iter_find = err_desc_.find(err); if (iter_find == err_desc_.end()) { @@ -63,13 +45,6 @@ class StatusFactory { return iter_find->second; } - void GetErrDesc(uint32_t err, AscendString &err_desc) { - auto iter_find = err_desc_.find(err); - if (iter_find != err_desc_.end()) { - err_desc = AscendString((iter_find->second).c_str()); - } - } - protected: StatusFactory() {} ~StatusFactory() {} @@ -81,7 +56,6 @@ class StatusFactory { class ErrorNoRegisterar { public: ErrorNoRegisterar(uint32_t err, const std::string &desc) { StatusFactory::Instance()->RegisterErrorNo(err, desc); } - ErrorNoRegisterar(uint32_t err, const char *desc) { StatusFactory::Instance()->RegisterErrorNo(err, desc); } ~ErrorNoRegisterar() {} }; diff --git a/inc/external/ge/ge_api_types.h b/inc/external/ge/ge_api_types.h index c439a8bf..28de4307 100644 --- a/inc/external/ge/ge_api_types.h +++ b/inc/external/ge/ge_api_types.h @@ -65,47 +65,7 @@ const char *const OPTION_EXEC_ENABLE_TAILING_OPTIMIZATION = "ge.exec.isTailingOp // Option key: memory init const char *const GRAPH_MEMORY_MAX_SIZE = "ge.graphMemoryMaxSize"; const char *const VARIABLE_MEMORY_MAX_SIZE = "ge.variableMemoryMaxSize"; -namespace configure_option { -const char *const STREAM_NUM = "ge.streamNum"; -const char *const HEAD_STREAM = "ge.headStream"; -const char *const PERF_LEVEL = "ge.perfLevel"; -const char *const ENCRYPT_MODE = "ge.encryptMode"; -const char *const EK_FILE = "ge.ekFile"; -const char *const CERT_FILE = "ge.certFile"; -const char *const HW_KEY_FILE = "ge.hwKeyFile"; -const char *const PRIVATE_KEY_FILE = "ge.privateKeyFile"; -const char *const FRAMEWORK_TYPE = "ge.frameworkType"; -const char *const CALIBRATION_CONF_FILE = "ge.calibrationConfFile"; -const char *const INSERT_OP_FILE = "ge.insertOpFile"; -const char *const OUTPUT_NODE_NAME = "ge.outputNodeName"; -const char *const COMPRESS_FLAG = "ge.compressFlag"; -const char *const PRECISION_MODE = "ge.exec.precision_mode"; -const char *const SINGLE_OP_FLAG = "ge.exec.single_op"; -const char *const TRAIN_FLAG = "ge.trainFlag"; -const char *const RUN_FLAG = "ge.runFlag"; -const char *const LOCAL_FMKOP_FLAG = "ge.enabledLocalFmkop"; -const char *const TBE_PLUGIN_PATH_FLAG = "ge.TBE_plugin_path"; -const char *const DDK_VERSION_FLAG = "ge.DDK_version"; -const char *const GE_FE_FLAG = "ge.feFlag"; -const char *const STREAM_MAX_PARALLEL_NUM = "ge.streamMaxParallelNum"; -const char *const OUTPUT_DATATYPE = "ge.outputDatatype"; -const char *const OP_SELECT_IMPL_MODE = "ge.opSelectImplmode"; -const char *const OPTYPELIST_FOR_IMPLMODE = "ge.optypelistForImplmode"; -const char *const HCOM_PARALLEL = "ge.hcomParallel"; -const char *const AUTO_TUNE_MODE = "ge.autoTuneMode"; -const char *const SOC_VERSION = "ge.socVersion"; -const char *const CORE_TYPE = "ge.engineType"; -const char *const AICORE_NUM = "ge.aicoreNum"; -const char *const L1_FUSION = "ge.l1Fusion"; -const char *const BUFFER_OPTIMIZE = "ge.bufferOptimize"; -const char *const ENABLE_SMALL_CHANNEL = "ge.enableSmallChannel"; -const char *const ENABLE_COMPRESS_WEIGHT = "ge.enableCompressWeight"; -const char *const FUSION_SWITCH_FILE = "ge.fusionSwitchFile"; -const char *const SAVE_ORIGINAL_MODEL = "ge.saveOriginalModel"; -const char *const ORIGINAL_MODEL_FILE = "ge.originalModelFile"; -const char *const INPUT_FP16_NODES = "ge.INPUT_NODES_SET_FP16"; -const char *const OP_DEBUG_LEVEL = "ge.opDebugLevel"; -} // namespace configure_option + // Configure stream num by Session constructor options param, // its value should be int32_t type, default value is "1" const std::string STREAM_NUM = "ge.streamNum"; diff --git a/inc/external/ge/ge_ir_build.h b/inc/external/ge/ge_ir_build.h index 778ec21d..7ac54781 100644 --- a/inc/external/ge/ge_ir_build.h +++ b/inc/external/ge/ge_ir_build.h @@ -44,11 +44,8 @@ struct ModelBufferData { * @retval GRAPH_SUCCESS The function is successfully executed. * @retval OtherValues Failure */ -ATTRIBUTED_DEPRECATED(graphStatus aclgrphBuildInitialize(std::map &)) graphStatus aclgrphBuildInitialize(std::map global_options); -graphStatus aclgrphBuildInitialize(std::map &global_options); - /** * @ingroup AscendCL * @brief build model.Notice the model is stored in buffer @@ -66,14 +63,9 @@ void aclgrphBuildFinalize(); * @retval GRAPH_SUCCESS The function is successfully executed. * @retval OtherValues Failure */ -ATTRIBUTED_DEPRECATED(graphStatus aclgrphBuildModel(const ge::Graph &, const std::map &, - ModelBufferData &)) graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, ModelBufferData &model); -graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, - ModelBufferData &model); - /** * @ingroup AscendCL * @brief save model buffer to file @@ -83,11 +75,8 @@ graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map Date: Wed, 25 Nov 2020 17:17:49 +0800 Subject: [PATCH 24/32] host cpu log modify --- ge/ge_local_engine/engine/host_cpu_engine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/ge_local_engine/engine/host_cpu_engine.cc b/ge/ge_local_engine/engine/host_cpu_engine.cc index 36b0eca4..2930880b 100755 --- a/ge/ge_local_engine/engine/host_cpu_engine.cc +++ b/ge/ge_local_engine/engine/host_cpu_engine.cc @@ -221,7 +221,7 @@ Status HostCpuEngine::RunInternal(const ge::OpDescPtr &op_desc, Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_desc); auto ret = op_kernel.Compute(op, named_inputs, named_outputs); if (ret != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to compute host cpu op. node = %s, ret = %u", op_desc->GetName().c_str(), ret); + GELOGW("Failed to compute host cpu op. node = %s, ret = %u", op_desc->GetName().c_str(), ret); return FAILED; } op.BreakConnect(); From c7692ff0d553c7084ffac12d4032587e5d055998 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Wed, 25 Nov 2020 17:20:54 +0800 Subject: [PATCH 25/32] host cpu log modify --- ge/ge_local_engine/engine/host_cpu_engine.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/ge_local_engine/engine/host_cpu_engine.cc b/ge/ge_local_engine/engine/host_cpu_engine.cc index 2930880b..f51c6bbb 100755 --- a/ge/ge_local_engine/engine/host_cpu_engine.cc +++ b/ge/ge_local_engine/engine/host_cpu_engine.cc @@ -221,7 +221,7 @@ Status HostCpuEngine::RunInternal(const ge::OpDescPtr &op_desc, Operator op = ge::OpDescUtils::CreateOperatorFromOpDesc(op_desc); auto ret = op_kernel.Compute(op, named_inputs, named_outputs); if (ret != GRAPH_SUCCESS) { - GELOGW("Failed to compute host cpu op. node = %s, ret = %u", op_desc->GetName().c_str(), ret); + GELOGW("Failed to compute host cpu op. node = %s", op_desc->GetName().c_str()); return FAILED; } op.BreakConnect(); From 606cd13a5d980bbe6f6c54f991546b91fb4715d7 Mon Sep 17 00:00:00 2001 From: zhou_lili Date: Wed, 25 Nov 2020 17:14:09 +0800 Subject: [PATCH 26/32] add check found by self --- .../load/new_model_manager/davinci_model.cc | 11 +++++--- .../new_model_manager/zero_copy_offset.cc | 28 ++++++------------- .../load/new_model_manager/zero_copy_offset.h | 3 +- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc index f15c0c5f..9ebfde7c 100755 --- a/ge/graph/load/new_model_manager/davinci_model.cc +++ b/ge/graph/load/new_model_manager/davinci_model.cc @@ -964,9 +964,10 @@ Status DavinciModel::InitDataOp(const NodePtr &node, uint32_t &data_op_index, ma const vector output_size_list = ModelUtils::GetOutputSize(op_desc); const vector virtual_addr_list = ModelUtils::GetOutputDataAddrs(runtime_param_, op_desc); const vector output_offset_list = op_desc->GetOutputOffset(); - if (output_offset_list.size() != virtual_addr_list.size()) { - GELOGE(PARAM_INVALID, "virtual_addr size:%zu should be equal to offset size:%zu.", virtual_addr_list.size(), - output_offset_list.size()); + if (output_size_list.empty() || virtual_addr_list.empty() || (output_size_list.size() != virtual_addr_list.size()) || + (output_offset_list.size() != virtual_addr_list.size())) { + GELOGE(PARAM_INVALID, "Data[%s] init failed: output size is %zu, virtual_addr size is %zu, offset size is %zu.", + op_desc->GetName().c_str(), output_size_list.size(), virtual_addr_list.size(), output_offset_list.size()); return PARAM_INVALID; } auto data_index = data_op_index; @@ -975,7 +976,9 @@ Status DavinciModel::InitDataOp(const NodePtr &node, uint32_t &data_op_index, ma } bool fusion_flag = false; ZeroCopyOffset zero_copy_offset; - Status ret = zero_copy_offset.InitInputDataInfo(output_size_list, virtual_addr_list, op_desc, fusion_flag); + int64_t data_size = output_size_list[kDataIndex]; + void *virtual_addr = virtual_addr_list[kDataIndex]; + Status ret = zero_copy_offset.InitInputDataInfo(data_size, virtual_addr, op_desc, fusion_flag); if (ret != SUCCESS) { GELOGE(PARAM_INVALID, "InitDataInfo of input_info %s failed.", op_desc->GetName().c_str()); return PARAM_INVALID; diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.cc b/ge/graph/load/new_model_manager/zero_copy_offset.cc index 709db259..97c310d1 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.cc +++ b/ge/graph/load/new_model_manager/zero_copy_offset.cc @@ -30,18 +30,11 @@ ZeroCopyOffset::ZeroCopyOffset() {} ZeroCopyOffset::~ZeroCopyOffset() {} -Status ZeroCopyOffset::InitInputDataInfo(const vector &output_size_list, - const vector &virtual_addr_list, const OpDescPtr &op_desc, +Status ZeroCopyOffset::InitInputDataInfo(int64_t output_size, void *virtual_addr, const OpDescPtr &op_desc, bool &fusion_flag) { GELOGI("[ZCPY] Start to InitInputDataInfo of %s, total_data_size is %ld, virtual_addr is %p", - op_desc->GetName().c_str(), output_size_list[kDataIndex], virtual_addr_list[kDataIndex]); - if (output_size_list.empty() || virtual_addr_list.empty() || (output_size_list.size() != virtual_addr_list.size())) { - GELOGE(PARAM_INVALID, "Data[%s] init failed: Output size is %zu, Output addr is %zu", op_desc->GetName().c_str(), - output_size_list.size(), virtual_addr_list.size()); - return PARAM_INVALID; - } - - basic_addr_ = virtual_addr_list[kDataIndex]; + op_desc->GetName().c_str(), output_size, virtual_addr); + basic_addr_ = virtual_addr; (void)ge::AttrUtils::GetListInt(op_desc, ATTR_ZERO_COPY_BASIC_OFFSET, zero_copy_basic_offset_); (void)ge::AttrUtils::GetListInt(op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset_); GE_CHK_BOOL_EXEC(zero_copy_basic_offset_.size() == zero_copy_relative_offset_.size(), return PARAM_INVALID, @@ -53,26 +46,23 @@ Status ZeroCopyOffset::InitInputDataInfo(const vector &output_size_list IsL2Fusion(zero_copy_basic_offset_, virtual_addr_offset, fusion_flag); uint32_t out_count = 0; - data_size_ = output_size_list[kDataIndex]; + data_size_ = output_size; if (!fusion_flag) { GELOGI("[ZCPY] %s not set l2_fusion.", op_desc->GetName().c_str()); out_count++; - data_info_.emplace_back(output_size_list[kDataIndex], virtual_addr_list[kDataIndex]); + data_info_.emplace_back(output_size, virtual_addr); relative_offset_.emplace_back(0); - GELOGI("[ZCPY] %s size is %ld, virtual_addr is %p.", op_desc->GetName().c_str(), output_size_list[kDataIndex], - virtual_addr_list[kDataIndex]); + GELOGI("[ZCPY] %s size is %ld, virtual_addr is %p.", op_desc->GetName().c_str(), output_size, virtual_addr); } else { GELOGI("[ZCPY] set l2_fusion for %s.", op_desc->GetName().c_str()); for (size_t index = 0; index < zero_copy_basic_offset_.size(); ++index) { if (zero_copy_basic_offset_.at(index) == virtual_addr_offset) { out_count++; - uint64_t out_offset = - reinterpret_cast(virtual_addr_list[kDataIndex]) + zero_copy_relative_offset_.at(index); - int64_t real_data_size = ModelUtils::GetOutputSize(op_desc).at(kDataIndex); - data_info_.emplace_back(real_data_size, reinterpret_cast(static_cast(out_offset))); + uint64_t out_offset = reinterpret_cast(virtual_addr) + zero_copy_relative_offset_.at(index); + data_info_.emplace_back(output_size, reinterpret_cast(static_cast(out_offset))); relative_offset_.emplace_back(zero_copy_relative_offset_.at(index)); GELOGI("[ZCPY] virtual_addr: %p has been l2-fusion to %lu, need copy data_size is %ld.", basic_addr_, - out_offset, real_data_size); + out_offset, output_size); } } } diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.h b/ge/graph/load/new_model_manager/zero_copy_offset.h index c662032b..025d1b14 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.h +++ b/ge/graph/load/new_model_manager/zero_copy_offset.h @@ -42,8 +42,7 @@ class ZeroCopyOffset { ZeroCopyOffset(); ~ZeroCopyOffset(); - Status InitInputDataInfo(const vector &output_size_list, const vector &virtual_addr_list, - const OpDescPtr &op_desc, bool &fusion_flag); + Status InitInputDataInfo(int64_t output_size, void *virtual_addr, const OpDescPtr &op_desc, bool &fusion_flag); void SetInputOutsideAddrs(const vector &output_offset_list, void *addr, const size_t &index, bool fusion_flag, std::set &real_virtual_addrs); From a9ce7611c8d70aec094230433db4801a0cc74f99 Mon Sep 17 00:00:00 2001 From: yanghaoran Date: Wed, 25 Nov 2020 19:46:08 +0800 Subject: [PATCH 27/32] support mindspore building tests --- CMakeLists.txt | 7 +++++++ cmake/external_libs/protobuf_static.cmake | 2 +- ge/CMakeLists.txt | 4 ++-- metadef | 2 +- parser | 2 +- third_party/prebuild/aarch64/libmmpa.a | Bin 0 -> 63182 bytes third_party/prebuild/x86_64/libmmpa.a | Bin 0 -> 57270 bytes 7 files changed, 12 insertions(+), 5 deletions(-) create mode 100755 third_party/prebuild/aarch64/libmmpa.a create mode 100755 third_party/prebuild/x86_64/libmmpa.a diff --git a/CMakeLists.txt b/CMakeLists.txt index 4134678f..dc0ec2c5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,6 +156,13 @@ elseif (ENABLE_D OR ENABLE_ACL) find_module(register libregister.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH}) endif () + set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) + add_subdirectory(metadef) +elseif(ENABLE_MS_TESTCASE) + include(cmake/external_libs/protobuf_static.cmake) + include(cmake/external_libs/securec.cmake) + include(cmake/intf_pub_linux.cmake) + set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) add_subdirectory(metadef) else() diff --git a/cmake/external_libs/protobuf_static.cmake b/cmake/external_libs/protobuf_static.cmake index 51f4ed25..23630d44 100755 --- a/cmake/external_libs/protobuf_static.cmake +++ b/cmake/external_libs/protobuf_static.cmake @@ -48,7 +48,7 @@ set_target_properties(ascend_protobuf_static_lib PROPERTIES add_library(ascend_protobuf_static INTERFACE) target_include_directories(ascend_protobuf_static INTERFACE ${PROTOBUF_STATIC_PKG_DIR}/include) target_link_libraries(ascend_protobuf_static INTERFACE ascend_protobuf_static_lib) -if (ENABLE_D OR ENABLE_ACL) +if (ENABLE_D OR ENABLE_ACL OR ENABLE_MS_TESTCASES) include_directories(${PROTOBUF_STATIC_PKG_DIR}/include) endif () diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index c895e7ce..88a5c52f 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -1,4 +1,4 @@ -if (NOT ENABLE_D AND NOT ENABLE_ACL) +if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) add_subdirectory(common) add_subdirectory(plugin/engine) add_subdirectory(graph/build/memory) @@ -600,7 +600,7 @@ set(INFER_SRC_LIST "analyzer/analyzer.cc" ) -if (NOT ENABLE_D AND NOT ENABLE_ACL) +if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) ############ libge_runner.so ############ add_library(ge_runner SHARED ${TRAIN_SRC_LIST} ${PROTO_SRCS} ${PROTO_CLIENT_SRCS}) diff --git a/metadef b/metadef index 89590b34..57e72aac 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 89590b3405f6c5714997c07f81470764ac66635b +Subproject commit 57e72aac24a35e40799e342fdacca362a66395c4 diff --git a/parser b/parser index c4f6e1e0..bb6424dc 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit c4f6e1e03ac58a5c24e9bd3a04634f7e7b3213c3 +Subproject commit bb6424dc6d9252a3ac70650cde2f547761237681 diff --git a/third_party/prebuild/aarch64/libmmpa.a b/third_party/prebuild/aarch64/libmmpa.a new file mode 100755 index 0000000000000000000000000000000000000000..d7c29e2b85f165c17eca9700d17cb7ec4e4235a5 GIT binary patch literal 63182 zcmeIb4R}@8c_zB`V_N}i%Rpih<8ZKXLNEbrlYnCjQ^tdRBo{ysO@A;Si|6+rG%0AH5Ro9oz4V+&tUlYH>+9J7Ze34zn}}eNq~KIY1p!KnWi+iYxA~K% zddbe8LYV+r(G(J5#NAuS&*OztFEGxW>a55(8!*|@(UrC55A@_Z)@VWfNo{ARlqr^S zUp5DQGM&5~7jfFWp+A@Hiq9K6+WdtUO#o@gbhmZ#hURRSm<=gW2dT!MepU`raaPNF zv)#aWxE;sF9)Dif+0#!+jjfVc(bth9(3H(E=VsJQmcs7o=;ry-4(LZgwXLn$US2@) zyR)q>KgVs(I-!U>{i~D-ID1(_7vTCkv&Sm;?1HGiy)^%nx-7a0< zDN5IOX4=~NaJ9a(e*^EY?^N~cJF|U#J-kL6_SI!NJMYOj_w?>u+uhcj&ADs5FWZ@g zi<5~nWFI(5v;fS5tER~B}$cm0!du=Yqi@2+?uctNJ-{08R;ffvt zV6?QOaka&SqH~(IzyEf~@+l;mx_r({dRlXIBUCN5R+n>?M$0aH7+*`ev$@(_k5>2M z4(BV*#*%h?NwcCQ3Cq-Hav6wtDAPHRUDDmE$>sqHmg^s$uP_+#2{`Vg*edneT&A@h zH+cAg476_S=%tI%7kMtHPCsA(6Z>Uz3*QIj1#-Hknc&ME0oBhbbk*9Kw# zd+8)~J#AD&PZ#&}b!BqPVEW8j!D-{=Yw9y>$*i@G)^&9~1KrF4r?6aSVxj~m-VmpMfGW##iyEGOTy(Q*KEj>R$7P}O<+Qm<-IHt(x{?B z+T%-nb9A^*dmJ?7`=p0!`_?L)^J$M4@>$x`O~%sxY?e`fajtKmyA>S;()9zqEDsL6 z0JrO=|3BE>+0jjEU3*s#V@OM9f1$icLuC&lBcJfi5@}}L-?G7Z%i{hG&L7>8+0?ar zGe6knyC}xLLb$AZ%tfzUUrWzAvC+NVF7}}EU826DkIn``_hkCBl0=5}9sTQAPtCoV zR##ctT4RcDt#S_a>jwJzvfa|CV_E`C!!&n%jcMTQ! zAXTW#WnCFo^0I;MWk?{^n^}!&9#}u8bxzORRMLp}!}I+>_`~yVU+6jMaZlX4ba8oE z83xAwQx<(aiq8~{qC-E8(={$x6I~l!6TSWTzkB}eisjrT@@ZhNeZX9>aQ`P8+@yJ)Km)@0RP+qrs+-lc$f$z4WhZg!>x&@v?qc z$g}1!+RoPL&~f*)nhQMEMrGexg!WM5{5IP5_Tw*$zy5ilY%2fl$N!&y#A|Uo4ed4- zUoM9|V3($`w71Lo-@nKzj)VUk?PdFdLAEXF3p6Iv=Z1i(?`u3CJ;wi;Z!_1UubC8~ zjYWsij^nuSeu)d$d;7Y4Cl%ZJ6KvN%j-IY4A3RwOe=frjGPV(8TSvd-W5WXUISY#W zoO`G<+BMqt;q*6tr>SPb?!KCh`RAgG>F-7xuWTN!h-Rgt=nHwor`G;Z=Md zd2Fn>0o?nM=d7q<^U2||{9CDw(Q`Gt|7MgA_eV9qf3l|k|9T7Y<7dmtVMF8{Ridwj zd|pp~>6w$q{?p#KqR+qh*0EcDg!^lrE5G=uXHyrScouTLU5@+j!Tr(3^5>A(w<(w9 z{1M7I1iR#6r-)@YWp({F%YCTq5!O`=Vqv9k`xBK{h;i>vigDk(Y@d8NpI3kQRm7Wr zTv>+-aU8aceQ{CgK58-j5B=?YHu1 z7pzmXp*LA~5$bLheYURVFxwgG?eNfjlCDJheo0p$y&Yo+-YVNz``q-4_dOfI zKc~|lsng^LK8SXx{pO-1pL#`n>R;^b?DlK3_fhBH^tHDif3awMQu8i}oruGzZ#O>w ztoR-Kcw$Lo8uif>eDq3iDW9=W{ggft-y4rzhOS3m@EdzS$M?Ih=h$noiPtDg+dO!W zq>WBq?&aqUmy1vT`;1}YaVBk7zG$#%2)0r?CE0lQq}a}bupi<|p?+CsH?e*x=T@}) zThY%o3^t{rXdLbRqT$o_gy-rKxYg0tWs!ejPN@CE zrMl=l!&gNYUb`wfJbYE$|0C`6R{5NB@;c@ccTRhy?2$b3Eu5b&bGo~8^s|mr!hew0 z(|*orY-{Ge&R%A`1D`v2HOtRAuKGFB-@SC{_l$p@WIt=iL?h}ZXlJym^Ha1l%C&Y% zqg=>$;z&P@bq?E61$C76Qz~zc>2}`$zmT^61=gV{C-iy7mGg$0!)}a$YvelJOy4AR z_>7AY=&!U63v+ms^Vgae%CsA8gE3?Xx)*dd>kdhNH=52rGxix|8nRj6>Wk_VyMZJ2 zy-+IOR(sGGFIL8gQHpXBr$Jk0sXZt(Wt`cEnIr>%`en#>}q1rS6>_i^mzyu$U&S0Gq>y@(*H!h%kIr$OeFy^5czq>jw(iPa-j|X!j`d+bL{oFB~{>}bK zk8eL7$9Owla%D38IQYKLVLzS}_k(p^C!;v#`}o3GFEVUD#8`)XM(u|f>$NWm4-IoJ!r#` zof|GMUZ-$#Zt=T3+b`1LTKOvaUMuE*RWkp>5i+-t3wvLv;n;Vr=7TkY1;EOHwZgw} zAAOWDIt8A)&&>JLVv{=Nf%SokO34F9a@lw2dWT)d;ChE!i%7U$?$$ZVORjU|xyAv% zPn3%`lyrSmxwpa>ST|fJW?A6l@;qTgxsTD-!eu$FpO)!-ba~Qz^jjs@I4H;Ze>&0M zV&59g|50C~wy*!?@)5tB{z)+bb^Ht2q{KYWjblu#`nl|E;;fFp-bsIF?9E^M$SbHP z`db8_#X8&#d5jC(x>v*Irs1-DAJ5s}j=e1LItA^6`$nt{CCU0E^^$nzVuRQ=Pk%)^ zj19}cuVMSYBRUL!X>#Kc`hFNIo{FA+3hjaGo=@V){2l*hlns2RkCc=BWLkXpLlPH; z7D)LG$LS>ZM)1{H%DvL*Wzl*pwC~HVH^t*r+fPT)fr%5LQv@5L9Ig+C4k&)`Y^gH3?KNjd#uuy00oNyT zycG8x(r>d(nK8W^4ZpAI`?sH{HYRUU>u>}OIhfL^rKp>zY=S(t~^+mEtCg+N9pp6 zTwk)|Ftzh97SH0b9qdt9?~3bM#=xlSqZk8+b^9porR~JbO;o3DTtCX^1j31`Dz9Uk zd64(vnM2u9SKsgbCUXYMsCmaHbTfX_)xl1kdGma?>*R{S>F6_bjV!S1n zF{jkLf-z(_$JXrQP*3B>@J@!C(;~jG&YgXwzu_E_a*FB&GG%^KB9{5K41OGMqzxav zRQ5c^rA5!%hET>~_(1gfNx|XXZd3_Kg)aGRDUd^0!gm^}IHB z@No3T#_y^v%Ms@b81B2NJ$1ftF7}S9+`7lC0*+@=o(F&7b0o+fLO(~n7DdszpIyAv zLLEk|dzm&Te)WutxoCT3umNN3?rF6NF}LP<*w3xYvh9TL1P#%L#72X(5&VtzVm+~5 zT`b0Rt;0f`fF0S-vYw=^O^o|%=~q$rL+CGdBj&P$1E)8IM#8AcC7iv@g(TO zj6bU1{fu_BHbvQ425BqLT+6(GVLik>&vffdw6W&THY4^as&8PijpMSg4(@Q>uyq535xUm@fgeRRW7auW}LRs0zT!>Q9 z)2`nFHmN##dOCQ+m?tvdba`~xt>YGCczrG}W3WgDVi?No%X*A;$aCbS7-Ix&r}6Y} z5%=OTn(sG4TbC*$b*J8!(~q`DDx><{?_y6AD#c- z_v>v34WqRK%y}3$$|}az4p=5_CwY|PpGy09lJy{M$oYY3KkocK?;o_kn>WShO=D?G zziMAt$T|_*+Zgmuxqa4N#>OM#)5x~#)-5;(LYo?*JQ+8;c9hVLwaqg2*>;Qk+;b}T zuEw>|VP1>hrI4}oRprlf9DS7I-1qx@hbyC&X%nJH2GK6jw>(mVwtXjL@430g&Hu|b z);#OtNL9@RjxmSvY}5G=Wnf&)_A>4Y(H-wivD|m){U}2j?sNA~!59o*p0qWR;6A*{*m#+vY+x$!el*d-qS%=L3gwnG;Ssn-H;uXG_@_Q(XL!{<}58Sl|p z`6=k`o==7IN{k66^4ju2Kd(eyDU2D=KVz%_jN=GApTd0cP~p5E=dd5J^&C$`oI^s6 zdq)xaEy5h~3vXjgfONhYcr%WC#-(e{D}!H+yZH>SvgY}ZbFD!2fgipI zALd#I?a60{Y!jS&(kD6IPAc#C|LN8WCYI?ucUmK5X{}@Eck&A8$9Fy4yTcfdQSOL&8rrU#YqOmg|6m!166V)wJteOA`2xrTJ~Qu*^7|6*M8!XWHOeK?=wZ;{x~xiy;Ku6-WuY3n`c2l0N! z1s)%c%D=UmV*!`1{Y{40L&|`4#=}MP+sl>7%xBf_bQ~U*iO-Vt9rmMWr}PKfYnXPI zIq@LVsIO@k7ZujCogKj~tOo>ZxXzB0hqj?{;qAxGItAaGNBQ<}oNx1y{H1NU^@lyE zuR?u;>+EY{>Sv|i7_S&-|JUVb>g{@zUFs=9zrl5_cTvB&5^HcRC36GBhy1rHFU8)iO^>fG{M;|cq_o7@kBc{1EDYmCVJPXD^h?#gUane0& z8DWdDuPqF+Eu%fr=d_Kve#iL?@<+Qo`b5R^N1v#~|0|w9dI#deOL#W=l&mY1h%L^q zF)nuR=0i5#r9Ygn!#Vp)p5xv9A+$@E=C}dti7w6e{n>Yt!`}g*-*jorpAkQr3VqCi z(bo*%7cMTdZ{d2Yj_VYE?OOM&tZ1C4*M5!nTqx*vRmAq`bmp2J%6Xx93_7wuEX2Qp zf9SfX_&DOBTPs2R>_HvwMcd~yr#=D=@~;HpTuL{b13%rExnpI+$n8U!Xaw zpSI&G#yk2>Dcw{r_7^Gi^X@(45p5}cuBq``+ezv7l7Df2sb{gyR*2I zXDM<&_0alpvGp=~7W+nAcJ+;4T-ML)2gP}-4Sf65wjFZ{?Ni!BisJ>QF%LbaZ3S~< z)(L%keyMh=b!X-yv)DGJKK}~i6gQTD4Hscz3F%3!zrQka%D`0_D2G1lGVNJx!Zu*WSc8;- zc0+mEzOQE4fN?I(vAK?mG=72mChbL^kho!*Dador$bb(4=Q|L)A=}vuIyxP=W`{nWI;KU3IMxR5 z606PFMy0%i)W_J5dAfNV^8`*F^NH%nCx4zeoXnT^Va?B9>DcYES4!t~SY&7z{P{t7LGfI_d0?Q=hK=${pJQ_1f*1N{3U|whHec05y z%MP=Jo5i-^7FtIm-oMSs{d7s|KaG$ChHKT{Eu-FKIGrin=9?x$7|wgJdt9UQ`A(}9G;$)vLw-8vJ+mz&djt^GG`<_)EDzzko6HN&j1fr^?*^1GP6jeUf~4udG+` z-XX>bCfxT_si5BeX{n;Bi>Dv{P^s_y|-rGS95-geuVF@ z!Iv*^4JrqDu5WpX<;VU;y6=RR9dX``EdyP2tU;XysFS-tdLd)%$3E`GaVST{iyN@k zjQ?D>zR|5)*Ye#=x#zVRC2Wp+rwb=)fUnGjeX;K4%7pcB_YU6qC%)^-a&9`%d^R-upsYelL4Q&#Tx@YVQ1ro=@=S|3%OJGv7N|SML7F{yNrUFf?Xt!~3}7 zBgTNkKdrcO7TU@zv=#hjtzs72%1y9eE&dNzRK4KpRP6{Kn$9u$D0XyXIE=lavwJsf z9PO(0iFV60+L?R*-#(AYvrhA{5q*&3gj;JaEW+L#wQpkWPkmYBuuk^Vw`8oy`g3zk zv~i9*ARqQKYc0#`6W(j9eI9Lj#zaM#V`~=KBi$%F3?n8oe$}hv%fwo|MM^kH_iQq3O zzs9;DiYEErcjH}0zR%&-+c3WJe8jrtkiFdNo`&wwbK(Q64{(PdlX8CPe2u=pl>U&z z_QADvjweg#_MH(nsf@lenq6vX7sy53-T5{6kZ)JfHrkhdz8h`pwTekE?=<+k$GxaO&Q*SNE!IVK{A1c*#@FLXlxZ^7F%ReAd;Dz*$0G$J9kI3<^LS1?N#ir&N(XmNUOFP>a%2Kd5>a#p5 zQO!_|C_>3?rHgm&LyqhWaZzhIZz4jD`ZWI%E9$I!Dc>Q z;T-p%U!LUpW%i$3H?aMv_f58|T9n7d(QmPgH7;&M+k70u``mTorQeIk^?I*smpZ2Z zF~+DP+U3|{nwKZ-#Jqo=hrdi=JArI)wju5x-tA+Q#KQ98HiGfQEL+b%HuVe{MeT{} zezYlYtnnAuv%DM6Jl)s`@wV(Z>decFv6q4Iy*2Pk+V-z`ZKQ4Aeq84V;|g)Fn~5hCXDHPX8nuCzN0sk9Zs=NfKA1%M|)XH!pIFIQl+y#VGHdyfkjiV^!7x{J_88hkR)> z<`a)ogSA|YW8HfT;**24DdG@ghsvsl9qCh?qf(xmH==Isy!0-qbNbSg>_?C{Wu#EQ z^CaSIPdvIhLwU8%;&+bCI?Q-yn|OSKF;5xS zU18T~g0s~ldD@oee8&mTIye?{WtV!QPHAvZUlW}@&Any%%%a-go2D&zo#(i3SY`9v zJUij~i}FxDw-*@8Wb;ZXNA${QUib|XdH+Ub^Blhk?ZP>IY$ES_s>JU=sTa6;{uUJ1 zk#FI7h0RyT*o8KLx|xpnI&yzkU5hHV_Ym?a_!Q!v#xmNF>6^4%lc6{4UCUU5d&=-m z;;~CdCoV$!#JJ6s#jWd6Z+TxaN$0CoCVb{{b*SZwp99G6*JV7+cZN_GvCk|LpONR5a~D&_mq##42cigxk8?HEZkdjcrv-rhvNhu zOa5M5+Lx1K?zQ!QBuA8{R!PW5LZQRA2Q5!(N+g1>N~D_&0=pqE-?;qrszEa z^jlw<20uX`4}DyG!+j_Dyyz>?doN-T-;vqPzRQgRq|ec{t;*<+X=~oYy5%}V91DWy z2B=$&ql2`g)T7pwTW1HR@krOwXeX{WuspH<_~!!i*3Z9f-ukwAcfe`*scl;J=)%=? z_yYmi^{ZejvB>f6)Dt%h4_KZeRJqq%X&Jw?%z&!`xo%AwRdZcc6pY z%wvyt{27ilnbzDuU)E6`#ozYm>06DzOX5FujSr?e_;(n(uopfkJnzNd@sP_AHvi9d zrnG;Xl3Y8~Qu&M^aLfQ~y9)PpYk}qb=JC ziK!3fQiVHGw}0$?Y9>rF@wXw`QvMG%K-99#`c!joHmmyf4?HY4rrh5Qnax9YPpYFo zbxZ#^$^0Mla9>^BM^ZEId*Hzjq!!G%V~(%Q2tP&fpR&(2MV0H{TXw^QX;BIg<^t}s zncub7%-eb8t}AM9Im?kS^k&W?eDjqcs&G{0-Fso7bz>nfBzXZ2YqoT;9Z+F7})0-SowSv3aE z;21c2$G~|-IHTG54dIMt!)gRJen#WW9|LFQ7&sfpz{!t+^YR!tuL~#5!o@!JpslY7 zn7H$EfOe|Arg7)EUGG4hmUjp#1$drtMzc@L7&z<4z}X?3Ua!w!+0N=+*HWQRdWERZ zu`zJ)jKX~;^Skz%>Ye4g${^+*TlT6-&zbKz>dzmyoY}&0?Y{OJc3<`lK5bTLO`X%T1B81mXDoNYcYmGiLG=eTeV7IQvpIcLWpXEI(!Xo(q8xmP^#)i9*e1d1kv2Z`fX#28aMGTmbzfx1<71F>Ryav| zryzf_C``YHJ|*MDLgCE!9Mz{NUaS(%Ss%ahWjiPDn#B0E!IvzBdk2N%#;>uT-EYgj zS2*e7yo$>H${09r2&bi3PSJR!`W?JD`j}?Ea7JqzD~03w<=SiF*xeJCeWP$jYtMP% zNIcc}QWQ^L7S28@9*fwCH%2eQw-- z%0Dk8-n(8no4p*>r)Ye+Lpah7l~dFXkBvdj8R0Z|KRi}hyR%`}eRRYJe(*yKXW1^R zFzMq*T*Srpse+|>A@cF)nc)N1X~CY;gQ+-Bhn7U%UFR?hy*aM)f?2&ciz zNj0LMBK~@@4yjKF9!(&zFy1TRQv?s?%uC=ml)zJvn-+Ygw|(!GT{Ochx>yRgQl2yKcfk-hSboLE89v?Xy=7D9zQ|tHN95dFrDrYD>yGFPsU*KFU0w zP+{byu&BgOi`Px-7kQRr4&!x8;d+DclG-VKtW!AZW2~1!!I(yws_SH2v0d=`;(W`s zQ%He+L^y8DUVF_j{CerG`)S=l=hx&63x{dQS6dXd*GlBc&r*KHeqJ>Hnkk%?Vop)) zTq>Mi&rw^+Xw{FGdWF+gEaxGun-uVE!pRlO`IO}x8be;E$H0lOz{Jm9e#K>9WAmCZ z22O);=rhL7i>;i_F>tmDC++2^4U1yVLE(rEl~ZKHQ)9^MqHrSbW7;+~OuM+4qT}Kt z2Nz4`%ZZe=`aam1(9#mzbOLvM3GS8z?%opILnXK==x{>t*+`rEY_RokPB=1;QTr9m zW2Rh30ch9!iv6N!jC{9nMw<_%g_ACpQ&gXugfq``w2c;x{r8Q5b9@Y(v%(oo=gAYP z$mnCBg=65X63$c#i(^mG8p)t=7J82M@rCgpt7@-sG;XGV9TIG`n00y#9Q;DWeMYnW z4B?2stByr&yFoZ^?I`w_a-C#T=T70YGsl=yG*{dzoSI_JGV8wwg>%kxw7>kE<(v}E zX!f}%oYBgjavc-aJ$zmzeY0LTuX|2mod1|8lmgx^9En+K!=jkAML3(h9Br4MvE@1- zoJP-4IYsM