#include "iostream" #include "sys/time.h" #include "mkl.h" using namespace std; int main() { const int n = 1000000; float r[n]; VSLStreamStatePtr stream; // set seed to clock timeval tim; gettimeofday(&tim, NULL); int seed = tim.tv_sec; // initialize RNG on MIC #pragma offload target(mic) in(seed) nocopy(stream) vslNewStream( &stream, VSL_BRNG_MT2203, seed ); #pragma offload target(mic) \ in(n) out(r) nocopy(stream) { vsRngUniform( VSL_RNG_METHOD_UNIFORM_STD, stream, n, r , 0.0, 1.0 ); } cout << "vsRngUniform:\n"; for(int i=0; i<5; i++) { cout << r[i] << endl; } cout << endl; #pragma offload target(mic) \ in(n) out(r) nocopy(stream) { vsRngGaussian( VSL_RNG_METHOD_GAUSSIAN_BOXMULLER2, stream, n, r, 0.0, 1.0 ); } cout << "vsRngGaussian:\n"; for(int i=0; i<5; i++) { cout << r[i] << endl; } cout << endl; }