Anyone want to help with some theoretical SIMD code?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Anyone want to help with some theoretical SIMD code?
The idea is just SIMD code that has massively wide registers. This was designed so it could be added to processors, but this is just the asm side of things. Not yet complete.
What I have thus far:
Code:
; Created by Branden C.
;copyright Branden C.
;date Wed Nov 7 13:57:11 MST 2012
;This is Draft 1
;License:
;Boost Software License - Version 1.0 - August 17th, 2003
;
;Permission is hereby granted, free of charge, to any person or organization
;obtaining a copy of the software and accompanying documentation covered by
;this license (the "Software") to use, reproduce, display, distribute,
;execute, and transmit the Software, and to prepare derivative works of the
;Software, and to permit third-parties to whom the Software is furnished to
;do so, all subject to the following:
;
;The copyright notices in the Software and this entire statement, including
;the above license grant, this restriction and the following disclaimer,
;must be included in all copies of the Software, in whole or in part, and
;all derivative works of the Software, unless such copies or derivative
;works are solely in the form of machine-executable object code generated by
;a source language processor.
;
;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
;SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
;FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
;ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
;DEALINGS IN THE SOFTWARE.
;There are 16 of these 1kB SIMD registers.
;A kilobyte is 1024 bytes
mov1k zmm0, mem64/mem32 ;Moves 1 kilobyte of data from memory to the 1 kilobyte register.
movk1 mem64/mem32, zmm0 ;Moves 1 kilobyte of data from the 1 kilobyte register to memory.
movreg reg32/reg64,zmm0 ;Moves anything from the general purpose register into the SIMD register, but either 64 bits or 32 bit.
; Like a bunch of 8 bit ints, 16 bit ints, 32 bit ints, 64 bit, 128 bit ints, 32 bit floats, 64 bit doubles, or 128 bit doubles
; to be exact you could have 1024 8 bit ints, 512 16 bit ints, 256 32 bit ints, 128 64 bit ints, 64 128 bit ints, 256 32 bit floats, 64 128 bit doubles
; Mathmatical operation supported would be sin, cos, tan, inverse of sin, inverse of cos, inverse of tan, sqrt, adding, subtracting, multiplication,
;division, and absolute values for floats, and doubles.
;sqrt, adding, subtracting, multiplication, division, and absolute values for ints.
;Xor,and,or,and nor are for everything.
; the first argument to the following instructions excluding bitwise operations is the target register and the last 3 bits determine that the zmm registers
;following are 8 bit ints, 16 bit ints, 32 bit ints, 64 bit, 128 bit ints, 32 bit floats, 64 bit doubles, or 128 bit doubles
zsin zmm3, zmm0, zmm1
zcos zmm3, zmm1, zmm0
ztan zmm3, zmm0, zmm1
zisin zmm3, zmm1,zmm0
zicos zmm3, zmm0, zmm1
zitan zmm3, zmm1, zmm0
zsqrt zmm3, zmm0, zmm1
zadd zmm3, zmm1, zmm0
zsub zmm3, zmm0, zmm1
zmul zmm3, zmm1, zmm0
zdiv zmm3, zmm0, zmm1
zabs zmm3, zmm1, zmm0
; the first register is really just the target register.
zxor zmm3, zmm0, zmm1
zor zmm3, zmm1, zmm0
zand zmm3, zmm0, zmm1
znor zmm3, zmm1, zmm0
;bitwise shifts like shift right and left can be done like so:
xshl zmm3, zmm0, zmm1 ;zmm3 can be one of the following
xshr zmm3, zmm1, zmm0 ;0 for the whole register, 1 for 8 bit ints, 2 for 16 bit ints, 3 for 32 bit ints, 4 for 64
;bit ints, and 5 for 128 bit ints.
; again the first register is the target register, as will all the instructions.
; Now for shuffling, considering there are 1024 places for any byte then 524801 shifts are possible, and the first variable is either
zshift zmm3, zmm0
; this is how they are found:
;0 = no change
;1 would be switching the first registers byte with a second one.
;2 would be switching the second registers byte with the third one.
;etc, You do not switch with a byte before itself
;Conditional execution is comparing to simd registers for a certain comparasine to be true, and if so store the result like:
zcmpxx zmm3, xmm1, zmm0 ; zoperation zmm3, xmm1, xmm0
; xx can be ne, eq, lt, gt,le, ge
;eq is basically if equal to then execute the next instruction
;ne is basically if not equal to then execute the next instruction
;lt is basically if less than then execute the next instruction
;gt is basically if greater than then execute the next instruction
;le is basically if less than or equal to then execute the next instruction
;ge is basically if greater or equal to then execute the next instruction
Last edited by onebuck; 11-07-2012 at 04:00 PM.
Reason: clean up by use of vbcode tags
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.