I am trying to use cuRAND library to randomly generate integer numbers between 0 to 100. It should be an integer type.
My Code:
%%cu
#include <cstdlib>
#include <cassert>
#include <curand.h>
#include <iostream>
using namespace std;
int main(){
int size = 8;
size_t bytes_a = size* sizeof(int);
// Allocate memory for our matrices
int *a;
cudaMallocManaged(&a, bytes_a);
// Pseudo random number generator
curandGenerator_t prng;
curandCreateGenerator(&prng, CURAND_RNG_PSEUDO_MRG32K3A);
// Set the seed
curandSetPseudoRandomGeneratorSeed(prng, (int)clock()%100);
// Fill the matrix with random numbers on the device
curandGenerate(prng, a, size);
for(int i = 0; i<size; i++){
cout<<a[i]<<endl;
}
return 0;
}
But I am getting error as:
error: argument of type "int *" is incompatible with parameter of type "unsigned int *"
Can someone suggest how can I generate random numbers between 0 and 100 using curandGenerate()
function?
Aucun commentaire:
Enregistrer un commentaire