2 Star 6 Fork 6

Chunel / CGraph

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

languages os stars forks

awesome-cpp HelloGithub GitHub-Chinese-Top-Charts

中文 | English Readme

CGraph 说明文档

CGraph is a cross-platform Directed Acyclic Graph framework based on pure C++ without any 3rd-party dependencies. You, with it, can build your own operators simply, and describe any running schedules as you need, such as dependence, parallelling, aggregation and so on. Some useful tools and plugins are also provide to improve your project. Tutorials and contact information are show as follows. Please get in touch with us for free if you need more about this repository.

一. 简介

CGraph中文名为【色丶图】,是一套无任何第三方依赖的跨平台图流程执行框架。通过GPipeline(流水线)底层调度,实现了依赖元素依次顺序执行、非依赖元素并发执行的调度功能。

使用者只需继承GNode(节点)类,实现子类的run()方法,并根据需要设定依赖关系,即可实现任务的图化执行或流水线执行。还可以通过设定各种包含多节点信息的GGroup(组),自行控制图的条件判断、循环和并发执行逻辑。

项目提供了丰富的Param(参数)类型,用于不同应用场景下的数据互通。此外,还可以通过添加GAspect(切面)的方式,实现以上各种元素功能的横向扩展;通过引入GAdapter(适配器)对单个节点功能进行加强;或者通过添加GEvent(信号),丰富和优化执行逻辑。

CGraph Skeleton

本工程使用纯C++11标准库编写,无任何第三方依赖。兼容MacOSLinuxWindowsAndroid系统,支持通过 CLionVSCodeXcodeVisual StudioCode::BlocksQt Creator等多款IDE进行本地编译和二次开发,具体编译方式请参考 CGraph 编译说明

详细功能介绍和用法,请参考 推荐阅读 中的文章内容。项目相关视频在B站持续更新中,欢迎观看交流和一键三连:

二. 使用Demo

MyNode.h

#include "CGraph.h"

class MyNode1 : public CGraph::GNode {
public:
    CStatus run() override {
        printf("[%s], Sleep for 1 second ...\n", this->getName().c_str());
        CGRAPH_SLEEP_SECOND(1)
        return CStatus();
    }
};

class MyNode2 : public CGraph::GNode {
public:
    CStatus run() override {
        printf("[%s], Sleep for 2 second ...\n", this->getName().c_str());
        CGRAPH_SLEEP_SECOND(2)
        return CStatus();
    }
};

main.cpp

#include "MyNode.h"

using namespace CGraph;

int main() {
    /* 创建一个流水线,用于设定和执行流图信息 */
    GPipelinePtr pipeline = GPipelineFactory::create();
    GElementPtr a, b, c, d = nullptr;

    /* 注册节点之间的依赖关系 */
    pipeline->registerGElement<MyNode1>(&a, {}, "nodeA");
    pipeline->registerGElement<MyNode2>(&b, {a}, "nodeB");
    pipeline->registerGElement<MyNode1>(&c, {a}, "nodeC");
    pipeline->registerGElement<MyNode2>(&d, {b, c}, "nodeD");

    /* 执行流图框架 */
    pipeline->process();
    GPipelineFactory::remove(pipeline);

    return 0;
}

CGraph Demo
如上图所示,图结构执行的时候,首先执行a节点。a节点执行完毕后,并行执行bc节点。bc节点全部执行完毕后,再执行d节点。

三. 推荐阅读


四. 关联项目

  • GraphANNS : Graph-based Approximate Nearest Neighbor Search Working off CGraph
  • CThreadPool : 一个简单好用、功能强大、性能优异、跨平台的C++线程池
  • taskflow : A General-purpose Parallel and Heterogeneous Task Programming System
  • awesome-cpp : A curated list of awesome C++ (or C) frameworks, libraries, resources, and shiny things. Inspired by awesome-... stuff.
  • awesome-workflow-engines : A curated list of awesome open source workflow engines

附录-1. 版本信息

[2021.05.04 - v1.0.0 - Chunel]

  • 提供图化执行功能,支持非依赖节点并行计算

