0

While I've been writing CUDA kernels for a while now, I've not used dynamic parallelism (DP) yet. I've come up against a task for which I think it might fit; however, the way I would like to be able to use DP is:

If block figures out it needs more threads to complete its work, it spawns them; it imparts to its spawned threads "what it knows" - essentially, the contents of its shared memory, which each block of spawned threads get a copy of in its own shared memory ; the threads use what their parent thread "knew" to figure out what they need to continue doing, and do it.

AFAICT, though, this "inheritance" of shared memory does not happen. Is global memory (and constant memory via kernel arguments) the only way the "parent" DP kernel block can impart information to its "child" blocks?

einpoklum
  • 118,144
  • 57
  • 340
  • 684

1 Answers1

3

There is no mechanism of the type you are envisaging. A parent thread cannot share either its local memory or its block's shared memory with a child kernel launched via dynamic parallelism. The only options are to use global or dynamically allocated heap memory when it is necessary for a parent thread to pass transient data to a child kernel.

talonmies
  • 70,661
  • 34
  • 192
  • 269
  • I have to wonder - why do you mark all(?) your answers as "community wiki"? – einpoklum Feb 16 '17 at 10:48
  • Because (a) I have so many answers that I can't realistically curate all of them and marking them as community wiki invites anyone to participate in keep answers correct and up to date, and (b) I already have enough rep to have all the privileges available on the site, so there is really no compelling reason to need to earn more – talonmies Feb 16 '17 at 10:52
  • Hmm. (a) You can edit anyone's posts anyway; do you want to target low-reputation editing without review? And does that kind of editing happen? (b) I understand you don't need more rep points, but why make your answers "stand out" as community wiki answers in order to not get points? Or rather, why do anything to avoid getting points? It's not like they're detrimental; you can just forget about them. – einpoklum Feb 16 '17 at 13:01
  • 1
    @einpoklum: You asked a question which is frankly none of your business, and I indulged you by answering it. If you think I am going to have a debate with you in comments about the merits of how I choose to use [SO], then you are sorely mistaken. I would appreciate it if you keep your opinions to yourself. – talonmies Feb 17 '17 at 12:06