LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-07-2012, 03:45 PM   #1
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Slackware and Fedora
Posts: 234

Rep: Reputation: 2
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
 
Old 11-07-2012, 06:11 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
What is exactly your goal/intent ?
 
Old 11-08-2012, 09:17 AM   #3
darkstarbyte
Member
 
Registered: May 2010
Location: 3 planets away from the sun.
Distribution: Slackware and Fedora
Posts: 234

Original Poster
Rep: Reputation: 2
To see how one would document huge SIMD registers for a cpu.
 
Old 11-08-2012, 10:30 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by darkstarbyte View Post
To see how one would document huge SIMD registers for a cpu.
I don't get it. Registers, including SIMD ones, are documented in the CPU architecture documents of CPU makers.

I.e. there is nothing to see, but something to learn and copy-paste - literally or metaphorically.
 
Old 11-08-2012, 01:10 PM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
This page has some good links on SIMD, but mostly in C not assembly:
http://lwn.net/Articles/517237/
 
  


Reply

Tags
architecture, assembly, cpus



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] I have a partially theoretical question. abcde597 Programming 7 11-06-2012 04:13 PM
Theoretical Future?? nathanhillinbl Linux - Security 5 05-04-2007 01:43 AM
Theoretical considerations about switching between OS's holrin Linux - Laptop and Netbook 2 10-06-2006 06:49 PM
Theoretical test enviroment Richie55 Linux - General 1 02-02-2006 07:15 AM
Theoretical Question jgr220 Linux - Security 3 03-29-2003 05:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration