From 08377ab32d19474b8496d38e0142ed85d8d77c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jer=C3=B3nimo=20S=C3=A1nchez?= Date: Sat, 27 May 2023 14:43:12 +0200 Subject: [PATCH] Update CI + fixed some Clippy warnigns (#22) --- .github/workflows/ci.yml | 65 ++++++++++++++----------------- Cargo.toml | 2 +- README.md | 2 +- examples/parallel-compute/main.rs | 4 +- examples/simple-compute/main.rs | 6 +-- src/primitives/buffers.rs | 4 +- src/primitives/images.rs | 4 +- 7 files changed, 40 insertions(+), 47 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de08c7c..5bb9c74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ env: jobs: fmt: - name: Format check + name: Rustfmt + Clippy runs-on: ubuntu-latest steps: - name: Checkout repo @@ -24,11 +24,20 @@ jobs: toolchain: stable profile: minimal override: true - components: rustfmt + components: rustfmt, clippy - name: Check formatting - run: | - cargo fmt -- --check + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + - name: Check Clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --no-deps --examples --tests --all-features -- -D warnings + build: needs: fmt @@ -37,30 +46,18 @@ jobs: matrix: include: # Windows - - name: Windows 2019 x86_64 - os: windows-2019 - target: x86_64-pc-windows-msvc - - - name: Windows 2022 x86_64 - os: windows-2022 + - name: Windows x86_64 latest + os: windows-latest target: x86_64-pc-windows-msvc # MacOS - - name: MacOS 10.15 x86_64 - os: macos-10.15 + - name: MacOS x86_64 latest + os: macos-latest target: x86_64-apple-darwin - - - name: MacOS 11 x86_64 - os: macos-11 - target: x86_64-apple-darwin - + # Linux - - name: Linux Ubuntu 18.04 x86_64 - os: ubuntu-18.04 - target: x86_64-unknown-linux-gnu - - - name: Linux Ubuntu 20.04 x86_64 - os: ubuntu-20.04 + - name: Linux Ubuntu x86_64 latest + os: ubuntu-latest target: x86_64-unknown-linux-gnu name: Check ${{ matrix.name }} @@ -97,18 +94,14 @@ jobs: echo """[profile.dev] debug = 1" > .cargo/config.toml - - name: Check no features - run: | - cargo clippy --target ${{ matrix.target }} - - - name: Check all features - run: | - cargo clippy --target ${{ matrix.target }} --examples --tests --all-features + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --target ${{ matrix.target }} - name: Build docs - run: | - cargo doc --target ${{ matrix.target }} --no-deps - - - name: Run tests - run: | - cargo test --target ${{ matrix.target }} + uses: actions-rs/cargo@v1 + with: + command: doc + args: --target ${{ matrix.target }} --no-deps diff --git a/Cargo.toml b/Cargo.toml index 2687c56..e6b901b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] authors = ["Jerónimo Sánchez "] -categories = ["concurrency", "science"] +categories = ["concurrency", "science", "asynchronous"] description = "Simple WIP GPGPU framework built on top of wgpu" edition = "2018" keywords = ["gpgpu", "compute", "opencl", "cuda"] diff --git a/README.md b/README.md index 68e70a2..3184251 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # gpgpu -![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/UpsettingBoy/gpgpu-rs/Rust%20CI/dev?label=Actions&style=flat-square) +![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/UpsettingBoy/gpgpu-rs/ci.yml?branch=dev&label=Actions&style=flat-square) ![Crates.io](https://img.shields.io/crates/l/gpgpu?style=flat-square) ![Crates.io](https://img.shields.io/crates/v/gpgpu?style=flat-square) [![docs.rs](https://img.shields.io/static/v1?label=docs.rs&message=read&color=brightgreen&style=flat-square)](https://docs.rs/gpgpu) diff --git a/examples/parallel-compute/main.rs b/examples/parallel-compute/main.rs index 1fa0e80..3703872 100644 --- a/examples/parallel-compute/main.rs +++ b/examples/parallel-compute/main.rs @@ -16,7 +16,7 @@ fn main() { let threading = 4; // Threading level let size = 32000; // Must be multiple of 32 - let cpu_data = (0..size).into_iter().collect::>(); + let cpu_data = (0..size).collect::>(); let shader_input_buffer = Arc::new(gpgpu::GpuBuffer::from_slice(&FW, &cpu_data)); // Data shared across threads shader invocations let mut handles = Vec::with_capacity(threading); @@ -27,7 +27,7 @@ fn main() { // Threads spawn let handle = std::thread::spawn(move || { // Current thread GPU objects - let local_cpu_data = (0..size).into_iter().collect::>(); + let local_cpu_data = (0..size).collect::>(); let local_input_buffer = gpgpu::GpuBuffer::from_slice(&FW, &local_cpu_data); let local_output_buffer = gpgpu::GpuBuffer::::with_capacity(&FW, size as u64); diff --git a/examples/simple-compute/main.rs b/examples/simple-compute/main.rs index bed04fc..7b8cb22 100644 --- a/examples/simple-compute/main.rs +++ b/examples/simple-compute/main.rs @@ -8,8 +8,8 @@ fn main() { let size = 10000; // Size of the vectors - let data_a = (0..size).into_iter().collect::>(); // Vector A data. 0, 1, 2, ..., 9999 (size - 1). - let data_b = (0..size).into_iter().rev().collect::>(); // Vector B data. 9999 (size - 1), 9998, ..., 0. + let data_a = (0..size).collect::>(); // Vector A data. 0, 1, 2, ..., 9999 (size - 1). + let data_b = (0..size).rev().collect::>(); // Vector B data. 9999 (size - 1), 9998, ..., 0. // Allocation of new vectors on the GPU let gpu_vec_a = gpgpu::GpuBuffer::from_slice(&fw, &data_a); // Input vector A. @@ -32,7 +32,7 @@ fn main() { // Execution of the kernel. It needs 3 dimmensions, x y and z. // Since we are using single-dim vectors, only x is required. - kernel.enqueue(size as u32, 1, 1); + kernel.enqueue(size, 1, 1); // After the kernel execution, we can read the results from the GPU. let gpu_result = gpu_vec_c.read_vec_blocking().unwrap(); diff --git a/src/primitives/buffers.rs b/src/primitives/buffers.rs index 6b1d4b7..8c321ee 100644 --- a/src/primitives/buffers.rs +++ b/src/primitives/buffers.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use thiserror::Error; -use wgpu::{util::DeviceExt, MapMode}; +use wgpu::util::DeviceExt; use crate::{GpuBuffer, GpuUniformBuffer}; @@ -104,7 +104,7 @@ where wgpu::util::DownloadBuffer::read_buffer( &self.fw.device, &self.fw.queue, - &self.buf.slice(..download_size as u64), + &self.buf.slice(..download_size), move |result| { tx.send(result) .unwrap_or_else(|_| panic!("Failed to download buffer.")); diff --git a/src/primitives/images.rs b/src/primitives/images.rs index 424ebf8..2c1df36 100644 --- a/src/primitives/images.rs +++ b/src/primitives/images.rs @@ -1,9 +1,9 @@ use std::marker::PhantomData; use thiserror::Error; -use wgpu::{util::DeviceExt, MapMode}; +use wgpu::util::DeviceExt; -use crate::{primitives::buffers, GpuConstImage, GpuImage}; +use crate::{GpuConstImage, GpuImage}; use super::{ImgOps, PixelInfo};