Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Random Number Generator

Ahmadi__Afshin
316 Views

Hi,

I have developed a function to generate a vector of random numbers. However, there are two problems:

1. When the number of random numbers to be generated is too large (e.g. 50000^2), it will output: MKL ERROR: Parameter 3 was incorrect on entry to vdRngUniform.

2. When the left bound is a positive number (i.e. a = 300 b = 100), the function violates the left bound condition and returns minimum value of zero! However, if 'a' is a negative number, it works correctly!

Can you please help? Thank you.

Afshin

 

int RNG_UNIF ( long int N, double a, double b, double *P )
{
    // N number of random values to be generated
    // a is the left bound
    // b is the right bound
	
    VSLStreamStatePtr stream;
    int errcode = 0;
    srand(time(0));    
    long seed = rand();
   	
    /***** Initialize *****/
    errcode = vslNewStream( &stream, VSL_BRNG_MT2203, seed ); 
    if (errcode != 0) goto err;
    /***** Call RNG *****/    	
    errcode = vdRngUniform( VSL_RNG_METHOD_UNIFORM_STD_ACCURATE, stream, N, P, a, b );
    if (errcode != 0) goto err;

    vslDeleteStream(&stream);
   
    err:
    return errcode; 	

}

 

0 Kudos
3 Replies
Gennady_F_Intel
Moderator
316 Views

did you link with ILP64 libraries?

0 Kudos
Ahmadi__Afshin
316 Views

Yes. I used the following switches: -lmkl_intel_thread -lmkl_core -lmkl_intel_lp64 -liomp5 -O2

I am using Intel MKL 2019 in Linux environment. How about the second problem?

0 Kudos
Gennady_F_Intel
Moderator
316 Views

50000^2 > int 32, therefore you have to link with ILP64 libs instead of LP64 ones. Please check user's guide or mkl linker adviser how to link properly

0 Kudos
Reply