When I compile a exist java project, for example, jpcsp, how can I invoke the jcuda?
Or how to use the jcuda when I compile a exist java project, for example, jpcsp, using netbeans?
I’ve searched google, but found nothing…
Hello
jpcsp seems to be a rather complex project. You should start with a simple example, like the Vector Addition Sample in a single, standalone project. Some basic introduction is also shown in the Tutorial, but it is not specific for NetBeans. Usually, you should only have to create a new project, add the JAR files to your project’s classpath, and put the native libraries into the root directory of your project. I am not so familiar with NetBeans, but I can try to post a more detailed description for a simple project if necessary.
bye
Marco
Thank you very much!! Marco13, You came to my rescue
So…If I want to make the jpcsp project use Jcuda, I need to rewrite it from scratch?
Well… it somehow sounds like you have a wrong idea of CUDA. You can NOT simply “let a program run with CUDA to make it faster”. CUDA is intended for data-parallel programming (see e.g. http://en.wikipedia.org/wiki/Data_parallelism ). There are several constraints on how CUDA may be used, and it is not suited equally for all kinds of problems. I assume that jpcsp is a program that may hardly be parallelized.
To simplify it a little: When you have a huge amount of data, and you have to perform a specific operation (like an arithmetic or trigonometric computation) on each element of the data, then you can use CUDA to let this computation be executed by 1000s of threads in parallel, and thus make the computation faster. If you have an arbitrary program and want to accelerate it with CUDA, you first have to identify the parts of the computation that are data-parallel (or possibly find a way to convert the problem into a data-parallel problem), and this may be challenging (or even impossible in some cases).
I recommend that you read a little about data-parallel programming and the general, basic concepts and ideas of CUDA, and then think about whether it may be used to accelerate a PSP emulation (I assume that this is not possible, but I may be wrong).
Hummm…
So, The jpcsp project may not be eligible for using cuda even if it supports multi-procesor? That’s interesting.
I’m a noob in cuda and I can’t find much about cuda with google. So it is nice to know something about jcuda and the constraints that are placed.
I did not say that it is not possible to use CUDA there - I only said that I have doubts
From a first, short glance at the project source code, it seems that it is a tremendously complex project (which was to be expected). Even if it uses multiple processors and multiple threads, this may not necessarily mean that CUDA can be used for such a program.
When you are, for example, starting 4 Java Threads, and have 4 processors (cores), then you will most likely end up with one thread running on each core (roughly and in the best case, just to give you an idea). However, these threads may do completely different things. One thread may be used for rendering, one for audio playback, one for the game logic…
In CUDA, you do usually not have 4 threads, but maybe 1000 or more threads. The large and important constraint is: ALL these threads HAVE to do exactly the same thing. They only operate on different parts of a large data block. So for example, you may easily parallelize a vector addition with cuda
float array0[] = ...
float array1[] = ...
float sum[] = new float[n];
for (int i=0; i<n; i++)
{
sum** = array0** + array1**;
}
(this is done in the Vector Addition sample mentioned above). When this is executed with ‚n‘ threads in CUDA, then each thread performs one addition.
In contrast, when you want to sum up all elements of one array, like this
float array[] = ...
float sum = 0;
for (int i=0; i<n; i++)
{
sum += array**;
}
then this can not easily be executed by ‚n‘ threads in parallel, because each thread has to add its array entry to the same ‚sum‘ variable.
(In fact, this is called a ‚scan‘ operation, and it can be executed in parallel, but it’s not trivial )
In any case, you should start with simple examples (like the samples from the website) before considering to use CUDA for something like the jpcsp, and „considering“ to use it here first of all means: Verifying that it is possible and that it makes sense…
bye
Thank you very much! Macro13, I’ve learned a lot from your words.