I'm a new OpenCL developer. I'm trying to solve a problem using a genetic algorithm and a very importan part of this kind of heuristic algorithms is the randomness. To solve my problem I need to generate randomly an initial population and then some genetic operators will be selected in a random way too. I want to solve my problem using heterogeneous computing, but the issue is that I cannot find a function to generate random numbers in the GPU. I was thinking that will be useful put this work into a CPU kernel.
Is there an allowed OpenCL function to generate random numbers in a kernel where the target is the CPU?
M.C Juan Garcia.
The OpenCL standard doesn't provide a built-in function to generate pseudorandom numbers. There are several ways to solve the problem, and for example, you can generate an array of random numbers on a host and pass the pointer to the array to a kernel, or, alternatively, use libraries like clRNG that provides streams of random numbers from the host. There are a lot of scientific papers and libraries that might also solve the problem in another way, but the selection will depend on your requirements for them. Unfortunately, I am not able to suggest any of them.