2d array and recursive functions in cuda

I need help how to use the following things

  1. How 2d array dynamically allocating in CUDA
    2)if this 2d array is an element of structure and how to use it
  2. how implement functions equivalent to recursive functions
    I request to one and all to reply for the same with suitable examples
  1. Don’t use 2D arrays unless you really have to. Flatten them as 1D: http://stackoverflow.com/questions/5631115/2d-array-on-cuda

  2. This also is not ideal: http://stackoverflow.com/questions/6564016/how-to-perform-deep-copying-of-struct-with-cuda

  3. You can do recursion via C++ templates like so: http://users.softlab.ntua.gr/~ttsiod/cudarenderer-BVH.html
    or via dynamic parallelism (requires Compute Capability 3.5+ device: