Majid Salimi
Majid Salimi

Reputation: 35

How to compile and run JCUDA in netbeans?

I want to compile and run my jcuda codes in an IDE (Netbeans) on ubuntu 16.04. I've already installed Netbeans, Maven, java and cuda 8.0.

For example, I want to run sample of vector add that the java file is JCudaVectorAdd.java and the cuda kernel is JCudaVectorAddKernel.cu. How can I compile and run this simple example using Netbeans?

Upvotes: 1

Views: 258

Answers (1)

Majid Salimi
Majid Salimi

Reputation: 35

You can create a maven project and add dependencies to the pom.xml file of the project:

<dependency>
    <groupId>org.jcuda</groupId>
    <artifactId>jcuda</artifactId>
    <version>0.9.2</version>
</dependency>
<dependency>
    <groupId>org.jcuda</groupId>
    <artifactId>jcublas</artifactId>
    <version>0.9.2</version>
</dependency>
<dependency>
    <groupId>org.jcuda</groupId>
    <artifactId>jcufft</artifactId>
    <version>0.9.2</version>
</dependency>
<dependency>
    <groupId>org.jcuda</groupId>
    <artifactId>jcusparse</artifactId>
    <version>0.9.2</version>
</dependency>
<dependency>
    <groupId>org.jcuda</groupId>
    <artifactId>jcusolver</artifactId>
    <version>0.9.2</version>
</dependency>
<dependency>
    <groupId>org.jcuda</groupId>
    <artifactId>jcurand</artifactId>
    <version>0.9.2</version>
</dependency>
<dependency>
    <groupId>org.jcuda</groupId>
    <artifactId>jnvgraph</artifactId>
    <version>0.9.2</version>
</dependency>
<dependency>
    <groupId>org.jcuda</groupId>
    <artifactId>jcudnn</artifactId>
    <version>0.9.2</version>
</dependency>

then add the JCudaVectorAdd.java to the project and give the address of JCudaVectorAddKernel.cu file in the java file:

String ptxFileName = preparePtxFile("JCudaVectorAddKernel.cu");

now you can build your project successfully.

Upvotes: 1

Related Questions