1

I am a newbie in cuda for Java. I have a simple task to do: parallelize a for loop.

my for loop is pretty simple, I have an array of objects and I have to perform some "evaluation" to each object in the array:

     for (int i=0; i < vec.length; i++){              
         int val =  evaluate((vec[i]));
     }

I was wondering I can I parallelize this. I only found examples of complex things in JCuda.

Thanks for helping

Maria

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257
Maria
  • 41
  • 4
  • The [JCudaVectorAdd sample](http://www.jcuda.org/samples/samples.html) should be easily adaptable to your case, and it is used in a [tutorial](http://www.jcuda.org/tutorial/TutorialIndex.html) as well. Doing arbitrary operations in JCuda often involves writing a CUDA kernel directly (the kernel is written in C/C++), as that sample demonstrates. Your CUDA kernel could hold the operations for the `evaluate` method. – Robert Crovella Sep 05 '14 at 17:59
  • 2
    Three people already voted as "too broad" - and they may be right. Maybe you want to have a look at http://stackoverflow.com/questions/22866901/using-java-with-nvidia-gpus-cuda/22868938#22868938 to decide whether what you are going to do there actually makes sense... – Marco13 Sep 07 '14 at 15:40

0 Answers0