Build MPI with CUDA Programs using NSight Eclipse edition

How to build the SimpleMPI sample provided along with the CUDA sample in CUDA 5.0 using the NSight Eclipse edition. The same thing can be build using the make file in the terminal. please help.

Nsight Eclipse Edition does not directly support MPI compiler. To use MPI compiler (or any other unsupported compiler) you need to configure a “Makefile project”. Please consult “Nsight, Eclipse Edition User Guide” available from Nsight help for more details on providing custom makefiles in your projects.

Note that not all Nsight Eclipse Edition features will be enabled for projects with custom makefiles.

Sijo, what OS are you working on? To compile simpleMPI sample you need to have Open MPI or MPICH2 installed.
Here the guide how to build MPICH2 on Mac OS X. Hope this will help you.

Thanks to all for the comments.

I successfully run the CUDA with MPI in CentOS 6.3 with MPICH2 with CUDA 5.0. But I was not able run CUDA with MPI using OpenMPI 1.6.3.

Is this the same for cudaOpenMP? It compiles fine using make on command line, but I cannot get it to work on Nsight. I’ve tried passing -Xcompiler -fopenmp in the Nsight, but it returns an error:

gcc: error: –fopenmp: No such file or directory

which is pretty strange.

Can you paste here failing nvcc invocation command-line from the build console?

Hmm, I don’t know why but a firewall is stopping me from posting the build reports here…

OK, I’ll attach the build results as an image…

This is Nsight bug, I will file a report to internal bugtracker. Let me see if I can find a solution.

Actually, I cannot confirm this one:

make all 
Building file: ../src/
Invoking: NVCC Compiler
nvcc -I"/usr/local/cuda-5.5/samples/0_Simple" -I"/usr/local/cuda-5.5/samples/common/inc" -I"/home/eostroukhov/cuda-workspace/matrixMul" -G -g -O0 -m64 -Xcompiler -fopenmp -gencode arch=compute_20,code=sm_20 -odir "src" -M -o "src/main.d" "../src/"
nvcc --compile -G -I"/usr/local/cuda-5.5/samples/0_Simple" -I"/usr/local/cuda-5.5/samples/common/inc" -I"/home/eostroukhov/cuda-workspace/matrixMul" -O0 -Xcompiler -fopenmp -g -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 -m64  -x cu -o  "src/main.o" "../src/"
Finished building: ../src/
Building target: matrixMul
Invoking: NVCC Linker
nvcc -m64 -Xlinker -rpath-link -L/homes/knoppik/tools/install/boost/lib -Xlinker -rpath-link -L/homes/knoppik/tools/install/jdk1.7.0_09/jre/lib/amd64/server -L/homes/knoppik/tools/install/rose/lib -link -o  "matrixMul"  ./src/main.o   
Finished building target: matrixMul

One theory I have is that you have several versions of GCC installed on your system, with Nsight having one without OpenMP support on its path.

I actually just solved the problem. Not only the preprocessor needs the option -fopenmp, but also the linker needs -lgomp too.

Here’s the full procedure:

  1. load the project into eclipse.
  2. Right click on it in the project explorer and click on properties.
  3. In the tool settings click on build stages first, and under preprocessor options press on the add icon. Type “-fopenmp” there.
  4. Now click on the Miscellaneous under the NVCC linker. in the other options window, press the add icon and type “-lgomp”.
  5. On the same window, make sure the shared option is selected. it’s not by default.
  6. Build the project successfully.

Hope this helps other people.

Hi, I am using Red Hat Enterprise 6.3, CUDA 5.0 and openMPI 1.6.4 and I can compile the simpleMPI sample just fine using the provided makefile. I am looking for a way to compile and run it completely through eclipse, I hoped that this thread would help me but the indication here were not enough.

For one, “Nsight, Eclipse Edition User Guide” does not seem to exist or I just can’t find it, there is only “Nsight_Eclipse_Edition_Getting_Started” which has very little to say about makefiles. Searching eclipse’s features I found under the project properties some build options, like having pre-build and post-build custom commands, getting different compilers yet I do not know how to have mpicc (or otherwise) there, nor how to call it. Also, how would the compiled version run, doesn’t it need mpirun?

Can anyone help me get this to work? I have little experience in Linux so any help will be appreciated.

Thanks for the short tutorial! :)

It works for me without the “Shared (-shared)” option ticked but the linking fails when I check it:

/usr/bin/ld: ./src/X.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
./src/X.o: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [libProblemSet3] Error 1

I think maybe I have found a quite stupid way to solve this problem. I write it here as simple as possible, hope it will help.
Take the cuda example “simpleMPI” as example (containing files: simpleMPI.cpp and simpleMPI.h).
Firstly, I need to modify one file’s name (change “simpleMPI.cpp” to “simple.cpp” or anything else).
Secondly, right click the projection name to change the “Properties”.

  1. In “Build”=>“Tool Chain Editor”, change “Current toolchain” from “CUDA Toolkit 5.0” to “Linux GCC”
  2. In “Build”=>“Tool Chain Editor”, click"Select Tool" to add “NVCC Compiler”
  3. In “Build”=>“Settings”=>“Tool Settings”=>“NVCC Compiler”=>“Includes”, add three paths:
    The first two paths may be different because of the location of CUDA Samples.
  4. In “Build”=>“Settings”=>“Tool Settings”=>“GCC C++ Linker”=>“Libraries”, add two lib:
    and a path:
    Fianlly, we can compile this project. To run this project, cd “./Debug” and run “mpirun -np 4 ***” may work.

sorry, cufft is not necessary