bla
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build_linux64/objstore/amscufhash.o
Normal file
BIN
build_linux64/objstore/amscufhash.o
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build_linux64/objstore/amscurandlcg.o
Normal file
BIN
build_linux64/objstore/amscurandlcg.o
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build_linux64/objstore/amscurandom_tests1.o
Normal file
BIN
build_linux64/objstore/amscurandom_tests1.o
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,55 +0,0 @@
|
||||
#ifndef __AMSCU_RANDOM_HPP__
|
||||
#define __AMSCU_RANDOM_HPP__
|
||||
|
||||
namespace amscuda
|
||||
{
|
||||
|
||||
// Random Number Gerneators
|
||||
|
||||
|
||||
// faster floating point hash function used in fractal generators
|
||||
__device__ __host__ float fhash1d_su(float x);
|
||||
|
||||
__device__ __host__ float fhash3d_su(float x, float y, float z);
|
||||
|
||||
__device__ __host__ float fhash4d_su(float x, float y, float z, float w);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Deterministic Pseudorandom int32_t Generator //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//Next seed in simple 32 bit integer deterministic psuedo-rand generator
|
||||
__host__ __device__ void dpr32_nextseed(int32_t *rseed_inout);
|
||||
|
||||
//Simple 32 bit integer deterministic pseudo-random generator
|
||||
// *not* for cryptography
|
||||
// Frequency of generated floats should be uniform [0,1)
|
||||
__host__ __device__ float dpr32_randf(int32_t *rseed_inout);
|
||||
|
||||
//box muller standard normal pseudorandom variable
|
||||
__host__ __device__ float dpr32_randnf(int32_t *rseed_inout);
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Deterministic Pseudorandom int64_t Generator //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//operates without side-effects on explicit seed for threaded use
|
||||
//deterministic pseudorandom number generator - takes seed and returns next seed
|
||||
__host__ __device__ void dpr64_nextseed(int64_t *seedinout);
|
||||
|
||||
//deterministic pseudorandom number generator - takes seed and returns next seed
|
||||
//returns uniformly distributed double
|
||||
__host__ __device__ double dpr64_randd(int64_t *seedinout);
|
||||
|
||||
__host__ __device__ float dpr64_randf(int64_t *seedinout);
|
||||
|
||||
|
||||
void test_dprg64();
|
||||
void test_dprg32();
|
||||
|
||||
|
||||
}; //end namespace amscuda
|
||||
|
||||
#endif
|
||||
|
||||
@ -39,8 +39,6 @@ namespace amscuda
|
||||
//random device buffer functions
|
||||
void dbuff_rand_dpr32(float *devbuffer, int N, int32_t *rseedinout, int nblocks, int nthreads); //
|
||||
void dbuff_rand_dpr32n(float *devbuffer, int N, int32_t *rseedinout, int nblocks, int nthreads); //
|
||||
|
||||
|
||||
void dbuff_rand_dpr64(float *devbuffer, int N, int64_t *rseedinout, int nblocks, int nthreads); //
|
||||
|
||||
//Elementwise device-buffer vector binary operation
|
||||
|
||||
@ -50,7 +50,6 @@ namespace amscuda
|
||||
|
||||
#include <amsculib3/amscuarray.hpp>
|
||||
#include <amsculib3/amscuda_binarrrw.hpp>
|
||||
#include <amsculib3/amscu_random.hpp>
|
||||
|
||||
#include <amsculib3/random/amscurandom.cuh>
|
||||
|
||||
|
||||
@ -11,7 +11,12 @@ namespace fhash
|
||||
{
|
||||
//Floating point hash functions
|
||||
|
||||
// legacy fast floating point hash function used in fractal generators
|
||||
__device__ __host__ float fhash1d_su(float x);
|
||||
|
||||
__device__ __host__ float fhash3d_su(float x, float y, float z);
|
||||
|
||||
__device__ __host__ float fhash4d_su(float x, float y, float z, float w);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -11,7 +11,38 @@ namespace lcg
|
||||
{
|
||||
//Legacy linear congruential generators
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Deterministic Pseudorandom int32_t Generator //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//Next seed in simple 32 bit integer deterministic psuedo-rand generator
|
||||
__host__ __device__ void dpr32_nextseed(int32_t *rseed_inout);
|
||||
|
||||
//Simple 32 bit integer deterministic pseudo-random generator
|
||||
// *not* for cryptography
|
||||
// Frequency of generated floats should be uniform [0,1)
|
||||
__host__ __device__ float dpr32_randf(int32_t *rseed_inout);
|
||||
|
||||
//box muller standard normal pseudorandom variable
|
||||
__host__ __device__ float dpr32_randnf(int32_t *rseed_inout);
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Deterministic Pseudorandom int64_t Generator //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//operates without side-effects on explicit seed for threaded use
|
||||
//deterministic pseudorandom number generator - takes seed and returns next seed
|
||||
__host__ __device__ void dpr64_nextseed(int64_t *seedinout);
|
||||
|
||||
//deterministic pseudorandom number generator - takes seed and returns next seed
|
||||
//returns uniformly distributed double
|
||||
__host__ __device__ double dpr64_randd(int64_t *seedinout);
|
||||
|
||||
__host__ __device__ float dpr64_randf(int64_t *seedinout);
|
||||
|
||||
|
||||
void test_dprg64();
|
||||
void test_dprg32();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@ -48,6 +48,10 @@ __host__ int dbuff_randn(double *hbuffer, int64_t size, randstate_t *state = NUL
|
||||
__host__ int dbuff_randint(int *hbuffer, int64_t size, int low, int high, randstate_t *state = NULL);
|
||||
|
||||
|
||||
//Tests
|
||||
__host__ void amscurand_tests1(); //test basic random functions
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ __global__ void dbuff_rand_dpr32_kf(float *devbuffer, int N, int32_t *seeds)
|
||||
lseed = seeds[I0];
|
||||
for(I=I0;I<N;I=I+Is)
|
||||
{
|
||||
f = dpr32_randf(&lseed);
|
||||
f = amscuda::random::lcg::dpr32_randf(&lseed);
|
||||
devbuffer[I] = f;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ void dbuff_rand_dpr32(float *devbuffer, int N, int32_t *rseedinout, int nblocks
|
||||
for(I=0;I<nblocks*nthreads;I++)
|
||||
{
|
||||
lseed = lseed + I + 1;
|
||||
dpr32_nextseed(&lseed);
|
||||
amscuda::random::lcg::dpr32_nextseed(&lseed);
|
||||
seeds[I] = lseed;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ __global__ void dbuff_rand_dpr32n_kf(float *devbuffer, int N, int32_t *seeds)
|
||||
lseed = seeds[I0];
|
||||
for(I=I0;I<N;I=I+Is)
|
||||
{
|
||||
f = dpr32_randnf(&lseed);
|
||||
f = amscuda::random::lcg::dpr32_randnf(&lseed);
|
||||
devbuffer[I] = f;
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ void dbuff_rand_dpr32n(float *devbuffer, int N, int32_t *rseedinout, int nblock
|
||||
for(I=0;I<nblocks*nthreads;I++)
|
||||
{
|
||||
lseed = lseed + I + 1;
|
||||
dpr32_nextseed(&lseed);
|
||||
amscuda::random::lcg::dpr32_nextseed(&lseed);
|
||||
seeds[I] = lseed;
|
||||
}
|
||||
|
||||
|
||||
51
src/amsculib3/random/amscufhash.cu
Normal file
51
src/amsculib3/random/amscufhash.cu
Normal file
@ -0,0 +1,51 @@
|
||||
#include <amsculib3/amsculib3.hpp>
|
||||
|
||||
namespace amscuda
|
||||
{
|
||||
namespace random
|
||||
{
|
||||
namespace fhash
|
||||
{
|
||||
|
||||
__device__ __host__ float fhash1d_su(float x)
|
||||
{
|
||||
float ret;
|
||||
ret = x*(x>0.0f) + -x*(x<0.0f); //sign without conditionals?
|
||||
ret = fmodf(ret,10000.0f); //restrain domain
|
||||
ret = fmodf(ret*(ret+3678.453f)+7890.453f,10000.0f);
|
||||
ret = fmodf(ret*(ret+8927.2134f),10000.0f);
|
||||
ret = fmodf(ret*(ret+3656.234f),10000.0f);
|
||||
//ret = fmodf(ret*(ret+892.2134f),1000.0f);
|
||||
//ret = fmodf(ret,1000.0f);
|
||||
ret = ret/10000.0f;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
__device__ __host__ float fhash3d_su(float x, float y=0.0f, float z=0.0f)
|
||||
{
|
||||
float ret = 0.0f;
|
||||
|
||||
ret = fhash1d_su(z);
|
||||
ret = fhash1d_su(1000.0f*ret*ret + y);
|
||||
ret = fhash1d_su(1000.0f*ret*ret + x);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
__device__ __host__ float fhash4d_su(float x, float y=0.0f, float z=0.0f, float w=0.0f)
|
||||
{
|
||||
float ret = 0.0f;
|
||||
|
||||
ret = fhash1d_su(w);
|
||||
ret = fhash1d_su(1000.0f*ret*ret + z);
|
||||
ret = fhash1d_su(1000.0f*ret*ret + y);
|
||||
ret = fhash1d_su(1000.0f*ret*ret + x);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
}; //end namespaces
|
||||
@ -2,44 +2,10 @@
|
||||
|
||||
namespace amscuda
|
||||
{
|
||||
|
||||
__device__ __host__ float fhash1d_su(float x)
|
||||
namespace random
|
||||
{
|
||||
float ret;
|
||||
ret = x*(x>0.0f) + -x*(x<0.0f); //sign without conditionals?
|
||||
ret = fmodf(ret,10000.0f); //restrain domain
|
||||
ret = fmodf(ret*(ret+3678.453f)+7890.453f,10000.0f);
|
||||
ret = fmodf(ret*(ret+8927.2134f),10000.0f);
|
||||
ret = fmodf(ret*(ret+3656.234f),10000.0f);
|
||||
//ret = fmodf(ret*(ret+892.2134f),1000.0f);
|
||||
//ret = fmodf(ret,1000.0f);
|
||||
ret = ret/10000.0f;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
__device__ __host__ float fhash3d_su(float x, float y=0.0f, float z=0.0f)
|
||||
namespace lcg
|
||||
{
|
||||
float ret = 0.0f;
|
||||
|
||||
ret = fhash1d_su(z);
|
||||
ret = fhash1d_su(1000.0f*ret*ret + y);
|
||||
ret = fhash1d_su(1000.0f*ret*ret + x);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
__device__ __host__ float fhash4d_su(float x, float y=0.0f, float z=0.0f, float w=0.0f)
|
||||
{
|
||||
float ret = 0.0f;
|
||||
|
||||
ret = fhash1d_su(w);
|
||||
ret = fhash1d_su(1000.0f*ret*ret + z);
|
||||
ret = fhash1d_su(1000.0f*ret*ret + y);
|
||||
ret = fhash1d_su(1000.0f*ret*ret + x);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Deterministic Pseudorandom int32_t Generator //
|
||||
@ -218,5 +184,6 @@ void test_dprg32()
|
||||
// return;
|
||||
}
|
||||
|
||||
|
||||
}; //namespace amscuda
|
||||
};
|
||||
};
|
||||
}; //end namespaces
|
||||
21
src/amsculib3/random/amscurandom_tests1.cu
Normal file
21
src/amsculib3/random/amscurandom_tests1.cu
Normal file
@ -0,0 +1,21 @@
|
||||
#include <amsculib3/amsculib3.hpp>
|
||||
|
||||
namespace amscuda
|
||||
{
|
||||
namespace random
|
||||
{
|
||||
|
||||
__host__ void amscurand_tests1()
|
||||
{
|
||||
using namespace random;
|
||||
printf("Random number generator basic function test:\n");
|
||||
|
||||
|
||||
rand_seed(0);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}; //end namespaces
|
||||
};
|
||||
@ -23,5 +23,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
//test_amscurarray1();
|
||||
|
||||
random::amscurand_tests1();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user