Giter Club home page Giter Club logo

oprsimd's Introduction

Operator SIMD

This is repository for collection of operator overloading written in Free Pascal that allows to do vectors and matrices operation using Intel SIMD SSE/SSE2/SSE3 instructions.

Requirement

How to use

Adding two vectors

program simd_vector_add;

uses

   vectypes,
   simdssevec;

var
    v1, v2, tot : TVector;

begin
    //v1.x = 1.0, v1.y = 1.0, v1.z = 1.0, v1.w = 1.0
    v1 := 1.0;

    //v2.x = 2.0, v2.y = 2.0, v2.z = 2.0, v2.w = 2.0
    v2 := 2.0;

    tot := v1 + v2;
    writeln('x:', tot.x, ' y:', tot.y, ' z:', tot.z, ' w:', tot.w);
end.

Subtract two vectors

program simd_vector_sub;

uses

   vectypes,
   simdssevec;

var
    v1, v2, tot : TVector;

begin
    //v1.x = 1.0, v1.y = 1.0, v1.z = 1.0, v1.w = 1.0
    v1 := 1.0;

    //v2.x = 2.0, v2.y = 2.0, v2.z = 2.0, v2.w = 2.0
    v2 := 2.0;

    tot := v1 - v2;
    writeln('x:', tot.x, ' y:', tot.y, ' z:', tot.z, ' w:', tot.w);
end.

Multiply a vector with scalar

program simd_vector_mulscalar;

uses

   vectypes,
   simdssevec;

var
    v1, tot : TVector;

begin
    //v1.x = 1.0, v1.y = 1.0, v1.z = 1.0, v1.w = 1.0
    v1 := 1.0;

    tot := v1 * 2.0;
    writeln('x:', tot.x, ' y:', tot.y, ' z:', tot.z, ' w:', tot.w);
end.

Calculate dot product of two vectors

program simd_vector_dot;

uses

   vectypes,
   simdssevec;

var
    v1, v2 : TVector;
    dot : single;

begin
    v1.x := 1.0;
    v1.y := 2.0;
    v1.z := 3.0;
    v1.w := 0.0;

    v2.x := 6.0;
    v2.y := 7.0;
    v2.z := 8.0;
    v2.w := 0.0;

    dot := v1 * v2;

    writeln('dot:', dot);
end.

Calculate cross product of two vectors

program simd_vector_cross;

uses

   vectypes,
   simdssevec;

var
    v1, v2, res : TVector;

begin
    v1.x := 2.0;
    v1.y := 3.0;
    v1.z := 4.0;
    v1.w := 0.0;

    v2.x := 5.0;
    v2.y := 6.0;
    v2.z := 7.0;
    v2.w := 0.0;

    res := v1 ** v2;

    writeln('x:', res.x, ' y:', res.y, ' z:', res.z, ' w:', res.w);
end.

Compile demo

Run

$ ./build-demo.sh

Run demo

For example

$ ./demo/simd_vector_add

oprsimd's People

Contributors

zamronypj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

oprsimd's Issues

double precision

Would you be interested in incorporating support for two packed double-precision floating-point calculations into this library? I could do a pull request with the code.

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.