summaryrefslogtreecommitdiff
path: root/src/solvers/ocl.rs
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2020-01-04 00:52:36 +0100
committerDennis Kobert <dennis@kobert.dev>2020-01-04 00:52:36 +0100
commit862695a7374bc60368d09a7e695ae0b8aa3b97c2 (patch)
tree81512be6ea894c3933ee20f0dbb85c02bc7c262d /src/solvers/ocl.rs
parent82a65a82873c6699f12c9c6186705e0089c58240 (diff)
Rework intuitive solver to consider all solutions
Diffstat (limited to 'src/solvers/ocl.rs')
-rw-r--r--src/solvers/ocl.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/solvers/ocl.rs b/src/solvers/ocl.rs
new file mode 100644
index 0000000..7c6bb16
--- /dev/null
+++ b/src/solvers/ocl.rs
@@ -0,0 +1,29 @@
+use ocl::ProQue;
+
+pub fn trivial() -> ocl::Result<()> {
+ let src = r#"
+ __kernel void add(__global float* buffer, float scalar) {
+ buffer[get_global_id(0)] += scalar;
+ }
+ "#;
+
+ let pro_que = ProQue::builder().src(src).dims(1 << 20).build()?;
+
+ let buffer = pro_que.create_buffer::<f32>()?;
+
+ let kernel = pro_que
+ .kernel_builder("add")
+ .arg(&buffer)
+ .arg(10.0f32)
+ .build()?;
+
+ unsafe {
+ kernel.enq()?;
+ }
+
+ let mut vec = vec![0.0f32; buffer.len()];
+ buffer.read(&mut vec).enq()?;
+
+ println!("The value at index [{}] is now '{}'!", 200007, vec[200007]);
+ Ok(())
+}