.. _ogn_tutorial_cpu_gpu_extended:

Tutorial 23 - Extended Attributes On The GPU
============================================

Extended attributes are no different from other types of attributes with respect to where their memory will be located.
The difference is that there is a slightly different API for accessing their data, illustrating by these examples.

This node also illustrates the new concept of having a node create an ABI function override that handles the runtime
type resolution of extended attribute types. In this case when any of the two input attributes or one output attribute
become resolved then the other two attributes are resolved to the same type, if possible.

OgnTutorialCpuGpuExtended.ogn
-----------------------------
The *ogn* file shows the implementation of a node named "omni.graph.tutorials.CpuGpuExtended" with an input **'any'**
attribute on the CPU, an input **'any'** attribute on the GPU, and an output whose memory location is decided at runtime
by a boolean.

.. literalinclude:: ../../../../../source/extensions/omni.graph.tutorials/tutorials/tutorial23/OgnTutorialCpuGpuExtended.ogn
    :linenos:
    :language: json

OgnTutorialCpuGpuExtended.cpp
-----------------------------
The *cpp* file contains the implementation of the compute method. It sums two inputs on either the
CPU or GPU based on the input boolean. For simplicity only the **float[3][]** attribute type is processed, with
all others resulting in a compute failure.

.. literalinclude:: ../../../../../source/extensions/omni.graph.tutorials/tutorials/tutorial23/OgnTutorialCpuGpuExtended.cpp
    :linenos:
    :language: c++

OgnTutorialCpuGpuExtendedPy.py
------------------------------
The *py* file contains the same algorithm as the C++ node, with the node implementation language being different.

.. literalinclude:: ../../../../../source/extensions/omni.graph.tutorials/tutorials/tutorial23/OgnTutorialCpuGpuExtendedPy.py
    :linenos:
    :language: python
