Code Monkey home page Code Monkey logo

xorshiftsse's Introduction

A vectorised implementation of Marsaglia's XORSHIFT random number generator

This vectorised version of Marsaglia's XORSHIFT random number generator (RNG) is implemented using Intel's streaming SIMD extensions (SSE) version 4.1. The RNG generates 32-bit random samples. The width of the vector registers is 128 bit giving a vector length of 4 32-bit integers.

Very brief overview of Intels streaming SIMD extensions (SSE)

To be written.

SSE based implementations

For a description of Marsaglia's XORSHIFT RNG, please refer to <> or the documentation of the TinyRNG library .

Ring buffer implementation

First iteration of the SSE implementation.

Unroll the ring buffer

Second iteration of the SSE implementation. Decrese the granularity

Replace the modulo counter by function pointers

Make it more fine grained again

Compiling

gcc test.c xorshiftSSE.c -o xorshiftSSE -O3 -msse4.1 -I.

== Timing results ==

guido@linux-9cge:~/scratch/xorshiftSSE/remake> ./xorshiftSSE xorshift32 1000000000 samples in 4.162631 sec. xorshift32SSE 1000000000 samples in 1.987162 sec. speedup 2.095 xorshift32SSE unrolled 1000000000 samples in 1.094806 sec. speedup 3.802 xorshift function pointers 1000000000 samples in 1.286171 sec.speedup 3.236

guido@linux-9cge:~/scratch/xorshiftSSE/remake> ./xorshiftSSE xorshift32 1000000000 samples in 3.843894 sec. xorshift32SSE 1000000000 samples in 1.756420 sec. speedup 2.188 xorshift32SSE unrolled 1000000000 samples in 0.918752 sec. speedup 4.184 xorshift function pointers 1000000000 samples in 1.282542 sec. speedup 2.997

guido@linux-9cge:~/scratch/xorshiftSSE/remake> ./xorshiftSSE xorshift32 1000000000 samples in 3.957081 sec. xorshift32SSE 1000000000 samples in 1.987700 sec. speedup 1.991 xorshift32SSE unrolled 1000000000 samples in 1.095842 sec. speedup 3.611 xorshift function pointers 1000000000 samples in 1.285295 sec. speedup 3.079

Average speed-up:

xorshift32SSE 2.091 xorshift32SSE unrolled 3.866 xorshift function pointers 3.104

xorshiftsse's People

Contributors

risingape avatar

Watchers

James Cloos avatar Simon Frost avatar

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.