Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoder crashes with target-cpu=native on Ryzen R7 2700X #1954

Closed
quietvoid opened this issue Dec 16, 2019 · 14 comments
Closed

Encoder crashes with target-cpu=native on Ryzen R7 2700X #1954

quietvoid opened this issue Dec 16, 2019 · 14 comments

Comments

@quietvoid
Copy link

quietvoid commented Dec 16, 2019

Hi,

Build from master, 1622e66
I've been building rav1e with this command in WSL:

RUSTFLAGS="-C target-cpu=native" cargo build --release --target=x86_64-pc-windows-gnu

The produced binary crashes with this command line:

.\rav1e.exe tos_8b.y4m --keyint 24 --threads 16 --tile-rows 8 --tile-cols 8 --bitrate 4000 --range limited --first-pass out.stats --output out.ivf

And error

index out of bounds: the len is 134912 but the index is 134944
in rav1e/src/frame/plane.rs, line 295

However building without target-cpu and the p20191215 binary works.
For a 10 bit input, rav1e also stops before the encoding starts, without error or panic.

The selected CPU level is AVX2, for a Ryzen R7 2700X.

@rzumer
Copy link
Collaborator

rzumer commented Dec 16, 2019

As of a few days ago I had no problem encoding in native mode, so unless one of the most recent two commits broke it, a sample to reproduce it would be helpful.

@quietvoid
Copy link
Author

quietvoid commented Dec 16, 2019

Both 8 bit and 10 bit samples can be found here: https://mega.nz/#F!dFUWkCKK!vB73_UAit1v2v_KjI-qH2Q
They are from Tears of Steel, downsampled to 1950x816 and split in 24 frames scenes.

@lu-zero
Copy link
Collaborator

lu-zero commented Dec 16, 2019

Tested on linux with your 8bit sample 1622e66 and rustc 1.39.0 (4560ea788 2019-11-04)

$ ./rav1e-p20191215 ~/Samples/sample_8b.y4m --keyint 24 --threads 16 --tile-rows 8 --tile-cols 8 --bitrate 4000 --range limited --first-pass out.stats --output out.ivf
 INFO  rav1e > Using y4m decoder: 1950x816p @ 24/1 fps, 4:2:0, 8-bit
 INFO  rav1e > Encoding settings: keyint_min=12 keyint_max=24 quantizer=255 bitrate=4000000 min_quantizer=0 low_latency=false tune=Psychovisual rdo_lookahead_frames=40 min_block_size=8x8 multiref=true fast_deblock=false reduced_tx_set=true tx_domain_distortion=false tx_domain_rate=false encode_bottomup=false rdo_tx_decision=false prediction_modes=Complex-KFs include_near_mvs=false no_scene_detection=false diamond_me=true cdef=true quantizer_rdo=false use_satd_subpel=true non_square_partition=false enable_timing_info=false
 INFO  rav1e::api::config > CPU Feature Level: AVX2
 INFO  rav1e::api::internal > Using 56 tiles (8x7)
 INFO  rav1e::stats         > encoded 49 frames, 1.924 fps, 3138.62 Kb/s
 INFO  rav1e::stats         > ----------
 INFO  rav1e::stats         > Key frame:             3 | avg QP:  66.00 | avg size:   80119 B
 INFO  rav1e::stats         > Inter frame:          46 | avg QP: 125.00 | avg size:   12187 B
 INFO  rav1e::stats         > Intra only frame:      0 | avg QP:   0.00 | avg size:       0 B
 INFO  rav1e::stats         > Switching frame:       0 | avg QP:   0.00 | avg size:       0 B

On windows using mingw64:

