NVIDIA CUDA on Mac with Eclipse NSight Edition

Nsight Eclipse Edition is a full-featured IDE, powered by the Eclipse platform that provides a complete integrated development environment to edit, build, debug and profile CUDA C/C++ applications on MAC and Linux platforms. The combination of CUDA aware source editor and powerful debugging and profiling tools make Nsight Eclipse Edition the ultimate development platform for heterogeneous computing.

The latest version of Nsight Eclipse Edition with support for CUDA C/C++ is bundled with the CUDA Toolkit 5.0 Preview available only for registered CUDA developers. NVIDIA is expected to roll out the production release of CUDA Toolkit 5.0 any time soon.

The Nsight Eclipse IDE comprises of three main components:

  • Nsight Source Code Editor
  • CUDA aware source code editor with syntax highlighting, smart completion and inline help
  • Project Builder with support for executable, static and dynamic library build configurations
  • Project templates and integration with the CUDA SDK samples
  • CUDA aware code refactoring improves productivity and code quality
  • Hyperlink navigation enables faster code browsing
  • Nsight Debugger
  • Simultaneous debugging of both CPU and GPU code
  • View program variables across several CUDA threads
  • Examine execution state and mapping of the kernels and GPUs
  • Breakpoints and single-step execution at source-code and assembly levels
  • CUDA memory checks to detect and prevent memory leaks and errors
  • Nsight Profiler
  • Timeline view with a unified CPU and GPU trace of application activity
  • Identify potential performance issues within the application kernels
  • Automated analysis system to pin-point optimization opportunities
  • Integration with Nsight Editor and Builder enable fast edit-build-profile optimization cycle

System Requirements

Here is a table specifying all the hardware and software requirements for Nsight Eclipse Edition (CUDA Toolkit 5.0 Preview).

To get started with Nsight Eclipse Edition, install the CUDA Toolkit 5.0 Preview and CUDA 5.0 drivers for the OS of your choice (MAC OSX or Linux) and run ‘nsight’ on the command line.

In the release preview it is not possible, unfortunately, to launch Nsight by double clicking the application in MAC OS X. A bug in the preview prevents shell script to properly setup paths. Use “/usr/local/cuda/bin/nsight” to launch the application. This will get sorted out in the final release version where the installer will handle this issue.

Getting Started with Nsight

Development using Nsight Eclipse IDE is divided into three distinct modes:

  • Edit & Build Mode
  • Debug Mode
  • Profile Mode

The Nsight IDE starts with Edit & Build Mode by default, which is naturally the place to start developing an application. You can switch between these modes by selecting Window->Open Perspective. Also you can customize a mode with your favorite layout and save that custom perspective for future use.

Here, we will touch on each of these modes and briefly explain their interface and usage.

Edit and Build Mode: This is the place where you start developing a CUDA C/C++ application using the Nsight source editor; which is a CUDA aware source editor for developing CUDA code. The editor supports highlighting for CUDA API calls and special indicators for recognizing the device kernel code and the host code, along with smart completion and pop-up help. This let you develop CUDA applications more quickly and efficiently. The below figure shows the edit and build mode.

 

The main window in the middle is the Nsight source editor, with a tabbed view of all of the open documents. The Project Explorer to the left of the source editor window shows the active executable, static library or shared library projects, which you are working on. You can configure all the build properties of an active project by navigating to the Properties menu of that project.  To the right of the source editor is the Outline view, which shows a complete breakdown of the active project, with included headers, defines, and the public and non-public functions. This allows a very easy navigation around the projects.

Above the source editor are the toolbars for creating, building and debugging the program. The build toolbar offers a hammer button to build the project with selected configuration; debug or release. Use the Run button to execute the program or the Debug button to start a debug session.

 

Debug Mode: On pressing the Debug button, the IDE reconfigures itself to enter the Debug Mode giving user access to all of the features and tools required to effectively debug the program. You can enter the debug mode by selecting Window->Open Perspective->debug.

The debug mode allows us to view all the threads and thread blocks of the kernel being executed, and we can select a thread important to us and view its state. We can view thread variables, register values for the thread in question and the disassembly of the code. We can also view the state of all the CUDA kernels in hardware that our application is using, available GPUs in our system and how our application is using them. We can see for a thread, which SM it is executing on, and which warp and lane it is using.

The standard debugging features, like single-step the code, set break-points, view variables and registers as they update, instruction stepping mode to step through the individual assembly code lines, are all supported in the Nsight Debugger.

 

Profiling Mode: Once you have developed and debugged an application to get it functional, you would want to gauge its performance and optimize the application using the profiler included in the Nsight IDE. To profile an application, build it in the release configuration. Use the Profile button on the toolbar to run the application in Profile mode and collect the profiling information. Once profiling information is collected the IDE switches to the Profiling Perspective, giving you access to all tools needed to optimize the application.

The Profiling Mode shows an application timeline, which displays all the kernel execution and memory copies with time stamps, as well as the activity on the host processor. The Analysis tab on the bottom left corner allows you to specify the analysis scope to analyze either the entire application or a specific kernel which you can select from the timeline. You can further select from the Stages to collect data for the Multiprocessor, Kernel Memory and the Kernel Instructions. Here is a sample figure showing the Profile Mode.

The profiler also includes an automated analysis engine that can help you pinpoint the optimization opportunity within your application. Each of these optimization opportunities is linked to online help where you can learn more about these performance issues and the ways you can resolve them.

Conclusion:

The Nsight Eclipse IDE includes all the right tools to edit, build, debug and profile your CUDA applications more efficiently thus enhancing your productivity a lot.