Shared Versus Texture

Hey all,
I have this massive 3D array (say BB) which I break up into smaller sub-volumes(say A). On each of these A’s I do some computation and store it in another location (of same size as A -> basically these new sub-volumes (say B’s) will be joined up later to form another massive 3D array). My question is

(a) which place would you suggest that I store these A’s in - Shared or Texture [Considering two facts - (i) can’t store the full BB array in device memory, its huge! (ii) to generate the new B’s I require elements an element in A and its close neighbours, in all 3 dimensions]
(B) How do I bring back the B’s to host, indirectly saying where do I store these B’s? [Another side questions - Whats the difference between cudaArray and cudaPitchedPtr - How do I use cudaPitchedPtr to access elements in a kernel?]

Vandhan (on behalf of a friend)

First things first – I respect the friendship that has put a “_confused” suffix on your name. :yes:

Since you cannot bring in all “BB” and hence all "A"s together in device memory – you need to do multiple kernel launches to do what you want to do.

i.e. Imagine a set {A} that covers all the 3D A’s required to be processed. Now, divide them into “N” sub-sets such that each “2*Subset_size” can be comfortably stored in device memory.

Now, copy the input subset to device memory and then launch a kernel, copy out the B’s generated. Repeat this step again and again for all subsets.

Your 3D spacial requirement necessitates a 3D-texture. So, Bind your input A’s to a 3D texture. Now this also necessitates that your {subset-A} 3D arrays also be together in the original-input’s 3D space. Its like eating an ice-cream. Your consecutive bites of an ice-cream are always bordering each other in the original 3D-space of that ice cream. If you equate your each bite of the ice-cream to a 3D array in {A} and then assign 3 bites of your ice-cream to {A} then {A} would contain 3D arrays that were consecutive in the original 3D space of the ice-cream (unless you want to eat an ice-cream in a way that would inspire Douglas Adams to write another trilogy of 5 books)