-
Notifications
You must be signed in to change notification settings - Fork 24
Safe intrinsics in core::arch #494
Copy link
Copy link
Closed
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Metadata
Metadata
Assignees
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Type
Fields
Give feedbackNo fields configured for issues without a type.
Proposal
Problem statement
With target features 1.1 now ready to be stabilized, it is soon going to be possible to write i.e. intrinsics-using SIMD code with minimal use of unsafe (specifically, only at the initial entry point of feature-using code.
However, most intrinsics in
core::archare currently unsafe (excludingwasm32intrinsics), requiring user code to introduce some amount of unsafe at the lowest level of the call hierarchy too.Motivating examples or use cases
For example, the DCT code in
jpeg-decoder(here) could reduce usage of unsafe to effectively just a couple of lines, making the code significantly easier to audit.This is common to multiple SIMD-using crates.
Solution sketch
Arch-specific intrinsics (such as AVX/AVX2 SIMD intrinsics) in
core::archthat do not operate on pointers, and do not affect global state (such as FP rounding modes) could be made safe once target_features 1.1 is stabilized.Alternatives
An alternative would be for people to write/use a crate that wraps relevant
core::archintrinsics in safe wrappers.