Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sycl/sycl-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ pin-project = "1.1.13"
thiserror = "2.0.18"

[dev-dependencies]
half = { version = "2.7.1", features = ["bytemuck"] }
tokio = { version = "1.52.3", features = ["macros", "rt", "rt-multi-thread"] }
11 changes: 6 additions & 5 deletions sycl/sycl-rs/examples/kernel_launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
//

use half::f16;
use sycl_rs::prelude::*;

static IOTA_SRC: &str = r#"
Expand All @@ -15,16 +16,16 @@ namespace syclexp = sycl::ext::oneapi::experimental;

extern "C"
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::nd_range_kernel<1>))
void iota(float start, float *ptr) {
void iota(sycl::half start, sycl::half *ptr) {
size_t id = syclext::this_work_item::get_nd_item<1>().get_global_linear_id();
ptr[id] = start + static_cast<float>(id);
ptr[id] = start + static_cast<sycl::half>(id);
}
"#;

#[tokio::main]
async fn main() -> sycl_rs::Result<()> {
let mut queue = Queue::new();
let mut device_array = queue.alloc_device::<f32>(1024)?.await?;
let mut device_array = queue.alloc_device::<f16>(1024)?.await?;

let kernel = queue
.get_context()
Expand All @@ -36,12 +37,12 @@ async fn main() -> sycl_rs::Result<()> {
queue.launch(
NdRange::new([1024], [16]),
&kernel,
(3.14_f32, &mut device_array),
(f16::from_f32(3.14), &mut device_array),
)
}?
.await?;

let mut host_array = queue.alloc_host::<f32>(1024)?.await?;
let mut host_array = queue.alloc_host::<f16>(1024)?.await?;

queue.copy(&device_array, &mut host_array)?.await?;

Expand Down