delete deprecated hccl calling

Signed-off-by: zhoufeng <zhoufeng54@huawei.com>
pull/301/head
zhoufeng 4 years ago
parent 9d5177a954
commit ad4523637d

@ -1,7 +1,14 @@
if (NOT TARGET protobuf::protobuf) if (NOT TARGET ge_protobuf::ascend_protobuf)
if (AS_MS_COMP)
set(protobuf_USE_STATIC_LIBS OFF)
set(protobuf_CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=ON -DLIB_PREFIX=ascend_
-DCMAKE_C_FLAGS=\"-Dgoogle=ascend_private\" -DCMAKE_CXX_FLAGS=\"-Dgoogle=ascend_private\")
else ()
set(protobuf_USE_STATIC_LIBS ON) set(protobuf_USE_STATIC_LIBS ON)
set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2") set(protobuf_CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -DLIB_PREFIX=ascend_)
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") endif ()
set(ge_protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -D_GLIBCXX_USE_CXX11_ABI=0")
set(ge_protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
set(_ge_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) set(_ge_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
@ -14,20 +21,20 @@ else()
set(MD5 "3d9e32700639618a4d2d342c99d4507a") set(MD5 "3d9e32700639618a4d2d342c99d4507a")
endif () endif ()
graphengine_add_pkg(protobuf graphengine_add_pkg(ge_protobuf
VER 3.8.0 VER 3.8.0
LIBS protobuf LIBS ascend_protobuf
EXE protoc EXE protoc
URL ${REQ_URL} URL ${REQ_URL}
MD5 ${MD5} MD5 ${MD5}
CMAKE_PATH ../cmake/ CMAKE_PATH ../cmake/
CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF) CMAKE_OPTION ${protobuf_CMAKE_OPTION})
set(CMAKE_CXX_FLAGS ${_ge_tmp_CMAKE_CXX_FLAGS}) set(CMAKE_CXX_FLAGS ${_ge_tmp_CMAKE_CXX_FLAGS})
endif() endif()
add_library(graphengine::protobuf ALIAS protobuf::protobuf) add_library(graphengine::protobuf ALIAS ge_protobuf::ascend_protobuf)
set(PROTOBUF_LIBRARY protobuf::protobuf) set(PROTOBUF_LIBRARY ge_protobuf::ascend_protobuf)
include_directories(${protobuf_INC}) include_directories(${ge_protobuf_INC})
include_directories(${protobuf_DIRPATH}/src) include_directories(${ge_protobuf_DIRPATH}/src)
function(ge_protobuf_generate comp c_var h_var) function(ge_protobuf_generate comp c_var h_var)
if(NOT ARGN) if(NOT ARGN)
@ -51,8 +58,8 @@ function(ge_protobuf_generate comp c_var h_var)
"${CMAKE_BINARY_DIR}/proto/${comp}/proto/${file_name}.pb.h" "${CMAKE_BINARY_DIR}/proto/${comp}/proto/${file_name}.pb.h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto/${comp}/proto" COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto/${comp}/proto"
COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto/${comp}/proto ${abs_file} COMMAND ge_protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto/${comp}/proto ${abs_file}
DEPENDS protobuf::protoc ${abs_file} DEPENDS ge_protobuf::protoc ${abs_file}
COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM ) COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM )
endforeach() endforeach()

@ -112,7 +112,9 @@ function(__find_pkg_then_add_target pkg_name pkg_exe)
if(NOT ${pkg_exe}_EXE) if(NOT ${pkg_exe}_EXE)
return() return()
endif() endif()
if (NOT TARGET ${pkg_name}::${pkg_exe})
add_executable(${pkg_name}::${pkg_exe} IMPORTED GLOBAL) add_executable(${pkg_name}::${pkg_exe} IMPORTED GLOBAL)
endif ()
set_target_properties(${pkg_name}::${pkg_exe} PROPERTIES set_target_properties(${pkg_name}::${pkg_exe} PROPERTIES
IMPORTED_LOCATION ${${pkg_exe}_EXE} IMPORTED_LOCATION ${${pkg_exe}_EXE}
) )

@ -18,7 +18,6 @@
#define INC_FRAMEWORK_GE_RUNTIME_TASK_INFO_H_ #define INC_FRAMEWORK_GE_RUNTIME_TASK_INFO_H_
#include <stdint.h> #include <stdint.h>
#include <functional>
#include <memory> #include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
@ -219,9 +218,9 @@ class LabelSwitchTaskInfo : public TaskInfo {
label_list_(label_list), label_list_(label_list),
cond_(cond) {} cond_(cond) {}
~LabelSwitchTaskInfo() override {} ~LabelSwitchTaskInfo() override {}
uint32_t label_size() { return label_size_; }; uint32_t label_size() const { return label_size_; }
const std::vector<uint32_t> &label_list() { return label_list_; }; const std::vector<uint32_t> &label_list() const { return label_list_; }
void *cond() { return cond_; }; void *cond() const { return cond_; }
private: private:
uint32_t label_size_; uint32_t label_size_;
@ -236,7 +235,7 @@ class EventTaskInfo : public TaskInfo {
protected: protected:
EventTaskInfo(const std::string &op_name, uint32_t stream_id, TaskInfoType type, uint32_t event_id) 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) {} : TaskInfo(op_name, stream_id, type, false), event_id_(event_id) {}
virtual ~EventTaskInfo() override {} ~EventTaskInfo() override {}
uint32_t event_id_; uint32_t event_id_;
}; };
@ -272,16 +271,13 @@ class FusionEndTaskInfo : public TaskInfo {
class HcclTaskInfo : public TaskInfo { class HcclTaskInfo : public TaskInfo {
public: public:
HcclTaskInfo(const std::string &op_name, uint32_t stream_id, const std::string hccl_type, void *input_data_addr, 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<uint8_t> &private_def, void *ops_kernel_store, int32_t count, int64_t root_id, const std::vector<uint8_t> &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, int64_t op_type, int64_t data_type, const std::string &group, bool dump_flag)
std::function<bool(void *, void *)> hcom_bind_model, std::function<bool(void *)> hcom_unbind_model,
std::function<bool(std::shared_ptr<HcclTaskInfo>, void *)> hcom_distribute_task, bool dump_flag)
: TaskInfo(op_name, stream_id, TaskInfoType::HCCL, dump_flag), : TaskInfo(op_name, stream_id, TaskInfoType::HCCL, dump_flag),
hccl_type_(hccl_type), hccl_type_(hccl_type),
input_data_addr_(input_data_addr), input_data_addr_(input_data_addr),
output_data_addr_(output_data_addr), output_data_addr_(output_data_addr),
workspace_addr_(workspace_addr),
workspace_size_(workspace_size), workspace_size_(workspace_size),
hccl_stream_num_(hccl_stream_num), hccl_stream_num_(hccl_stream_num),
private_def_(private_def), private_def_(private_def),
@ -290,16 +286,12 @@ class HcclTaskInfo : public TaskInfo {
root_id_(root_id), root_id_(root_id),
op_type_(op_type), op_type_(op_type),
data_type_(data_type), data_type_(data_type),
group_(group), group_(group) {}
hcom_bind_model_(hcom_bind_model),
hcom_unbind_model_(hcom_unbind_model),
hcom_distribute_task_(hcom_distribute_task) {}
~HcclTaskInfo() override {} ~HcclTaskInfo() override {}
const std::string &hccl_type() const { return hccl_type_; } const std::string &hccl_type() const { return hccl_type_; }
void *input_data_addr() const { return input_data_addr_; } void *input_data_addr() const { return input_data_addr_; }
void *output_data_addr() const { return output_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 workspace_size() const { return workspace_size_; }
int64_t hccl_stream_num() const { return hccl_stream_num_; } int64_t hccl_stream_num() const { return hccl_stream_num_; }
const std::vector<uint8_t> &private_def() const { return private_def_; } const std::vector<uint8_t> &private_def() const { return private_def_; }
@ -309,17 +301,11 @@ class HcclTaskInfo : public TaskInfo {
int64_t op_type() const { return op_type_; } int64_t op_type() const { return op_type_; }
int64_t data_type() const { return data_type_; } int64_t data_type() const { return data_type_; }
const std::string &group() const { return group_; } const std::string &group() const { return group_; }
std::function<bool(void *, void *)> hcom_bind_model() const { return hcom_bind_model_; }
std::function<bool(void *)> hcom_unbind_model() const { return hcom_unbind_model_; }
std::function<bool(std::shared_ptr<HcclTaskInfo>, void *)> hcom_distribute_task() const {
return hcom_distribute_task_;
}
private: private:
std::string hccl_type_; std::string hccl_type_;
void *input_data_addr_; void *input_data_addr_;
void *output_data_addr_; void *output_data_addr_;
void *workspace_addr_;
int64_t workspace_size_; int64_t workspace_size_;
int64_t hccl_stream_num_; int64_t hccl_stream_num_;
std::vector<uint8_t> private_def_; std::vector<uint8_t> private_def_;
@ -329,9 +315,6 @@ class HcclTaskInfo : public TaskInfo {
int64_t op_type_; int64_t op_type_;
int64_t data_type_; int64_t data_type_;
std::string group_; std::string group_;
std::function<bool(void *, void *)> hcom_bind_model_;
std::function<bool(void *)> hcom_unbind_model_;
std::function<bool(std::shared_ptr<HcclTaskInfo>, void *)> hcom_distribute_task_;
}; };
class ProfilerTraceTaskInfo : public TaskInfo { class ProfilerTraceTaskInfo : public TaskInfo {

File diff suppressed because it is too large Load Diff

@ -19,7 +19,9 @@
#include <memory> #include <memory>
#include <set> #include <set>
#include <map>
#include <vector> #include <vector>
#include <mutex>
#include "ge_runtime/task/task.h" #include "ge_runtime/task/task.h"
namespace ge { namespace ge {
@ -33,18 +35,34 @@ class HcclTask : public TaskRepeater<HcclTaskInfo> {
bool Distribute() override; bool Distribute() override;
private: 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<StreamGuard> &stream);
std::shared_ptr<HcclTaskInfo> task_info_; std::shared_ptr<HcclTaskInfo> task_info_;
void *stream_; void *stream_;
void *workspace_mem_;
rtModel_t rt_model_handle_; rtModel_t rt_model_handle_;
int32_t priority_; int32_t priority_;
std::vector<void *> slave_stream_list_; std::vector<std::shared_ptr<StreamGuard>> secondary_stream_list_;
std::function<bool(void *, void *)> hcom_bind_model_;
std::function<bool(void *)> hcom_unbind_model_; // map<key: model pointer, value: map<key: primary stream id, value: vector<secondary stream pointer>>>
std::function<bool(std::shared_ptr<HcclTaskInfo>, void *)> hcom_distribute_task_; static std::map<rtModel_t, std::map<uint32_t, std::vector<std::weak_ptr<StreamGuard>>>> model_stream_mapping_;
static std::set<rtModel_t> rt_model_handle_list_; static std::mutex model_stream_mapping_mutex_;
}; };
std::set<rtModel_t> 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 model_runner
} // namespace ge } // namespace ge

Loading…
Cancel
Save