微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

DtCraft 通用分布式编程系统

程序名称:DtCraft

授权协议: MIT

操作系统: 跨平台

开发语言: C/C++

DtCraft 介绍

DtCraft是一种基于数据并行流的通用分布式编程系统。 它提供了一种称为流图的新型强大编程模型,用于构建并行和分布式工作负载
将应用程序转换为此框架后,内核将透明地为您执行作业分发。 您不必担心系统编程,可以专注于高级开发!

无论您是应用程序开发人员还是特定领域的工程师,都可以使用 DtCraft 来做:

  • 分布式编程 distributed computing
  • 事件驱动编程 Event-driven programming
  • 网络编程 Network programming
  • 数据流处理 Data stream processing

示例代码

#include <dtc/dtc.hpp>

using namespace std::literals;  // for the use of string literal
using namespace dtc::literals;  // for the use of memory literal

int main(int argc, char* argv[]) {

  dtc::Graph G;

  auto A = G.vertex();
  auto B = G.vertex();

  auto lambda = [] (dtc::Vertex& v, dtc::InputStream& is) {
    if(std::string s; is(s) != -1) {
      std::cout << "Received: " << s << '\n';
      return dtc::Event::REMOVE;
    }
    return dtc::Event::DEFAULT;
  };

  auto AB = G.stream(A, B).on(lambda);
  auto BA = G.stream(B, A).on(lambda);

  A.on([&AB] (dtc::Vertex& v) { (*v.ostream(AB))("hello world from A"s); });  
  B.on([&BA] (dtc::Vertex& v) { (*v.ostream(BA))("hello world from B"s); });

  G.container().add(A).cpu(1).memory(1_GB);
  G.container().add(B).cpu(1).memory(1_GB);

  dtc::Executor(G).run();
}

DtCraft 官网

https://tsung-wei-huang.github.io/DtCraft/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