Hello to everyone,

I have a very simple question. Is there a way to get current time systems in Cuda, at least in microseconds or more? I work on Linux (CentOS).

Thank you very much for your kind attention and my best regards!

Jason.

Hello to everyone,

I have a very simple question. Is there a way to get current time systems in Cuda, at least in microseconds or more? I work on Linux (CentOS).

Thank you very much for your kind attention and my best regards!

Jason.

Same question for me.

If the question is “Does CUDA provide a function callable from device code that is equivalent to the gettimeofday() function of Linux?” then the answer is “No”.

Then when we are using curand to generate random numbers recursively for a kernel, how do we make sure that each run gives a different result?

Side remark: For reproducability, it is best for applications to return the same sequence of random numbers for each run by default, unless an application user specifically requests otherwise.

One approach would be to either have the application user provide a seed value (e.g. on the commandline or via a GUI menu), or alternatively generate a seed value in the host code of the CUDA-accelerated app, in whatever way the application writer deems sufficient, then pass that seed to the CUDA kernel(s) for use with CURAND.

Actually I am working with OptiX on research purpose. I need to do diffuse ray casting each time a ray hits the geometry and reflects. So the next ray direction has to be random. And this ray reflection works in a recursive way until certain criterion is met, e.g. the maximum number of reflections is achieved.

Sorry, I don’t understand the details of your use case. Specifically, I don’t understand why it requires the re-seeding of the PRNG for a new ray, rather than simply pulling up the next random number from the PRNG’s current sequence to randomize the ray direction.

If you are convinced that re-seeding on the device is in fact the right thing to do, you might want to look into using the data returned by the clock() or clock64() device functions for that. No guarantees that this is a suitable way of re-seeding. You could probably also look into combining the normal CURAND output with whatever new seed value you are using, by either XORing or hashing.

You reminded me of one solution. I can actually create a buffer with random seeds for each ray. In each ray generation, I will use the corresponding seed from the buffer. Meanwhile, I will keep track of the current depth of the recursion. The depth is then used as the sequence input of the function call. What do you think?