CUDPP 1.1
rand_app.cu File Reference

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

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

Functions

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

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
 All Classes Files Functions Variables Enumerations Enumerator Defines