尧图网站设计 尧图网站设计YAOTU DESIGN
ARTICLE DETAIL

资讯详情

深耕网站设计与一线实操的经验洞察。

Bend 如何安装并运行第一个 .bend 程序?

Bend 如何安装并运行第一个 .bend 程序? Bend 如何安装并运行第一个 .bend 程序【免费下载链接】BendA massively parallel, high-level programming language项目地址: https://gitcode.com/GitHub_Trending/be/Bend要在自己的机器上安装 Bend 并跑通第一个.bend程序需要完成三步安装依赖Rust 与 GCC可选 CUDA、通过 cargo 安装 HVM2 运行时和 Bend 本身、然后写一个 Hello, world! 程序并用 Bend 的内置解释器运行、确认输出。Bend 是一个高级、大规模并行的编程语言语法接近 Python底层由 HVM2 运行时驱动见 README.md。适用平台以官方文档为准Linux 和 macOS 均给出安装步骤Windows 官方说明还在开发中文档建议用 WSL2 代替见 FAQ.md。GPU 路径bend run-cu目前只支持 NVIDIA 显卡CPU 路径不受此限制。第一步安装依赖依赖分两部分Rust 工具链用于 cargo 安装 HVM2 和 Bend和 GCCBend 的 C 版本使用 GCC官方建议用不超过 12.x 的版本。Linux 上按 README.md 执行# Install Rust if you havent already. curl --proto https --tlsv1.2 -sSf https://sh.rustup.rs | sh # For the C version of Bend, use GCC. We recommend a version up to 12.x. sudo apt install gccmacOS 上对应 Homebrew 命令# Install Rust if you havent it already. curl --proto https --tlsv1.2 -sSf https://sh.rustup.rs | sh # For the C version of Bend, use GCC. We recommend a version up to 12.x. brew install gcc说明一下副作用与前提sudo apt install gcc需要管理员权限并在 Debian/Ubuntu 系仓库中安装包brew install gcc依赖已安装 Homebrew。如果你打算在 GPU 上运行可选分支还需要在 Linux 上安装 CUDA toolkit 12.xREADME 中给出的是 NVIDIA 官方下载页的链接需自行前往安装。仅跑第一个 CPU 程序可以跳过这一步。第二步安装 HVM2 并验证Bend 的运行依赖 HVM2README 称之为 HOCs massively parallel Interaction Combinator evaluator所以必须先装 HVM2再装 Bend# HVM2 is HOCs massively parallel Interaction Combinator evaluator. cargo install hvm # This ensures HVM is correctly installed and accessible. hvm --versionhvm --version能打印版本号说明 HVM2 已安装且hvm在 PATH 中可访问。第三步安装 Bend 并验证# This command will install Bend cargo install bend-lang # This ensures Bend is correctly installed and accessible. bend --version验证方式是bend --version能输出版本信息。如果这一步报 command not found见文末的排查一节。写第一个程序GUIDE.md 给出的最小 Hello, world! 程序如下保存为main.benddef main(): return Hello, world!然后运行bend run-rs main.bend按 GUIDE 的说法If all goes well, you should seeHello, world!in both cases即终端应显示Hello, world!。如果想体会 Bend 的 IO 写法仓库自带 examples/hello_world.bend内容是def main() - IO(u24): with IO: * - IO/print(Hello, world!\n) return wrap(0)GUIDE 指出 Bend 的 IO 目前处于实验阶段experimental stage这个 IO 版本的运行命令是bend run-c main.bend选择运行命令README 列出了四个运行入口第一个程序用其中任意 CPU 路径即可bend run file.bend # uses the C interpreter by default (parallel) bend run-rs file.bend # uses the Rust interpreter (sequential) bend run-c file.bend # uses the C interpreter (parallel) bend run-cu file.bend # uses the CUDA interpreter (massively parallel)run-rsRust 参考解释器顺序执行GUIDE 说明它最慢run-c/runC 解释器可并行速度更快run-cuCUDA 解释器仅在装有 NVIDIA GPU 和 CUDA toolkit 12.x 时使用。如果代码本身可并行换用并行解释器就会并行执行不需要额外的线程创建或并行标注README 原话If your code can run in parallel it will run in parallel。可选README 提到加-s参数可以打印更多信息包括 Reductions归约次数、Time the code took to run运行耗时和 Interaction per second每秒交互数单位百万例如bend run-c main.bend -s。安装后的常见问题排查以下现象和处理方式均来自 FAQ.md只对应当前安装场景终端提示Commandbendnot found多数情况是~/.cargo/bin没进 PATH。FAQ 给出的修复步骤会修改你的 shell 配置文件~/.bashrc或~/.zshrc副作用是追加一条export语句确认 shell 类型后执行# 使用 bash 的系统 echo -n export PATH$PATH:$HOME/.cargo/bin ~/.bashrc source ~/.bashrc # 使用 zsh 的系统把 ~/.bashrc 换成 ~/.zshrc然后重新执行bend --version验证。提示CUDA not available!但已安装 CUDACUDA 支持只在安装 HVM 时检测。如果先装了 HVM 再装 CUDA 和nvcc需要重新安装 HVM 让它重新检测。Linux 上安装 HVM 时报错FAQ 列了两类已知报错——错误发生在编译 CUDA runtime 时或内容涉及ccbin或错误内容涉及libcmissing。具体讨论指向 FAQ 中引用的上游 issue可对照 FAQ.md 中 I got an error when installing HVM on Linux 一节。GPU 支持范围FAQ 说明 GPUs with 96KB L1 cache per SMshouldwork其中只有 RTX 4090 标注为已测试Tested? Yes其余 40/30 系列桌面与移动显卡均未测试AMD/Intel/Apple GPU 暂不支持。如果你只跑 CPU 路径这些限制不影响第一个程序。验证完成安装与首次运行成功的判定依据是文档中明确给出的三处检查点hvm --version能输出 HVM2 的版本号bend --version能输出 Bend 的版本号运行main.bend后终端打印Hello, world!。到此 Bend 的安装和首个程序运行流程即已完成。后续如果想了解语言特性或更多示例可以看 GUIDE.md 的教程正文和 examples 目录下的.bend文件如 examples/fib.bend。【免费下载链接】BendA massively parallel, high-level programming language项目地址: https://gitcode.com/GitHub_Trending/be/Bend创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表