-
Notifications
You must be signed in to change notification settings - Fork 2
add CodeQL, Trivy and Clippy checks #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4963e75
2d87932
8425ae2
9527432
c8c2203
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| name: "CodeQL" | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| schedule: | ||
| - cron: "0 15 * * 0" # Every Sunday at 15:00 UTC | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| analyze: | ||
| name: "Analyze (${{ matrix.language }})" | ||
| runs-on: ["oneapi-rs", "Linux"] | ||
|
|
||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| packages: read | ||
| security-events: write | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - language: c-cpp | ||
| build-mode: manual | ||
| - language: rust | ||
| build-mode: none | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
|
|
||
| - name: Check if oneAPI is already installed | ||
| id: check-oneapi | ||
| run: | | ||
| if [ -f /home/test-user/intel/oneapi/setvars.sh ]; then | ||
| echo "installed=true" >> $GITHUB_OUTPUT | ||
| source /home/test-user/intel/oneapi/setvars.sh | ||
| printenv | grep -E '^(PATH|LD_LIBRARY_PATH|LIBRARY_PATH|CPATH|C_INCLUDE_PATH|CPLUS_INCLUDE_PATH)=' >> $GITHUB_ENV | ||
| else | ||
| echo "installed=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Setup oneAPI | ||
| if: steps.check-oneapi.outputs.installed != 'true' | ||
| run: | | ||
| installer="intel-oneapi-toolkit-2026.1.0.192_offline.sh" | ||
| checksum="9d969de9cafbb698bf50f088c4b5174b50fc816f504049e685d6f6d198e10dbc17ef2cd4cfb0bc2b3d2179644a8d77d1" | ||
| curl --fail --location --retry 3 --silent --show-error --output "$installer" \ | ||
| "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/33cb2a22-ddf1-4aa9-8d68-1f5a118acaf2/intel-oneapi-toolkit-2026.1.0.192_offline.sh" | ||
| echo "$checksum $installer" | sha384sum --check | ||
| sh "./$installer" -a --silent --cli --eula accept | ||
|
|
||
| source /home/test-user/intel/oneapi/setvars.sh | ||
| printenv | grep -E '^(PATH|LD_LIBRARY_PATH|LIBRARY_PATH|CPATH|C_INCLUDE_PATH|CPLUS_INCLUDE_PATH)=' >> $GITHUB_ENV | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9 | ||
| with: | ||
| languages: ${{ matrix.language }} | ||
| build-mode: ${{ matrix.build-mode }} | ||
|
|
||
| - name: Build | ||
| run: cargo build --verbose | ||
|
|
||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9 | ||
| with: | ||
| category: "/language:${{ matrix.language }}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ fn main() { | |
| "include/kernel-bundle.hpp", | ||
| ]; | ||
|
|
||
| cxx_build::bridges(&rust_sources) | ||
| cxx_build::bridges(rust_sources) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixes: |
||
| .compiler(&compiler_path) | ||
| .flag("-fsycl") | ||
| .files(&cpp_sources) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ use std::sync::{Arc, atomic::Ordering::Relaxed}; | |
|
|
||
| use crate::types::SharedWaker; | ||
|
|
||
| // WA for Clippy issue https://github.com/rust-lang/rust-clippy/issues/16317 | ||
| #[allow(clippy::missing_safety_doc)] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this issue the reason behind that attribute? If yes - it should be documented with a comment.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this a fix for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These warnings are incorrectly emitted due to the linked issue. This |
||
| #[cxx::bridge(namespace = "sycl_shims::event")] | ||
| pub mod ffi { | ||
| #[namespace = "sycl_shims"] | ||
|
|
@@ -29,6 +31,10 @@ pub mod ffi { | |
|
|
||
| fn wait(event: &mut UniquePtr<Event>) -> Result<()>; | ||
|
|
||
| /// # Safety | ||
| /// | ||
| /// `waker` must come from `Arc::into_raw` and transfer one strong reference to the | ||
| /// callback, which will consume it after the event completes. | ||
| unsafe fn register_callback( | ||
| queue: &mut UniquePtr<Queue>, | ||
| event: &Event, | ||
|
|
@@ -41,12 +47,18 @@ pub mod ffi { | |
|
|
||
| extern "Rust" { | ||
| type SharedWaker; | ||
| /// # Safety | ||
| /// | ||
| /// `ptr` must come from `Arc::into_raw` and represent a strong reference owned by this | ||
| /// callback. | ||
| unsafe fn wake(ptr: *const SharedWaker); | ||
| } | ||
| } | ||
|
|
||
| // Safety: SharedWaker must by a pointer created by Arc::into_raw. The caller must increment the | ||
| // SharedWaker's strong reference count before calling. | ||
| /// # Safety | ||
| /// | ||
| /// SharedWaker must by a pointer created by Arc::into_raw. The caller must increment the | ||
|
|
||
| /// SharedWaker's strong reference count before calling. | ||
| unsafe fn wake(ptr: *const SharedWaker) { | ||
| unsafe { | ||
| (*ptr).done.store(true, Relaxed); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ | |
| // SPDX-License-Identifier: MIT OR Apache-2.0 | ||
| // | ||
|
|
||
| // WA for Clippy issue https://github.com/rust-lang/rust-clippy/issues/16317 | ||
| #[allow(clippy::missing_safety_doc)] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this issue the reason behind that attribute? If yes - it should be documented with a comment. |
||
| #[cxx::bridge(namespace = "sycl_shims::queue")] | ||
| pub mod ffi { | ||
| #[namespace = "sycl_shims"] | ||
|
|
@@ -44,6 +46,10 @@ pub mod ffi { | |
|
|
||
| fn clone(queue: &Queue) -> UniquePtr<Queue>; | ||
|
|
||
| /// # Safety | ||
| /// | ||
| /// `ptr` must be valid for writes of `num_bytes` bytes and remain valid until the | ||
| /// returned event completes. The memory must not be accessed concurrently. | ||
| unsafe fn memset( | ||
| queue: &mut UniquePtr<Queue>, | ||
| ptr: *mut u8, | ||
|
|
@@ -52,6 +58,11 @@ pub mod ffi { | |
| dep_events: Vec<EventPtr>, | ||
| ) -> Result<UniquePtr<Event>>; | ||
|
|
||
| /// # Safety | ||
| /// | ||
| /// `src` and `dest` must be valid for reads and writes, respectively, of `num_bytes` | ||
| /// bytes and remain valid until the returned event completes. The regions must not | ||
| /// overlap or be accessed concurrently. | ||
| unsafe fn memcpy( | ||
| queue: &mut UniquePtr<Queue>, | ||
| dest: *mut u8, | ||
|
|
@@ -67,6 +78,10 @@ pub mod ffi { | |
|
|
||
| fn wait(queue: &mut UniquePtr<Queue>) -> Result<()>; | ||
|
|
||
| /// # Safety | ||
| /// | ||
| /// Each entry in `args` must match the corresponding kernel parameter's size, layout, | ||
| /// and alignment. | ||
| unsafe fn launch_1d( | ||
| queue: &mut UniquePtr<Queue>, | ||
| global_size: Range1, | ||
|
|
@@ -75,6 +90,10 @@ pub mod ffi { | |
| args: &[&[u8]], | ||
| ) -> Result<UniquePtr<Event>>; | ||
|
|
||
| /// # Safety | ||
| /// | ||
| /// Each entry in `args` must match the corresponding kernel parameter's size, layout, | ||
| /// and alignment. | ||
| unsafe fn launch_2d( | ||
| queue: &mut UniquePtr<Queue>, | ||
| global_size: Range2, | ||
|
|
@@ -83,6 +102,10 @@ pub mod ffi { | |
| args: &[&[u8]], | ||
| ) -> Result<UniquePtr<Event>>; | ||
|
|
||
| /// # Safety | ||
| /// | ||
| /// Each entry in `args` must match the corresponding kernel parameter's size, layout, | ||
| /// and alignment. | ||
| unsafe fn launch_3d( | ||
| queue: &mut UniquePtr<Queue>, | ||
| global_size: Range3, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,12 @@ impl SharedWaker { | |
| } | ||
| } | ||
|
|
||
| impl Default for SharedWaker { | ||
| fn default() -> Self { | ||
| Self::new() | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
+27
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code will never be used.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a fix for warning |
||
| #[cxx::bridge(namespace = "sycl_shims")] | ||
| pub mod ffi { | ||
| unsafe extern "C++" { | ||
|
|
@@ -56,7 +62,10 @@ pub mod ffi { | |
|
|
||
| #[derive(Debug, Hash)] | ||
| enum Aspect { | ||
| /// Indicates that the device supports the `PciBdfAddress` information descriptor. | ||
| ExtIntelPciAddress, | ||
| /// Indicates that the implementation identifies this device as integrated GPU. | ||
|
|
||
| ExtOneapiIsIntegratedGpu, | ||
| } | ||
|
|
||
| #[derive(Debug, Hash)] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,7 @@ impl Future for EventFuture { | |
| let this = self.project(); | ||
|
|
||
| // Set the callback on first Future poll (Futures can't be active until polled) | ||
| if *this.set_callback == false { | ||
| if !*this.set_callback { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixes: |
||
| *this.set_callback = true; | ||
| let mut queue = Queue::new_immediate(); | ||
| this.shared.waker.register(cx.waker()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes: