1

I'm trying to compile a dynamic parallelism example on CUDA and when i try to compile it gives and error saying,

kernel launch from __device__ or __global__ functions requires separate compilation modes

Later found that I have to set the --relocatable-device-code flag to true. But, is there a flag to set in order to make the set relocatable-device-code to true in Nsight Eclipse?

BAdhi
  • 420
  • 7
  • 19
  • 1
    The defined way to enable this capability for an Nsight EE project is to do so at project creation time. After selecting File...New...CUDA C/C++ Project, you will be presented with the project creation wizard/dialog. Enter a project name and click "Next". You will then be taken to the "Basic settings" dialog page. Here you will see an option "Device linker mode:" and the choices will be "Whole program compilation" (default) or "Separate compilation". If you select "Separate compilation", then your project will be set up for relocatable device code generation. – Robert Crovella Jul 08 '16 at 10:42
  • 3
    After a project is created, you can also make this change by going to Project...Properties...Build...Settings. Here you will see a page similar to the one mentioned above in the "Basic settings" dialog page. You can similarly change "Device linker mode:" on this page from "Whole program compilation" to "Separate compilation" in order to turn on generation of relocatable device code, after the project has already been created. – Robert Crovella Jul 08 '16 at 10:47
  • What @robertcrovella said – interestedparty333 Mar 26 '18 at 22:05

3 Answers3

1

If you are not using makefile project, you could change the options passed to nvcc of a Nsight project at the following position, starting from the menu.

Project - Properties - Build - Settings - Tool Settings - NVCC Compiler

As Nsight does not provide a rdc option for you to check, you could directly change 'Commnad' from

nvcc

to

nvcc -rdc=true

or change 'Command line pattern' from

${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX} ${OUTPUT} ${INPUTS}

to

${COMMAND} ${FLAGS} -rdc=true ${OUTPUT_FLAG} ${OUTPUT_PREFIX} ${OUTPUT} ${INPUTS}

The second one is better.

You may also want to change this for 'All configurations' rather than 'Debug' or 'Release' only.

EDIT

You should follow @RobertCrovella's instructions in the comment. It is the official way.

kangshiyin
  • 9,681
  • 1
  • 17
  • 29
0

After a project is created, you can also make this change by going to Project...Properties...Build...Settings. Here you will see a page similar to the one mentioned above in the "Basic settings" dialog page. You can similarly change "Device linker mode:" on this page from "Whole program compilation" to "Separate compilation" in order to turn on generation of relocatable device code, after the project has already been created.

Credit goes to @robertcrovella. This was actually the answer I was looking for, so I've made it a separate answer.

interestedparty333
  • 2,386
  • 1
  • 21
  • 35
-2

you can use nvcc option "-dc" or "-rdc=true", you can ref this as as sample.

nvlink, relocatable device code and static device libraries

Community
  • 1
  • 1
harryz
  • 42
  • 1
  • 1
    This doesn't answer the question. The OP clearly knows which options are required to generate relocatable device code, and has written so in the question. The question is how to specify them **from within Nsight Eclipse**. How does this answer that? – talonmies Jul 08 '16 at 07:54