Skip to content

Commit

Permalink
[bugfix] fix makeSerial bug in cluster and condition situation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Jul 18, 2023
1 parent 39d74ef commit 57984f7
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 24 deletions.
9 changes: 4 additions & 5 deletions src/CBasic/CStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ CGRAPH_NAMESPACE_BEGIN
* 仅针对类似 bean 数据类型的定义
*/
class CStruct {
/**
* 初始化所有字段的值信息
* @return
*/
public:
/**
* 初始化所有字段的值信息
* @return
*/
virtual CStatus setup() {
CGRAPH_EMPTY_FUNCTION
}
Expand Down
2 changes: 1 addition & 1 deletion src/DomainCtrl/Ann/DAnnObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
CGRAPH_NAMESPACE_BEGIN

class DAnnObject : public DomainObject {
public:
protected:
CStatus run() override {
CGRAPH_NO_SUPPORT
}
Expand Down
6 changes: 3 additions & 3 deletions src/GraphCtrl/GraphElement/GAdapter/GFunction/GFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class GFunction : public GAdapter {
private:
explicit GFunction();

CStatus init() override;
CStatus init() final;

CStatus run() override;
CStatus run() final;

CStatus destroy() override;
CStatus destroy() final;

private:
CGRAPH_CSTATUS_FUNCTION init_function_ = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ CBool GCluster::isDone() {
/* 所有的element均被执行过,则提示true */
return std::all_of(group_elements_arr_.begin(), group_elements_arr_.end(),
[](GElementPtr element) {
return element->done_;
});
return element->done_;
});
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CVoid GCondition::dump(std::ostream& oss) {
const auto& cur = group_elements_arr_[i];
cur->dump(oss);

std::string label = "[label=\"" + std::to_string(i) + "\"]";
const std::string& label = "[label=\"" + std::to_string(i) + "\"]";
dumpEdge(oss, this, cur, label);
}

Expand Down
16 changes: 14 additions & 2 deletions src/GraphCtrl/GraphElement/GGroup/GCondition/GMultiCondition.inl
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,20 @@ CIndex GMultiCondition<type>::choose() {

template<GMultiConditionType type>
CBool GMultiCondition<type>::isSerializable() {
// 当其中只有一个元素,或者设定了串行模式的时候,才可以线性执行
return group_elements_arr_.size() <= 1 || GMultiConditionType::SERIAL == type;
if (GMultiConditionType::PARALLEL == type && group_elements_arr_.size() > 1) {
/**
* 如果是PARALLEL模式的话,并且其中的元素个数大于1,则一定不可以串行执行
* PARALLEL模式中,仅有一个元素的情况,和 SERIAL模式的判断方式一样,
* 均为判断其中所有的element是否可以并行
* 故放在下面的条件中判断了
*/
return false;
}

return std::all_of(group_elements_arr_.begin(), group_elements_arr_.end(),
[](GElementPtr element) {
return element->isSerializable();
});
}

CGRAPH_NAMESPACE_END
12 changes: 12 additions & 0 deletions src/GraphCtrl/GraphElement/GGroup/GGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ CVoid GGroup::dumpGroupLabelEnd(std::ostream& oss) {
oss << "}\n";
}


CBool GGroup::isSerializable() {
/**
* 针对group的情况,应该是所有在其中的element 都是可以串行的,才认定为可串行
* 但是在 region和 multiCondition中,有针对性的判断
*/
return std::all_of(group_elements_arr_.begin(), group_elements_arr_.end(),
[](GElementPtr element) {
return element->isSerializable();
});
}

CGRAPH_NAMESPACE_END
20 changes: 12 additions & 8 deletions src/GraphCtrl/GraphElement/GGroup/GGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,14 @@ CGRAPH_NAMESPACE_BEGIN

/* 所有节点组合的基类,所有节点组合功能,均继承自此类 */
class GGroup : public GElement {
public:
explicit GGroup();

protected:
/**
* 向group中,添加element信息
* @param element
* @return
*/
virtual CStatus addElement(GElementPtr element) = 0;

CStatus init() override;

CStatus destroy() override;

protected:
/**
* 生成graphviz中 group对应的label 的开头信息
* @param oss
Expand All @@ -48,8 +41,19 @@ class GGroup : public GElement {
*/
CVoid dumpGroupLabelEnd(std::ostream& oss);

explicit GGroup();

CStatus init() override;

CStatus destroy() override;

CBool isSerializable() override;

protected:
GElementPtrArr group_elements_arr_; // 存放 element的数组

friend class GStaticEngine;
friend class GPipeline;
};

using GGroupPtr = GGroup *;
Expand Down
4 changes: 3 additions & 1 deletion src/GraphCtrl/GraphPipeline/_GSchedule/GSchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
CGRAPH_NAMESPACE_BEGIN

class GSchedule : public GraphObject {
protected:
private:
/**
* 设置调度资源模式
* @param tp
Expand All @@ -35,6 +35,8 @@ class GSchedule : public GraphObject {

CStatus destroy() final;

explicit GSchedule() = default;

~GSchedule() override;

private:
Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set_project("CGraph")

-- set project version
set_version("2.4.0")
set_version("2.4.3")

-- set language: c++11
set_languages("c++11")
Expand Down

0 comments on commit 57984f7

Please sign in to comment.