-
-
Notifications
You must be signed in to change notification settings - Fork 684
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
Generic #simd type and intrinsics #1807
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_target_feature - required by the target micro-architecture enable_target_feature - will be enabled for the specified procedure only
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#simd[N]T
where
T
must be an integer, float, or boolean, with no specific endianness. It is an semi-opaque data type which will not allow for indexing. All operators for array programming that are supported by[N]T
are supported for the#simd[N]T
.The lane width (
len(#simd[N]T) == N
) of the simd vector type must be one of the following: 1, 2, 4, 8, 16, 32, 64 (power of two between1..=64
)Note: Platform-specific SIMD intrinsics will be added in the future.
Rationale for a Generic SIMD Interface
Each platform has completely different instructions which may not work or behave the same, and have completely different trade-offs depending on the context of their use. In many cases, you want to be able to use those specific instructions in different ways depending on the specific platform, but there are numerous reasons for wanting to a highish-level generic abstraction for SIMD:
The end goal has always been to have a very well designed inline assembler embedded into Odin and have that assembly language partially understand its parent language. The inline assembler has been put on the back-burner for a little while until other things have been implemented and finalized.
The inline assembler is the only language feature missing from Odin now which when that is done, I will be writing up the full language specification and then have v1.0.
Rationale for Opaqueness
Indexing
Lane/element indexing is currently not allowed on a
#simd
type because when replacing an element, it will do so by creating a new vector rather updating the current vector.v[1]
could be allowed for extracting but it would not make much sense for replacing:This behaviour would necessitate another addressing mode in Odin for it to work correctly. Keeping things to procedure calls makes things much more consistent, less surprising, and clearer what is actually happening.
Intrinsics
New Package
core:simd
Contains aliases of the
intrinsics.simd_*
as justsimd.*
e.g.intrinsics.simd_ceil
issimd.ceil
.Utility procedures within
core:simd
:New Package
core:simd/x86
Support for x86 specific instructions from the following sets:
Attributes
TODO for future specific stuff:
@(require_target_feature=<string>)
@(enable_target_feature=<string>)
Compile Intrinsics
intrinsics.x86_cpuid :: proc(ax, cx: u32) -> (eax, ebc, ecx, edx: u32) ---
intrinsics.xgetbv :: proc(cx: u32) -> (eax, edx: u32) ---