- udf_cublas_py_init.py: creates the schema & input table and loads test data
- udf_cublas_py_proc.py: the UDF itself
- udf_cublas_py_exec.py: creates & executes the UDF
All commands should be run as the
gpudb user.Set CUDA Path
Install Scikit-CUDA Package
gpudb-accessible
directory on the Kinetica head node, the example can be run as follows,
specifying the database URL, username, & password to the Python scripts:
Run Example
Execution Detail
The UDF will load data upon which calculations will be performed fromexample_udf_python.udf_cublas_in_table. Results of those calculations will
be logged to the system log.
The input table will contain three float columns and be populated with 10
sets of randomly-generated numbers. The output log will contain the results of
each operation, first in NumPy and then in cuBLAS, which should match.
udf_cublas_py_init.py
This initialization script creates the schema & input table and populates it using the standard Kinetica Python API outside of the UDF execution framework. Several aspects of the initialization process are noteworthy:-
The external database connection, indicative of the use of the standard
Kinetica Python API—the UDF itself will not have this, as it runs within
the database:
Connect to the Database
-
Schema and input table creation:
Create SchemaCreate Input Table
udf_cublas_py_proc.py
This is the UDF itself. It uses the Kinetica Python UDF API to perform various mathematical functions against the input table column values and output the results to the system log. It runs within the UDF execution framework, and as such, is not called directly—instead, it is registered and launched by udf_cublas_py_exec.py. Noteworthy in the UDF are the following:-
The initial call to
ProcData()to access the database:Begin UDF -
The retrieval of input data values:
Retrieve Input Data Values
-
The final call to
complete()to mark the process as finished and ready for clean-up:End UDF
udf_cublas_py_exec.py
The execution script uses the standard Kinetica Python API to register the UDF in the database and then execute it. The registration step associates a name with the UDF execution code contained in udf_cublas_py_proc.py, the command ( python ) and arguments (the name of the proc script) to use to run it, and that it will run in distributed mode.Create UDF
Execute UDF