You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code does not print what I would expect:
#![feature(portable_simd)]use std::simd::*;fnmain(){let a = i32x4::splat(10);let b = i32x4::from_array([1,2,12, -4]);println!("{:?} {:?}", a.max(b), a.min(b));}
I expected element-wise max/min, but I got:
[10, 10, 10, 10] [1, 2, 12, -4]
The funny thing is that portable-simd does not even define max/min on its integer SIMD types (only on the float ones). What happens is that it falls back to Ord::max, and it looks like vectors implement Ord by comparing them as arrays, which probably uses lexicographic comparison.
However this means integer and float vectors max/min methods behave very differently, so this is probably not intended?
Hello!
Yes, it is a bit peculiar and we should fix that.
We usually track library-level issues over there and integration-level issues on the Rust issue tracker.
The following code does not print what I would expect:
I expected element-wise max/min, but I got:
The funny thing is that portable-simd does not even define
max
/min
on its integer SIMD types (only on the float ones). What happens is that it falls back toOrd::max
, and it looks like vectors implementOrd
by comparing them as arrays, which probably uses lexicographic comparison.However this means integer and float vectors
max
/min
methods behave very differently, so this is probably not intended?Cc @workingjubilee
The text was updated successfully, but these errors were encountered: