GithubHelp home page GithubHelp logo

joshuawierenga / cpptemplatevectorlibrary Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 33 KB

Attempt at emulating scalar style operation syntax but with x86 simd types.

License: MIT License

C++ 100.00%

cpptemplatevectorlibrary's People

Contributors

joshuawierenga avatar

Watchers

 avatar  avatar

cpptemplatevectorlibrary's Issues

Add Vector<int32_t, 64> Support

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

General Vector<X, 64> Support

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.

Constructors

  • std::Array Constructor
    • 8 bit 1f4c242
    • 16 bit Waiting on full value constructor
    • 32 bit Waiting on full value constructor
  • Single Value Constructor
  • Full Value Constructor
  • C Style Array Constructor?

Arithmetic Operators

  • Addition
    • 8 bit Almost, addition is supported but only with assignment.
    • 16 bit
    • 32 bit
  • Subtraction
    • 8 bit
    • 16 bit
    • 32 bit
  • Multiplication
  • Division(is this possible?)
    • 8 bit
    • 16 bit
    • 32 bit
  • Modulus(is this possible?)
    • 8 bit
    • 16 bit
    • 32 bit

Bitwise Operators

"Bitwise" Stream Operators

  • Insert(<<)
  • Extract(>>)
    • 8 bit
    • 16 bit
    • 32 bit

(Compound) Assignment Operators

No Special Assignment/Copy/Move Operators, defaults appear fine i.e. using rule of zero.

Comparision/Relational Operators

  • Equal
    • 8 bit
    • 16 bit
    • 32 bit
  • Not Equal
    • 8 bit
    • 16 bit
    • 32 bit
  • Greater Than
  • Less Than
    • 8 bit
    • 16 bit
    • 32 bit
  • Greater Than or Equal
    • 8 bit
    • 16 bit
    • 32 bit
  • Less Than or Equal
    • 8 bit
    • 16 bit
    • 32 bit

Logical Operators (do these exist for simd? I would count things like _mm_and_ps but that doesn't have an integer equivalent.)

  • Not
    • 8 bit
    • 16 bit
    • 32 bit
  • And
    • 8 bit
    • 16 bit
    • 32 bit
  • Or
    • 8 bit
    • 16 bit
    • 32 bit

Variation Operators

  • Prefix Increment(++x)
    • 8 bit
    • 16 bit
    • 32 bit
  • Postfix Increment(x++)
    • 8 bit
    • 16 bit
    • 32 bit
  • Prefix Decrement(--x)
    • 8 bit
    • 16 bit
    • 32 bit
  • Postfix Decrement(x--)
    • 8 bit
    • 16 bit
    • 32 bit

Left Over Operators and Functions

  • Blend(BlendV internally)
    • 8 bit
    • 16 bit
    • 32 bit
  • Cast to std::Array
    • 8 bit
    • 16 bit
    • 32 bit

Add Vector<int16_t, 64> Support

See #2 for info.

Functions already supported but of course, modified to match new vector size:

// 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

New Functions:

// 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

Currently unsupported/not considered functions:

_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

Add Vector<int8_t, 64> Support

See #2 for info.

Constructors

Vector(int32_t) => _mm_set1_pi8
Vector(int32_t, int32_t) => _mm_setr_pi8

Arithmetic Operators

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% =>

Bitwise Operators

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>> =>

"Bitwise" Operators

operator<< => insert into stream
operator>> => extract from stream

(Compound) Assignment Operators

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?

Comparision/Relational Operators

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)

Logical Operators

operator! =>
operator&& =>
operator|| =>

Variation Operators

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?

Conversion Operators

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))

Currently unsupported/not considered functions:

_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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.