Skip to content

Commit

Permalink
Merge branch 'main' into fix-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielsimard authored Sep 9, 2024
2 parents c75011f + f086ffa commit a354333
Show file tree
Hide file tree
Showing 51 changed files with 574 additions and 1,070 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[alias]
xtask = "run --target-dir target/xtask/debug --package xtask --bin xtask --"
xtask = "run --target-dir target/xtask --color always --package xtask --bin xtask --"
189 changes: 152 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: CI

env:
CARGO_TERM_COLOR: always

# For now we execute CI only on PR to save on CI time
on:
push:
branches:
Expand All @@ -27,44 +23,163 @@ on:
- '!LICENSE-APACHE'
- '!LICENSE-MIT'

env:
CARGO_TERM_COLOR: always
RUST_PREVIOUS_VERSION: 1.79.0

# Sourced from https://vulkan.lunarg.com/sdk/home#linux
VULKAN_SDK_VERSION: "1.3.268"

# Sourced from https://archive.mesa3d.org/. Bumping this requires
# updating the mesa build in https://github.com/gfx-rs/ci-build and creating a new release.
MESA_VERSION: "23.3.1"
# Corresponds to https://github.com/gfx-rs/ci-build/releases
MESA_CI_BINARY_BUILD: "build18"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
crates:
runs-on: ubuntu-latest
prepare-checks:
runs-on: ubuntu-22.04
outputs:
rust-prev-version: ${{ env.RUST_PREVIOUS_VERSION }}
steps:
- name: Do Nothing
if: false
run: echo

code-quality:
runs-on: ubuntu-22.04
needs: prepare-checks
strategy:
matrix:
rust: [stable]
include:
- rust: stable
toolchain: stable
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
- name: Setup Rust
uses: tracel-ai/github-actions/setup-rust@v1
with:
components: clippy, rustfmt
toolchain: stable
- uses: Swatinem/rust-cache@v2
rust-toolchain: ${{ matrix.toolchain }}
cache-key: ${{ matrix.rust }}-linux
# --------------------------------------------------------------------------------
- name: Audit
run: cargo xtask check audit
# --------------------------------------------------------------------------------
- name: Format
run: cargo xtask ci --target crates format
shell: bash
env:
# work around for colors
# see: https://github.com/rust-lang/rustfmt/issues/3385
TERM: xterm-256color
run: cargo xtask check format
# --------------------------------------------------------------------------------
- name: Lint
run: cargo xtask ci --target crates lint
- name: Audit
run: cargo xtask ci --target crates audit
- name: Unit Tests
run: cargo xtask ci --target crates unit-tests
- name: Integration Tests
run: cargo xtask ci --target crates integration-tests
- name: Documentation Tests
run: cargo xtask ci --target crates doc-tests
examples:
runs-on: ubuntu-latest
run: cargo xtask check lint
# --------------------------------------------------------------------------------
- name: Typos
uses: tracel-ai/github-actions/check-typos@v1

documentation:
runs-on: ubuntu-22.04
needs: prepare-checks
strategy:
matrix:
rust: [stable]
include:
- rust: stable
toolchain: stable
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
- name: Setup Rust
uses: tracel-ai/github-actions/setup-rust@v1
with:
components: clippy, rustfmt
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Format
run: cargo xtask ci --target examples format
- name: Lint
run: cargo xtask ci --target examples lint
- name: Unit Tests
run: cargo xtask ci --target examples unit-tests
- name: Integration Tests
run: cargo xtask ci --target examples integration-tests
rust-toolchain: ${{ matrix.toolchain }}
cache-key: ${{ matrix.rust }}-linux
# --------------------------------------------------------------------------------
- name: Documentation Build
run: cargo xtask doc build
# --------------------------------------------------------------------------------
- name: Documentation Tests
run: cargo xtask ci --target examples doc-tests
run: cargo xtask doc tests

linux-std-tests:
runs-on: ubuntu-22.04
needs: prepare-checks
strategy:
matrix:
rust: [stable, prev]
include:
- rust: stable
toolchain: stable
- rust: prev
toolchain: ${{ needs.prepare-checks.outputs.rust-prev-version }}
steps:
- name: Setup Rust
uses: tracel-ai/github-actions/setup-rust@v1
with:
rust-toolchain: ${{ matrix.toolchain }}
cache-key: ${{ matrix.rust }}-linux
# --------------------------------------------------------------------------------
- name: Setup Linux runner
uses: tracel-ai/github-actions/setup-linux@v1
with:
vulkan-sdk-version: ${{ env.VULKAN_SDK_VERSION }}
mesa-version: ${{ env.MESA_VERSION }}
mesa-ci-build-version: ${{ env.MESA_CI_BINARY_BUILD }}
# --------------------------------------------------------------------------------
- name: Tests
run: cargo xtask test --ci

