|
|
睿智的柿子 · cef qt - Bigben · 3 月前 · |
|
|
豪爽的豌豆 · 还在为玩不了ChatGPT苦恼?这十几个开源 ...· 3 周前 · |
|
|
深情的砖头 · 解决pdf文件无法打印问题的最好方法_spl ...· 9 月前 · |
|
|
老实的香槟 · 人工智能如何赋能业务创新?安克创新有话要说_ ...· 1 年前 · |
|
|
打酱油的青蛙 · 深公司早报丨比亚迪采购40亿元锂产品,欣旺达 ...· 1 年前 · |
|
|
帅气的木耳 · 小红帽sana动画在哪里看 – 快看漫画问答· 2 年前 · |
|
|
强悍的台灯 · Read replicas - Azure ...· 2 年前 · |
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
扫码关注腾讯云开发者
领取腾讯云代金券