mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
Merge pull request #3228 from rtfeldman/illegal_instruction_PENTIUM_N3700
WIP don't require avx, avx2, sse, sse4.2 on all x86-64
This commit is contained in:
commit
033efe33e5
5 changed files with 51 additions and 9 deletions
|
@ -9,6 +9,10 @@ test-gen-wasm = "test -p roc_gen_wasm -p test_gen --no-default-features --featur
|
||||||
# lto=fat Spend extra effort on link-time optimization across crates
|
# lto=fat Spend extra effort on link-time optimization across crates
|
||||||
rustflags = ["-Copt-level=s", "-Clto=fat"]
|
rustflags = ["-Copt-level=s", "-Clto=fat"]
|
||||||
|
|
||||||
|
[target.'cfg(not(target = "wasm32-unknown-unknown"))']
|
||||||
|
# Sets the avx, avx2, sse2 and sse4.2 target-features correctly based on your CPU.
|
||||||
|
rustflags = ["-Ctarget-cpu=native"]
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
# Gives us the path of the workspace root for use in cargo tests without having
|
# Gives us the path of the workspace root for use in cargo tests without having
|
||||||
# to compute it per-package.
|
# to compute it per-package.
|
||||||
|
|
|
@ -146,6 +146,8 @@ build-nightly-release:
|
||||||
# compile everything needed for benchmarks and output a self-contained dir from which benchmarks can be run.
|
# compile everything needed for benchmarks and output a self-contained dir from which benchmarks can be run.
|
||||||
prep-bench-folder:
|
prep-bench-folder:
|
||||||
FROM +copy-dirs
|
FROM +copy-dirs
|
||||||
|
# to make use of avx, avx2, sse2, sse4.2... instructions
|
||||||
|
ENV RUSTFLAGS="-C link-arg=-fuse-ld=lld -C target-cpu=native"
|
||||||
ARG BENCH_SUFFIX=branch
|
ARG BENCH_SUFFIX=branch
|
||||||
RUN cargo criterion -V
|
RUN cargo criterion -V
|
||||||
RUN --mount=type=cache,target=$SCCACHE_DIR cd cli && cargo criterion --no-run
|
RUN --mount=type=cache,target=$SCCACHE_DIR cd cli && cargo criterion --no-run
|
||||||
|
|
|
@ -164,7 +164,9 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
// flaky test error that only occurs sometimes inside MacOS ci run
|
// flaky test error that only occurs sometimes inside MacOS ci run
|
||||||
if error_str.contains("unable to build stage1 zig object: FileNotFound") {
|
if error_str.contains("unable to build stage1 zig object: FileNotFound")
|
||||||
|
|| error_str.contains("unable to save cached ZIR code")
|
||||||
|
{
|
||||||
run_command(path, command_str, args)
|
run_command(path, command_str, args)
|
||||||
} else {
|
} else {
|
||||||
panic!("{} failed: {}", command_str, error_str);
|
panic!("{} failed: {}", command_str, error_str);
|
||||||
|
|
|
@ -251,14 +251,27 @@ impl SmallStringInterner {
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn find_i16_slice(slice: &[i16], key: i16) -> Option<usize> {
|
fn find_i16_slice(slice: &[i16], key: i16) -> Option<usize> {
|
||||||
#[cfg(target_arch = "x86_64")]
|
// run with RUSTFLAGS="-C target-cpu=native" to enable
|
||||||
|
#[cfg(all(
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_feature = "avx",
|
||||||
|
target_feature = "avx2"
|
||||||
|
))]
|
||||||
return find_i16_slice_x86_64(slice, key);
|
return find_i16_slice_x86_64(slice, key);
|
||||||
|
|
||||||
#[cfg(not(target_arch = "x86_64"))]
|
#[cfg(not(all(
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_feature = "avx",
|
||||||
|
target_feature = "avx2"
|
||||||
|
)))]
|
||||||
return find_i16_slice_fallback(slice, key);
|
return find_i16_slice_fallback(slice, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(all(
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_feature = "avx",
|
||||||
|
target_feature = "avx2"
|
||||||
|
))]
|
||||||
fn find_i16_slice_x86_64(slice: &[i16], key: i16) -> Option<usize> {
|
fn find_i16_slice_x86_64(slice: &[i16], key: i16) -> Option<usize> {
|
||||||
use std::arch::x86_64::*;
|
use std::arch::x86_64::*;
|
||||||
|
|
||||||
|
@ -332,7 +345,11 @@ mod test {
|
||||||
assert!(interner.find_and_update("c", "cd").is_some());
|
assert!(interner.find_and_update("c", "cd").is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(all(
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_feature = "avx",
|
||||||
|
target_feature = "avx2"
|
||||||
|
))]
|
||||||
#[test]
|
#[test]
|
||||||
fn find_test_1() {
|
fn find_test_1() {
|
||||||
use super::find_i16_slice;
|
use super::find_i16_slice;
|
||||||
|
|
|
@ -254,7 +254,12 @@ fn fast_eat_spaces(state: &State) -> FastSpaceState {
|
||||||
index += 1;
|
index += 1;
|
||||||
|
|
||||||
// try to use SIMD instructions explicitly
|
// try to use SIMD instructions explicitly
|
||||||
#[cfg(target_arch = "x86_64")]
|
// run with RUSTFLAGS="-C target-cpu=native" to enable
|
||||||
|
#[cfg(all(
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_feature = "sse2",
|
||||||
|
target_feature = "sse4.2"
|
||||||
|
))]
|
||||||
{
|
{
|
||||||
use std::arch::x86_64::*;
|
use std::arch::x86_64::*;
|
||||||
|
|
||||||
|
@ -287,7 +292,11 @@ fn fast_eat_spaces(state: &State) -> FastSpaceState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "x86_64"))]
|
#[cfg(not(all(
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_feature = "sse2",
|
||||||
|
target_feature = "sse4.2"
|
||||||
|
)))]
|
||||||
{
|
{
|
||||||
while index < length {
|
while index < length {
|
||||||
match bytes[index] {
|
match bytes[index] {
|
||||||
|
@ -431,7 +440,11 @@ fn eat_line_comment<'a>(
|
||||||
|
|
||||||
let loop_start = index;
|
let loop_start = index;
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(all(
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_feature = "sse2",
|
||||||
|
target_feature = "sse4.2"
|
||||||
|
))]
|
||||||
{
|
{
|
||||||
use std::arch::x86_64::*;
|
use std::arch::x86_64::*;
|
||||||
|
|
||||||
|
@ -519,7 +532,11 @@ fn eat_line_comment<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "x86_64"))]
|
#[cfg(not(all(
|
||||||
|
target_arch = "x86_64",
|
||||||
|
target_feature = "sse2",
|
||||||
|
target_feature = "sse4.2"
|
||||||
|
)))]
|
||||||
while index < length {
|
while index < length {
|
||||||
match bytes[index] {
|
match bytes[index] {
|
||||||
b'\t' => unreachable!(),
|
b'\t' => unreachable!(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue