66// SPDX-License-Identifier: MIT OR Apache-2.0
77//
88
9+ use half:: f16;
910use sycl_rs:: prelude:: * ;
1011
1112static IOTA_SRC : & str = r#"
@@ -15,16 +16,16 @@ namespace syclexp = sycl::ext::oneapi::experimental;
1516
1617extern "C"
1718SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::nd_range_kernel<1>))
18- void iota(float start, float *ptr) {
19+ void iota(sycl::half start, sycl::half *ptr) {
1920 size_t id = syclext::this_work_item::get_nd_item<1>().get_global_linear_id();
20- ptr[id] = start + static_cast<float >(id);
21+ ptr[id] = start + static_cast<sycl::half >(id);
2122}
2223"# ;
2324
2425#[ tokio:: main]
2526async fn main ( ) -> sycl_rs:: Result < ( ) > {
2627 let mut queue = Queue :: new ( ) ;
27- let mut device_array = queue. alloc_device :: < f32 > ( 1024 ) ?. await ?;
28+ let mut device_array = queue. alloc_device :: < f16 > ( 1024 ) ?. await ?;
2829
2930 let kernel = queue
3031 . get_context ( )
@@ -36,12 +37,12 @@ async fn main() -> sycl_rs::Result<()> {
3637 queue. launch (
3738 NdRange :: new ( [ 1024 ] , [ 16 ] ) ,
3839 & kernel,
39- ( 3.14_f32 , & mut device_array) ,
40+ ( f16 :: from_f32 ( 3.14 ) , & mut device_array) ,
4041 )
4142 } ?
4243 . await ?;
4344
44- let mut host_array = queue. alloc_host :: < f32 > ( 1024 ) ?. await ?;
45+ let mut host_array = queue. alloc_host :: < f16 > ( 1024 ) ?. await ?;
4546
4647 queue. copy ( & device_array, & mut host_array) ?. await ?;
4748
0 commit comments