From 862695a7374bc60368d09a7e695ae0b8aa3b97c2 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sat, 4 Jan 2020 00:52:36 +0100 Subject: Rework intuitive solver to consider all solutions --- src/solvers/ocl.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/solvers/ocl.rs (limited to 'src/solvers/ocl.rs') 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::()?; + + 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(()) +} -- cgit v1.2.3-70-g09d2