Skip to content

Commit

Permalink
Update CI + fixed some Clippy warnigns (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
UpsettingBoy authored May 27, 2023
1 parent 8981eb1 commit 08377ab
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 47 deletions.
65 changes: 29 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:

jobs:
fmt:
name: Format check
name: Rustfmt + Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout repo
Expand All @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
authors = ["Jerónimo Sánchez <[email protected]>"]
categories = ["concurrency", "science"]
categories = ["concurrency", "science", "asynchronous"]
description = "Simple WIP GPGPU framework built on top of wgpu"
edition = "2018"
keywords = ["gpgpu", "compute", "opencl", "cuda"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions examples/parallel-compute/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<u32>>();
let cpu_data = (0..size).collect::<Vec<u32>>();
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);
Expand All @@ -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::<Vec<u32>>();
let local_cpu_data = (0..size).collect::<Vec<u32>>();
let local_input_buffer = gpgpu::GpuBuffer::from_slice(&FW, &local_cpu_data);
let local_output_buffer = gpgpu::GpuBuffer::<u32>::with_capacity(&FW, size as u64);

Expand Down
6 changes: 3 additions & 3 deletions examples/simple-compute/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ fn main() {

let size = 10000; // Size of the vectors

let data_a = (0..size).into_iter().collect::<Vec<u32>>(); // Vector A data. 0, 1, 2, ..., 9999 (size - 1).
let data_b = (0..size).into_iter().rev().collect::<Vec<u32>>(); // Vector B data. 9999 (size - 1), 9998, ..., 0.
let data_a = (0..size).collect::<Vec<u32>>(); // Vector A data. 0, 1, 2, ..., 9999 (size - 1).
let data_b = (0..size).rev().collect::<Vec<u32>>(); // 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.
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/primitives/buffers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::marker::PhantomData;

use thiserror::Error;
use wgpu::{util::DeviceExt, MapMode};
use wgpu::util::DeviceExt;

use crate::{GpuBuffer, GpuUniformBuffer};

Expand Down Expand Up @@ -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."));
Expand Down
4 changes: 2 additions & 2 deletions src/primitives/images.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down

0 comments on commit 08377ab

Please sign in to comment.