1 个不稳定版本
使用旧的 Rust 2015
0.1.0 | 2016年5月23日 |
---|
在 #build-time 中排名 51
43KB
949 行
rispc
使用 rispc
首先,您需要为您的 crate 添加一个构建脚本 (build.rs
),并将 rispc
添加到您的 build-dependencies
中,将 rispsrt
添加到您的 dependencies
中。
# Cargo.toml
[package]
# ...
build = "build.rs"
[build-dependencies]
rispc = "0.1"
[dependencies]
rispcrt = "0.1"
接下来,您需要编写一个像这样的构建脚本
// build.rs
extern crate rispc;
fn main() {
rispc::compile_library("libmandelbrot.a", &[ "src/mandelbrot.ispc" ]);
}
就是这样!运行 cargo build
应该可以处理剩下的工作,并且您的 Rust 应用程序现在将包含编译进它的 ispc 文件 mandelbrot.ispc
。您可以用与 C 函数相同的方式调用 Rust 中的函数。
示例
查看 ispc-demo
文件夹以获取使用 ISPC 绑定的示例应用程序。
许可证
The MIT License (MIT)
Copyright (c) 2016 Clark Gaebel <cg.wowus.cg@gmail.com>
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.
lib.rs
:
rispc 构建代码的任务系统。
如果您的 ispc 代码使用任务,则需要将此库作为依赖项。
目前使用 pthreads。将来,我希望此库能够支持自定义的可插拔任务系统。欢迎提交拉取请求。
有关更多文档,请参阅 rispc
crate。