Code Monkey home page Code Monkey logo

gammarng's Introduction

gammaRNG

This repo contains the CUDA implementation of five gamma generator kernels and benchmarking code for the M.Sc. thesis : Gamma Random Number Generation on GPUs using CUDA

The best performing kernels on all GPUs tested are cheng1977 and marsaglia_tsang

For usage on GPUs I recommend using either cheng1977 or marsaglia_tsang, the best performing kernel can depend on your GPU type, but they should outperform all other kernels for all values of alpha larger than 1. More information about the the theory of RNGs and the gamma distribution and further references can be found in the thesis.

Gamma Generation Kernels

The following gamma generators were selected as potential candidates for effective generators on GPU architectures and implemented in CUDA (gamma_generators.cuh):

marsaglia_tsang - The generator (without squeeze step) from:

cheng1977 - The generator (GA) from:

  • R. C. H. Cheng. The Generation of Gamma Variables with Non-Integral Shape Parameter. Journal of the Royal Statistical Society. Series C (Applied Statistics) 26, no. 1 (1977): pp. 71–75. https://doi.org/10.2307/2346871

GKM1, GKM2, GKM3 - The generators with corresponding names from:

  • R. C. H. Cheng and G. M. Feast. Some Simple Gamma Variate Generators. Journal of the Royal Statistical Society. Series C (Applied Statistics) 28.3 (1979): pp. 290–295. https://doi.org/10.2307/2347200.

GC - The generator (GA) from:

  • J.H. Ahrens and U. Dieter. Computer methods for sampling from gamma, beta, poisson and bionomial distributions. *ComputingÄ 12.3 (1974): pp. 223–246. https://doi.org/10.1007/BF02293108.

best1978 - The generator (XG) from:

Build Instructions and Usage

The build system used is cmake and the target gamma_kernel_benchmark correspond to the benchmark executable. An example of how to build and execute the code, and analyze the benchmark output can be found in the google COLAB notebook: gammaRNG.

The kernels are written to be used inlined and to be compiled with the O3 optimization flag. If you would like to use the kernel with lower optimization or run out of registers (and are unable to inline), then I highly recommend you to split up the kernels into:

  1. a setup step (that initialize the constants before the do loop).
  2. a rejection loop (coresponding to the do loop).

gammarng's People

Contributors

wertysas avatar

Watchers

 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.