• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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 
17 #ifndef MINDSPORE_MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_EXECUTOR_HCCL_DYNAMIC_KERNEL_H_
18 #define MINDSPORE_MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_EXECUTOR_HCCL_DYNAMIC_KERNEL_H_
19 
20 #include <condition_variable>
21 #include <string>
22 #include "runtime/device/executor/dynamic_kernel.h"
23 
24 #include "utils/ms_utils.h"
25 
26 namespace mindspore {
27 namespace device {
28 namespace ascend {
29 class HcclDynamicKernel : public DynamicKernel {
30  public:
HcclDynamicKernel(const std::string & hccl_type,void * input_ptr,void * output_ptr,uint64_t count,int32_t data_type,int32_t op_type,int32_t root,void * stream,const CNodePtr & cnode_ptr)31   HcclDynamicKernel(const std::string &hccl_type, void *input_ptr, void *output_ptr, uint64_t count, int32_t data_type,
32                     int32_t op_type, int32_t root, void *stream, const CNodePtr &cnode_ptr)
33       : DynamicKernel(stream, cnode_ptr),
34         hccl_type_(hccl_type),
35         input_ptr_(input_ptr),
36         output_ptr_(output_ptr),
37         count_(count),
38         data_type_(data_type),
39         op_type_(op_type),
40         root_(root) {}
41   ~HcclDynamicKernel() override = default;
42   void UpdateArgs() override;
43   void Execute() override;
44   void PostExecute() override;
45 
46  private:
47   std::string hccl_type_;
48   void *input_ptr_;
49   void *output_ptr_;
50   uint64_t count_{0};
51   int32_t data_type_{0};
52   int32_t op_type_{0};
53   int32_t root_{0};
54   std::mutex hccl_mutex_;
55   std::condition_variable cond_;
56 
57   void StaticShapeExecute();
58 };
59 }  // namespace ascend
60 }  // namespace device
61 }  // namespace mindspore
62 #endif  // MINDSPORE_MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_EXECUTOR_HCCL_DYNAMIC_KERNEL_H_
63