![]() |
乖乖的绿豆 · 如何通过C/C++实现IP直连访问HTTPD ...· 1 月前 · |
![]() |
俊逸的茶壶 · 【漏洞预警】CVE-2022-2588:Li ...· 1 月前 · |
![]() |
气势凌人的拐杖 · SQL character-阿里云· 3 周前 · |
![]() |
听话的香菜 · 【深度学习目标检测】_深度学习目标检测问题与 ...· 1 周前 · |
![]() |
大方的铁板烧 · 【HPPTDNS】WebView为什么只设置 ...· 3 天前 · |
![]() |
愉快的匕首 · 如何使用通义千问API_大模型服务平台百炼( ...· 7 月前 · |
![]() |
威武的水桶 · 如何用ArcGIS做一张彩色地图? - 知乎· 1 年前 · |
![]() |
奔跑的猴子 · python - Python ...· 1 年前 · |
![]() |
含蓄的酸菜鱼 · linux lib64目录下载 - ...· 1 年前 · |
![]() |
腼腆的八宝粥 · SqlServer-IN写法(普通、存储过程 ...· 1 年前 · |
Taskflow
可以帮助您在现代 C + + 中快速编写并行和异构的任务程序 。
Taskflow
是一款 C++ 下任务流程框架,可以管理
Pipeline
并执行并行工作。
Taskflow
的流程管理有
论文支撑
,具有一定理论安全性。
Taskflow
可以帮助您快速编写具有高性能和同时高生产率的并行和异构任务程序。与许多现有的任务编程库相比,它更快、更具表现力、代码行更少、更容易进行插入式集成。
v3.5
,
7.7k stars
Taskflow
使用需要源码
也可以直接获取整个仓库:
1 |
git clone https://github.com/taskflow/taskflow |
---|
下载仓库后切换到
v3.5.0
版本
1 |
git checkout v3.5.0 |
---|
使用时仅需引入源码目录中的
taskflow/taskflow.hpp
即可
将
Taskflow
源码目录添加到系统环境变量,在项目中添加引用目录,代码中直接
include
就可以使用了
1 |
#include <taskflow/taskflow.hpp> // Taskflow is header-only |
---|
命名空间叫
tf
:
1 |
using namespace tf; |
---|
Taskflow
需要 C++17 编译环境
如果使用 g++ 需要在命令行添加参数
-std=c++17
:
1 |
g++ -std=c++17 |
---|
属性
->
C/C++
->
语言
->
C++ 语言标准
中修改:
123456789101112131415161718192021 |
#include <taskflow/taskflow.hpp> // Taskflow is header-onlyint main(){ tf::Executor executor; tf::Taskflow taskflow; auto [A, B, C, D] = taskflow.emplace( // create four tasks [] () { std::cout << "TaskA\n"; }, [] () { std::cout << "TaskB\n"; }, [] () { std::cout << "TaskC\n"; }, [] () { std::cout << "TaskD\n"; } ); A.precede(B, C); // A runs before B and C D.succeed(B, C); // D runs after B and C executor.run(taskflow).wait(); return 0;} |
---|
1234 |
TaskATaskCTaskBTaskD |
---|
Taskflow
可以输出代码运行拓扑图
Taskflow
提供了解释流程图的网页工具
taskflow.dump(std::cout);
可以输出流程图代码
12345678910111213141516171819202122 |
#include <taskflow/taskflow.hpp> // Taskflow is header-onlyint main(){ tf::Executor executor; tf::Taskflow taskflow; tf::Task A = taskflow.emplace([]() {}).name("A"); tf::Task B = taskflow.emplace([]() {}).name("B"); tf::Task C = taskflow.emplace([]() {}).name("C"); tf::Task D = taskflow.emplace([]() {}).name("D"); tf::Task E = taskflow.emplace([]() {}).name("E"); A.precede(B, C, E); C.precede(D); B.precede(D, E); executor.run(taskflow).wait(); taskflow.dump(std::cout); return 0;} |
---|
12345678910111213141516 |
digraph Taskflow {subgraph cluster_p000000B14C93F2A8 {label="Taskflow: p000000B14C93F230";p0000022B29D89270[label="A" ];p0000022B29D89270 -> p0000022B29D89380;p0000022B29D89270 -> p0000022B29D89490;p0000022B29D89270 -> p0000022B29D896B0;p0000022B29D89380[label="B" ];p0000022B29D89380 -> p0000022B29D895A0;p0000022B29D89380 -> p0000022B29D896B0;p0000022B29D89490[label="C" ];p0000022B29D89490 -> p0000022B29D895A0;p0000022B29D895A0[label="D" ];p0000022B29D896B0[label="E" ];}} |
---|
Taskflow
还提供了 Profile 工具 (需要较高的
Taskflow
版本)
TF_ENABLE_PROFILER
指向一个 json 文件位置(路径可以相对、可以绝对)
123 |
[{"executor":"0","data":[{"worker":10,"level":0,"data":[{"span":[81,83],"name":"B","type":"static"},{"span":[84,84],"name":"E","type":"static"}]},{"worker":11,"level":0,"data":[{"span":[68,73],"name":"A","type":"static"},{"span":[80,80],"name":"C","type":"static"},{"span":[85,85],"name":"D","type":"static"}]}]}] |
---|
《Taskflow:A Lightweight Parallel and Heterogeneous Task Graph Computing System》
Copyright © 2013 - 2023 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号: 粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
扫码关注腾讯云开发者
领取腾讯云代金券