Nsight Eclipse Plugins Edition Getting Started Guide
The user guide for using Nsight Eclipse Plugins Edition.
1. Introduction
This guide introduces Nsight Eclipse Plugins Edition and provides instructions necessary to start using this tool. Nsight Eclipse is based on Eclipse CDT project. For a detailed description of Eclipse CDT features consult the integrated help "C/C++ Development User Guide" available from inside Nsight (through Help->Help Contents menu).
1.1. About Nsight Eclipse Plugins Edition
- Edit, build, debug and profile CUDA-C applications
- CUDA aware source code editor – syntax highlighting, code completion and inline help
- Graphical user interface for debugging heterogeneous applications
- Profiler integration – Launch visual profiler as an external application with the CUDA application built in this IDE to easily identify performance bottlenecks
For more information about Eclipse Platform, visit http://eclipse.org
Using Nsight Eclipse Edition
2.1. Installing Nsight Eclipse Edition
Nsight Eclipse Plugins archive is part of the CUDA Toolkit. Nsight Eclipse Plugins archive can be installed using the Help -> Install New Software... Menu on Eclipse
2.1.1. Installing CUDA Toolkit
To install CUDA Toolkit:
- Visit the NVIDIA CUDA Zone download page:http://www.nvidia.com/object/cuda_get.html
- Select appropriate operating system. Nsight Eclipse Edition is available in Mac OS X and Linux toolkit packages.
- Download and install the CUDA Driver.
- Download and install the CUDA Toolkit.
- Follow instructions to configure CUDA Driver and Toolkit on your system.
2.1.2. Configure CUDA Toolkit Path
When Eclipse is first launched with Nsight Eclipse plugins in the new workspace, NVIDIA usage data collection dialog will
be displayed as below.
Click Yes to enable usage collection. This can be disabled later from the CUDA preference page.
To get started, CUDA Toolkit path must be configured in Eclipse with Nsight Plugins:
- Open the Preferences page, Window > Preferences.
- Go to CUDA toolkit section.
- Select the CUDA toolkit path to be used by Nsight. CUDA tookits that
are installed in the default location will automatically appear.
- CUDA toolkit path can be also specified in the project properties page in order to use different toolkit for a project.
- Enable usage data collection if you wish to send usage data to NVIDIA.
- Click on the button to set cuda-gdb and Visual Profiler as the default launchers.
- For QNX:
When QNX is selected as Target OS, a dialog will be displayed to set the
QNX_HOST and QNX_TARGET environment variables if they were not already set.
QNX_HOST environment variable identifies the directory that holds the host-related components:
QNX_TARGET environment variable identifies the directory that holds the target-related components:
2.2. Nsight Eclipse Main Window
On the first run Eclipse will ask to pick a workspace location. The workspace is a folder where Nsight will store its settings, local files history and caches. An empty folder should be selected to avoid overwriting existing files.
- Editor - displays source files that are opened for editing.
- Project Explorer - displays project files
- Outline - displays structure of the source file in the current editor.
- Problems - displays errors and warnings detected by static code analysis in IDE or by a compiler during the build.
- Console - displays make output during the build or output from the running application.
2.3. Creating a New Project
- From the main menu, open the new project wizard - File > New... > C/C++ Project
- Specify the project name and project files location.
- Specify the project type like executable project.
- Specify the CUDA toolchain from the list of toolchains.
- Specify the project configurations on the next wizard page.
- Complete the wizard. The project will be shown in the Project Explorer view and source editor will be opened.
- Build the project by clicking on the hammer button on the main toolbar.
2.4. Importing CUDA Samples
- From the main menu, open the new project wizard - File > New... > C/C++ Project
- Specify the project name and project files location.
- Select Import CUDA Sample under Executable in the Project type tree.
- Select CUDA toolchain from the Toolchains option. location.
- On the next wizard page select project sample you want to import. Also select the target CPU architecture. Press Next...
- Specify the project parameters on the next wizard page.
- Complete the wizard. The project will be shown in the Project Explorer view and source editor will be opened.
- Build the project by clicking on the hammer button on the main toolbar.
cuHook Sample
- From the main menu, open the new project wizard - File > New... > C/C++ Project
- Select project type "Makefile project" and choose "Empty Project"
- Specify the project name and project files location.
- Complete the wizard. The project will be shown in the Project Explorer view.
- Right click on the project - Import... > General > File System
- On the next wizard page, select the location of cuHook sample(Samples/7_CUDALibraries/cuHook)
- Select all the source files and makefile and Finish the wizard
- Build the project by clicking on the hammer button on the main toolbar.
- To run the sample, from the main menu - Run > Run Configurations... > Select the executable > Go to Environment tab > New... > enter Name=LD_PRELOAD, Value=./libcuhook.so.1 > Run will execute the sample
2.5. Configure Build Settings
To define build settings:
In the C/C++ Projects view, right-click your project, and select Properties. Select C/C++ Build, Settings from the list.
-
Libraries
- Configure library search path(-L) and to include linker libraries(-l).
When you are cross compiling for different target os,
the library search path should point to the appropriate location
where the target os libraries are present.
- Miscellaneous - Set additional linker options and option to link with OpenGL libraries.
- Shared Library Settings - Set option to build a shared library.
- Dialect - Select the language standard and dialect options.
- Preprocessor - Add the defined and undefined symbols for the preprocessor.
- Includes - Set include paths and include files for the compiler.
- Optimization - Set the compiler optimization level.
- Debugging - Set the options to generate debug information.
- Warnings - Set inhibit all warning messages.
- CUDA - Generate code for different real architectures with the PTX for the same vitrual architectures.
2.6. Debugging CUDA Applications
- In the Project Explorer view, select project you want to debug. Make sure the project executable is compiled and no error markers are shown on the project.
- Right click on the project and go to Debug As > NVIDIA CUDA GDB Debugger menu.
- You will be offered to switch perspective when you run debugger for the first time. Click "Yes". Perspective is a window layout preset specifically designed for a particular task.
- Application will suspend in the main function. At this point there is no GPU code running.
- Add a breakpoint in the device code. Resume the application.
Debugger will break when application reaches the breakpoint. You can now explore your CUDA device state, step through your GPU code or resume the application.
Additional debugger options can be set in the debug configuration dialog through Run > Debug Configurations .. menu..
2.7. Remote development of CUDA Applications
Nsight Eclipse Plugins supports the cross compilation mode for remote devices.
In the cross compilation mode the project resides on the host system and the cross compilation is also done on the host system. The cross compilation mode is only supported on an Ubuntu x86 host system.
To cross compile select the target cross compile architecture in CPU architecture drop down in the project properties page:
2.8. Debugging Remote CUDA Applications
-
Select the project and right click then go to
Debug As...>NVIDIA CUDA GDB Debugger(Remote)
menu item.
-
Type the full path to a local executable or select one using the Local file... button.
- Select a remote connection from a drop-down list or press the Add connection... button to create a new one.
-
If you are creating a new remote connection,
enter the host name(or IP address) as well as the user name. Select the SSH as system type.
Also select the QNX check box for QNX targets and then press Finish.
-
For Android devices:
To configure the remote connection using Android debug bridge,
select the Android debug bridge from the Remote Connection drop-down list,
Android device must be connected to the host system using USB port.
Press Manage button, and enter or select the path to adb utility. You need to install Android SDK platform tools to use Android debug bridge. press Detect button to find the android device available through ADB.
- Optional: Press Connect to verify the selected remote connection.
- Press the Next button.
-
Type the full path to cuda-gdbserver on the remote system or
select one using the Browse... button.
- Click on "Add new path" or on the Browse... button to specify the path to the shared libraries the remote application depends on.
- Click on the Finish button to finish the new debug configuration wizard and start debugging the application.
- You will be offered to switch perspective when you run the debugger for the first time. Click Yes. Perspective is a window layout preset specifically designed for a particular task.
The debugger will stop at the application main routine. You can now set breakpoints, or resume the application.
2.9. Profiling CUDA applications
- In the Project Explorer view, select project you want to profile. Make sure the project executable is compiled and no error markers are shown on the project.
-
Select the project and right click and go to
Profile As>NVIDIA Visual Profiler
menu.
Nsight Eclipse will launch the Visual Profiler to specify extra profiler options with the executable information already passed from the selected project.
2.10. Build Projects in a Docker Container
- Open Nsight Eclipse Edition and configure the container settings.
-
Open the Preferences page, Window > Preferences and go to:
CUDA
>
Container Settings
- Select the option if you want to build the projects inside the Docker container. Make sure the CUDA toolkit path that is specified in the CUDA preferences is the path of the CUDA toolkit inside a Docker container.
- Select the Connection and the Image dropdown will display all the Docker images that are currently installed. Choose the docker image that you want to use to build/debug the projects. The preferences that are set here will be automatically displayed in the project setup wizard. You can choose to modify the container settings for the individual projects from the project setup wizard.
- To create a project, From the main menu, open the new project wizard: File > New... > CUDA C/C++ Project
- Specify the project name and project files location. And select the CUDA toolchain from the list of toolchains.
-
In the last page of project setup wizard, the container options will be displayed.
The default container settings from the preference page will be displayed here.
You can choose to modify the settings for this project in this Container settings page.
- Complete the project setup wizard. The project will be created and shown in the Project Explorer view.
- The project source directories will be automatically mounted to the docker container.
- If you need to mount any other directories that contains the include files/libraries and etc to the docker container, you can mount those directories from the project property page.
-
Right click on the project and go to Properties. Select C/C++ Build > Settings > Container Settigns Tab.
Additional directories can be mounted from this property page.
- Build the project by hitting the hammer button on the main toolbar. The project is now built in the chosen Docker container the executable will be available on the host.
2.11. Importing Nsight Eclipse Projects
- Open Nsight Eclipse edition and select the project that needs to be exported.
-
Right click on the Nsight Eclipse project and go to -
Export
>
C/C++
>
C/C++ Project Settings
>
Next
menu.
- Select the project and settings to export.
- Specify the "Export to file" location.
- Settings will be stored in the given XML file.
- Go to Eclipse workbench where the project settings needs to be imported.
- Create a C/C++ Project from the main menu File > New > C/C++ Project
- Specify the project name and choose Empty project type with CUDA toolchains.
- Right click on the project to import the source files. Import > General > File System >(From directory) or copy the source files from the existing project.
- Import the project settings like include paths and symbols using the following right click menu Import > C/C++ > C/C++ Project Settings >Next...
-
Select the location of the project settigns file and select the project and configuration
on the next wizard page.
- Complete the wizard. The project settings will be imported from the file exported from Nsight Eclipse Edition.
- Build the project by clicking on the hammer button on the main toolbar.
2.12. More Information
More information about the Eclipse CDT features and other topics is available in the Help contents. To access Help contents select Help->Help Contents from the Nsight main menu.
More information about CUDA, CUDA Toolkit and other tools is available on CUDA web page at http://developer.nvidia.com/cuda
Notices
Notice
ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, "MATERIALS") ARE BEING PROVIDED "AS IS." NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
Information furnished is believed to be accurate and reliable. However, NVIDIA Corporation assumes no responsibility for the consequences of use of such information or for any infringement of patents or other rights of third parties that may result from its use. No license is granted by implication of otherwise under any patent rights of NVIDIA Corporation. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all other information previously supplied. NVIDIA Corporation products are not authorized as critical components in life support devices or systems without express written approval of NVIDIA Corporation.