Restricting a function to run only in a specific device (CPU/GPU)#

Assuming you already have a connection to the HeavyDB server:

from test_devices of rbc/tests/heavydb/test_howtos.py#
1@heavydb('int32(int32, int32)', devices=['CPU', 'GPU'])
2def add(a, b):
3    return a + b

By default, both devices are used if available. Otherwise, only the CPU is used.

Example SQL Query
from test_devices of rbc/tests/heavydb/test_howtos.py#
1_, result = heavydb.sql_execute('SELECT add(-3, 3);')
2assert list(result) == [(0,)]