windows-std-tests:
runs-on: windows-2022
needs: prepare-checks
env:
DISABLE_WGPU: '1'
# Keep the stragegy to be able to easily add new rust versions if required
strategy:
matrix:
rust: [stable]
include:
- rust: stable
toolchain: stable
steps:
- name: Setup Rust
uses: tracel-ai/github-actions/setup-rust@v1
with:
rust-toolchain: ${{ matrix.toolchain }}
cache-key: ${{ matrix.rust }}-windows
# --------------------------------------------------------------------------------
- name: Setup Windows runner
if: env.DISABLE_WGPU != '1'
uses: tracel-ai/github-actions/setup-windows@v1
with:
dxc-release: ${{ env.DXC_RELEASE }}
dxc-filename: ${{ env.DXC_FILENAME }}
mesa-version: ${{ env.MESA_VERSION }}
warp-version: ${{ env.WARP_VERSION }}
# --------------------------------------------------------------------------------
- name: Tests
run: cargo xtask test --ci

macos-std-tests:
runs-on: macos-14
needs: prepare-checks
# Keep the stragegy to be able to easily add new rust versions if required
strategy:
matrix:
rust: [stable]
include:
- rust: stable
toolchain: stable
steps:
- name: Setup Rust
uses: tracel-ai/github-actions/setup-rust@v1
with:
rust-toolchain: ${{ matrix.toolchain }}
cache-key: ${{ matrix.rust }}-macos
# --------------------------------------------------------------------------------
- name: Tests
run: cargo xtask test --ci
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ proc-macro2 = "1.0.86"
syn = { version = "2.0.69", features = ["full", "extra-traits"] }
quote = "1.0.36"

# xtask
anyhow = "1.0.86"
clap = { version = "4.5.9", features = ["derive"] }
derive_more = { version = "0.99.18", features = ["display"], default-features = false }
env_logger = "0.11.3"
### For xtask crate ###
strum = {version = "0.26.3", features = ["derive"]}
tracel-xtask = { version = "~1.0" }

portable-atomic-util = { version = "0.2.2", features = ["alloc"] } # alloc is for no_std

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

