Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ahmadi__Afshin
Beginner
64 Views

Random Number Generator

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
64 Views

did you link with ILP64 libraries?

Ahmadi__Afshin
Beginner
64 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?

Gennady_F_Intel
Moderator
64 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

Reply