Closed Ote-Leo closed 7 months ago
You want a vector of u8
not u16
. Characters are 8 bits. In case it was confusing, the 16 in char16
just means the length of the vector (so 16 x 8 total bits per vector in this case).
Oh thanks, I fixed it
use ocl::{MemFlags, ProQue, Result};
const KERNEL: &str = r#"
__kernel void hello_kernel(__global uchar16* message) {
*message = (uchar16) ( 'H', 'e', 'l', 'l', 'o', ' ', 'K', 'e', 'r', 'n', 'e', 'l', '!', '!', '!', '\0' );
}
"#;
pub fn run() -> Result<()> {
let pro_que = ProQue::builder().src(KERNEL).dims(1).build()?;
let buffer = pro_que
.buffer_builder::<u8>()
.flags(MemFlags::WRITE_ONLY)
.len(16)
.build()?;
let kernel = pro_que
.kernel_builder("hello_kernel")
.arg(&buffer)
.build()?;
unsafe {
kernel.enq()?;
}
let mut message = [0u8; 16];
buffer.read(message.as_mut_slice()).enq()?;
let message = String::from_utf8_lossy(&message);
println!("Found Message: {message}");
Ok(())
}
fn main() {
run().unwrap();
}
I'm trying to learn OpenCL and I cannot figure out how to overcome this runtime error:
The original code is: