• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2024 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include <string>
17 #include "transform/symbol/symbol_utils.h"
18 #include "transform/symbol/acl_prof_symbol.h"
19 
20 namespace mindspore {
21 namespace transform {
22 aclprofCreateConfigFunObj aclprofCreateConfig_ = nullptr;
23 aclprofDestroyConfigFunObj aclprofDestroyConfig_ = nullptr;
24 aclprofFinalizeFunObj aclprofFinalize_ = nullptr;
25 aclprofInitFunObj aclprofInit_ = nullptr;
26 aclprofStartFunObj aclprofStart_ = nullptr;
27 aclprofStopFunObj aclprofStop_ = nullptr;
28 aclprofCreateStepInfoFunObj aclprofCreateStepInfo_ = nullptr;
29 aclprofGetStepTimestampFunObj aclprofGetStepTimestamp_ = nullptr;
30 aclprofDestroyStepInfoFunObj aclprofDestroyStepInfo_ = nullptr;
31 
LoadProfApiSymbol(const std::string & ascend_path)32 void LoadProfApiSymbol(const std::string &ascend_path) {
33   std::string profiler_plugin_path = ascend_path + "lib64/libmsprofiler.so";
34   auto handler = GetLibHandler(profiler_plugin_path);
35   if (handler == nullptr) {
36     MS_LOG(WARNING) << "Dlopen " << profiler_plugin_path << " failed!" << dlerror();
37     return;
38   }
39   aclprofCreateConfig_ = DlsymAscendFuncObj(aclprofCreateConfig, handler);
40   aclprofDestroyConfig_ = DlsymAscendFuncObj(aclprofDestroyConfig, handler);
41   aclprofFinalize_ = DlsymAscendFuncObj(aclprofFinalize, handler);
42   aclprofInit_ = DlsymAscendFuncObj(aclprofInit, handler);
43   aclprofStart_ = DlsymAscendFuncObj(aclprofStart, handler);
44   aclprofStop_ = DlsymAscendFuncObj(aclprofStop, handler);
45   aclprofCreateStepInfo_ = DlsymAscendFuncObj(aclprofCreateStepInfo, handler);
46   aclprofGetStepTimestamp_ = DlsymAscendFuncObj(aclprofGetStepTimestamp, handler);
47   aclprofDestroyStepInfo_ = DlsymAscendFuncObj(aclprofDestroyStepInfo, handler);
48   MS_LOG(INFO) << "Load acl prof api success!";
49 }
50 
51 }  // namespace transform
52 }  // namespace mindspore
53