From c2dc58de179111e28af1ad1be2670a68ca39e8d4 Mon Sep 17 00:00:00 2001 From: Szymon Zadworny Date: Mon, 29 Jun 2026 08:40:48 +0000 Subject: [PATCH 01/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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/29] 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() }