joshuawierenga / cpptemplatevectorlibrary Goto Github PK
View Code? Open in Web Editor NEWAttempt at emulating scalar style operation syntax but with x86 simd types.
License: MIT License
Attempt at emulating scalar style operation syntax but with x86 simd types.
License: MIT License
The current plan is to take the existing structure and totally redo supported operations for initially just Vector<int32_t, 64> but in such a way that supporting both other types and vector sizes is easier than it is currently. Ideally, some effort will be taken to ensure that whatever is done don't rule out floating-point types at a later point.
Below is a list of simd functions I have I looked at and how they map to relevant c++ operators, there are lots of gaps currently.
Functions already supported but of course modified to match new vector size:
// Constructors
Vector(int32_t) => _mm_set1_pi32
Vector(int32_t, int32_t) => _mm_setr_pi32
static Blend => ? Actual blendv was added in sse4.1
// "Bitwise" Operators
operator<< => insert into stream
// (Compound) Assignment Operators
operator+= => _mm_add_pi32 / _m_paddd + Assignment
// Comparision/Relational Operators
operator> => _mm_cmpgt_pi32 / _m_pcmpgtd
New Functions:
// Arithmetic Operators
operator+ => _mm_add_pi32 / _m_paddd
operator- => _mm_sub_pi32 / _m_psubd
operator* =>
operator/ =>
operator% =>
// Bitwise Operators
operator^ =>
operator| =>
operator& =>
operator~ =>
operator<< =>
operator>> =>
// "Bitwise" Operators
operator>> => extract from stream
// (Compound) Assignment Operators
operator= => Assignment Operator
operator-= => _mm_sub_pi32 / _m_psubd + Assignment
operator*= =>
operator/= =>
operator%= =>
operator&= =>
operator|= =>
operator^= =>
operator<<= => either _mm_sll_pi32 / _m_pslld or _mm_slli_pi32 / _m_pslldi
operator>>= => one of _mm_sra_pi32 / _m_psrad, _mm_srai_pi32 / _m_psradi, _mm_srl_pi32 / _m_psrld and _mm_srli_pi32 / _m_psrldi
// Variation Operators
operator++ =>
operator++(int) =>
operator-- =>
operator--(int) =>
// Comparision/Relational Operators
operator== => _mm_cmpeq_pi32 / _m_pcmpeqd
operator!= =>
operator< =>
operator>= =>
operator<= =>
// Logical Operators
operator! =>
operator&& =>
operator|| =>
// Conversion Operators
operator std::array => Array Cast++
Currently unsupported/not considered functions:
_mm_set_pi32
_mm_cvtsi32_si64
_m_from_int
_mm_packs_pi32
_m_packssdw
_m_punpckhdq
_m_punpckldq
int _m_to_int
_mm_unpackhi_pi32
_mm_unpacklo_pi32
This issue could get long so keeping it separate, also allows for putting all statuses in one table.
See #2, #3 and #4 for details.
No Special Assignment/Copy/Move Operators, defaults appear fine i.e. using rule of zero.
See #2 for info.
// Constructors
Vector(int32_t) => _mm_set1_pi16
Vector(int32_t, int32_t) => _mm_setr_pi16
static Blend => ? Actual blendv was added in sse4.1
// "Bitwise" Operators
operator<< => insert into stream
// (Compound) Assignment Operators
operator+= => _mm_add_pi16 / _m_paddw + Assignment
// Comparision/Relational Operators
operator> => _mm_cmpgt_pi16 / _m_pcmpgtw
// Arithmetic Operators
operator+ => _mm_add_pi16 / _m_paddw
operator- => _mm_sub_pi16 / _m_psubw
operator* => _mm_mullo_pi16 / _m_pmullw
operator/ =>
operator% =>
// Bitwise Operators
operator^ =>
operator| =>
operator& =>
operator~ =>
operator<< =>
operator>> =>
// "Bitwise" Operators
operator>> => extract from stream
// (Compound) Assignment Operators
operator= => Assignment Operator
operator-= => _mm_sub_pi16 / _m_psubw + Assignment
operator*= => _mm_mullo_pi16 / _m_pmullw + Assignment
operator/= =>
operator%= =>
operator&= =>
operator|= =>
operator^= =>
operator<<= => either _mm_sll_pi16 / _m_psllw or _mm_slli_pi16 / _m_psllwi
operator>>= => one of _mm_sra_pi16 / _m_psraw, _mm_srai_pi16 / _m_psrawi, _mm_srl_pi16 / _m_psrlw and _mm_srli_pi16 / _m_psrlwi
// Variation Operators
operator++ =>
operator++(int) =>
operator-- =>
operator--(int) =>
// Comparision/Relational Operators
operator== => _mm_cmpeq_pi16 / _m_pcmpeqw
operator!= =>
operator< =>
operator>= =>
operator<= =>
// Logical Operators
operator! =>
operator&& =>
operator|| =>
// Conversion Operators
operator std::array => Array Cast
_mm_adds_pi16
_mm_adds_pu16
_mm_madd_pi16
_mm_mulhi_pi16
_mm_packs_pi16
_mm_packs_pi32
_mm_packs_pu1
_m_packssdw
_m_packsswb
_m_packuswb
_m_paddsw
_m_paddusw
_m_pmaddwd
_m_pmulhw
_m_psubsw
_m_psubusw
_m_punpckhwd
_m_punpcklwd
_mm_set_pi16
_mm_subs_pi16
_mm_subs_pu16
_mm_unpackhi_pi16
_mm_unpacklo_pi16
See #2 for info.
Vector(int32_t) => _mm_set1_pi8
Vector(int32_t, int32_t) => _mm_setr_pi8
operator+ => _mm_add_pi8/_m_paddb
operator- => _mm_sub_pi8/_m_psubb
operator* => convert to 2 x 16 bit vectors to access mullo?
operator/ =>
operator% =>
operator^ => _mm_xor_si64/_m_pxor
operator| => _mm_or_si64/_m_por
operator& => _mm_and_si64/_m_pand
operator~ => _mm_andnot_si64/_m_pandn with all ones as second argument
operator<< =>
operator>> =>
operator<< => insert into stream
operator>> => extract from stream
operator= => Assignment Operator
operator+= => _mm_add_pi8/_m_paddb + Assignment
operator-= => _mm_sub_pi8/_m_psubb + Assignment
operator*= =>
operator/= =>
operator%= =>
operator&= => _mm_and_si64/_m_pand + Assignment
operator|= => _mm_or_si64/_m_por + Assignment
operator^= => _mm_xor_si64/_m_pxor + Assignment
operator<<= => convert to 2 x 16 bit vectors and use _mm_sll_pi16?
operator>>= => convert to 2 x 16 bit vectors and use _mm_srl_pi16/_mm_sra_pi16?
operator== => _mm_cmpeq_pi8/_m_pcmpeqb
operator!= => not(equal)
operator> => _mm_cmpgt_pi8/_m_pcmpgtb
operator< => and(not(equal), not(greater)) or and(not(and(equal, greater))) depends which is quicker
operator>= => and(equal, greater)
operator<= => not(greater)
operator! =>
operator&& =>
operator|| =>
operator++ => _mm_add_pi8/_m_paddb?
operator++(int) => _mm_add_pi8/_m_paddb?
operator-- => _mm_sub_pi8/_m_psubb?
operator--(int) => _mm_sub_pi8/_m_psubb?
operator std::array => Array Cast
static Blend => ? Actual blendv was added in sse4.1, repeated use of the unpack instructions might work.
Nope, just use or(and(a, c), andnot(b, c))
_mm_adds_pi8/_m_paddsb
_mm_adds_pu8/_m_paddusb
_mm_subs_pi8/_m_psubsb
_mm_subs_pu8/_m_psubusb
_mm_set_pi8
_mm_unpackhi_pi8/_m_punpckhbw
_mm_unpacklo_pi8/_m_punpcklbw
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.