.. _ogn_tutorial_cudaDataOnCpu:


Tutorial 27 - GPU Data Node with CPU Array Pointers
===================================================

The GPU data node illustrates the alternative method of extracting array data from the GPU by returning a CPU pointer
to the GPU array. Normally the data returns a GPU pointer to an array of GPU pointers, optimized for future use in
parallel processing of GPU array data. By returning a CPU pointer to the array you can use host-side processing to
dereference the pointers.

OgnTutorialCudaDataCpu.ogn
--------------------------
The *ogn* file shows the implementation of a node named "omni.graph.tutorials.CudaCpuArrays", which has an input and
an output of type `float[3][]`, along with the special keyword to indicate that the pointer to the CUDA arrays should
be in CPU space.

.. literalinclude:: OgnTutorialCudaDataCpu.ogn
    :linenos:
    :language: json
    :emphasize-lines: 5

OgnTutorialCudaDataCpu.cpp
--------------------------
The *cpp* file contains the implementation of the compute method, which in turn calls the CUDA algorithm.

.. literalinclude:: OgnTutorialCudaDataCpu.cpp
    :linenos:
    :language: c++
    :emphasize-lines: 31-35

OgnTutorialCudaDataCpu_CUDA.cu
------------------------------
The *cu* file contains the implementation of the algorithm on the GPU using CUDA.

.. literalinclude:: OgnTutorialCudaDataCpu_CUDA.cu
    :linenos:
    :language: c++

OgnTutorialCudaDataCpuPy.py
---------------------------
The *py* file contains the implementation of the compute method, which for this example doesn't actually compute as
extra extension support is required for Python to run on the GPU (e.g. a Python -> CUDA compiler).

.. literalinclude:: OgnTutorialCudaDataCpuPy.py
    :linenos:
    :language: python
    :emphasize-lines: 31-35
