Skip to content

Commit

Permalink
Added AVX2, some rework and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed May 28, 2024
1 parent f0d7f27 commit 9f369d8
Show file tree
Hide file tree
Showing 15 changed files with 531 additions and 36 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Build"

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

on:
push:
branches:
- '*'
- '!ci_test_*'
tags-ignore:
- '*'
pull_request:
branches:
- '*'
- '!ci_test_*'

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: rustup target add aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu
- run: cargo build --target aarch64-unknown-linux-gnu
- run: cargo build --features "nightly_avx512" --target x86_64-unknown-linux-gnu
- name: Test release pipeline
run: cargo publish --dry-run
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ workspace = { members = ["src/app"] }

[package]
name = "colorutils-rs"
version = "0.1.4"
version = "0.2.0"
edition = "2021"
description = "Rust utilities for color format handling and conversion."
readme = "README.md"
keywords = ["yuv"]
keywords = ["lab", "hsv", "xyz", "luv", "hsl"]
license = "Apache-2.0 OR BSD-3-Clause"
authors = ["Radzivon Bartoshyk"]
documentation = "https://github.com/awxkee/colorutils-rs"
Expand All @@ -17,3 +17,7 @@ exclude = ["*.jpg"]

[dependencies]
half = "2.4.1"

[features]
default = []
avx2 = []
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ srgb_to_lab(src_bytes, width * components, & mut xyz, width * 3 * std::mem::size

Prebuilt solutions ~3-5 times faster than naive implementation. If your case fits that you prebuilt function.
Speed increasing done with AVX, NEON and SSE, if you are disabled or not using CPU with this features then you won't
receive any benefits.
receive any benefits.

Also, `fma` target feature for x86-64 is available.

Target feature at compile time `+avx2` must be activated to properly compile avx2 instructions. This is an important step even when runtime dispatch are used.
2 changes: 1 addition & 1 deletion src/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version = "0.1.0"
edition = "2021"

[dependencies]
colorutils-rs = {path = "../../"}
colorutils-rs = {path = "../../", features = ["avx2"]}
image = "0.25.1"
4 changes: 2 additions & 2 deletions src/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn main() {
println!("dimensions {:?}", img.dimensions());

println!("{:?}", img.color());
let mut src_bytes = img.as_bytes();
let src_bytes = img.as_bytes();
let width = dimensions.0;
let height = dimensions.1;
let components = 3;
Expand All @@ -70,7 +70,7 @@ fn main() {
let mut a_plane: Vec<f32> = vec![];
a_plane.resize(width as usize * height as usize, 0f32);

for i in 0..10 {
for i in 0..1 {
let start_time = Instant::now();
// srgba_to_xyza(
// src_bytes,
Expand Down
Loading

0 comments on commit 9f369d8

Please sign in to comment.