Best Way to Represent a Tree

Hello…

Need some advice from a voice of experience:

What is the best way to represent a binary (unbalanced) tree within kernel code which handles the following features:

-traversal
-pruning/grafting
etc.

I’m basically looking for a versatile solution to represent a tree.

I’ve already attempted two methods:

Linked List with simulated recursion using user defined stack to facilitate traversal… something tells me that memory access aren’t aligned since they appear random. Threads are heavy due to stacks stored in shared memory…small block sizes and low occupancy

Array - code was verbose, clumsy and something far from an elegant solution.

Out of interest how have people implemented kd-trees for ray tracing?

Yes I have. I generate the kd-tree on CPU, then move it to GPU and use it there.