From c2dc58de179111e28af1ad1be2670a68ca39e8d4 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Mon, 29 Jun 2026 08:40:48 +0000 Subject: [PATCH 01/54] Add Cargo project files --- .gitignore | 1 + Cargo.lock | 290 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 7 ++ src/main.rs | 3 + 4 files changed, 301 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..07c3da9 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,290 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "cc" +version = "1.2.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "clap" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "cxx" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747d8437319e3a2f43d93b341c137927ca70c0f5dabeea7a005a73665e247c7e" +dependencies = [ + "cc", + "cxx-build", + "cxxbridge-cmd", + "cxxbridge-flags", + "cxxbridge-macro", + "foldhash", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0f4697d190a142477b16aef7da8a99bfdc41e7e8b1687583c0d23a79c7afc1e" +dependencies = [ + "cc", + "codespan-reporting", + "indexmap", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-cmd" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0956799fa8678d4c50eed028f2de1c0552ae183c76e976cf7ca8c4e36a7c328" +dependencies = [ + "clap", + "codespan-reporting", + "indexmap", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23384a836ab4f0ad98ace7e3955ad2de39de42378ab487dc28d3990392cb283a" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6acc6b5822b9526adfb4fc377b67128fdd60aac757cc4a741a6278603f763cf" +dependencies = [ + "indexmap", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f78c730aaa7d0b9336a299029ea49f9ee53b0ed06e9202e8cb7db9bae7b8c82" +dependencies = [ + "cc", +] + +[[package]] +name = "oneapi-rs" +version = "0.1.0" +dependencies = [ + "cxx", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "scratch" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..0ea8678 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "oneapi-rs" +version = "0.1.0" +edition = "2024" + +[dependencies] +cxx = "1.0.194" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} From 3073e59b03eca7a7a350a427f81d376944ec5712 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Mon, 29 Jun 2026 10:36:35 +0000 Subject: [PATCH 02/54] Add clang format --- .clang-format | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..ecb44bf --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: LLVM +LineEnding: LF From f8b2a5bc2cfc95cf6f70b4892c1d39391540cf51 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Mon, 29 Jun 2026 13:57:31 +0000 Subject: [PATCH 03/54] Ignore VS Code files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ea8c4bf..81cf465 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/.vscode From eb9f925b772f998469d8f513079c7c5cd20fdd05 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Mon, 29 Jun 2026 13:58:41 +0000 Subject: [PATCH 04/54] Add a new system bindings workspace member --- Cargo.lock | 3 +- Cargo.toml | 10 +- oneapi-rs-sys/Cargo.lock | 291 +++++++++++++++++++++++++++++++++ oneapi-rs-sys/Cargo.toml | 10 ++ oneapi-rs-sys/build.rs | 10 ++ oneapi-rs-sys/include/shim.hpp | 2 + oneapi-rs-sys/src/main.rs | 11 ++ oneapi-rs-sys/src/shim.cpp | 5 + src/main.rs | 3 - 9 files changed, 334 insertions(+), 11 deletions(-) create mode 100644 oneapi-rs-sys/Cargo.lock create mode 100644 oneapi-rs-sys/Cargo.toml create mode 100644 oneapi-rs-sys/build.rs create mode 100644 oneapi-rs-sys/include/shim.hpp create mode 100644 oneapi-rs-sys/src/main.rs create mode 100644 oneapi-rs-sys/src/shim.cpp delete mode 100644 src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 07c3da9..96822b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,10 +161,11 @@ dependencies = [ ] [[package]] -name = "oneapi-rs" +name = "oneapi-rs-sys" version = "0.1.0" dependencies = [ "cxx", + "cxx-build", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0ea8678..f7f26e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,3 @@ -[package] -name = "oneapi-rs" -version = "0.1.0" -edition = "2024" - -[dependencies] -cxx = "1.0.194" +[workspace] +resolver = "3" +members = ["oneapi-rs-sys"] diff --git a/oneapi-rs-sys/Cargo.lock b/oneapi-rs-sys/Cargo.lock new file mode 100644 index 0000000..3db85fb --- /dev/null +++ b/oneapi-rs-sys/Cargo.lock @@ -0,0 +1,291 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "cc" +version = "1.2.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "clap" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "cxx" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747d8437319e3a2f43d93b341c137927ca70c0f5dabeea7a005a73665e247c7e" +dependencies = [ + "cc", + "cxx-build", + "cxxbridge-cmd", + "cxxbridge-flags", + "cxxbridge-macro", + "foldhash", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0f4697d190a142477b16aef7da8a99bfdc41e7e8b1687583c0d23a79c7afc1e" +dependencies = [ + "cc", + "codespan-reporting", + "indexmap", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-cmd" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0956799fa8678d4c50eed028f2de1c0552ae183c76e976cf7ca8c4e36a7c328" +dependencies = [ + "clap", + "codespan-reporting", + "indexmap", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23384a836ab4f0ad98ace7e3955ad2de39de42378ab487dc28d3990392cb283a" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6acc6b5822b9526adfb4fc377b67128fdd60aac757cc4a741a6278603f763cf" +dependencies = [ + "indexmap", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f78c730aaa7d0b9336a299029ea49f9ee53b0ed06e9202e8cb7db9bae7b8c82" +dependencies = [ + "cc", +] + +[[package]] +name = "oneapi-rs" +version = "0.1.0" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "scratch" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] diff --git a/oneapi-rs-sys/Cargo.toml b/oneapi-rs-sys/Cargo.toml new file mode 100644 index 0000000..e01b737 --- /dev/null +++ b/oneapi-rs-sys/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "oneapi-rs-sys" +version = "0.1.0" +edition = "2024" + +[dependencies] +cxx = "1.0.194" + +[build-dependencies] +cxx-build = "1.0.194" diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs new file mode 100644 index 0000000..7eb0065 --- /dev/null +++ b/oneapi-rs-sys/build.rs @@ -0,0 +1,10 @@ +fn main() { + cxx_build::bridge("src/main.rs") + .include("include") + .file("src/shim.cpp") + .std("c++17") + .compile("test"); + + println!("cargo:rerun-if-changed=src/test.cpp"); + println!("cargo:rerun-if-changed=include/shim.hpp"); +} \ No newline at end of file diff --git a/oneapi-rs-sys/include/shim.hpp b/oneapi-rs-sys/include/shim.hpp new file mode 100644 index 0000000..0641d3a --- /dev/null +++ b/oneapi-rs-sys/include/shim.hpp @@ -0,0 +1,2 @@ +#pragma once +int test(); \ No newline at end of file diff --git a/oneapi-rs-sys/src/main.rs b/oneapi-rs-sys/src/main.rs new file mode 100644 index 0000000..265a046 --- /dev/null +++ b/oneapi-rs-sys/src/main.rs @@ -0,0 +1,11 @@ +#[cxx::bridge] +mod ffi { + unsafe extern "C++" { + include!("oneapi-rs-sys/include/shim.hpp"); + fn test() -> i32; + } +} + +fn main() { + println!("Calling: {}", ffi::test()); +} diff --git a/oneapi-rs-sys/src/shim.cpp b/oneapi-rs-sys/src/shim.cpp new file mode 100644 index 0000000..afc9c27 --- /dev/null +++ b/oneapi-rs-sys/src/shim.cpp @@ -0,0 +1,5 @@ +#include "oneapi-rs-sys/include/shim.hpp" + +int test() { + return 0; +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} From deb83f5fb7bc4589baffe330519a8718f4ae55ab Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Mon, 29 Jun 2026 14:11:14 +0000 Subject: [PATCH 05/54] Use icpx compiler --- oneapi-rs-sys/build.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index 7eb0065..7cc6a13 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -1,6 +1,10 @@ fn main() { + let compiler_root = std::env::var("CMPLR_ROOT") + .expect("No valid OneAPI installation found."); + cxx_build::bridge("src/main.rs") - .include("include") + .compiler(compiler_root + "/bin/icpx") + .flag("-fsycl") .file("src/shim.cpp") .std("c++17") .compile("test"); From b6ecbbf503dc360b5485129220cbad7ef22f2ec0 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Mon, 29 Jun 2026 14:30:18 +0000 Subject: [PATCH 06/54] Add OneAPI include dirs --- oneapi-rs-sys/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index 7cc6a13..b535a0c 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -3,7 +3,8 @@ fn main() { .expect("No valid OneAPI installation found."); cxx_build::bridge("src/main.rs") - .compiler(compiler_root + "/bin/icpx") + .compiler(format!("{compiler_root}/bin/icpx")) + .include(format!("{compiler_root}/include")) .flag("-fsycl") .file("src/shim.cpp") .std("c++17") From 3c0395b1ffc652eefd45e4f35928fa3443e956db Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 09:02:17 +0000 Subject: [PATCH 07/54] Link against SYCL --- oneapi-rs-sys/build.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index b535a0c..3f01363 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -8,8 +8,9 @@ fn main() { .flag("-fsycl") .file("src/shim.cpp") .std("c++17") - .compile("test"); + .compile("oneapi-shim"); - println!("cargo:rerun-if-changed=src/test.cpp"); - println!("cargo:rerun-if-changed=include/shim.hpp"); -} \ No newline at end of file + println!("cargo::rustc-link-lib=sycl"); + println!("cargo::rerun-if-changed=include/shim.hpp"); + println!("cargo::rerun-if-changed=include/shim.cpp"); +} From ce7b3eba2b05b005225e4d272844654e049798dc Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 09:03:09 +0000 Subject: [PATCH 08/54] Add basic SYCL platform printing --- oneapi-rs-sys/include/shim.hpp | 8 +++++++- oneapi-rs-sys/src/main.rs | 9 +++++++-- oneapi-rs-sys/src/shim.cpp | 8 ++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/oneapi-rs-sys/include/shim.hpp b/oneapi-rs-sys/include/shim.hpp index 0641d3a..74f295d 100644 --- a/oneapi-rs-sys/include/shim.hpp +++ b/oneapi-rs-sys/include/shim.hpp @@ -1,2 +1,8 @@ #pragma once -int test(); \ No newline at end of file +#include +#include +#include +#include + +std::unique_ptr> get_platforms(); +std::unique_ptr get_name(sycl::platform const& p); \ No newline at end of file diff --git a/oneapi-rs-sys/src/main.rs b/oneapi-rs-sys/src/main.rs index 265a046..363ceae 100644 --- a/oneapi-rs-sys/src/main.rs +++ b/oneapi-rs-sys/src/main.rs @@ -2,10 +2,15 @@ mod ffi { unsafe extern "C++" { include!("oneapi-rs-sys/include/shim.hpp"); - fn test() -> i32; + #[namespace = "sycl"] + type platform; + fn get_platforms() -> UniquePtr>; + fn get_name(p: &platform) -> UniquePtr; } } fn main() { - println!("Calling: {}", ffi::test()); + for platform in &*ffi::get_platforms() { + println!("{}", ffi::get_name(platform)); + } } diff --git a/oneapi-rs-sys/src/shim.cpp b/oneapi-rs-sys/src/shim.cpp index afc9c27..4ba224b 100644 --- a/oneapi-rs-sys/src/shim.cpp +++ b/oneapi-rs-sys/src/shim.cpp @@ -1,5 +1,9 @@ #include "oneapi-rs-sys/include/shim.hpp" -int test() { - return 0; +std::unique_ptr> get_platforms() { + return std::make_unique>(sycl::platform::get_platforms()); +} + +std::unique_ptr get_name(sycl::platform const& p) { + return std::make_unique(p.get_info()); } \ No newline at end of file From df829c31bb3787b25b37eb1d78ac822d56af9924 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 09:19:37 +0000 Subject: [PATCH 09/54] clang-format --- oneapi-rs-sys/include/shim.hpp | 6 +++--- oneapi-rs-sys/src/shim.cpp | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/oneapi-rs-sys/include/shim.hpp b/oneapi-rs-sys/include/shim.hpp index 74f295d..362b9bf 100644 --- a/oneapi-rs-sys/include/shim.hpp +++ b/oneapi-rs-sys/include/shim.hpp @@ -1,8 +1,8 @@ #pragma once -#include +#include #include +#include #include -#include std::unique_ptr> get_platforms(); -std::unique_ptr get_name(sycl::platform const& p); \ No newline at end of file +std::unique_ptr get_name(sycl::platform const &p); \ No newline at end of file diff --git a/oneapi-rs-sys/src/shim.cpp b/oneapi-rs-sys/src/shim.cpp index 4ba224b..2046589 100644 --- a/oneapi-rs-sys/src/shim.cpp +++ b/oneapi-rs-sys/src/shim.cpp @@ -1,9 +1,11 @@ #include "oneapi-rs-sys/include/shim.hpp" std::unique_ptr> get_platforms() { - return std::make_unique>(sycl::platform::get_platforms()); + return std::make_unique>( + sycl::platform::get_platforms()); } -std::unique_ptr get_name(sycl::platform const& p) { - return std::make_unique(p.get_info()); +std::unique_ptr get_name(sycl::platform const &p) { + return std::make_unique( + p.get_info()); } \ No newline at end of file From 5fe5755f96f2280bf3cb8f85a190acc30afc9fd9 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 09:27:30 +0000 Subject: [PATCH 10/54] Link against Intel libraries --- oneapi-rs-sys/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index 3f01363..dd2d67b 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -11,6 +11,8 @@ fn main() { .compile("oneapi-shim"); println!("cargo::rustc-link-lib=sycl"); + println!("cargo::rustc-link-lib=ze_loader"); + println!("cargo::rustc-link-lib=intlc"); println!("cargo::rerun-if-changed=include/shim.hpp"); println!("cargo::rerun-if-changed=include/shim.cpp"); } From c221021ed25e2ddd76ae347d1d6b0c73bfa80229 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 10:10:19 +0000 Subject: [PATCH 11/54] Whitespace --- oneapi-rs-sys/build.rs | 1 + oneapi-rs-sys/include/shim.hpp | 3 ++- oneapi-rs-sys/src/main.rs | 1 + oneapi-rs-sys/src/shim.cpp | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index dd2d67b..aceb4ce 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -13,6 +13,7 @@ fn main() { println!("cargo::rustc-link-lib=sycl"); println!("cargo::rustc-link-lib=ze_loader"); println!("cargo::rustc-link-lib=intlc"); + println!("cargo::rerun-if-changed=include/shim.hpp"); println!("cargo::rerun-if-changed=include/shim.cpp"); } diff --git a/oneapi-rs-sys/include/shim.hpp b/oneapi-rs-sys/include/shim.hpp index 362b9bf..1ed0294 100644 --- a/oneapi-rs-sys/include/shim.hpp +++ b/oneapi-rs-sys/include/shim.hpp @@ -1,8 +1,9 @@ #pragma once + #include #include #include #include std::unique_ptr> get_platforms(); -std::unique_ptr get_name(sycl::platform const &p); \ No newline at end of file +std::unique_ptr get_name(sycl::platform const &p); diff --git a/oneapi-rs-sys/src/main.rs b/oneapi-rs-sys/src/main.rs index 363ceae..7f09c63 100644 --- a/oneapi-rs-sys/src/main.rs +++ b/oneapi-rs-sys/src/main.rs @@ -2,6 +2,7 @@ mod ffi { unsafe extern "C++" { include!("oneapi-rs-sys/include/shim.hpp"); + #[namespace = "sycl"] type platform; fn get_platforms() -> UniquePtr>; diff --git a/oneapi-rs-sys/src/shim.cpp b/oneapi-rs-sys/src/shim.cpp index 2046589..1fc1f87 100644 --- a/oneapi-rs-sys/src/shim.cpp +++ b/oneapi-rs-sys/src/shim.cpp @@ -8,4 +8,4 @@ std::unique_ptr> get_platforms() { std::unique_ptr get_name(sycl::platform const &p) { return std::make_unique( p.get_info()); -} \ No newline at end of file +} From d90609683d1dd5b60f4aaa13ce09305191dc1783 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 13:38:07 +0000 Subject: [PATCH 12/54] Create a C++ side sycl::platform shim --- oneapi-rs-sys/build.rs | 4 +++- oneapi-rs-sys/include/platform.hpp | 23 +++++++++++++++++++++++ oneapi-rs-sys/include/shim.hpp | 9 --------- oneapi-rs-sys/src/main.rs | 24 ++++++++++++++---------- oneapi-rs-sys/src/platform.cpp | 23 +++++++++++++++++++++++ oneapi-rs-sys/src/shim.cpp | 11 ----------- 6 files changed, 63 insertions(+), 31 deletions(-) create mode 100644 oneapi-rs-sys/include/platform.hpp delete mode 100644 oneapi-rs-sys/include/shim.hpp create mode 100644 oneapi-rs-sys/src/platform.cpp delete mode 100644 oneapi-rs-sys/src/shim.cpp diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index aceb4ce..df4cd81 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -6,7 +6,9 @@ fn main() { .compiler(format!("{compiler_root}/bin/icpx")) .include(format!("{compiler_root}/include")) .flag("-fsycl") - .file("src/shim.cpp") + .files(&[ + "src/platform.cpp" + ]) .std("c++17") .compile("oneapi-shim"); diff --git a/oneapi-rs-sys/include/platform.hpp b/oneapi-rs-sys/include/platform.hpp new file mode 100644 index 0000000..c808914 --- /dev/null +++ b/oneapi-rs-sys/include/platform.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "rust/cxx.h" + +#include + +#include +#include + +namespace sycl_shims { +class Platform { +public: + Platform(sycl::platform p) : inner(p) {} + + static std::unique_ptr> get_platforms(); + rust::String get_version() const; + rust::String get_name() const; + rust::String get_vendor() const; + +private: + sycl::platform inner; +}; +} // namespace sycl_shims diff --git a/oneapi-rs-sys/include/shim.hpp b/oneapi-rs-sys/include/shim.hpp deleted file mode 100644 index 1ed0294..0000000 --- a/oneapi-rs-sys/include/shim.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -std::unique_ptr> get_platforms(); -std::unique_ptr get_name(sycl::platform const &p); diff --git a/oneapi-rs-sys/src/main.rs b/oneapi-rs-sys/src/main.rs index 7f09c63..41d8f88 100644 --- a/oneapi-rs-sys/src/main.rs +++ b/oneapi-rs-sys/src/main.rs @@ -1,17 +1,21 @@ -#[cxx::bridge] -mod ffi { +#[cxx::bridge(namespace = "sycl_shims")] +mod sycl { unsafe extern "C++" { - include!("oneapi-rs-sys/include/shim.hpp"); - - #[namespace = "sycl"] - type platform; - fn get_platforms() -> UniquePtr>; - fn get_name(p: &platform) -> UniquePtr; + include!("oneapi-rs-sys/include/platform.hpp"); + + type Platform; + + #[Self = "Platform"] + fn get_platforms() -> UniquePtr>; + + fn get_version(&self) -> String; + fn get_name(&self) -> String; + fn get_vendor(&self) -> String; } } fn main() { - for platform in &*ffi::get_platforms() { - println!("{}", ffi::get_name(platform)); + for platform in &*sycl::Platform::get_platforms() { + println!("[{}] [{}] [{}]", platform.get_version(), platform.get_name(), platform.get_vendor()); } } diff --git a/oneapi-rs-sys/src/platform.cpp b/oneapi-rs-sys/src/platform.cpp new file mode 100644 index 0000000..20bdeb9 --- /dev/null +++ b/oneapi-rs-sys/src/platform.cpp @@ -0,0 +1,23 @@ +#include "oneapi-rs-sys/include/platform.hpp" + +namespace sycl_shims { +std::unique_ptr> Platform::get_platforms() { + std::vector platforms; + for (auto &&platform : sycl::platform::get_platforms()) + platforms.push_back(platform); + + return std::make_unique>(platforms); +} + +rust::String Platform::get_version() const { + return this->inner.get_info(); +} + +rust::String Platform::get_name() const { + return this->inner.get_info(); +} + +rust::String Platform::get_vendor() const { + return this->inner.get_info(); +} +} // namespace sycl_shims diff --git a/oneapi-rs-sys/src/shim.cpp b/oneapi-rs-sys/src/shim.cpp deleted file mode 100644 index 1fc1f87..0000000 --- a/oneapi-rs-sys/src/shim.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "oneapi-rs-sys/include/shim.hpp" - -std::unique_ptr> get_platforms() { - return std::make_unique>( - sycl::platform::get_platforms()); -} - -std::unique_ptr get_name(sycl::platform const &p) { - return std::make_unique( - p.get_info()); -} From e72c7c7cd37fe687fb09290024ece770f2878bac Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 13:53:51 +0000 Subject: [PATCH 13/54] Change oneapi-rs-sys to a library-type crate --- oneapi-rs-sys/build.rs | 4 +++- oneapi-rs-sys/src/lib.rs | 1 + oneapi-rs-sys/src/{main.rs => platform.rs} | 8 +------- 3 files changed, 5 insertions(+), 8 deletions(-) create mode 100644 oneapi-rs-sys/src/lib.rs rename oneapi-rs-sys/src/{main.rs => platform.rs} (65%) diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index df4cd81..697e96e 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -2,7 +2,9 @@ fn main() { let compiler_root = std::env::var("CMPLR_ROOT") .expect("No valid OneAPI installation found."); - cxx_build::bridge("src/main.rs") + cxx_build::bridges(&[ + "src/platform.rs" + ]) .compiler(format!("{compiler_root}/bin/icpx")) .include(format!("{compiler_root}/include")) .flag("-fsycl") diff --git a/oneapi-rs-sys/src/lib.rs b/oneapi-rs-sys/src/lib.rs new file mode 100644 index 0000000..3be4447 --- /dev/null +++ b/oneapi-rs-sys/src/lib.rs @@ -0,0 +1 @@ +pub mod platform; diff --git a/oneapi-rs-sys/src/main.rs b/oneapi-rs-sys/src/platform.rs similarity index 65% rename from oneapi-rs-sys/src/main.rs rename to oneapi-rs-sys/src/platform.rs index 41d8f88..216aef3 100644 --- a/oneapi-rs-sys/src/main.rs +++ b/oneapi-rs-sys/src/platform.rs @@ -1,5 +1,5 @@ #[cxx::bridge(namespace = "sycl_shims")] -mod sycl { +pub mod ffi { unsafe extern "C++" { include!("oneapi-rs-sys/include/platform.hpp"); @@ -13,9 +13,3 @@ mod sycl { fn get_vendor(&self) -> String; } } - -fn main() { - for platform in &*sycl::Platform::get_platforms() { - println!("[{}] [{}] [{}]", platform.get_version(), platform.get_name(), platform.get_vendor()); - } -} From 1f84b6e308a14498de7fe4a2931c4ccaf65570c5 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 14:03:01 +0000 Subject: [PATCH 14/54] Add a oneapi-rs safe library crate --- Cargo.lock | 7 +++++++ Cargo.toml | 2 +- oneapi-rs/Cargo.toml | 7 +++++++ oneapi-rs/src/lib.rs | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 oneapi-rs/Cargo.toml create mode 100644 oneapi-rs/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 96822b0..1871261 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -160,6 +160,13 @@ dependencies = [ "cc", ] +[[package]] +name = "oneapi-rs" +version = "0.1.0" +dependencies = [ + "oneapi-rs-sys", +] + [[package]] name = "oneapi-rs-sys" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index f7f26e4..0e6831f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,3 @@ [workspace] resolver = "3" -members = ["oneapi-rs-sys"] +members = ["oneapi-rs","oneapi-rs-sys"] diff --git a/oneapi-rs/Cargo.toml b/oneapi-rs/Cargo.toml new file mode 100644 index 0000000..958947b --- /dev/null +++ b/oneapi-rs/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "oneapi-rs" +version = "0.1.0" +edition = "2024" + +[dependencies] +oneapi-rs-sys = { path = "../oneapi-rs-sys" } diff --git a/oneapi-rs/src/lib.rs b/oneapi-rs/src/lib.rs new file mode 100644 index 0000000..b93cf3f --- /dev/null +++ b/oneapi-rs/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: u64, right: u64) -> u64 { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} From a8d8b8c5e271ff731650d1fc58d52ef1831d30d5 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 15:27:45 +0000 Subject: [PATCH 15/54] Remove lifetime requirement from Platform opaque type --- oneapi-rs-sys/include/platform.hpp | 4 +++- oneapi-rs-sys/src/platform.cpp | 9 +++++---- oneapi-rs-sys/src/platform.rs | 11 ++++++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/oneapi-rs-sys/include/platform.hpp b/oneapi-rs-sys/include/platform.hpp index c808914..ab46fda 100644 --- a/oneapi-rs-sys/include/platform.hpp +++ b/oneapi-rs-sys/include/platform.hpp @@ -8,11 +8,13 @@ #include namespace sycl_shims { +struct PlatformPtr; + class Platform { public: Platform(sycl::platform p) : inner(p) {} - static std::unique_ptr> get_platforms(); + static std::unique_ptr> get_platforms(); rust::String get_version() const; rust::String get_name() const; rust::String get_vendor() const; diff --git a/oneapi-rs-sys/src/platform.cpp b/oneapi-rs-sys/src/platform.cpp index 20bdeb9..51a3883 100644 --- a/oneapi-rs-sys/src/platform.cpp +++ b/oneapi-rs-sys/src/platform.cpp @@ -1,12 +1,13 @@ #include "oneapi-rs-sys/include/platform.hpp" +#include "oneapi-rs-sys/src/platform.rs.h" namespace sycl_shims { -std::unique_ptr> Platform::get_platforms() { - std::vector platforms; +std::unique_ptr> Platform::get_platforms() { + std::vector platforms; for (auto &&platform : sycl::platform::get_platforms()) - platforms.push_back(platform); + platforms.push_back(PlatformPtr { std::make_shared(platform) }); - return std::make_unique>(platforms); + return std::make_unique>(platforms); } rust::String Platform::get_version() const { diff --git a/oneapi-rs-sys/src/platform.rs b/oneapi-rs-sys/src/platform.rs index 216aef3..dc5439a 100644 --- a/oneapi-rs-sys/src/platform.rs +++ b/oneapi-rs-sys/src/platform.rs @@ -1,12 +1,21 @@ #[cxx::bridge(namespace = "sycl_shims")] pub mod ffi { + // This is a workaround - cxx currently doesn't support passing + // around C++ vectors of pointers directly + // https://github.com/dtolnay/cxx/issues/774#issuecomment-808674945 + struct PlatformPtr { + // This has to be a SharedPtr because a shared struct needs to be + // copy-constructible + ptr: SharedPtr + } + unsafe extern "C++" { include!("oneapi-rs-sys/include/platform.hpp"); type Platform; #[Self = "Platform"] - fn get_platforms() -> UniquePtr>; + fn get_platforms() -> UniquePtr>; fn get_version(&self) -> String; fn get_name(&self) -> String; From b3cb28286b1c083ad5ff44c442034240227b5126 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 15:28:31 +0000 Subject: [PATCH 16/54] Add an idiomatic Platform implementation --- Cargo.lock | 1 + oneapi-rs/Cargo.toml | 1 + oneapi-rs/src/lib.rs | 15 +-------------- oneapi-rs/src/platform.rs | 12 ++++++++++++ 4 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 oneapi-rs/src/platform.rs diff --git a/Cargo.lock b/Cargo.lock index 1871261..dee04c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,6 +164,7 @@ dependencies = [ name = "oneapi-rs" version = "0.1.0" dependencies = [ + "cxx", "oneapi-rs-sys", ] diff --git a/oneapi-rs/Cargo.toml b/oneapi-rs/Cargo.toml index 958947b..5260f92 100644 --- a/oneapi-rs/Cargo.toml +++ b/oneapi-rs/Cargo.toml @@ -4,4 +4,5 @@ version = "0.1.0" edition = "2024" [dependencies] +cxx = "1.0.194" oneapi-rs-sys = { path = "../oneapi-rs-sys" } diff --git a/oneapi-rs/src/lib.rs b/oneapi-rs/src/lib.rs index b93cf3f..7ddff28 100644 --- a/oneapi-rs/src/lib.rs +++ b/oneapi-rs/src/lib.rs @@ -1,14 +1 @@ -pub fn add(left: u64, right: u64) -> u64 { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} +pub mod platform; \ No newline at end of file diff --git a/oneapi-rs/src/platform.rs b/oneapi-rs/src/platform.rs new file mode 100644 index 0000000..d6ec7aa --- /dev/null +++ b/oneapi-rs/src/platform.rs @@ -0,0 +1,12 @@ +use oneapi_rs_sys::platform::ffi; + +pub struct Platform(cxx::SharedPtr); + +impl Platform { + pub fn get_platforms() -> Vec { + ffi::Platform::get_platforms() + .into_iter() + .map(|platform| Platform(platform.ptr.clone())) + .collect() + } +} From 738556c4bdc6957e108bafd0db46aff1e6b0853f Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 15:50:28 +0000 Subject: [PATCH 17/54] Add platform info submodule --- oneapi-rs/src/info.rs | 1 + oneapi-rs/src/info/platform.rs | 30 ++++++++++++++++++++++++++++++ oneapi-rs/src/lib.rs | 3 ++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 oneapi-rs/src/info.rs create mode 100644 oneapi-rs/src/info/platform.rs diff --git a/oneapi-rs/src/info.rs b/oneapi-rs/src/info.rs new file mode 100644 index 0000000..7ddff28 --- /dev/null +++ b/oneapi-rs/src/info.rs @@ -0,0 +1 @@ +pub mod platform; \ No newline at end of file diff --git a/oneapi-rs/src/info/platform.rs b/oneapi-rs/src/info/platform.rs new file mode 100644 index 0000000..06d465d --- /dev/null +++ b/oneapi-rs/src/info/platform.rs @@ -0,0 +1,30 @@ +use crate::platform::Platform; + +pub trait PlatformInfo { + type Item; + fn get_item(platform: &Platform) -> Self::Item; +} + +pub struct Version; +impl PlatformInfo for Version { + type Item = String; + fn get_item(platform: &Platform) -> Self::Item { + platform.0.get_version() + } +} + +pub struct Name; +impl PlatformInfo for Name { + type Item = String; + fn get_item(platform: &Platform) -> Self::Item { + platform.0.get_name() + } +} + +pub struct Vendor; +impl PlatformInfo for Vendor { + type Item = String; + fn get_item(platform: &Platform) -> Self::Item { + platform.0.get_name() + } +} diff --git a/oneapi-rs/src/lib.rs b/oneapi-rs/src/lib.rs index 7ddff28..5ec9d69 100644 --- a/oneapi-rs/src/lib.rs +++ b/oneapi-rs/src/lib.rs @@ -1 +1,2 @@ -pub mod platform; \ No newline at end of file +pub mod info; +pub mod platform; From 1049f339a17a2ace2506492a6608409c1c6f064a Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 15:50:45 +0000 Subject: [PATCH 18/54] Implement get_info for Platform --- oneapi-rs/src/platform.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/oneapi-rs/src/platform.rs b/oneapi-rs/src/platform.rs index d6ec7aa..14a9f94 100644 --- a/oneapi-rs/src/platform.rs +++ b/oneapi-rs/src/platform.rs @@ -1,6 +1,8 @@ use oneapi_rs_sys::platform::ffi; -pub struct Platform(cxx::SharedPtr); +use crate::info::platform::PlatformInfo; + +pub struct Platform(pub(crate) cxx::SharedPtr); impl Platform { pub fn get_platforms() -> Vec { @@ -9,4 +11,8 @@ impl Platform { .map(|platform| Platform(platform.ptr.clone())) .collect() } + + pub fn get_info(&self) -> T::Item { + T::get_item(self) + } } From dcb216a5138331a3df182e4d3bd16c206632c11a Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Tue, 30 Jun 2026 16:01:43 +0000 Subject: [PATCH 19/54] Add platform printing example --- oneapi-rs/examples/print-platforms.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 oneapi-rs/examples/print-platforms.rs diff --git a/oneapi-rs/examples/print-platforms.rs b/oneapi-rs/examples/print-platforms.rs new file mode 100644 index 0000000..9ae4f71 --- /dev/null +++ b/oneapi-rs/examples/print-platforms.rs @@ -0,0 +1,11 @@ +use oneapi_rs::platform::Platform; +use oneapi_rs::info::platform::*; + +fn main() { + for platform in Platform::get_platforms() { + println!("Platform:"); + println!("- Name: {}", platform.get_info::()); + println!("- Vendor: {}", platform.get_info::()); + println!("- Vendor: {}", platform.get_info::()); + } +} From e0719e86288c1fd8fbc53498b2c9ea349314b48b Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 08:33:02 +0000 Subject: [PATCH 20/54] Use different filenames for related Rust modules --- oneapi-rs-sys/build.rs | 2 +- oneapi-rs-sys/src/lib.rs | 1 + oneapi-rs-sys/src/{platform.rs => platform-sys.rs} | 0 oneapi-rs/src/info.rs | 1 + oneapi-rs/src/info/{platform.rs => platform-info.rs} | 0 5 files changed, 3 insertions(+), 1 deletion(-) rename oneapi-rs-sys/src/{platform.rs => platform-sys.rs} (100%) rename oneapi-rs/src/info/{platform.rs => platform-info.rs} (100%) diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index 697e96e..13fc96e 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -3,7 +3,7 @@ fn main() { .expect("No valid OneAPI installation found."); cxx_build::bridges(&[ - "src/platform.rs" + "src/platform-sys.rs" ]) .compiler(format!("{compiler_root}/bin/icpx")) .include(format!("{compiler_root}/include")) diff --git a/oneapi-rs-sys/src/lib.rs b/oneapi-rs-sys/src/lib.rs index 3be4447..b4cb532 100644 --- a/oneapi-rs-sys/src/lib.rs +++ b/oneapi-rs-sys/src/lib.rs @@ -1 +1,2 @@ +#[path = "platform-sys.rs"] pub mod platform; diff --git a/oneapi-rs-sys/src/platform.rs b/oneapi-rs-sys/src/platform-sys.rs similarity index 100% rename from oneapi-rs-sys/src/platform.rs rename to oneapi-rs-sys/src/platform-sys.rs diff --git a/oneapi-rs/src/info.rs b/oneapi-rs/src/info.rs index 7ddff28..58b6acc 100644 --- a/oneapi-rs/src/info.rs +++ b/oneapi-rs/src/info.rs @@ -1 +1,2 @@ +#[path = "./info/platform-info.rs"] pub mod platform; \ No newline at end of file diff --git a/oneapi-rs/src/info/platform.rs b/oneapi-rs/src/info/platform-info.rs similarity index 100% rename from oneapi-rs/src/info/platform.rs rename to oneapi-rs/src/info/platform-info.rs From 7913fe8b634c80ca8b37ae851838aacd08c5a201 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny <102227406+szymon-zadworny@users.noreply.github.com> Date: Wed, 1 Jul 2026 10:54:57 +0200 Subject: [PATCH 21/54] Create LICENSE-APACHE --- LICENSE-APACHE | 176 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 LICENSE-APACHE diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..d9a10c0 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS From 97575f247ad0b3978c334bfb81b7e6e3395d546b Mon Sep 17 00:00:00 2001 From: Szymon Zadworny <102227406+szymon-zadworny@users.noreply.github.com> Date: Wed, 1 Jul 2026 10:56:04 +0200 Subject: [PATCH 22/54] Create LICENSE-MIT --- LICENSE-MIT | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE-MIT diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..c1abfb2 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Intel Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 198a84822efbe512660dea3316ecffef20fca3b8 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 09:02:26 +0000 Subject: [PATCH 23/54] Add license symlinks --- oneapi-rs-sys/LICENSE-APACHE | 1 + oneapi-rs-sys/LICENSE-MIT | 1 + oneapi-rs/LICENSE-APACHE | 1 + oneapi-rs/LICENSE-MIT | 1 + 4 files changed, 4 insertions(+) create mode 120000 oneapi-rs-sys/LICENSE-APACHE create mode 120000 oneapi-rs-sys/LICENSE-MIT create mode 120000 oneapi-rs/LICENSE-APACHE create mode 120000 oneapi-rs/LICENSE-MIT diff --git a/oneapi-rs-sys/LICENSE-APACHE b/oneapi-rs-sys/LICENSE-APACHE new file mode 120000 index 0000000..965b606 --- /dev/null +++ b/oneapi-rs-sys/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/oneapi-rs-sys/LICENSE-MIT b/oneapi-rs-sys/LICENSE-MIT new file mode 120000 index 0000000..76219eb --- /dev/null +++ b/oneapi-rs-sys/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file diff --git a/oneapi-rs/LICENSE-APACHE b/oneapi-rs/LICENSE-APACHE new file mode 120000 index 0000000..965b606 --- /dev/null +++ b/oneapi-rs/LICENSE-APACHE @@ -0,0 +1 @@ +../LICENSE-APACHE \ No newline at end of file diff --git a/oneapi-rs/LICENSE-MIT b/oneapi-rs/LICENSE-MIT new file mode 120000 index 0000000..76219eb --- /dev/null +++ b/oneapi-rs/LICENSE-MIT @@ -0,0 +1 @@ +../LICENSE-MIT \ No newline at end of file From 867928f8751442284222c30c718337fbfa38f85b Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 09:04:35 +0000 Subject: [PATCH 24/54] Update Cargo licenses --- oneapi-rs-sys/Cargo.toml | 1 + oneapi-rs/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/oneapi-rs-sys/Cargo.toml b/oneapi-rs-sys/Cargo.toml index e01b737..af7bb91 100644 --- a/oneapi-rs-sys/Cargo.toml +++ b/oneapi-rs-sys/Cargo.toml @@ -2,6 +2,7 @@ name = "oneapi-rs-sys" version = "0.1.0" edition = "2024" +license = "MIT OR Apache-2.0" [dependencies] cxx = "1.0.194" diff --git a/oneapi-rs/Cargo.toml b/oneapi-rs/Cargo.toml index 5260f92..0615d00 100644 --- a/oneapi-rs/Cargo.toml +++ b/oneapi-rs/Cargo.toml @@ -2,6 +2,7 @@ name = "oneapi-rs" version = "0.1.0" edition = "2024" +license = "MIT OR Apache-2.0" [dependencies] cxx = "1.0.194" From e186e26a18d5850a1182e57ac829e8b52befaa1d Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 09:12:39 +0000 Subject: [PATCH 25/54] Add license notice to source code files --- oneapi-rs-sys/build.rs | 8 ++++++++ oneapi-rs-sys/include/platform.hpp | 8 ++++++++ oneapi-rs-sys/src/lib.rs | 8 ++++++++ oneapi-rs-sys/src/platform-sys.rs | 8 ++++++++ oneapi-rs-sys/src/platform.cpp | 8 ++++++++ oneapi-rs/examples/print-platforms.rs | 8 ++++++++ oneapi-rs/src/info.rs | 10 +++++++++- oneapi-rs/src/info/platform-info.rs | 8 ++++++++ oneapi-rs/src/lib.rs | 8 ++++++++ oneapi-rs/src/platform.rs | 8 ++++++++ 10 files changed, 81 insertions(+), 1 deletion(-) diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index 13fc96e..f2402b3 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -1,3 +1,11 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + fn main() { let compiler_root = std::env::var("CMPLR_ROOT") .expect("No valid OneAPI installation found."); diff --git a/oneapi-rs-sys/include/platform.hpp b/oneapi-rs-sys/include/platform.hpp index ab46fda..ec5c16a 100644 --- a/oneapi-rs-sys/include/platform.hpp +++ b/oneapi-rs-sys/include/platform.hpp @@ -1,3 +1,11 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + #pragma once #include "rust/cxx.h" diff --git a/oneapi-rs-sys/src/lib.rs b/oneapi-rs-sys/src/lib.rs index b4cb532..cf72b68 100644 --- a/oneapi-rs-sys/src/lib.rs +++ b/oneapi-rs-sys/src/lib.rs @@ -1,2 +1,10 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + #[path = "platform-sys.rs"] pub mod platform; diff --git a/oneapi-rs-sys/src/platform-sys.rs b/oneapi-rs-sys/src/platform-sys.rs index dc5439a..9c5680c 100644 --- a/oneapi-rs-sys/src/platform-sys.rs +++ b/oneapi-rs-sys/src/platform-sys.rs @@ -1,3 +1,11 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + #[cxx::bridge(namespace = "sycl_shims")] pub mod ffi { // This is a workaround - cxx currently doesn't support passing diff --git a/oneapi-rs-sys/src/platform.cpp b/oneapi-rs-sys/src/platform.cpp index 51a3883..6201d48 100644 --- a/oneapi-rs-sys/src/platform.cpp +++ b/oneapi-rs-sys/src/platform.cpp @@ -1,3 +1,11 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + #include "oneapi-rs-sys/include/platform.hpp" #include "oneapi-rs-sys/src/platform.rs.h" diff --git a/oneapi-rs/examples/print-platforms.rs b/oneapi-rs/examples/print-platforms.rs index 9ae4f71..cbc7db1 100644 --- a/oneapi-rs/examples/print-platforms.rs +++ b/oneapi-rs/examples/print-platforms.rs @@ -1,3 +1,11 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + use oneapi_rs::platform::Platform; use oneapi_rs::info::platform::*; diff --git a/oneapi-rs/src/info.rs b/oneapi-rs/src/info.rs index 58b6acc..6046c49 100644 --- a/oneapi-rs/src/info.rs +++ b/oneapi-rs/src/info.rs @@ -1,2 +1,10 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + #[path = "./info/platform-info.rs"] -pub mod platform; \ No newline at end of file +pub mod platform; diff --git a/oneapi-rs/src/info/platform-info.rs b/oneapi-rs/src/info/platform-info.rs index 06d465d..3014c5d 100644 --- a/oneapi-rs/src/info/platform-info.rs +++ b/oneapi-rs/src/info/platform-info.rs @@ -1,3 +1,11 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + use crate::platform::Platform; pub trait PlatformInfo { diff --git a/oneapi-rs/src/lib.rs b/oneapi-rs/src/lib.rs index 5ec9d69..d905f41 100644 --- a/oneapi-rs/src/lib.rs +++ b/oneapi-rs/src/lib.rs @@ -1,2 +1,10 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + pub mod info; pub mod platform; diff --git a/oneapi-rs/src/platform.rs b/oneapi-rs/src/platform.rs index 14a9f94..23ed062 100644 --- a/oneapi-rs/src/platform.rs +++ b/oneapi-rs/src/platform.rs @@ -1,3 +1,11 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + use oneapi_rs_sys::platform::ffi; use crate::info::platform::PlatformInfo; From bc8c7066363ae174004eeee3dec9731e604228e9 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 09:50:19 +0000 Subject: [PATCH 26/54] Simplify ffi::Platform::get_platforms return type --- oneapi-rs-sys/include/platform.hpp | 2 +- oneapi-rs-sys/src/platform-sys.rs | 8 +++----- oneapi-rs-sys/src/platform.cpp | 11 ++++++----- oneapi-rs/src/platform.rs | 4 ++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/oneapi-rs-sys/include/platform.hpp b/oneapi-rs-sys/include/platform.hpp index ec5c16a..0bbee7d 100644 --- a/oneapi-rs-sys/include/platform.hpp +++ b/oneapi-rs-sys/include/platform.hpp @@ -22,7 +22,7 @@ class Platform { public: Platform(sycl::platform p) : inner(p) {} - static std::unique_ptr> get_platforms(); + static rust::Vec get_platforms(); rust::String get_version() const; rust::String get_name() const; rust::String get_vendor() const; diff --git a/oneapi-rs-sys/src/platform-sys.rs b/oneapi-rs-sys/src/platform-sys.rs index 9c5680c..3a77c94 100644 --- a/oneapi-rs-sys/src/platform-sys.rs +++ b/oneapi-rs-sys/src/platform-sys.rs @@ -9,12 +9,10 @@ #[cxx::bridge(namespace = "sycl_shims")] pub mod ffi { // This is a workaround - cxx currently doesn't support passing - // around C++ vectors of pointers directly + // around vectors of pointers directly // https://github.com/dtolnay/cxx/issues/774#issuecomment-808674945 struct PlatformPtr { - // This has to be a SharedPtr because a shared struct needs to be - // copy-constructible - ptr: SharedPtr + ptr: UniquePtr } unsafe extern "C++" { @@ -23,7 +21,7 @@ pub mod ffi { type Platform; #[Self = "Platform"] - fn get_platforms() -> UniquePtr>; + fn get_platforms() -> Vec; fn get_version(&self) -> String; fn get_name(&self) -> String; diff --git a/oneapi-rs-sys/src/platform.cpp b/oneapi-rs-sys/src/platform.cpp index 6201d48..9dd595d 100644 --- a/oneapi-rs-sys/src/platform.cpp +++ b/oneapi-rs-sys/src/platform.cpp @@ -7,15 +7,16 @@ // #include "oneapi-rs-sys/include/platform.hpp" -#include "oneapi-rs-sys/src/platform.rs.h" +#include "oneapi-rs-sys/src/platform-sys.rs.h" namespace sycl_shims { -std::unique_ptr> Platform::get_platforms() { - std::vector platforms; +rust::Vec Platform::get_platforms() { + rust::Vec platforms; + for (auto &&platform : sycl::platform::get_platforms()) - platforms.push_back(PlatformPtr { std::make_shared(platform) }); + platforms.push_back(PlatformPtr { std::make_unique(platform) }); - return std::make_unique>(platforms); + return platforms; } rust::String Platform::get_version() const { diff --git a/oneapi-rs/src/platform.rs b/oneapi-rs/src/platform.rs index 23ed062..c2c852c 100644 --- a/oneapi-rs/src/platform.rs +++ b/oneapi-rs/src/platform.rs @@ -10,13 +10,13 @@ use oneapi_rs_sys::platform::ffi; use crate::info::platform::PlatformInfo; -pub struct Platform(pub(crate) cxx::SharedPtr); +pub struct Platform(pub(crate) cxx::UniquePtr); impl Platform { pub fn get_platforms() -> Vec { ffi::Platform::get_platforms() .into_iter() - .map(|platform| Platform(platform.ptr.clone())) + .map(|platform| Platform(platform.ptr)) .collect() } From 0c8f7ddba01835892539a1dbfec485de8272110d Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 09:59:08 +0000 Subject: [PATCH 27/54] Add cargo rerun on all C++ file changes --- oneapi-rs-sys/build.rs | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index f2402b3..fd97ec9 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -10,15 +10,23 @@ fn main() { let compiler_root = std::env::var("CMPLR_ROOT") .expect("No valid OneAPI installation found."); - cxx_build::bridges(&[ - "src/platform-sys.rs" - ]) + let rust_sources = [ + "src/platform-sys.rs" + ]; + + let cpp_sources = [ + "src/platform.cpp" + ]; + + let cpp_headers = [ + "include/platform.hpp" + ]; + + cxx_build::bridges(&rust_sources) .compiler(format!("{compiler_root}/bin/icpx")) .include(format!("{compiler_root}/include")) .flag("-fsycl") - .files(&[ - "src/platform.cpp" - ]) + .files(&cpp_sources) .std("c++17") .compile("oneapi-shim"); @@ -26,6 +34,11 @@ fn main() { println!("cargo::rustc-link-lib=ze_loader"); println!("cargo::rustc-link-lib=intlc"); - println!("cargo::rerun-if-changed=include/shim.hpp"); - println!("cargo::rerun-if-changed=include/shim.cpp"); + for source in cpp_sources { + println!("cargo::rerun-if-changed={source}"); + } + + for header in cpp_headers { + println!("cargo::rerun-if-changed={header}"); + } } From 0e8ca04301616c85cd0bfd5a15f90948321a52e7 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 10:14:01 +0000 Subject: [PATCH 28/54] Fix version printing --- oneapi-rs/examples/print-platforms.rs | 2 +- oneapi-rs/src/info/platform-info.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/oneapi-rs/examples/print-platforms.rs b/oneapi-rs/examples/print-platforms.rs index cbc7db1..8cfad3a 100644 --- a/oneapi-rs/examples/print-platforms.rs +++ b/oneapi-rs/examples/print-platforms.rs @@ -14,6 +14,6 @@ fn main() { println!("Platform:"); println!("- Name: {}", platform.get_info::()); println!("- Vendor: {}", platform.get_info::()); - println!("- Vendor: {}", platform.get_info::()); + println!("- Version: {}", platform.get_info::()); } } diff --git a/oneapi-rs/src/info/platform-info.rs b/oneapi-rs/src/info/platform-info.rs index 3014c5d..7872390 100644 --- a/oneapi-rs/src/info/platform-info.rs +++ b/oneapi-rs/src/info/platform-info.rs @@ -33,6 +33,6 @@ pub struct Vendor; impl PlatformInfo for Vendor { type Item = String; fn get_item(platform: &Platform) -> Self::Item { - platform.0.get_name() + platform.0.get_vendor() } } From e2b8fd9b33107e7c8118abb95d28e412f74b45f6 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 11:52:21 +0000 Subject: [PATCH 29/54] Replace Platform with Self in impl block --- oneapi-rs/src/platform.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oneapi-rs/src/platform.rs b/oneapi-rs/src/platform.rs index c2c852c..79c6071 100644 --- a/oneapi-rs/src/platform.rs +++ b/oneapi-rs/src/platform.rs @@ -13,10 +13,10 @@ use crate::info::platform::PlatformInfo; pub struct Platform(pub(crate) cxx::UniquePtr); impl Platform { - pub fn get_platforms() -> Vec { + pub fn get_platforms() -> Vec { ffi::Platform::get_platforms() .into_iter() - .map(|platform| Platform(platform.ptr)) + .map(|platform| Self(platform.ptr)) .collect() } From 29d1e4b6f1ced572167b7c987f51d79e388b139f Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 13:23:25 +0000 Subject: [PATCH 30/54] Add Device files --- oneapi-rs-sys/build.rs | 9 ++++++--- oneapi-rs-sys/include/device.hpp | 30 ++++++++++++++++++++++++++++++ oneapi-rs-sys/src/device-sys.rs | 26 ++++++++++++++++++++++++++ oneapi-rs-sys/src/device.cpp | 21 +++++++++++++++++++++ oneapi-rs-sys/src/lib.rs | 3 +++ 5 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 oneapi-rs-sys/include/device.hpp create mode 100644 oneapi-rs-sys/src/device-sys.rs create mode 100644 oneapi-rs-sys/src/device.cpp diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index fd97ec9..40f4322 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -11,15 +11,18 @@ fn main() { .expect("No valid OneAPI installation found."); let rust_sources = [ - "src/platform-sys.rs" + "src/platform-sys.rs", + "src/device-sys.rs", ]; let cpp_sources = [ - "src/platform.cpp" + "src/platform.cpp", + "src/device.cpp", ]; let cpp_headers = [ - "include/platform.hpp" + "include/platform.hpp", + "include/device.hpp", ]; cxx_build::bridges(&rust_sources) diff --git a/oneapi-rs-sys/include/device.hpp b/oneapi-rs-sys/include/device.hpp new file mode 100644 index 0000000..a3e6eec --- /dev/null +++ b/oneapi-rs-sys/include/device.hpp @@ -0,0 +1,30 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + +#pragma once + +#include "rust/cxx.h" + +#include + +#include +#include + +namespace sycl_shims { +struct DevicePtr; + +class Device { +public: + Device(sycl::device p) : inner(p) {} + + static rust::Vec get_devices(); + +private: + sycl::device inner; +}; +} // namespace sycl_shims diff --git a/oneapi-rs-sys/src/device-sys.rs b/oneapi-rs-sys/src/device-sys.rs new file mode 100644 index 0000000..b9880d4 --- /dev/null +++ b/oneapi-rs-sys/src/device-sys.rs @@ -0,0 +1,26 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + +#[cxx::bridge(namespace = "sycl_shims")] +pub mod ffi { + // This is a workaround - cxx currently doesn't support passing + // around vectors of pointers directly + // https://github.com/dtolnay/cxx/issues/774#issuecomment-808674945 + struct DevicePtr { + ptr: UniquePtr + } + + unsafe extern "C++" { + include!("oneapi-rs-sys/include/device.hpp"); + + type Device; + + #[Self = "Device"] + fn get_devices() -> Vec; + } +} diff --git a/oneapi-rs-sys/src/device.cpp b/oneapi-rs-sys/src/device.cpp new file mode 100644 index 0000000..1b1be9c --- /dev/null +++ b/oneapi-rs-sys/src/device.cpp @@ -0,0 +1,21 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + +#include "oneapi-rs-sys/include/device.hpp" +#include "oneapi-rs-sys/src/device-sys.rs.h" + +namespace sycl_shims { +rust::Vec Device::get_devices() { + rust::Vec devices; + + for (auto &&device : sycl::device::get_devices()) + devices.push_back(DevicePtr { std::make_unique(device) }); + + return devices; +} +} // namespace sycl_shims diff --git a/oneapi-rs-sys/src/lib.rs b/oneapi-rs-sys/src/lib.rs index cf72b68..47d00a8 100644 --- a/oneapi-rs-sys/src/lib.rs +++ b/oneapi-rs-sys/src/lib.rs @@ -8,3 +8,6 @@ #[path = "platform-sys.rs"] pub mod platform; + +#[path = "device-sys.rs"] +pub mod device; From 09750369f00dfdfb55e4eb30a481180140352c1c Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 14:00:01 +0000 Subject: [PATCH 31/54] Add C++-side get_device_type wrapper --- oneapi-rs-sys/include/device.hpp | 2 ++ oneapi-rs-sys/src/device-sys.rs | 12 ++++++++++++ oneapi-rs-sys/src/device.cpp | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/oneapi-rs-sys/include/device.hpp b/oneapi-rs-sys/include/device.hpp index a3e6eec..67872ee 100644 --- a/oneapi-rs-sys/include/device.hpp +++ b/oneapi-rs-sys/include/device.hpp @@ -17,12 +17,14 @@ namespace sycl_shims { struct DevicePtr; +enum class DeviceType: std::uint8_t; class Device { public: Device(sycl::device p) : inner(p) {} static rust::Vec get_devices(); + DeviceType get_device_type() const; private: sycl::device inner; diff --git a/oneapi-rs-sys/src/device-sys.rs b/oneapi-rs-sys/src/device-sys.rs index b9880d4..287aeae 100644 --- a/oneapi-rs-sys/src/device-sys.rs +++ b/oneapi-rs-sys/src/device-sys.rs @@ -15,6 +15,16 @@ pub mod ffi { ptr: UniquePtr } + enum DeviceType { + Cpu, + Gpu, + Accelerator, + Custom, + Automatic, + All, + Unimplemented + } + unsafe extern "C++" { include!("oneapi-rs-sys/include/device.hpp"); @@ -22,5 +32,7 @@ pub mod ffi { #[Self = "Device"] fn get_devices() -> Vec; + + fn get_device_type(&self) -> DeviceType; } } diff --git a/oneapi-rs-sys/src/device.cpp b/oneapi-rs-sys/src/device.cpp index 1b1be9c..5381571 100644 --- a/oneapi-rs-sys/src/device.cpp +++ b/oneapi-rs-sys/src/device.cpp @@ -9,6 +9,8 @@ #include "oneapi-rs-sys/include/device.hpp" #include "oneapi-rs-sys/src/device-sys.rs.h" +using dt = sycl::info::device_type; + namespace sycl_shims { rust::Vec Device::get_devices() { rust::Vec devices; @@ -18,4 +20,25 @@ rust::Vec Device::get_devices() { return devices; } + +DeviceType Device::get_device_type() const { + auto type = this->inner.get_info(); + + switch(type) { + case dt::cpu: + return DeviceType::Cpu; + case dt::gpu: + return DeviceType::Gpu; + case dt::accelerator: + return DeviceType::Accelerator; + case dt::custom: + return DeviceType::Custom; + case dt::automatic: + return DeviceType::Automatic; + case dt::all: + return DeviceType::All; + default: + return DeviceType::Unimplemented; + } +} } // namespace sycl_shims From 800bec1b02cd2fe48c8d21f2b5f4901cb1be42e3 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 14:12:55 +0000 Subject: [PATCH 32/54] Add idiomatic Rust device type info binding --- oneapi-rs/src/device.rs | 26 ++++++++++++++++++++++++++ oneapi-rs/src/info.rs | 5 +++++ oneapi-rs/src/info/device-info.rs | 22 ++++++++++++++++++++++ oneapi-rs/src/lib.rs | 1 + 4 files changed, 54 insertions(+) create mode 100644 oneapi-rs/src/device.rs create mode 100644 oneapi-rs/src/info/device-info.rs diff --git a/oneapi-rs/src/device.rs b/oneapi-rs/src/device.rs new file mode 100644 index 0000000..ca3d19a --- /dev/null +++ b/oneapi-rs/src/device.rs @@ -0,0 +1,26 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + +use oneapi_rs_sys::device::ffi; + +use crate::info::device::DeviceInfo; + +pub struct Device(pub(crate) cxx::UniquePtr); + +impl Device { + pub fn get_devices() -> Vec { + ffi::Device::get_devices() + .into_iter() + .map(|device| Self(device.ptr)) + .collect() + } + + pub fn get_info(&self) -> T::Item { + T::get_item(self) + } +} diff --git a/oneapi-rs/src/info.rs b/oneapi-rs/src/info.rs index 6046c49..beb2534 100644 --- a/oneapi-rs/src/info.rs +++ b/oneapi-rs/src/info.rs @@ -8,3 +8,8 @@ #[path = "./info/platform-info.rs"] pub mod platform; + +#[path = "./info/device-info.rs"] +pub mod device; + +pub use oneapi_rs_sys::device::ffi::DeviceType; \ No newline at end of file diff --git a/oneapi-rs/src/info/device-info.rs b/oneapi-rs/src/info/device-info.rs new file mode 100644 index 0000000..ec001e5 --- /dev/null +++ b/oneapi-rs/src/info/device-info.rs @@ -0,0 +1,22 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + +use crate::device::Device; + +pub trait DeviceInfo { + type Item; + fn get_item(device: &Device) -> Self::Item; +} + +pub struct DeviceType; +impl DeviceInfo for DeviceType { + type Item = crate::info::DeviceType; + fn get_item(device: &Device) -> Self::Item { + device.0.get_device_type() + } +} diff --git a/oneapi-rs/src/lib.rs b/oneapi-rs/src/lib.rs index d905f41..c3dac94 100644 --- a/oneapi-rs/src/lib.rs +++ b/oneapi-rs/src/lib.rs @@ -8,3 +8,4 @@ pub mod info; pub mod platform; +pub mod device; From ce1097a3f083fd9c044a0839778c49a184f2f9c6 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 14:21:45 +0000 Subject: [PATCH 33/54] Add print devices example --- oneapi-rs-sys/src/device-sys.rs | 1 + oneapi-rs/examples/print-devices.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 oneapi-rs/examples/print-devices.rs diff --git a/oneapi-rs-sys/src/device-sys.rs b/oneapi-rs-sys/src/device-sys.rs index 287aeae..6766d23 100644 --- a/oneapi-rs-sys/src/device-sys.rs +++ b/oneapi-rs-sys/src/device-sys.rs @@ -15,6 +15,7 @@ pub mod ffi { ptr: UniquePtr } + #[derive(Debug)] enum DeviceType { Cpu, Gpu, diff --git a/oneapi-rs/examples/print-devices.rs b/oneapi-rs/examples/print-devices.rs new file mode 100644 index 0000000..8139518 --- /dev/null +++ b/oneapi-rs/examples/print-devices.rs @@ -0,0 +1,17 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + +use oneapi_rs::device::Device; +use oneapi_rs::info::device::*; + +fn main() { + for device in Device::get_devices() { + println!("Device:"); + println!("- Type: {:?}", device.get_info::()); + } +} From e8b7ab184e60a96d0b481f63f894fb47ab48f131 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 14:26:37 +0000 Subject: [PATCH 34/54] Add C++ device version binding --- oneapi-rs-sys/include/device.hpp | 1 + oneapi-rs-sys/src/device-sys.rs | 1 + oneapi-rs-sys/src/device.cpp | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/oneapi-rs-sys/include/device.hpp b/oneapi-rs-sys/include/device.hpp index 67872ee..83bf5d5 100644 --- a/oneapi-rs-sys/include/device.hpp +++ b/oneapi-rs-sys/include/device.hpp @@ -25,6 +25,7 @@ class Device { static rust::Vec get_devices(); DeviceType get_device_type() const; + rust::String get_version() const; private: sycl::device inner; diff --git a/oneapi-rs-sys/src/device-sys.rs b/oneapi-rs-sys/src/device-sys.rs index 6766d23..f18471d 100644 --- a/oneapi-rs-sys/src/device-sys.rs +++ b/oneapi-rs-sys/src/device-sys.rs @@ -35,5 +35,6 @@ pub mod ffi { fn get_devices() -> Vec; fn get_device_type(&self) -> DeviceType; + fn get_version(&self) -> String; } } diff --git a/oneapi-rs-sys/src/device.cpp b/oneapi-rs-sys/src/device.cpp index 5381571..3a4642f 100644 --- a/oneapi-rs-sys/src/device.cpp +++ b/oneapi-rs-sys/src/device.cpp @@ -41,4 +41,8 @@ DeviceType Device::get_device_type() const { return DeviceType::Unimplemented; } } + +rust::String Device::get_version() const { + return this->inner.get_info(); +} } // namespace sycl_shims From 68a8851ca0acde6a886b5e0b62518d75f893eb62 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 14:32:52 +0000 Subject: [PATCH 35/54] Add Rust device version bindings --- oneapi-rs/examples/print-devices.rs | 1 + oneapi-rs/src/info/device-info.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/oneapi-rs/examples/print-devices.rs b/oneapi-rs/examples/print-devices.rs index 8139518..71a40ec 100644 --- a/oneapi-rs/examples/print-devices.rs +++ b/oneapi-rs/examples/print-devices.rs @@ -12,6 +12,7 @@ use oneapi_rs::info::device::*; fn main() { for device in Device::get_devices() { println!("Device:"); + println!("- Version: {}", device.get_info::()); println!("- Type: {:?}", device.get_info::()); } } diff --git a/oneapi-rs/src/info/device-info.rs b/oneapi-rs/src/info/device-info.rs index ec001e5..62ece03 100644 --- a/oneapi-rs/src/info/device-info.rs +++ b/oneapi-rs/src/info/device-info.rs @@ -20,3 +20,11 @@ impl DeviceInfo for DeviceType { device.0.get_device_type() } } + +pub struct Version; +impl DeviceInfo for Version { + type Item = String; + fn get_item(device: &Device) -> Self::Item { + device.0.get_version() + } +} From 9945e9fb02cbbf2965dbda2a8588ca6e1877f808 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 14:36:38 +0000 Subject: [PATCH 36/54] Add C++ device name bindings --- oneapi-rs-sys/include/device.hpp | 1 + oneapi-rs-sys/src/device-sys.rs | 1 + oneapi-rs-sys/src/device.cpp | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/oneapi-rs-sys/include/device.hpp b/oneapi-rs-sys/include/device.hpp index 83bf5d5..0284e7e 100644 --- a/oneapi-rs-sys/include/device.hpp +++ b/oneapi-rs-sys/include/device.hpp @@ -26,6 +26,7 @@ class Device { static rust::Vec get_devices(); DeviceType get_device_type() const; rust::String get_version() const; + rust::String get_name() const; private: sycl::device inner; diff --git a/oneapi-rs-sys/src/device-sys.rs b/oneapi-rs-sys/src/device-sys.rs index f18471d..6c70792 100644 --- a/oneapi-rs-sys/src/device-sys.rs +++ b/oneapi-rs-sys/src/device-sys.rs @@ -36,5 +36,6 @@ pub mod ffi { fn get_device_type(&self) -> DeviceType; fn get_version(&self) -> String; + fn get_name(&self) -> String; } } diff --git a/oneapi-rs-sys/src/device.cpp b/oneapi-rs-sys/src/device.cpp index 3a4642f..e564bf4 100644 --- a/oneapi-rs-sys/src/device.cpp +++ b/oneapi-rs-sys/src/device.cpp @@ -45,4 +45,8 @@ DeviceType Device::get_device_type() const { rust::String Device::get_version() const { return this->inner.get_info(); } + +rust::String Device::get_name() const { + return this->inner.get_info(); +} } // namespace sycl_shims From 8650dbccc8588e9eb55a6997fb06ba6a1569bd78 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 14:39:26 +0000 Subject: [PATCH 37/54] Add Rust device name bindings --- oneapi-rs/examples/print-devices.rs | 1 + oneapi-rs/src/info/device-info.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/oneapi-rs/examples/print-devices.rs b/oneapi-rs/examples/print-devices.rs index 71a40ec..2b36a6d 100644 --- a/oneapi-rs/examples/print-devices.rs +++ b/oneapi-rs/examples/print-devices.rs @@ -12,6 +12,7 @@ use oneapi_rs::info::device::*; fn main() { for device in Device::get_devices() { println!("Device:"); + println!("- Name: {}", device.get_info::()); println!("- Version: {}", device.get_info::()); println!("- Type: {:?}", device.get_info::()); } diff --git a/oneapi-rs/src/info/device-info.rs b/oneapi-rs/src/info/device-info.rs index 62ece03..d4dcccb 100644 --- a/oneapi-rs/src/info/device-info.rs +++ b/oneapi-rs/src/info/device-info.rs @@ -28,3 +28,11 @@ impl DeviceInfo for Version { device.0.get_version() } } + +pub struct Name; +impl DeviceInfo for Name { + type Item = String; + fn get_item(device: &Device) -> Self::Item { + device.0.get_name() + } +} From 6cccafd9eaec70f90f602caea2c3b5367c697cd7 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 14:55:09 +0000 Subject: [PATCH 38/54] Add C++ get_platform bindings --- oneapi-rs-sys/include/device.hpp | 2 ++ oneapi-rs-sys/src/device-sys.rs | 9 ++++++--- oneapi-rs-sys/src/device.cpp | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/oneapi-rs-sys/include/device.hpp b/oneapi-rs-sys/include/device.hpp index 0284e7e..c961248 100644 --- a/oneapi-rs-sys/include/device.hpp +++ b/oneapi-rs-sys/include/device.hpp @@ -9,6 +9,7 @@ #pragma once #include "rust/cxx.h" +#include "oneapi-rs-sys/include/platform.hpp" #include @@ -27,6 +28,7 @@ class Device { DeviceType get_device_type() const; rust::String get_version() const; rust::String get_name() const; + std::unique_ptr get_platform() const; private: sycl::device inner; diff --git a/oneapi-rs-sys/src/device-sys.rs b/oneapi-rs-sys/src/device-sys.rs index 6c70792..80635fe 100644 --- a/oneapi-rs-sys/src/device-sys.rs +++ b/oneapi-rs-sys/src/device-sys.rs @@ -30,12 +30,15 @@ pub mod ffi { include!("oneapi-rs-sys/include/device.hpp"); type Device; + type Platform = crate::platform::ffi::Platform; #[Self = "Device"] fn get_devices() -> Vec; - fn get_device_type(&self) -> DeviceType; - fn get_version(&self) -> String; - fn get_name(&self) -> String; + fn get_platform(self: &Device) -> UniquePtr; + + fn get_device_type(self: &Device) -> DeviceType; + fn get_version(self: &Device) -> String; + fn get_name(self: &Device) -> String; } } diff --git a/oneapi-rs-sys/src/device.cpp b/oneapi-rs-sys/src/device.cpp index e564bf4..afdbd65 100644 --- a/oneapi-rs-sys/src/device.cpp +++ b/oneapi-rs-sys/src/device.cpp @@ -49,4 +49,8 @@ rust::String Device::get_version() const { rust::String Device::get_name() const { return this->inner.get_info(); } + +std::unique_ptr Device::get_platform() const { + return std::make_unique(this->inner.get_platform()); +} } // namespace sycl_shims From 97c758a4f2001b2f418c7e947aa872f3cd543b9d Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Wed, 1 Jul 2026 15:00:25 +0000 Subject: [PATCH 39/54] Add Rust get_platform bindings --- oneapi-rs/examples/print-devices.rs | 3 ++- oneapi-rs/src/device.rs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/oneapi-rs/examples/print-devices.rs b/oneapi-rs/examples/print-devices.rs index 2b36a6d..c4ca7c5 100644 --- a/oneapi-rs/examples/print-devices.rs +++ b/oneapi-rs/examples/print-devices.rs @@ -7,7 +7,7 @@ // use oneapi_rs::device::Device; -use oneapi_rs::info::device::*; +use oneapi_rs::info::{self, device::*}; fn main() { for device in Device::get_devices() { @@ -15,5 +15,6 @@ fn main() { println!("- Name: {}", device.get_info::()); println!("- Version: {}", device.get_info::()); println!("- Type: {:?}", device.get_info::()); + println!("- Platform name: {}", device.get_platform().get_info::()); } } diff --git a/oneapi-rs/src/device.rs b/oneapi-rs/src/device.rs index ca3d19a..b12789a 100644 --- a/oneapi-rs/src/device.rs +++ b/oneapi-rs/src/device.rs @@ -8,7 +8,7 @@ use oneapi_rs_sys::device::ffi; -use crate::info::device::DeviceInfo; +use crate::{info::device::DeviceInfo, platform::Platform}; pub struct Device(pub(crate) cxx::UniquePtr); @@ -23,4 +23,9 @@ impl Device { pub fn get_info(&self) -> T::Item { T::get_item(self) } + + pub fn get_platform(&self) -> Platform { + let raw_platform = self.0.get_platform(); + Platform(raw_platform) + } } From 4a7c95d02beee234fee0b900deb837b5cb778504 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 09:30:55 +0000 Subject: [PATCH 40/54] Separate types from implementation headers --- oneapi-rs-sys/build.rs | 2 ++ oneapi-rs-sys/include/device.hpp | 26 ++++++++------------------ oneapi-rs-sys/include/opaque.hpp | 8 ++++++++ oneapi-rs-sys/include/platform.hpp | 21 +++++++-------------- oneapi-rs-sys/src/device-sys.rs | 19 ++++++++++--------- oneapi-rs-sys/src/device.cpp | 22 +++++++++++----------- oneapi-rs-sys/src/lib.rs | 3 +++ oneapi-rs-sys/src/opaque-sys.rs | 19 +++++++++++++++++++ oneapi-rs-sys/src/opaque.cpp | 8 ++++++++ oneapi-rs-sys/src/platform-sys.rs | 16 +++++++++------- oneapi-rs-sys/src/platform.cpp | 18 +++++++++--------- oneapi-rs/src/device.rs | 4 ++-- oneapi-rs/src/info/device-info.rs | 7 ++++--- oneapi-rs/src/info/platform-info.rs | 7 ++++--- oneapi-rs/src/platform.rs | 2 +- 15 files changed, 105 insertions(+), 77 deletions(-) create mode 100644 oneapi-rs-sys/include/opaque.hpp create mode 100644 oneapi-rs-sys/src/opaque-sys.rs create mode 100644 oneapi-rs-sys/src/opaque.cpp diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index 40f4322..8b85df3 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -11,6 +11,7 @@ fn main() { .expect("No valid OneAPI installation found."); let rust_sources = [ + "src/opaque-sys.rs", "src/platform-sys.rs", "src/device-sys.rs", ]; @@ -21,6 +22,7 @@ fn main() { ]; let cpp_headers = [ + "include/opaque.hpp", "include/platform.hpp", "include/device.hpp", ]; diff --git a/oneapi-rs-sys/include/device.hpp b/oneapi-rs-sys/include/device.hpp index c961248..98406ae 100644 --- a/oneapi-rs-sys/include/device.hpp +++ b/oneapi-rs-sys/include/device.hpp @@ -9,28 +9,18 @@ #pragma once #include "rust/cxx.h" -#include "oneapi-rs-sys/include/platform.hpp" - -#include +#include "oneapi-rs-sys/include/opaque.hpp" #include #include -namespace sycl_shims { +namespace sycl_shims::device { struct DevicePtr; enum class DeviceType: std::uint8_t; -class Device { -public: - Device(sycl::device p) : inner(p) {} - - static rust::Vec get_devices(); - DeviceType get_device_type() const; - rust::String get_version() const; - rust::String get_name() const; - std::unique_ptr get_platform() const; - -private: - sycl::device inner; -}; -} // namespace sycl_shims +rust::Vec get_devices(); +DeviceType get_device_type(Device const& device); +rust::String get_version(Device const& device); +rust::String get_name(Device const& device); +std::unique_ptr get_platform(Device const& device); +} // namespace sycl_shims::device diff --git a/oneapi-rs-sys/include/opaque.hpp b/oneapi-rs-sys/include/opaque.hpp new file mode 100644 index 0000000..6d4d859 --- /dev/null +++ b/oneapi-rs-sys/include/opaque.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace sycl_shims { +using Device = sycl::device; +using Platform = sycl::platform; +} \ No newline at end of file diff --git a/oneapi-rs-sys/include/platform.hpp b/oneapi-rs-sys/include/platform.hpp index 0bbee7d..708550f 100644 --- a/oneapi-rs-sys/include/platform.hpp +++ b/oneapi-rs-sys/include/platform.hpp @@ -9,25 +9,18 @@ #pragma once #include "rust/cxx.h" +#include "oneapi-rs-sys/include/opaque.hpp" #include #include #include -namespace sycl_shims { +namespace sycl_shims::platform { struct PlatformPtr; -class Platform { -public: - Platform(sycl::platform p) : inner(p) {} - - static rust::Vec get_platforms(); - rust::String get_version() const; - rust::String get_name() const; - rust::String get_vendor() const; - -private: - sycl::platform inner; -}; -} // namespace sycl_shims +rust::Vec get_platforms(); +rust::String get_version(Platform const&); +rust::String get_name(Platform const&); +rust::String get_vendor(Platform const&); +} // namespace sycl_shims::platform diff --git a/oneapi-rs-sys/src/device-sys.rs b/oneapi-rs-sys/src/device-sys.rs index 80635fe..c773047 100644 --- a/oneapi-rs-sys/src/device-sys.rs +++ b/oneapi-rs-sys/src/device-sys.rs @@ -6,7 +6,7 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 // -#[cxx::bridge(namespace = "sycl_shims")] +#[cxx::bridge(namespace = "sycl_shims::device")] pub mod ffi { // This is a workaround - cxx currently doesn't support passing // around vectors of pointers directly @@ -28,17 +28,18 @@ pub mod ffi { unsafe extern "C++" { include!("oneapi-rs-sys/include/device.hpp"); - - type Device; - type Platform = crate::platform::ffi::Platform; - #[Self = "Device"] + #[namespace = "sycl_shims"] + type Device = crate::opaque::ffi::Device; + #[namespace = "sycl_shims"] + type Platform = crate::opaque::ffi::Platform; + fn get_devices() -> Vec; - fn get_platform(self: &Device) -> UniquePtr; + fn get_platform(device: &Device) -> UniquePtr; - fn get_device_type(self: &Device) -> DeviceType; - fn get_version(self: &Device) -> String; - fn get_name(self: &Device) -> String; + fn get_device_type(device: &Device) -> DeviceType; + fn get_version(device: &Device) -> String; + fn get_name(device: &Device) -> String; } } diff --git a/oneapi-rs-sys/src/device.cpp b/oneapi-rs-sys/src/device.cpp index afdbd65..3190b4c 100644 --- a/oneapi-rs-sys/src/device.cpp +++ b/oneapi-rs-sys/src/device.cpp @@ -11,8 +11,8 @@ using dt = sycl::info::device_type; -namespace sycl_shims { -rust::Vec Device::get_devices() { +namespace sycl_shims::device { +rust::Vec get_devices() { rust::Vec devices; for (auto &&device : sycl::device::get_devices()) @@ -21,8 +21,8 @@ rust::Vec Device::get_devices() { return devices; } -DeviceType Device::get_device_type() const { - auto type = this->inner.get_info(); +DeviceType get_device_type(Device const& device) { + auto type = device.get_info(); switch(type) { case dt::cpu: @@ -42,15 +42,15 @@ DeviceType Device::get_device_type() const { } } -rust::String Device::get_version() const { - return this->inner.get_info(); +rust::String get_version(Device const& device) { + return device.get_info(); } -rust::String Device::get_name() const { - return this->inner.get_info(); +rust::String get_name(Device const& device) { + return device.get_info(); } -std::unique_ptr Device::get_platform() const { - return std::make_unique(this->inner.get_platform()); +std::unique_ptr get_platform(Device const& device) { + return std::make_unique(device.get_platform()); } -} // namespace sycl_shims +} // namespace sycl_shims::device diff --git a/oneapi-rs-sys/src/lib.rs b/oneapi-rs-sys/src/lib.rs index 47d00a8..860af04 100644 --- a/oneapi-rs-sys/src/lib.rs +++ b/oneapi-rs-sys/src/lib.rs @@ -6,6 +6,9 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 // +#[path = "opaque-sys.rs"] +pub mod opaque; + #[path = "platform-sys.rs"] pub mod platform; diff --git a/oneapi-rs-sys/src/opaque-sys.rs b/oneapi-rs-sys/src/opaque-sys.rs new file mode 100644 index 0000000..9ed5eed --- /dev/null +++ b/oneapi-rs-sys/src/opaque-sys.rs @@ -0,0 +1,19 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + +#[cxx::bridge(namespace = "sycl_shims")] +pub mod ffi { + unsafe extern "C++" { + include!("oneapi-rs-sys/include/opaque.hpp"); + type Device; + type Platform; + } + + impl UniquePtr {} + impl UniquePtr {} +} diff --git a/oneapi-rs-sys/src/opaque.cpp b/oneapi-rs-sys/src/opaque.cpp new file mode 100644 index 0000000..65ccfb0 --- /dev/null +++ b/oneapi-rs-sys/src/opaque.cpp @@ -0,0 +1,8 @@ +#pragma once +#include "oneapi-rs-sys/include/device.hpp" +#include "oneapi-rs-sys/src/opaque-sys.rs.h" +#include + +std::unique_ptr get_device(std::unique_ptr ptr) { + return std::move(ptr); +} \ No newline at end of file diff --git a/oneapi-rs-sys/src/platform-sys.rs b/oneapi-rs-sys/src/platform-sys.rs index 3a77c94..7d0d19d 100644 --- a/oneapi-rs-sys/src/platform-sys.rs +++ b/oneapi-rs-sys/src/platform-sys.rs @@ -6,7 +6,7 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 // -#[cxx::bridge(namespace = "sycl_shims")] +#[cxx::bridge(namespace = "sycl_shims::platform")] pub mod ffi { // This is a workaround - cxx currently doesn't support passing // around vectors of pointers directly @@ -17,14 +17,16 @@ pub mod ffi { unsafe extern "C++" { include!("oneapi-rs-sys/include/platform.hpp"); - - type Platform; - #[Self = "Platform"] + #[namespace = "sycl_shims"] + type Device = crate::opaque::ffi::Device; + #[namespace = "sycl_shims"] + type Platform = crate::opaque::ffi::Platform; + fn get_platforms() -> Vec; - fn get_version(&self) -> String; - fn get_name(&self) -> String; - fn get_vendor(&self) -> String; + fn get_version(platform: &Platform) -> String; + fn get_name(platform: &Platform) -> String; + fn get_vendor(platform: &Platform) -> String; } } diff --git a/oneapi-rs-sys/src/platform.cpp b/oneapi-rs-sys/src/platform.cpp index 9dd595d..b9dfccc 100644 --- a/oneapi-rs-sys/src/platform.cpp +++ b/oneapi-rs-sys/src/platform.cpp @@ -9,8 +9,8 @@ #include "oneapi-rs-sys/include/platform.hpp" #include "oneapi-rs-sys/src/platform-sys.rs.h" -namespace sycl_shims { -rust::Vec Platform::get_platforms() { +namespace sycl_shims::platform { +rust::Vec get_platforms() { rust::Vec platforms; for (auto &&platform : sycl::platform::get_platforms()) @@ -19,15 +19,15 @@ rust::Vec Platform::get_platforms() { return platforms; } -rust::String Platform::get_version() const { - return this->inner.get_info(); +rust::String get_version(Platform const& platform) { + return platform.get_info(); } -rust::String Platform::get_name() const { - return this->inner.get_info(); +rust::String get_name(Platform const& platform) { + return platform.get_info(); } -rust::String Platform::get_vendor() const { - return this->inner.get_info(); +rust::String get_vendor(Platform const& platform) { + return platform.get_info(); } -} // namespace sycl_shims +} // namespace sycl_shims::platform diff --git a/oneapi-rs/src/device.rs b/oneapi-rs/src/device.rs index b12789a..55998c6 100644 --- a/oneapi-rs/src/device.rs +++ b/oneapi-rs/src/device.rs @@ -14,7 +14,7 @@ pub struct Device(pub(crate) cxx::UniquePtr); impl Device { pub fn get_devices() -> Vec { - ffi::Device::get_devices() + ffi::get_devices() .into_iter() .map(|device| Self(device.ptr)) .collect() @@ -25,7 +25,7 @@ impl Device { } pub fn get_platform(&self) -> Platform { - let raw_platform = self.0.get_platform(); + let raw_platform = ffi::get_platform(&self.0); Platform(raw_platform) } } diff --git a/oneapi-rs/src/info/device-info.rs b/oneapi-rs/src/info/device-info.rs index d4dcccb..5ada93f 100644 --- a/oneapi-rs/src/info/device-info.rs +++ b/oneapi-rs/src/info/device-info.rs @@ -7,6 +7,7 @@ // use crate::device::Device; +use oneapi_rs_sys::device::ffi; pub trait DeviceInfo { type Item; @@ -17,7 +18,7 @@ pub struct DeviceType; impl DeviceInfo for DeviceType { type Item = crate::info::DeviceType; fn get_item(device: &Device) -> Self::Item { - device.0.get_device_type() + ffi::get_device_type(&device.0) } } @@ -25,7 +26,7 @@ pub struct Version; impl DeviceInfo for Version { type Item = String; fn get_item(device: &Device) -> Self::Item { - device.0.get_version() + ffi::get_version(&device.0) } } @@ -33,6 +34,6 @@ pub struct Name; impl DeviceInfo for Name { type Item = String; fn get_item(device: &Device) -> Self::Item { - device.0.get_name() + ffi::get_name(&device.0) } } diff --git a/oneapi-rs/src/info/platform-info.rs b/oneapi-rs/src/info/platform-info.rs index 7872390..3c78d77 100644 --- a/oneapi-rs/src/info/platform-info.rs +++ b/oneapi-rs/src/info/platform-info.rs @@ -7,6 +7,7 @@ // use crate::platform::Platform; +use oneapi_rs_sys::platform::ffi; pub trait PlatformInfo { type Item; @@ -17,7 +18,7 @@ pub struct Version; impl PlatformInfo for Version { type Item = String; fn get_item(platform: &Platform) -> Self::Item { - platform.0.get_version() + ffi::get_version(&platform.0) } } @@ -25,7 +26,7 @@ pub struct Name; impl PlatformInfo for Name { type Item = String; fn get_item(platform: &Platform) -> Self::Item { - platform.0.get_name() + ffi::get_name(&platform.0) } } @@ -33,6 +34,6 @@ pub struct Vendor; impl PlatformInfo for Vendor { type Item = String; fn get_item(platform: &Platform) -> Self::Item { - platform.0.get_vendor() + ffi::get_vendor(&platform.0) } } diff --git a/oneapi-rs/src/platform.rs b/oneapi-rs/src/platform.rs index 79c6071..e64f1a2 100644 --- a/oneapi-rs/src/platform.rs +++ b/oneapi-rs/src/platform.rs @@ -14,7 +14,7 @@ pub struct Platform(pub(crate) cxx::UniquePtr); impl Platform { pub fn get_platforms() -> Vec { - ffi::Platform::get_platforms() + ffi::get_platforms() .into_iter() .map(|platform| Self(platform.ptr)) .collect() From 017be856e3896f6758d220a7e5c528041b7782ed Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 09:53:46 +0000 Subject: [PATCH 41/54] Add C++ platform::get_devices --- oneapi-rs-sys/include/platform.hpp | 5 +++++ oneapi-rs-sys/src/platform-sys.rs | 12 ++++++++++++ oneapi-rs-sys/src/platform.cpp | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/oneapi-rs-sys/include/platform.hpp b/oneapi-rs-sys/include/platform.hpp index 708550f..483d0ec 100644 --- a/oneapi-rs-sys/include/platform.hpp +++ b/oneapi-rs-sys/include/platform.hpp @@ -16,10 +16,15 @@ #include #include +namespace sycl_shims::device { +struct DevicePtr; +} // namespace sycl_shims::device + namespace sycl_shims::platform { struct PlatformPtr; rust::Vec get_platforms(); +rust::Vec get_devices(Platform const&); rust::String get_version(Platform const&); rust::String get_name(Platform const&); rust::String get_vendor(Platform const&); diff --git a/oneapi-rs-sys/src/platform-sys.rs b/oneapi-rs-sys/src/platform-sys.rs index 7d0d19d..3b2a356 100644 --- a/oneapi-rs-sys/src/platform-sys.rs +++ b/oneapi-rs-sys/src/platform-sys.rs @@ -15,6 +15,16 @@ pub mod ffi { ptr: UniquePtr } + // We're trying to import a DevicePtr defined in device-sys.rs. + // This syntax will be refactored in a further cxx pull request, + // see https://github.com/dtolnay/cxx/issues/297 + // and https://github.com/dtolnay/cxx/issues/353 + #[namespace = "sycl_shims::device"] + extern "C++" { + include!("oneapi-rs-sys/src/device-sys.rs.h"); + type DevicePtr = crate::device::ffi::DevicePtr; + } + unsafe extern "C++" { include!("oneapi-rs-sys/include/platform.hpp"); @@ -25,6 +35,8 @@ pub mod ffi { fn get_platforms() -> Vec; + fn get_devices(platform: &Platform) -> Vec; + fn get_version(platform: &Platform) -> String; fn get_name(platform: &Platform) -> String; fn get_vendor(platform: &Platform) -> String; diff --git a/oneapi-rs-sys/src/platform.cpp b/oneapi-rs-sys/src/platform.cpp index b9dfccc..95c0ee5 100644 --- a/oneapi-rs-sys/src/platform.cpp +++ b/oneapi-rs-sys/src/platform.cpp @@ -19,6 +19,15 @@ rust::Vec get_platforms() { return platforms; } +rust::Vec get_devices(Platform const& platform) { + rust::Vec devices; + + for (auto &&device : platform.get_devices()) + devices.push_back(device::DevicePtr { std::make_unique(device) }); + + return devices; +} + rust::String get_version(Platform const& platform) { return platform.get_info(); } From f2e973186d34fd8edd37b2b9fd109483b59de7d5 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 10:10:55 +0000 Subject: [PATCH 42/54] Move pointer wrappers to opaque-sys.rs --- oneapi-rs-sys/include/device.hpp | 6 +++++- oneapi-rs-sys/include/platform.hpp | 9 ++++----- oneapi-rs-sys/src/device-sys.rs | 10 +++++----- oneapi-rs-sys/src/opaque-sys.rs | 15 +++++++++++++++ oneapi-rs-sys/src/platform-sys.rs | 18 ++++-------------- oneapi-rs-sys/src/platform.cpp | 6 +++--- 6 files changed, 36 insertions(+), 28 deletions(-) diff --git a/oneapi-rs-sys/include/device.hpp b/oneapi-rs-sys/include/device.hpp index 98406ae..eb62c69 100644 --- a/oneapi-rs-sys/include/device.hpp +++ b/oneapi-rs-sys/include/device.hpp @@ -14,8 +14,12 @@ #include #include -namespace sycl_shims::device { +namespace sycl_shims { struct DevicePtr; +struct PlatformPtr; +} // namespace sycl_shims + +namespace sycl_shims::device { enum class DeviceType: std::uint8_t; rust::Vec get_devices(); diff --git a/oneapi-rs-sys/include/platform.hpp b/oneapi-rs-sys/include/platform.hpp index 483d0ec..da9bb77 100644 --- a/oneapi-rs-sys/include/platform.hpp +++ b/oneapi-rs-sys/include/platform.hpp @@ -16,15 +16,14 @@ #include #include -namespace sycl_shims::device { +namespace sycl_shims { struct DevicePtr; -} // namespace sycl_shims::device - -namespace sycl_shims::platform { struct PlatformPtr; +} // namespace sycl_shims +namespace sycl_shims::platform { rust::Vec get_platforms(); -rust::Vec get_devices(Platform const&); +rust::Vec get_devices(Platform const&); rust::String get_version(Platform const&); rust::String get_name(Platform const&); rust::String get_vendor(Platform const&); diff --git a/oneapi-rs-sys/src/device-sys.rs b/oneapi-rs-sys/src/device-sys.rs index c773047..9e1a535 100644 --- a/oneapi-rs-sys/src/device-sys.rs +++ b/oneapi-rs-sys/src/device-sys.rs @@ -8,11 +8,11 @@ #[cxx::bridge(namespace = "sycl_shims::device")] pub mod ffi { - // This is a workaround - cxx currently doesn't support passing - // around vectors of pointers directly - // https://github.com/dtolnay/cxx/issues/774#issuecomment-808674945 - struct DevicePtr { - ptr: UniquePtr + #[namespace = "sycl_shims"] + extern "C++" { + include!("oneapi-rs-sys/src/opaque-sys.rs.h"); + type DevicePtr = crate::opaque::ffi::DevicePtr; + type PlatformPtr = crate::opaque::ffi::PlatformPtr; } #[derive(Debug)] diff --git a/oneapi-rs-sys/src/opaque-sys.rs b/oneapi-rs-sys/src/opaque-sys.rs index 9ed5eed..c4d12bb 100644 --- a/oneapi-rs-sys/src/opaque-sys.rs +++ b/oneapi-rs-sys/src/opaque-sys.rs @@ -14,6 +14,21 @@ pub mod ffi { type Platform; } + // This is a workaround - cxx currently doesn't support passing + // around vectors of pointers directly + // https://github.com/dtolnay/cxx/issues/774#issuecomment-808674945 + // We must use pointer wrapper structs instead. + struct DevicePtr { + ptr: UniquePtr + } + + struct PlatformPtr { + ptr: UniquePtr + } + impl UniquePtr {} impl UniquePtr {} + + impl Vec {} + impl Vec {} } diff --git a/oneapi-rs-sys/src/platform-sys.rs b/oneapi-rs-sys/src/platform-sys.rs index 3b2a356..6bbd3cf 100644 --- a/oneapi-rs-sys/src/platform-sys.rs +++ b/oneapi-rs-sys/src/platform-sys.rs @@ -8,21 +8,11 @@ #[cxx::bridge(namespace = "sycl_shims::platform")] pub mod ffi { - // This is a workaround - cxx currently doesn't support passing - // around vectors of pointers directly - // https://github.com/dtolnay/cxx/issues/774#issuecomment-808674945 - struct PlatformPtr { - ptr: UniquePtr - } - - // We're trying to import a DevicePtr defined in device-sys.rs. - // This syntax will be refactored in a further cxx pull request, - // see https://github.com/dtolnay/cxx/issues/297 - // and https://github.com/dtolnay/cxx/issues/353 - #[namespace = "sycl_shims::device"] + #[namespace = "sycl_shims"] extern "C++" { - include!("oneapi-rs-sys/src/device-sys.rs.h"); - type DevicePtr = crate::device::ffi::DevicePtr; + include!("oneapi-rs-sys/src/opaque-sys.rs.h"); + type DevicePtr = crate::opaque::ffi::DevicePtr; + type PlatformPtr = crate::opaque::ffi::PlatformPtr; } unsafe extern "C++" { diff --git a/oneapi-rs-sys/src/platform.cpp b/oneapi-rs-sys/src/platform.cpp index 95c0ee5..6ccd50a 100644 --- a/oneapi-rs-sys/src/platform.cpp +++ b/oneapi-rs-sys/src/platform.cpp @@ -19,11 +19,11 @@ rust::Vec get_platforms() { return platforms; } -rust::Vec get_devices(Platform const& platform) { - rust::Vec devices; +rust::Vec get_devices(Platform const& platform) { + rust::Vec devices; for (auto &&device : platform.get_devices()) - devices.push_back(device::DevicePtr { std::make_unique(device) }); + devices.push_back(DevicePtr { std::make_unique(device) }); return devices; } From 98da98a66cc92515d67138327fd6158c8758ccb9 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 10:22:07 +0000 Subject: [PATCH 43/54] Move DeviceType to opaque-sys.rs --- oneapi-rs-sys/include/device.hpp | 3 +-- oneapi-rs-sys/src/device-sys.rs | 12 +----------- oneapi-rs-sys/src/opaque-sys.rs | 11 +++++++++++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/oneapi-rs-sys/include/device.hpp b/oneapi-rs-sys/include/device.hpp index eb62c69..a1026b9 100644 --- a/oneapi-rs-sys/include/device.hpp +++ b/oneapi-rs-sys/include/device.hpp @@ -17,11 +17,10 @@ namespace sycl_shims { struct DevicePtr; struct PlatformPtr; +enum class DeviceType: std::uint8_t; } // namespace sycl_shims namespace sycl_shims::device { -enum class DeviceType: std::uint8_t; - rust::Vec get_devices(); DeviceType get_device_type(Device const& device); rust::String get_version(Device const& device); diff --git a/oneapi-rs-sys/src/device-sys.rs b/oneapi-rs-sys/src/device-sys.rs index 9e1a535..514f6ea 100644 --- a/oneapi-rs-sys/src/device-sys.rs +++ b/oneapi-rs-sys/src/device-sys.rs @@ -13,17 +13,7 @@ pub mod ffi { include!("oneapi-rs-sys/src/opaque-sys.rs.h"); type DevicePtr = crate::opaque::ffi::DevicePtr; type PlatformPtr = crate::opaque::ffi::PlatformPtr; - } - - #[derive(Debug)] - enum DeviceType { - Cpu, - Gpu, - Accelerator, - Custom, - Automatic, - All, - Unimplemented + type DeviceType = crate::opaque::ffi::DeviceType; } unsafe extern "C++" { diff --git a/oneapi-rs-sys/src/opaque-sys.rs b/oneapi-rs-sys/src/opaque-sys.rs index c4d12bb..de7a971 100644 --- a/oneapi-rs-sys/src/opaque-sys.rs +++ b/oneapi-rs-sys/src/opaque-sys.rs @@ -26,6 +26,17 @@ pub mod ffi { ptr: UniquePtr } + #[derive(Debug)] + enum DeviceType { + Cpu, + Gpu, + Accelerator, + Custom, + Automatic, + All, + Unimplemented + } + impl UniquePtr {} impl UniquePtr {} From 0ede82568826251e756061e953b072c7bb88b5c9 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 10:26:20 +0000 Subject: [PATCH 44/54] clang-format --- oneapi-rs-sys/include/device.hpp | 12 +++++----- oneapi-rs-sys/src/device.cpp | 40 ++++++++++++++++---------------- oneapi-rs-sys/src/platform.cpp | 12 +++++----- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/oneapi-rs-sys/include/device.hpp b/oneapi-rs-sys/include/device.hpp index a1026b9..afdc474 100644 --- a/oneapi-rs-sys/include/device.hpp +++ b/oneapi-rs-sys/include/device.hpp @@ -8,8 +8,8 @@ #pragma once -#include "rust/cxx.h" #include "oneapi-rs-sys/include/opaque.hpp" +#include "rust/cxx.h" #include #include @@ -17,13 +17,13 @@ namespace sycl_shims { struct DevicePtr; struct PlatformPtr; -enum class DeviceType: std::uint8_t; +enum class DeviceType : std::uint8_t; } // namespace sycl_shims namespace sycl_shims::device { rust::Vec get_devices(); -DeviceType get_device_type(Device const& device); -rust::String get_version(Device const& device); -rust::String get_name(Device const& device); -std::unique_ptr get_platform(Device const& device); +DeviceType get_device_type(Device const &); +rust::String get_version(Device const &); +rust::String get_name(Device const &); +std::unique_ptr get_platform(Device const &); } // namespace sycl_shims::device diff --git a/oneapi-rs-sys/src/device.cpp b/oneapi-rs-sys/src/device.cpp index 3190b4c..6d87359 100644 --- a/oneapi-rs-sys/src/device.cpp +++ b/oneapi-rs-sys/src/device.cpp @@ -16,41 +16,41 @@ rust::Vec get_devices() { rust::Vec devices; for (auto &&device : sycl::device::get_devices()) - devices.push_back(DevicePtr { std::make_unique(device) }); + devices.push_back(DevicePtr{std::make_unique(device)}); return devices; } -DeviceType get_device_type(Device const& device) { +DeviceType get_device_type(Device const &device) { auto type = device.get_info(); - switch(type) { - case dt::cpu: - return DeviceType::Cpu; - case dt::gpu: - return DeviceType::Gpu; - case dt::accelerator: - return DeviceType::Accelerator; - case dt::custom: - return DeviceType::Custom; - case dt::automatic: - return DeviceType::Automatic; - case dt::all: - return DeviceType::All; - default: - return DeviceType::Unimplemented; + switch (type) { + case dt::cpu: + return DeviceType::Cpu; + case dt::gpu: + return DeviceType::Gpu; + case dt::accelerator: + return DeviceType::Accelerator; + case dt::custom: + return DeviceType::Custom; + case dt::automatic: + return DeviceType::Automatic; + case dt::all: + return DeviceType::All; + default: + return DeviceType::Unimplemented; } } -rust::String get_version(Device const& device) { +rust::String get_version(Device const &device) { return device.get_info(); } -rust::String get_name(Device const& device) { +rust::String get_name(Device const &device) { return device.get_info(); } -std::unique_ptr get_platform(Device const& device) { +std::unique_ptr get_platform(Device const &device) { return std::make_unique(device.get_platform()); } } // namespace sycl_shims::device diff --git a/oneapi-rs-sys/src/platform.cpp b/oneapi-rs-sys/src/platform.cpp index 6ccd50a..013e254 100644 --- a/oneapi-rs-sys/src/platform.cpp +++ b/oneapi-rs-sys/src/platform.cpp @@ -14,29 +14,29 @@ rust::Vec get_platforms() { rust::Vec platforms; for (auto &&platform : sycl::platform::get_platforms()) - platforms.push_back(PlatformPtr { std::make_unique(platform) }); + platforms.push_back(PlatformPtr{std::make_unique(platform)}); return platforms; } -rust::Vec get_devices(Platform const& platform) { +rust::Vec get_devices(Platform const &platform) { rust::Vec devices; for (auto &&device : platform.get_devices()) - devices.push_back(DevicePtr { std::make_unique(device) }); + devices.push_back(DevicePtr{std::make_unique(device)}); return devices; } -rust::String get_version(Platform const& platform) { +rust::String get_version(Platform const &platform) { return platform.get_info(); } -rust::String get_name(Platform const& platform) { +rust::String get_name(Platform const &platform) { return platform.get_info(); } -rust::String get_vendor(Platform const& platform) { +rust::String get_vendor(Platform const &platform) { return platform.get_info(); } } // namespace sycl_shims::platform From ef320336b93e26abb7e9199511babc3014989827 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 10:31:21 +0000 Subject: [PATCH 45/54] Rename opaque-sys.rs to types-sys.rs --- oneapi-rs-sys/build.rs | 4 ++-- oneapi-rs-sys/include/device.hpp | 2 +- oneapi-rs-sys/include/platform.hpp | 2 +- oneapi-rs-sys/include/{opaque.hpp => types.hpp} | 0 oneapi-rs-sys/src/device-sys.rs | 12 ++++++------ oneapi-rs-sys/src/lib.rs | 4 ++-- oneapi-rs-sys/src/opaque.cpp | 8 -------- oneapi-rs-sys/src/platform-sys.rs | 10 +++++----- oneapi-rs-sys/src/{opaque-sys.rs => types-sys.rs} | 2 +- 9 files changed, 18 insertions(+), 26 deletions(-) rename oneapi-rs-sys/include/{opaque.hpp => types.hpp} (100%) delete mode 100644 oneapi-rs-sys/src/opaque.cpp rename oneapi-rs-sys/src/{opaque-sys.rs => types-sys.rs} (94%) diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index 8b85df3..d23882a 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -11,7 +11,7 @@ fn main() { .expect("No valid OneAPI installation found."); let rust_sources = [ - "src/opaque-sys.rs", + "src/types-sys.rs", "src/platform-sys.rs", "src/device-sys.rs", ]; @@ -22,7 +22,7 @@ fn main() { ]; let cpp_headers = [ - "include/opaque.hpp", + "include/types.hpp", "include/platform.hpp", "include/device.hpp", ]; diff --git a/oneapi-rs-sys/include/device.hpp b/oneapi-rs-sys/include/device.hpp index afdc474..9dfaa4c 100644 --- a/oneapi-rs-sys/include/device.hpp +++ b/oneapi-rs-sys/include/device.hpp @@ -8,7 +8,7 @@ #pragma once -#include "oneapi-rs-sys/include/opaque.hpp" +#include "oneapi-rs-sys/include/types.hpp" #include "rust/cxx.h" #include diff --git a/oneapi-rs-sys/include/platform.hpp b/oneapi-rs-sys/include/platform.hpp index da9bb77..9dbb3f7 100644 --- a/oneapi-rs-sys/include/platform.hpp +++ b/oneapi-rs-sys/include/platform.hpp @@ -9,7 +9,7 @@ #pragma once #include "rust/cxx.h" -#include "oneapi-rs-sys/include/opaque.hpp" +#include "oneapi-rs-sys/include/types.hpp" #include diff --git a/oneapi-rs-sys/include/opaque.hpp b/oneapi-rs-sys/include/types.hpp similarity index 100% rename from oneapi-rs-sys/include/opaque.hpp rename to oneapi-rs-sys/include/types.hpp diff --git a/oneapi-rs-sys/src/device-sys.rs b/oneapi-rs-sys/src/device-sys.rs index 514f6ea..f272172 100644 --- a/oneapi-rs-sys/src/device-sys.rs +++ b/oneapi-rs-sys/src/device-sys.rs @@ -10,19 +10,19 @@ pub mod ffi { #[namespace = "sycl_shims"] extern "C++" { - include!("oneapi-rs-sys/src/opaque-sys.rs.h"); - type DevicePtr = crate::opaque::ffi::DevicePtr; - type PlatformPtr = crate::opaque::ffi::PlatformPtr; - type DeviceType = crate::opaque::ffi::DeviceType; + include!("oneapi-rs-sys/src/types-sys.rs.h"); + type DevicePtr = crate::types::ffi::DevicePtr; + type PlatformPtr = crate::types::ffi::PlatformPtr; + type DeviceType = crate::types::ffi::DeviceType; } unsafe extern "C++" { include!("oneapi-rs-sys/include/device.hpp"); #[namespace = "sycl_shims"] - type Device = crate::opaque::ffi::Device; + type Device = crate::types::ffi::Device; #[namespace = "sycl_shims"] - type Platform = crate::opaque::ffi::Platform; + type Platform = crate::types::ffi::Platform; fn get_devices() -> Vec; diff --git a/oneapi-rs-sys/src/lib.rs b/oneapi-rs-sys/src/lib.rs index 860af04..4163989 100644 --- a/oneapi-rs-sys/src/lib.rs +++ b/oneapi-rs-sys/src/lib.rs @@ -6,8 +6,8 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 // -#[path = "opaque-sys.rs"] -pub mod opaque; +#[path = "types-sys.rs"] +pub mod types; #[path = "platform-sys.rs"] pub mod platform; diff --git a/oneapi-rs-sys/src/opaque.cpp b/oneapi-rs-sys/src/opaque.cpp deleted file mode 100644 index 65ccfb0..0000000 --- a/oneapi-rs-sys/src/opaque.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include "oneapi-rs-sys/include/device.hpp" -#include "oneapi-rs-sys/src/opaque-sys.rs.h" -#include - -std::unique_ptr get_device(std::unique_ptr ptr) { - return std::move(ptr); -} \ No newline at end of file diff --git a/oneapi-rs-sys/src/platform-sys.rs b/oneapi-rs-sys/src/platform-sys.rs index 6bbd3cf..a29a3ed 100644 --- a/oneapi-rs-sys/src/platform-sys.rs +++ b/oneapi-rs-sys/src/platform-sys.rs @@ -10,18 +10,18 @@ pub mod ffi { #[namespace = "sycl_shims"] extern "C++" { - include!("oneapi-rs-sys/src/opaque-sys.rs.h"); - type DevicePtr = crate::opaque::ffi::DevicePtr; - type PlatformPtr = crate::opaque::ffi::PlatformPtr; + include!("oneapi-rs-sys/src/types-sys.rs.h"); + type DevicePtr = crate::types::ffi::DevicePtr; + type PlatformPtr = crate::types::ffi::PlatformPtr; } unsafe extern "C++" { include!("oneapi-rs-sys/include/platform.hpp"); #[namespace = "sycl_shims"] - type Device = crate::opaque::ffi::Device; + type Device = crate::types::ffi::Device; #[namespace = "sycl_shims"] - type Platform = crate::opaque::ffi::Platform; + type Platform = crate::types::ffi::Platform; fn get_platforms() -> Vec; diff --git a/oneapi-rs-sys/src/opaque-sys.rs b/oneapi-rs-sys/src/types-sys.rs similarity index 94% rename from oneapi-rs-sys/src/opaque-sys.rs rename to oneapi-rs-sys/src/types-sys.rs index de7a971..b14407f 100644 --- a/oneapi-rs-sys/src/opaque-sys.rs +++ b/oneapi-rs-sys/src/types-sys.rs @@ -9,7 +9,7 @@ #[cxx::bridge(namespace = "sycl_shims")] pub mod ffi { unsafe extern "C++" { - include!("oneapi-rs-sys/include/opaque.hpp"); + include!("oneapi-rs-sys/include/types.hpp"); type Device; type Platform; } From d1d741c20c94c91fa3b18f2648c38ee2a52045fb Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 10:40:57 +0000 Subject: [PATCH 46/54] Add Rust Platform::get_devices --- oneapi-rs/src/platform.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/oneapi-rs/src/platform.rs b/oneapi-rs/src/platform.rs index e64f1a2..0207fd3 100644 --- a/oneapi-rs/src/platform.rs +++ b/oneapi-rs/src/platform.rs @@ -8,7 +8,7 @@ use oneapi_rs_sys::platform::ffi; -use crate::info::platform::PlatformInfo; +use crate::{device::Device, info::platform::PlatformInfo}; pub struct Platform(pub(crate) cxx::UniquePtr); @@ -20,6 +20,13 @@ impl Platform { .collect() } + pub fn get_devices(&self) -> Vec { + ffi::get_devices(&self.0) + .into_iter() + .map(|device| Device(device.ptr)) + .collect() + } + pub fn get_info(&self) -> T::Item { T::get_item(self) } From 974d9ddc4d478cab9e1f4423fb0afaa878404d90 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 10:49:38 +0000 Subject: [PATCH 47/54] Merge printing examples into sycl-ls --- oneapi-rs/examples/print-devices.rs | 20 -------------------- oneapi-rs/examples/print-platforms.rs | 19 ------------------- oneapi-rs/examples/sycl-ls.rs | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 39 deletions(-) delete mode 100644 oneapi-rs/examples/print-devices.rs delete mode 100644 oneapi-rs/examples/print-platforms.rs create mode 100644 oneapi-rs/examples/sycl-ls.rs diff --git a/oneapi-rs/examples/print-devices.rs b/oneapi-rs/examples/print-devices.rs deleted file mode 100644 index c4ca7c5..0000000 --- a/oneapi-rs/examples/print-devices.rs +++ /dev/null @@ -1,20 +0,0 @@ -// -// Copyright (C) 2026 Intel Corporation -// -// Under the MIT License or the Apache License v2.0. -// See LICENSE-MIT and LICENSE-APACHE for license information. -// SPDX-License-Identifier: MIT OR Apache-2.0 -// - -use oneapi_rs::device::Device; -use oneapi_rs::info::{self, device::*}; - -fn main() { - for device in Device::get_devices() { - println!("Device:"); - println!("- Name: {}", device.get_info::()); - println!("- Version: {}", device.get_info::()); - println!("- Type: {:?}", device.get_info::()); - println!("- Platform name: {}", device.get_platform().get_info::()); - } -} diff --git a/oneapi-rs/examples/print-platforms.rs b/oneapi-rs/examples/print-platforms.rs deleted file mode 100644 index 8cfad3a..0000000 --- a/oneapi-rs/examples/print-platforms.rs +++ /dev/null @@ -1,19 +0,0 @@ -// -// Copyright (C) 2026 Intel Corporation -// -// Under the MIT License or the Apache License v2.0. -// See LICENSE-MIT and LICENSE-APACHE for license information. -// SPDX-License-Identifier: MIT OR Apache-2.0 -// - -use oneapi_rs::platform::Platform; -use oneapi_rs::info::platform::*; - -fn main() { - for platform in Platform::get_platforms() { - println!("Platform:"); - println!("- Name: {}", platform.get_info::()); - println!("- Vendor: {}", platform.get_info::()); - println!("- Version: {}", platform.get_info::()); - } -} diff --git a/oneapi-rs/examples/sycl-ls.rs b/oneapi-rs/examples/sycl-ls.rs new file mode 100644 index 0000000..9870312 --- /dev/null +++ b/oneapi-rs/examples/sycl-ls.rs @@ -0,0 +1,24 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + +use oneapi_rs::platform::Platform; +use oneapi_rs::info; + +fn main() { + for platform in Platform::get_platforms() { + for device in platform.get_devices() { + let device_type = device.get_info::(); + let platform_name = platform.get_info::(); + let device_name = device.get_info::(); + let device_version = device.get_info::(); + let platform_version = platform.get_info::(); + + println!("[{device_type:?}] {platform_name}, {device_name} {device_version} [{platform_version}]"); + } + } +} From 8508cfb1ba9e32efc2337c6afc0290207fb6f42b Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 13:55:09 +0000 Subject: [PATCH 48/54] Add missing license header --- oneapi-rs-sys/include/types.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/oneapi-rs-sys/include/types.hpp b/oneapi-rs-sys/include/types.hpp index 6d4d859..1592c70 100644 --- a/oneapi-rs-sys/include/types.hpp +++ b/oneapi-rs-sys/include/types.hpp @@ -1,3 +1,11 @@ +// +// Copyright (C) 2026 Intel Corporation +// +// Under the MIT License or the Apache License v2.0. +// See LICENSE-MIT and LICENSE-APACHE for license information. +// SPDX-License-Identifier: MIT OR Apache-2.0 +// + #pragma once #include @@ -5,4 +13,4 @@ namespace sycl_shims { using Device = sycl::device; using Platform = sycl::platform; -} \ No newline at end of file +} From bb7fad1f2c1e87cb34d447f79036a421cebb17eb Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 15:09:44 +0000 Subject: [PATCH 49/54] Add fallback compiler support --- Cargo.lock | 16 ++++++++++++++++ oneapi-rs-sys/Cargo.toml | 1 + oneapi-rs-sys/build.rs | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dee04c8..275eb5a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -151,6 +151,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + [[package]] name = "link-cplusplus" version = "1.0.12" @@ -174,6 +180,7 @@ version = "0.1.0" dependencies = [ "cxx", "cxx-build", + "which", ] [[package]] @@ -274,6 +281,15 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" +[[package]] +name = "which" +version = "8.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d7cd18d4acb58fb3cdfe9ea54e6cd96a4e7d4cc45c56338b236e82dad47248" +dependencies = [ + "libc", +] + [[package]] name = "winapi-util" version = "0.1.11" diff --git a/oneapi-rs-sys/Cargo.toml b/oneapi-rs-sys/Cargo.toml index af7bb91..55f0953 100644 --- a/oneapi-rs-sys/Cargo.toml +++ b/oneapi-rs-sys/Cargo.toml @@ -9,3 +9,4 @@ cxx = "1.0.194" [build-dependencies] cxx-build = "1.0.194" +which = "8.0.4" diff --git a/oneapi-rs-sys/build.rs b/oneapi-rs-sys/build.rs index d23882a..7284e62 100644 --- a/oneapi-rs-sys/build.rs +++ b/oneapi-rs-sys/build.rs @@ -6,9 +6,12 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 // +use std::{io::Error, path::PathBuf}; +use which::which; + fn main() { - let compiler_root = std::env::var("CMPLR_ROOT") - .expect("No valid OneAPI installation found."); + let compiler_path = get_compiler_path() + .expect("Expecting a compiler. Set the ONEAPI_CXX environment variable."); let rust_sources = [ "src/types-sys.rs", @@ -28,8 +31,7 @@ fn main() { ]; cxx_build::bridges(&rust_sources) - .compiler(format!("{compiler_root}/bin/icpx")) - .include(format!("{compiler_root}/include")) + .compiler(&compiler_path) .flag("-fsycl") .files(&cpp_sources) .std("c++17") @@ -47,3 +49,29 @@ fn main() { println!("cargo::rerun-if-changed={header}"); } } + +fn get_compiler_path() -> Result { + if let Ok(path) = std::env::var("ONEAPI_CXX") { + let path = PathBuf::from(path); + if path.exists() { + return Ok(path); + } + } + if let Ok(path) = std::env::var("CMPLR_ROOT") { + let path = PathBuf::from(path).join("bin/icpx"); + if path.exists() { + return Ok(path) + } + } + if let Ok(path) = which("icpx") { + return Ok(path); + } + if let Ok(path) = which("dpcpp") { + return Ok(path); + } + if let Ok(path) = which("clang++") { + return Ok(path); + } + + Err(Error::new(std::io::ErrorKind::NotFound, "No OneAPI compiler found")) +} \ No newline at end of file From 46ce9dced20336eeded04bd25d0ddb1d7bdc5fb9 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 15:16:57 +0000 Subject: [PATCH 50/54] Add device info documentation --- oneapi-rs/src/info/device-info.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/oneapi-rs/src/info/device-info.rs b/oneapi-rs/src/info/device-info.rs index 5ada93f..f630b72 100644 --- a/oneapi-rs/src/info/device-info.rs +++ b/oneapi-rs/src/info/device-info.rs @@ -14,6 +14,7 @@ pub trait DeviceInfo { fn get_item(device: &Device) -> Self::Item; } +/// Returns the device type associated with the device. May not return `oneapi_rs::info::DeviceType::All` pub struct DeviceType; impl DeviceInfo for DeviceType { type Item = crate::info::DeviceType; @@ -22,6 +23,7 @@ impl DeviceInfo for DeviceType { } } +/// Returns a backend-defined device version. pub struct Version; impl DeviceInfo for Version { type Item = String; @@ -30,6 +32,7 @@ impl DeviceInfo for Version { } } +/// Returns the device name of this SYCL device. pub struct Name; impl DeviceInfo for Name { type Item = String; From 0335d9f87532767521d057340b2c4abfbb6179c4 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 15:18:39 +0000 Subject: [PATCH 51/54] Add platform info documentation --- oneapi-rs/src/info/platform-info.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/oneapi-rs/src/info/platform-info.rs b/oneapi-rs/src/info/platform-info.rs index 3c78d77..168381d 100644 --- a/oneapi-rs/src/info/platform-info.rs +++ b/oneapi-rs/src/info/platform-info.rs @@ -14,6 +14,7 @@ pub trait PlatformInfo { fn get_item(platform: &Platform) -> Self::Item; } +/// Returns a backend-defined platform version. pub struct Version; impl PlatformInfo for Version { type Item = String; @@ -22,6 +23,7 @@ impl PlatformInfo for Version { } } +/// Returns the name of the platform. pub struct Name; impl PlatformInfo for Name { type Item = String; @@ -30,6 +32,7 @@ impl PlatformInfo for Name { } } +/// Returns the name of the vendor providing the platform. pub struct Vendor; impl PlatformInfo for Vendor { type Item = String; From d5c086591c66c23043a6b9d164c3c2a7dbd06d3e Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 15:27:12 +0000 Subject: [PATCH 52/54] Add platform documentation --- oneapi-rs/src/platform.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/oneapi-rs/src/platform.rs b/oneapi-rs/src/platform.rs index 0207fd3..d9ea4f3 100644 --- a/oneapi-rs/src/platform.rs +++ b/oneapi-rs/src/platform.rs @@ -10,9 +10,16 @@ use oneapi_rs_sys::platform::ffi; use crate::{device::Device, info::platform::PlatformInfo}; +/// Abstraction for SYCL platform. +/// +/// The `Platform` struct encapsulates a single SYCL platform on which SYCL kernel functions may be executed. +/// A SYCL platform must be associated with a single SYCL backend. +/// +/// A `Platform` is also associated with one or more SYCL devices associated with the same SYCL backend. pub struct Platform(pub(crate) cxx::UniquePtr); impl Platform { + /// Returns a `Vec` containing all SYCL platforms from all SYCL backends available in the system. pub fn get_platforms() -> Vec { ffi::get_platforms() .into_iter() @@ -20,6 +27,7 @@ impl Platform { .collect() } + /// Returns a `Vec` containing all the root devices associated with this `Platform`. pub fn get_devices(&self) -> Vec { ffi::get_devices(&self.0) .into_iter() @@ -27,6 +35,9 @@ impl Platform { .collect() } + /// Queries this `Platform` for information requested by the generic parameter `Param`. + /// The associated type `Param::Item` must be defined in accordance with the info parameters + /// in `oneapi_rs::info::platform` to facilitate returning the type associated with the `Param` parameter. pub fn get_info(&self) -> T::Item { T::get_item(self) } From e1da1e028b50ea0e8ce34ef4b2ff5cdca6c3f9bb Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 15:35:19 +0000 Subject: [PATCH 53/54] Add device documentation --- oneapi-rs/src/device.rs | 12 ++++++++++++ oneapi-rs/src/info.rs | 1 + 2 files changed, 13 insertions(+) diff --git a/oneapi-rs/src/device.rs b/oneapi-rs/src/device.rs index 55998c6..2096fe0 100644 --- a/oneapi-rs/src/device.rs +++ b/oneapi-rs/src/device.rs @@ -10,9 +10,17 @@ use oneapi_rs_sys::device::ffi; use crate::{info::device::DeviceInfo, platform::Platform}; +/// The `Device` struct encapsulates a single SYCL device on which kernels can be executed. +/// +/// All member functions of the `Device` struct are synchronous and errors are handled by +/// throwing synchronous SYCL exceptions. +/// +/// The `Device` struct provides the common reference semantics. pub struct Device(pub(crate) cxx::UniquePtr); impl Device { + /// Returns a `Vec` containing all the root devices from all SYCL backends + /// available in the system which have the device type encapsulated by `DeviceType`. pub fn get_devices() -> Vec { ffi::get_devices() .into_iter() @@ -20,10 +28,14 @@ impl Device { .collect() } + /// Queries this `Device` for information requested by the generic parameter `Param`. + /// The associated type `Param::Item` must be defined in accordance with the info parameters + /// in `oneapi_rs::info::device` to facilitate returning the type associated with the `Param` parameter. pub fn get_info(&self) -> T::Item { T::get_item(self) } + /// Returns the associated SYCL platform. pub fn get_platform(&self) -> Platform { let raw_platform = ffi::get_platform(&self.0); Platform(raw_platform) diff --git a/oneapi-rs/src/info.rs b/oneapi-rs/src/info.rs index beb2534..95898ed 100644 --- a/oneapi-rs/src/info.rs +++ b/oneapi-rs/src/info.rs @@ -12,4 +12,5 @@ pub mod platform; #[path = "./info/device-info.rs"] pub mod device; +/// The type of the SYCL device. pub use oneapi_rs_sys::device::ffi::DeviceType; \ No newline at end of file From bfeee563a071ec391228c1409ab6e52dd55e4263 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Thu, 2 Jul 2026 15:53:48 +0000 Subject: [PATCH 54/54] Add link formatting to docs --- oneapi-rs/src/device.rs | 7 ++++--- oneapi-rs/src/platform.rs | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/oneapi-rs/src/device.rs b/oneapi-rs/src/device.rs index 2096fe0..1a0a6b2 100644 --- a/oneapi-rs/src/device.rs +++ b/oneapi-rs/src/device.rs @@ -19,8 +19,8 @@ use crate::{info::device::DeviceInfo, platform::Platform}; pub struct Device(pub(crate) cxx::UniquePtr); impl Device { - /// Returns a `Vec` containing all the root devices from all SYCL backends - /// available in the system which have the device type encapsulated by `DeviceType`. + /// Returns a [`Vec`] containing all the root devices from all SYCL backends + /// available in the system which have the device type encapsulated by [`DeviceType`](crate::info::DeviceType). pub fn get_devices() -> Vec { ffi::get_devices() .into_iter() @@ -30,7 +30,8 @@ impl Device { /// Queries this `Device` for information requested by the generic parameter `Param`. /// The associated type `Param::Item` must be defined in accordance with the info parameters - /// in `oneapi_rs::info::device` to facilitate returning the type associated with the `Param` parameter. + /// in [`oneapi_rs::info::device`](`crate::info::device`) to facilitate returning the type + /// associated with the `Param` parameter. pub fn get_info(&self) -> T::Item { T::get_item(self) } diff --git a/oneapi-rs/src/platform.rs b/oneapi-rs/src/platform.rs index d9ea4f3..7af6fe3 100644 --- a/oneapi-rs/src/platform.rs +++ b/oneapi-rs/src/platform.rs @@ -19,7 +19,7 @@ use crate::{device::Device, info::platform::PlatformInfo}; pub struct Platform(pub(crate) cxx::UniquePtr); impl Platform { - /// Returns a `Vec` containing all SYCL platforms from all SYCL backends available in the system. + /// Returns a [`Vec`] containing all SYCL platforms from all SYCL backends available in the system. pub fn get_platforms() -> Vec { ffi::get_platforms() .into_iter() @@ -27,7 +27,7 @@ impl Platform { .collect() } - /// Returns a `Vec` containing all the root devices associated with this `Platform`. + /// Returns a [`Vec`] containing all the root devices associated with this `Platform`. pub fn get_devices(&self) -> Vec { ffi::get_devices(&self.0) .into_iter() @@ -37,7 +37,7 @@ impl Platform { /// Queries this `Platform` for information requested by the generic parameter `Param`. /// The associated type `Param::Item` must be defined in accordance with the info parameters - /// in `oneapi_rs::info::platform` to facilitate returning the type associated with the `Param` parameter. + /// in [`oneapi_rs::info::platform`](`crate::info::platform`) to facilitate returning the type associated with the `Param` parameter. pub fn get_info(&self) -> T::Item { T::get_item(self) }