$ ./target/release/rav1e.exe ../sample_8b.y4m --keyint 24 --threads 16 --tile-rows 8 --tile-cols 8 --bitrate 4000 --range limited --first-pass out.stats --output out.ivf
 INFO  rav1e > Using y4m decoder: 1950x816p @ 24/1 fps, 4:2:0, 8-bit
 INFO  rav1e > Encoding settings: keyint_min=12 keyint_max=24 quantizer=255 bitrate=4000000 min_quantizer=0 low_latency=false tune=Psychovisual rdo_lookahead_frames=40 min_block_size=8x8 multiref=true fast_deblock=false reduced_tx_set=true tx_domain_distortion=false tx_domain_rate=false encode_bottomup=false rdo_tx_decision=false prediction_modes=Complex-KFs include_near_mvs=false no_scene_detection=false diamond_me=true cdef=true quantizer_rdo=false use_satd_subpel=true non_square_partition=false enable_timing_info=false
 INFO  rav1e::api::config > CPU Feature Level: AVX2
 INFO  rav1e::api::internal > Using 56 tiles (8x7)
 INFO  rav1e::stats         > encoded 49 frames, 0.906 fps, 3138.62 Kb/s
 INFO  rav1e::stats         > ----------
 INFO  rav1e::stats         > Key frame:             3 | avg QP:  66.00 | avg size:   80119 B
 INFO  rav1e::stats         > Inter frame:          46 | avg QP: 125.00 | avg size:   12187 B
 INFO  rav1e::stats         > Intra only frame:      0 | avg QP:   0.00 | avg size:       0 B
 INFO  rav1e::stats         > Switching frame:       0 | avg QP:   0.00 | avg size:       0 B

$ rustc --version
rustc 1.39.0 (4560ea788 2019-11-04)

@lu-zero
Copy link
Collaborator

lu-zero commented Dec 16, 2019

Can you please tell me the compiler version and if using

RUSTFLAGS="-C target-cpu=+avx2"

Is still causing problems?

@lu-zero lu-zero added the cursed label Dec 16, 2019
@lu-zero lu-zero changed the title Encoder crashes with target-cpu=native Encoder crashes with target-cpu=native on Ryzen R7 2700X Dec 16, 2019
@quietvoid
Copy link
Author

quietvoid commented Dec 16, 2019

It seems I can't build some dependencies with RUSTFLAGS="-C target-cpu=+avx2" on WSL with --target=x86_64-pc-windows-gnu.

LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it!
error: could not compile lazy_static.
'+avx2' is not a recognized processor for this target (ignoring processor)
...
LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it!
error: could not compile regex-syntax.

Building for Linux with RUSTFLAGS="-C target-cpu=native" cargo build --release works when running straight from WSL.

So there's somehow an issue with targeting x86_64-pc-windows-gnu
rustc 1.39.0 (4560ea788 2019-11-04)

@lu-zero
Copy link
Collaborator

lu-zero commented Dec 16, 2019

I typoed target-cpu for target-feature= sorry.

@lu-zero
Copy link
Collaborator

lu-zero commented Dec 16, 2019

Passing `RUSTFLAGS="-C target-feature=+avx2" I cannot still reproduce the problem here.

@easyfab
Copy link

easyfab commented Dec 16, 2019

For info,
Building rav1e under windows 10 ( msys2) for my 2700x with:
RUSTFLAGS="-C target-cpu=native" cargo build -j16 --release
No problem here with your samples and command lines

@quietvoid
Copy link
Author

quietvoid commented Dec 16, 2019

Indeed compiling with RUSTFLAGS="-C target-feature=+avx2" cargo build --release --target=x86_64-pc-windows-gnu, rav1e does not crash.
So this might just be a cross compiling issue with rustc, and target-cpu=native when using WSL.

@lu-zero
Copy link
Collaborator

lu-zero commented Dec 16, 2019

I guess we should suggest to not use the -C target-cpu=native and explicitly enable certain features.

@shssoichiro
Copy link
Collaborator

Specifically with WSL, anyway. I have no problems using target-cpu=native on Linux with a 2700X.

@quietvoid
Copy link
Author

Since it's so specific, this can be closed?

@lu-zero
Copy link
Collaborator

lu-zero commented Dec 18, 2019

Probably it could be reported upstream, but I guess there isn't much we can do on our side :)

@lu-zero lu-zero closed this as completed Dec 18, 2019
@shssoichiro
Copy link
Collaborator

Hey, I believe this is already fixed upstream: rust-lang/rust#63959 although it won't be released until Rust 1.41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants