Skip to content

Commit

Permalink
day21
Browse files Browse the repository at this point in the history
  • Loading branch information
vslinko committed Dec 21, 2024
1 parent 5485ffe commit 13d265d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ name = "bench"
harness = false

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(day19_series)'] }
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(day19_series)', 'cfg(avx512_available)'] }
11 changes: 8 additions & 3 deletions src/day21.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ const LUT2: [usize; LUT_SIZE] = {
lut
};

pub fn solve(input: &str, lut: &[usize]) -> usize {
#[cfg_attr(
target_arch = "x86_64",
target_feature(enable = "popcnt,avx2,ssse3,bmi1,bmi2,lzcnt")
)]
#[cfg_attr(avx512_available, target_feature(enable = "avx512vl"))]
unsafe fn solve(input: &str, lut: &[usize]) -> usize {
let input = input.as_bytes();

let u1 = usizex8::splat(1);
Expand Down Expand Up @@ -302,11 +307,11 @@ pub fn solve(input: &str, lut: &[usize]) -> usize {
}

pub fn part1(input: &str) -> usize {
solve(input, &LUT1)
unsafe { solve(input, &LUT1) }
}

pub fn part2(input: &str) -> usize {
solve(input, &LUT2)
unsafe { solve(input, &LUT2) }
}

#[cfg(test)]
Expand Down

0 comments on commit 13d265d

Please sign in to comment.