0

I'm attempting different techniques for constructing a kd-tree on a GPU. I'm currently working on using dynamic parallelism to instruct the gpu to calculate an entire level of the kd-tree at the same time (or rather streaming every position in a given level at the same time).

As the values to be placed in the struct are neither calculated nor provided by the host, is there a way to declare the format of a struct on the GPU and then just define an array of that struct type from the kernel which uses it?

7
  • Are you sure your of the use of declare in this question? Are you trying to ask "Is there a way to declare the format of a struct on the GPU and then define an array of that struct type from the kernel which uses it?" ? Commented Apr 25, 2015 at 9:52
  • I edited the second instance of the word "declare" to "define" as you suggested. I'm more interested in making the format of a struct available on the GPU then concerned about creating an array of that struct once its there. Commented Apr 25, 2015 at 10:25
  • The very short answer is that CUDA supports structures (and classes) in GPU code. Is that really all you are trying to ask? Commented Apr 25, 2015 at 10:27
  • I was wondering about the syntax of declaring a struct on the GPU. I've passed plenty of arrays from host to device, I've also seen some examples where people seem to create an array of structs and then pass that array to the device. I'm wondering how I would create an empty array of type struct on the GPU without involving the host. I believe one can place an array on the GPU in global memory by saying device int arrayA[2048]; - if I wanted to make that an array of structures, how would I make the structure known to the GPU so I could say device structType arrayB[2048]; ? Commented Apr 25, 2015 at 11:07
  • 1
    There is no syntactical difference between declaring a structure in device code and declaring a structure in host code. I am still struggling to understand what your question is beyond the patently obvious. Commented Apr 25, 2015 at 16:05

1 Answer 1

2

Just restating what Talonmies noted in the comments.

There is no syntactical difference between declaring a structure in device code and declaring a structure in host code.

A far more trivial solution then I had hoped for.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.