[2021.05.09 - v1.1.0 - Chunel]

  • 优化图执行过程中的并发度

[2021.05.18 - v1.1.1 - Chunel]

  • 添加节点namesession信息

[2021.05.23 - v1.2.0 - Chunel]

  • 提供单节点循环执行功能

[2021.05.29 - v1.3.0 - Chunel]

  • 提供cluster(簇)和region(区域)划分和循环执行功能
  • 提供tutorial内容,包含多种使用样例

[2021.06.14 - v1.4.0 - Chunel]

  • 提供param(参数)传递机制
  • 提供group(组)功能,多节点模块统一继承自group模块
  • 添加对Linux系统的的支持

[2021.06.20 - v1.4.1 - Chunel]

  • 提供condition(条件)功能
  • 添加对Windows系统的支持

[2021.06.24 - v1.5.0 - Chunel]

  • 提供pipeline工厂创建方法
  • 更新tutorial内容

[2021.07.07 - v1.5.1 - Chunel]

  • 优化线程池功能。实现任务盗取机制

[2021.07.11 - v1.5.2 - Chunel]

  • 优化线程池功能。实现线程数量自动调节机制

[2021.07.31 - v1.5.3 - Chunel]

  • 优化线程池功能。实现任务批量获取功能,优化任务盗取机制

[2021.08.29 - v1.6.0 - Chunel]

  • 提供多pipeline功能,优化底层逻辑
  • 更新tutorial内容

[2021.09.19 - v1.6.1 - Chunel]

  • 提供Lru算子、Trie算子和模板节点功能,优化底层逻辑
  • 更新tutorial内容

[2021.09.29 - v1.7.0 - Chunel]

  • 提供aspect(切面)功能,用于横向扩展nodegroup功能
  • 更新tutorial内容

[2021.10.07 - v1.7.1 - Chunel]

  • 优化aspect(切面)实现逻辑,提供切面参数功能,提供批量添加切面功能
  • 更新tutorial内容

[2021.11.01 - v1.8.0 - Chunel]

  • 提供adapter(适配器)功能,提供singleton适配器功能
  • 优化pipeline执行逻辑
  • 更新tutorial内容

[2021.12.18 - v1.8.1 - Chunel]

  • 优化了返回值CStatus信息

[2022.01.02 - v1.8.2 - Chunel]

  • 提供节点执行超时自动退出功能,提供task group(任务组)功能
  • 提供线程池配置参数设置方法

[2022.01.23 - v1.8.3 - Chunel]

  • 提供function适配器,实现函数式编程功能
  • 提供线程优先级调度功能,提供线程绑定cpu执行功能
  • 更新tutorial内容

[2022.01.31 - v1.8.4 - Chunel]

  • 提供node(节点)异步执行的功能

[2022.02.03 - v1.8.5 - Chunel]

  • 提供daemon(守护)功能,用于定时执行非流图中任务
  • 更新tutorial内容

[2022.04.03 - v1.8.6 - Chunel]

  • 提供DistanceCalculator算子,用于实现任意数据类型、任意距离类型的计算
  • 更新tutorial内容

[2022.04.05 - v2.0.0 - Chunel]

  • 提供domain(领域)功能,提供Ann领域抽象模型,开始支持个别专业方向
  • 提供hold执行机制
  • 更新tutorial内容

[2022.05.01 - v2.0.1 - Chunel]

  • 优化pipeline注册机制,支持init方法自定义顺序执行
  • 提供一键编译脚本

[2022.05.29 - v2.1.0 - Chunel]

  • 提供element参数写入方法
  • 提供针对C++14版本的支持
  • 更新tutorial内容

[2022.10.03 - v2.1.1 - Chunel]

  • 提供线程池中的任务优先级机制
  • 优化group执行逻辑

[2022.11.03 - v2.2.0 - Chunel]

  • 提供message(消息)功能,主要用于完成不同pipeline之间的数据传递
  • 更新tutorial内容

