Introduction#
This section contains general instructions for calling AOCL-DA using the Python APIs.
Installation#
Your AOCL-DA package comes bundled with a Python wheel, aoclda-*.whl, where * depends on your particular system.
To install the AOCL-DA Python API simply use the command pip install aoclda-*.whl. This will install the necessary libraries and dependencies.
Note
Python support on Windows is currently experimental. A Fortran runtime library libifcore-mt.lib is required, so you will need to install the Intel Fortran compiler and set the environment variable FORTRAN_RUNTIME to point to the directory containing the corresponding DLL.
You may also need to install an OpenMP runtime and add it to your Windows environment. If you encounter issues using the Python wheel on Windows, please e-mail us on
toolchainsupport@amd.com.
NumPy arrays#
AOCL-DA Python interfaces typically expect data to be supplied as NumPy arrays. These can be supplied either with order='C' or order='F' for row- or column-major ordering respectively.
The AOCL-DA interface will convert C-style NumPy arrays to Fortran style, so for best performance, it is recommended to use order='F' when supplying NumPy arrays to AOCL-DA functions.
Python examples#
The AOCL-DA Python API comes with numerous example scripts, which are installed when you invoke pip install aoclda-*.whl.
To locate these examples, the following commands can be used in your Python interpreter:
>>> from aoclda.examples import info
>>> info.examples_path()
>>> info.examples_list()
Alternatively, from your command prompt, you can call aocl.examples.info as a module to obtain the same information:
python -m aoclda.examples.info
The examples can then be run as standard Python scripts from the command prompt. For example:
python path/to/examples/pca_ex.py
You can also inspect and run the examples from a Python interpreter. For example:
>>> from aoclda.examples import pca_ex
>>> import inspect
>>> print(''.join(inspect.getsourcelines(pca_ex)[0]))
>>> pca_ex.test_pca()