The program activity demonstrates how C/C++ or even CUDA codes can be used in Python scripts.
- The
_pointers.cppfile is loaded with the corresponding header file named_pointers.h. The header file is very much important here! Declaration asextern "C"is needed in order for the function to be read by the Python API. The compilation usingnvccis as follows:
C:> nvcc _pointers.cpp -shared -o <outputfile.dll>
- Run
main.pyto load function from the shared library. The function names can be checked by runningdumpbinfor Windows ornmfor Unix.