0% found this document useful (0 votes)
271 views

CUDA Netbeans

To develop CUDA projects in NetBeans, you must: 1. Configure NetBeans to recognize .cu files and use the nvcc compiler. 2. Create a new C/C++ project and set the toolchain to CUDA to build and run CUDA code. 3. Open existing CUDA projects created in NetBeans, or import external projects with or without a Makefile and configure the toolchain.

Uploaded by

bboy0303
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
271 views

CUDA Netbeans

To develop CUDA projects in NetBeans, you must: 1. Configure NetBeans to recognize .cu files and use the nvcc compiler. 2. Create a new C/C++ project and set the toolchain to CUDA to build and run CUDA code. 3. Open existing CUDA projects created in NetBeans, or import external projects with or without a Makefile and configure the toolchain.

Uploaded by

bboy0303
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

NETBEANS AND CUDA

HOW TO BUILD OR OPEN A CUDA PROJECT IN THE


GRAPHICAL DEVELOPMENT ENVIRONMENT NETBEANS

Version 1.0
Department of Electromagnetism
Faculty of Physics
University of Salamanca
Index

1.  Introduction ................................................................................. 1

2.  Configure NetBeans to develop CUDA ....................................... 2

3.  Creating a new CUDA project in NetBeans ................................ 5

4.  Open a CUDA project in NetBeans ............................................. 7


4.1.  A CUDA project created previously with NetBeans ........................... 7

4.2.  A CUDA project from existing code files that already have a
Makefile.. ........................................................................................... 7

4.3.  A CUDA project from existing code files that have not a Makefile ..... 8 

I
NETBEANS AND CUDA - HOW TO BUILD OR OPEN A CUDA PROJECT IN THE
GRAPHICAL DEVELOPMENT ENVIRONMENT NETBEANS

1. Introduction

This document details a little tutorial of how can create a new CUDA
project or load one already create in the tool or development environment
NetBeans.
This allows programming within a graphical environment, offering many
facilities such as integration of all elements and tasks required during
development in the same environment. Enables us to program, compile, debug
an run applications from the same development environment, without the need
for multiple windows, consoles and text editors open.
Currently, at the time of writing this document, the installed version of the
development environment is 6.5.1.
In first, any graphical development environment is ready to develop in
CUDA, so it must be configured to recognize the extensions ".cu" and compile
using the NVIDIA compiler (nvcc). In this tutorial there is a section dedicated to
it.

1
VERSION: 1.0
JAVIER GÓMEZ MARTÍN

2. Configure NetBeans to develop CUDA

First of all you must configure the development environment to associate


".cu" extensions whit C++ projects (based programming language to CUDA)
and to use the NVIDIA compiler (nvcc).
To do this, go to menu "Tools Æ Options", in the "C/C++" section
select the tab "Build Tools". Select GNU and click on "Duplicate...".
We named the new Tool Collection as CUDA. In the form whit the routes
of the compilers write the values you see in the next screenshot:

2
NETBEANS AND CUDA - HOW TO BUILD OR OPEN A CUDA PROJECT IN THE
GRAPHICAL DEVELOPMENT ENVIRONMENT NETBEANS

Now, in the tab "Code Assistance", select as Tool Collection "CUDA"


and add in "C++ Compiler" the following routes:

• /usr/include
• /usr/local/cuda/include

3
VERSION: 1.0
JAVIER GÓMEZ MARTÍN

Finally, in the tab "Other", in "C++ File Extensions" edit and add the
extension ".cu". It should be something like this:

4
NETBEANS AND CUDA - HOW TO BUILD OR OPEN A CUDA PROJECT IN THE
GRAPHICAL DEVELOPMENT ENVIRONMENT NETBEANS

3. Creating a new CUDA project in NetBeans

To create a new CUDA project in NetBeans, it must first load the


development environment. This is on the menu “Applications Æ
Programming Æ NetBeans IDE”.
Then go to menu “File Æ New Project Æ C/C++ Application” and click
on "Next".

Then write the project name and click on "Finish".

5
VERSION: 1.0
JAVIER GÓMEZ MARTÍN

Finally, we have created the project, we have got the latest details. Let
the projects options on menu “File Æ Project Properties”, in the category
"Build" check that the Tool Collection selected is CUDA and the option "Enable
Make Dependency Checking" is unchecked.

In the category "C++ Compiler", check that as Tool is "nvcc" and in


"Include Directories" add “/usr/include” and “/usr/local/cuda/include”, with
this:

We can add both source files (.cpp and .cu) and header files (.h) to our
project.

6
NETBEANS AND CUDA - HOW TO BUILD OR OPEN A CUDA PROJECT IN THE
GRAPHICAL DEVELOPMENT ENVIRONMENT NETBEANS

4. Open a CUDA project in NetBeans

4.1. A CUDA project created previously with NetBeans

Simply go to the menu “File Æ Open Project” and search in our file
system the NetBeans project that we want to open.

4.2. A CUDA project from existing code files that already


have a Makefile

The process would be the same as for creating a new CUDA project, but
now when selecting the type of C/C++ application in the menu “File Æ New
Project” would select the option “C/C++ Project From Existing Code”.

Then we follow the steps that the wizard give us to select the path of the
"Makefile" and source files. In first, the rest of configuration and compilation
options would not have to change anything.
Finally it should be set up "Project Properties" as in the case of a new
project. For this see section 3 of this document.

7
VERSION: 1.0
JAVIER GÓMEZ MARTÍN

4.3. A CUDA project from existing code files that have


not a Makefile

The process would be the same as for creating a new CUDA project, but
instead of adding new files to the project, add the existing files.
Finally it should be set up "Project Properties" as in the case of a new
project. For this see section 3 of this document.

You might also like