CUDPP  2.2
CUDA Data-Parallel Primitives Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
rand_app.cu File Reference

CUDPP application-level rand routine for MD5. More...

#include "cuda_util.h"
#include "cudpp.h"
#include "cudpp_util.h"
#include "cudpp_plan.h"
#include <cstdlib>
#include <cstdio>
#include <assert.h>
#include "cta/rand_cta.cuh"
#include "kernel/rand_kernel.cuh"

Functions

Rand Functions
void launchRandMD5Kernel (unsigned int *d_out, unsigned int seed, size_t numElements)
 Launches the MD5 Random number generator kernel. More...
 
void cudppRandDispatch (void *d_out, size_t numElements, const CUDPPRandPlan *plan)
 Dispatches the rand function based on the plan. More...
 

Detailed Description

CUDPP application-level rand routine for MD5.

rand_md5_app.cu

Function Documentation

void launchRandMD5Kernel ( unsigned int *  d_out,
unsigned int  seed,
size_t  numElements 
)

Launches the MD5 Random number generator kernel.

The MD5 Random number generator works by generating 128 bit digests which are then broken down into 32 bit chunks and stored inside d_out. d_out is expected to be of type unsigned int and can hold numElements elements.

An analysis of the stastical distribution of the MD5 random number generator can be found in the original paper Parallel white noise generation on a GPU via cryptographic hash. The optimizations mentioned in the paper are also present in the CUDPP version of the MD5 Random number generator.

It is also worth pointing out that the GPU version will not generate the same output * as the CPU version. This is due to the difference in the floating point accuracy and several optimizations that have been used (i.e. calculating sin using device hardware rather than storing it in an array that the original implementation does). However, the distribution of the numbers is well suited for random number generation, even without the CPU-GPU invariance.

Parameters
[out]d_outthe array of unsigned integers allocated on device memory
[in]seedthe random seed used to vary the output
[in]numElementsthe number of elements in d_out
See Also
gen_randMD5()
cudppRand()
Todo:
: chose a better block size, perhaps a multiple of two is optimal
void cudppRandDispatch ( void *  d_out,
size_t  numElements,
const CUDPPRandPlan plan 
)

Dispatches the rand function based on the plan.

This is the dispatch call which looks at the algorithm specified in plan and calls the appropriate random number generation algorithm.

Parameters
[out]d_outthe array allocated on device memory where the random numbers will be stored must be of type unsigned int
[in]numElementsthe number of elements in the array d_out
[in]planpointer to CUDPPRandPlan which contains the algorithm to run