[![Discord](https://img.shields.io/discord/1038839012602941528.svg?color=7289da&&logo=discord)](https://discord.gg/KSBSPhAUCc)
[![Current Crates.io Version](https://img.shields.io/crates/v/cubecl.svg)](https://crates.io/crates/cubecl)
[![Minimum Supported Rust Version](https://img.shields.io/crates/msrv/cubecl)](https://crates.io/crates/burn)
[![Test Status](https://github.com/tracel-ai/cubecl/actions/workflows/ci.yml/badge.svg)](https://github.com/tracel-ai/cubecl/actions/workflows/test.yml)
[![Rust Version](https://img.shields.io/badge/Rust-1.79.0+-blue)](https://releases.rs/docs/1.79.0)
![license](https://shields.io/badge/license-MIT%2FApache--2.0-blue)
<br />
[![NVIDIA](https://img.shields.io/badge/nvidia-cuda-84b629)](https://github.com/tracel-ai/cubecl/tree/main/crates/cubecl-cuda)
Expand Down
10 changes: 5 additions & 5 deletions crates/cubecl-core/src/compute/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn format_str(kernel_id: &str, markers: &[(char, char)], include_space: bool) ->
let kernel_id = kernel_id.to_string();
let mut result = String::new();
let mut depth = 0;
let indendation = 4;
let indentation = 4;

let mut prev = ' ';

Expand All @@ -105,7 +105,7 @@ fn format_str(kernel_id: &str, markers: &[(char, char)], include_space: bool) ->
}
result.push(start);
result.push('\n');
result.push_str(&" ".repeat(indendation * depth));
result.push_str(&" ".repeat(indentation * depth));
found_marker = true;
} else if c == end {
depth -= 1;
Expand All @@ -114,10 +114,10 @@ fn format_str(kernel_id: &str, markers: &[(char, char)], include_space: bool) ->
result.pop();
}
result.push_str(",\n");
result.push_str(&" ".repeat(indendation * depth));
result.push_str(&" ".repeat(indentation * depth));
result.push(end);
} else {
for _ in 0..(&" ".repeat(indendation * depth).len()) + 1 + indendation {
for _ in 0..(&" ".repeat(indentation * depth).len()) + 1 + indentation {
result.pop();
}
result.push(end);
Expand All @@ -137,7 +137,7 @@ fn format_str(kernel_id: &str, markers: &[(char, char)], include_space: bool) ->
}

result.push_str(",\n");
result.push_str(&" ".repeat(indendation * depth));
result.push_str(&" ".repeat(indentation * depth));
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions crates/cubecl-core/src/frontend/element/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl<'a, R: Runtime> ArrayArg<'a, R> {
///
/// # Safety
///
/// Specifying the wrong lenght may lead to out-of-bounds reads and writes.
/// Specifying the wrong length may lead to out-of-bounds reads and writes.
pub unsafe fn from_raw_parts(
handle: &'a cubecl_runtime::server::Handle<R::Server>,
length: usize,
Expand All @@ -225,7 +225,7 @@ impl<'a, R: Runtime> ArrayHandleRef<'a, R> {
///
/// # Safety
///
/// Specifying the wrong lenght may lead to out-of-bounds reads and writes.
/// Specifying the wrong length may lead to out-of-bounds reads and writes.
pub unsafe fn from_raw_parts(
handle: &'a cubecl_runtime::server::Handle<R::Server>,
length: usize,
Expand Down
2 changes: 1 addition & 1 deletion crates/cubecl-core/src/frontend/element/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl<T: CubeType> From<ExpandElementTyped<T>> for ExpandElement {
}

impl<T: CubePrimitive> ExpandElementTyped<T> {
/// Create an [ExpandElementTyped] from a value that is normaly a literal.
/// Create an [ExpandElementTyped] from a value that is normally a literal.
pub fn from_lit<L: Into<Variable>>(lit: L) -> Self {
let variable: Variable = lit.into();
let variable = T::as_elem().from_constant(variable);
Expand Down
5 changes: 4 additions & 1 deletion crates/cubecl-core/src/frontend/element/float.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use half::{bf16, f16};

use crate::frontend::{Ceil, Cos, Erf, Exp, Floor, Log, Log1p, Powf, Recip, Sin, Sqrt, Tanh};
use crate::frontend::{
Ceil, Cos, Erf, Exp, Floor, Log, Log1p, Powf, Recip, Round, Sin, Sqrt, Tanh,
};
use crate::frontend::{
ComptimeType, CubeContext, CubePrimitive, CubeType, ExpandElement, ExpandElementBaseInit,
ExpandElementTyped, Numeric,
Expand All @@ -25,6 +27,7 @@ pub trait Float:
+ Tanh
+ Powf
+ Sqrt
+ Round
+ Floor
+ Ceil
+ Erf
Expand Down
20 changes: 20 additions & 0 deletions crates/cubecl-core/src/frontend/operation/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,26 @@ pub mod bitand {
}
}

pub mod bitor {
use super::*;

pub fn expand<C: CubePrimitive>(
context: &mut CubeContext,
lhs: ExpandElementTyped<C>,
rhs: ExpandElementTyped<C>,
) -> ExpandElementTyped<C> {
binary_expand(context, lhs.into(), rhs.into(), Operator::BitwiseOr).into()
}

impl core::ops::BitOr for UInt {
type Output = UInt;

fn bitor(self, _rhs: Self) -> Self::Output {
unexpanded!()
}
}
}

pub mod or {
use super::*;

Expand Down
10 changes: 10 additions & 0 deletions crates/cubecl-core/src/frontend/operation/unary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ impl_unary_func!(
F32,
F64
);
impl_unary_func!(
Round,
round,
__expand_round,
Operator::Round,
F16,
BF16,
F32,
F64
);
impl_unary_func!(
Floor,
floor,
Expand Down
2 changes: 2 additions & 0 deletions crates/cubecl-core/src/ir/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub enum Operator {
Tanh(UnaryOperator),
Powf(BinaryOperator),
Sqrt(UnaryOperator),
Round(UnaryOperator),
Floor(UnaryOperator),
Ceil(UnaryOperator),
Erf(UnaryOperator),
Expand All @@ -63,6 +64,7 @@ pub enum Operator {
Max(BinaryOperator),
Min(BinaryOperator),
BitwiseAnd(BinaryOperator),
BitwiseOr(BinaryOperator),
BitwiseXor(BinaryOperator),
ShiftLeft(BinaryOperator),
ShiftRight(BinaryOperator),
Expand Down
Loading

0 comments on commit a354333

Please sign in to comment.