-6

I want to improve a JAVA program performances using GPU programming. After some research on the internet I found that it is possible if i use jcuda or jocl, but the problem is that the kernel code must be written in C in both cases. and the algorithm that i want every thread to execute is very complicated to be written in C (it does some computations to know if there will be an accident between two aircrafts) so an object-oriented language is necessery.

Is there a solution ? or must we translate the whole project to C++ ?

Thanks for your help !

  • Can you please see [here](http://stackoverflow.com/help/how-to-ask) first . Thanks – Nepal12 Mar 24 '15 at 15:10
  • 1
    [this](http://stackoverflow.com/questions/22866901/using-java-with-nvidia-gpus-cuda) may be of interest – Robert Crovella Mar 24 '15 at 15:18
  • Why must it be GPU optimization? This seems like a prime suspect for parallelization so you can solve the problem "simply" with decent hardware and plenty of CPUs. – Gimby Mar 24 '15 at 15:35
  • There can be a java class that turns sphere objects into pure float arrays to be processed in gpu. Then there is a struct builder in the device side that receives pure array and constructs structs. Then you can use those structs to check if ray intersects them. If structs are not enough, then you should wait for Aparapi to become objectively better. Maybe it already is. Check out aparapi that translates your java code to opencl kernels. – huseyin tugrul buyukisik Mar 24 '15 at 18:40
  • @_Nepal12 My question is clear if read with few attention (may be i wasn't very polite ..sorry). @_Robert the link is very intresting but doesn't solve the problem unfortunately.. thank you friend. @_Gimby it's because i have 200 plane to deal with and may be more in the futur so there is ~2000 comparision per update.. the algorithm is also used for a resolving conflicts algorithm that calls him lot of times .. do you think that CPUs can do fine ? – Mouhcine Amira Mar 24 '15 at 19:25
  • GPUs are really not very much faster than CPUs in most cases. You should always try making the CPU code faster first and consider GPU code an optimisation. – Lee Mar 24 '15 at 21:07
  • The link mentioned by @RobertCrovella does not answer your (particular) question, but what I wanted to emphasize in this answer is: Answering your particular question is hard. And we simply don't have enough details to even *try* to give a good answer here. You'll have to carefully analyze the performance bottlenecks of your application, and whether it can be accelerated by exploiting the *data-parallel processing power* of a GPU. (Blindly porting it to C++ for higher performance is not a realistic option - and without a detailed analysis, most likely a waste of time) – Marco13 Mar 28 '15 at 16:02

1 Answers1

2

Simple rule: if it needs object orientation, it looses its performance. Even if you are using GPU acceleration.

I would advise you to identify the parallel parts of your program code. You do not have to transfer all of your algorithm to the GPU device. Is there any aspect of paralellization, e.g. arrays or grids that are filled?

What kind is your simulation message exchange? Is it explicit, i.e. sending messages around your kernels, or implicit via synchronization.

You should at least give us some more information about you algorithm and its data layout.

Christian
  • 395
  • 2
  • 13
  • Thanks for the answers In general the algorithm must detect conflicts within a set of around 200 planes above an area. To do so, it listens to a predictor of trajectories that gives him, every 1-4 minutes, an update or a new trajectory of a plane (pn) which he must compare to the others (lets call them p1 .. p200). But his answer is quite late for now, so i wanted to use GPU programming to optimize it. the 1st thread compare pn & p1 , the 2nd pn & p2 ... but this comparison uses many objects and it would be easier if kernels functions could be implemented in java. Sorry for my english – Mouhcine Amira Mar 24 '15 at 18:50
  • I see some application of GPU enhancement here. But forget about your OO design. So what is your plane and your trajectory? In its most simple case, I would see a plane as a 3D point/vector and a trajectory as a list of vectors. This is a perfect match to GPU evaluation. How complex are your objects? Make them simple, e.g. use arrays for your planes. Do you need the complete set of information for your comparisons? What exactly do you even compare? Only its geometric coordinates? You see, there is a potential to reduce the data used for GPU coding. – Christian Mar 25 '15 at 11:17
  • I see ... Thanks Christian that's very helpful – Mouhcine Amira Mar 25 '15 at 12:34