[2022.12.24 - v2.2.1 - Chunel]

  • 提供TemplateNode(模板节点)功能,用于优化参数传参方式
  • 更新tutorial内容

[2022.12.25 - v2.2.2 - yeshenyong]

  • 优化图执行逻辑

[2022.12.30 - v2.2.3 - Chunel]

  • 提供message发布订阅功能
  • 提供执行引擎切换功能

[2023.01.21 - v2.3.0 - Chunel]

  • 提供event(事件)功能
  • 提供CGraph Intro.xmind文件,通过脑图的方式,介绍了CGraph的整体逻辑

[2023.01.25 - v2.3.1 - Chunel]

  • 提供针对C++11版本的支持。感谢 MirrorYuChen 提供相关解决方案

[2023.02.10 - v2.3.2 - Chunel]

  • 优化调度策略,提供调度参数配置接口
  • 提供英文版本readme.md

[2023.02.12 - v2.3.3 - yeshenyong, Chunel]

  • 提供graphviz可视化图展示功能
  • 提供参数链路追踪功能

[2023.02.22 - v2.3.4 - Chunel]

  • 优化Windows系统下调度机制
  • 优化param机制和event(事件)机制

[2023.03.25 - v2.4.0 - woodx, Chunel]

  • 提供可运行的docker环境,和构建docker环境的dockerfile文件
  • 提供pipeline调度资源管控机制
  • 优化调度性能

[2023.05.05 - v2.4.1 - Chunel]

  • 提供线程绑定执行功能
  • 提供pipeline最大并发度获取方法。感谢 Hanano-Yuuki 提供相关解决方案
  • 提供pipeline异步执行功能和执行时退出功能

[2023.06.17 - v2.4.2 - Chunel]

  • 提供MultiCondition(多条件)功能
  • 提供pipeline暂停执行和恢复执行功能

[2023.07.12 - v2.4.3 - Chunel]

  • 优化CStatus功能,添加了异常定位信息

[2023.09.05 - v2.5.0 - Chunel]

  • 提供perf功能,用于做pipeline的性能分析
  • 提供element的超时机制
  • 提供some(部分)功能,优化pipeline的异步执行方式

[2023.09.15 - v2.5.1 - Chunel]

  • 提供fence(栅栏)功能
  • 提供coordinator(协调)功能

[2023.11.06 - v2.5.2 - Chunel]

  • 优化message(消息)功能,可以设定写入阻塞时的处理方式,减少内存copy次数
  • 添加example相关内容,针对不同行业,提供一些简单实现
  • 优化调度性能

[2023.11.15 - v2.5.3 - Chunel]

  • 提供proto定义文件
  • 添加mutable(异变)功能,提供依赖关系注册语法糖

[2024.01.05 - v2.5.4 - Chunel]

  • 提供test内容,包含性能和功能方面的测试用例
  • 优化event(事件)机制,支持异步等待功能

[2024.01.24 - v2.6.0 - Chunel]

  • 提供pipeline的拓扑执行的方式
  • 提供判定element之间是否有依赖关系的方法

附录-2. 感谢

  • Thanks to the recommendation from awesome-cpp, we all know, it is the most authoritative recommendation list for cpp project in the world
  • Thanks to the recommendation from Taskflow Group: awesome-parallel-computing, and we always treat taskflow as a role model
  • Thanks to the recommendation from awesome-workflow-engines
  • 感谢各位开发者 CONTRIBUTORS 为项目做出的贡献
  • 感谢所有为CGraph项目提出的意见和建议的朋友,在此不一一提及。随时欢迎大家加入,一起共建

附录-3. 联系方式
MIT License Copyright (c) 2024 Chunel Feng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

【A simple C++ DAG framework】 一个简单好用的、无任何三方依赖的、跨平台的、收录于awesome-cpp的、基于流图的并行计算框架。欢迎star & fork 展开 收起
C++ 等 5 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/Chunel_Feng/CGraph.git
git@gitee.com:Chunel_Feng/CGraph.git
Chunel_Feng
CGraph
CGraph
main

搜索帮助