Interfaces

CULA is available in a variety of different interfaces to integrate directly into your existing code.  Programmers can easily call GPU-acclerated CULA from their C/C++, FORTRAN, MATLAB, or Python codes.  This can all be done with no GPU programming experience. Simply replace your existing function calls with CULA function calls to start accelerating your codes today.  CULA takes care of all GPU memory management for you, but for the more experienced GPU programmer we also have a "device" interface to work with GPU memory directly.

C/C++ Interfaces

CULA provides two interfaces to be used in C or C++ applications: the host interface and the device interface. These two interfaces differ in the location of the input and output memory.  The normal (host) interface requires the memory pointers to be located on the CPU.  As this interface is designed to be used by developers with little-to-no GPU experience, CULA will then take care of all memory transfers to and from the GPU.   This interface will also attempt to maximize memory throughput by padding your allocations to carefully chosen sizes based on your hardware generation.  In the device interface, all memory pointers are assumed to point to GPU memory.  This interface should only be used by those familiar with CUDA programming.

#include <culapack.h>

int main()
{
    culaStatus status;

    // A and TAU are pointers to host memory
    status = culaSgeqrf(M, N, A, LDA, TAU);

    return 0;
}

Link Interface

The link interface is targeted at users who are porting existing C/C++ & FORTRAN based linear algebra codes to a GPU-accelerated environment. This interface provides a migration path by matching the function names and signatures of several popular linear algebra packages. It additionally provides a fallback to CPU execution when a user does not have a GPU or when problem size is too small to take advantage of GPU execution. For more information on this interface, see the 'link_interface.txt' document in the 'doc' directory of the CULA SDK.

FORTRAN Interface

CULA has an additional interface intended to be used in FORTRAN programs. This interface follows the conventions of FORTRAN programming by taking all parameters by reference rather than by value. For more information on this interface, see the 'fortran_interface.txt' document in the 'doc' directory of the CULA SDK.

REAL A(M, N)
REAL TAU(K)
INTEGER M, N, LDA, STATUS
STATUS = CULA_SGEQRF(M, N, A, LDA, TAU)

MATLAB

CULA can easily be utilized by the MATALAB MEX compiler to integrate our libraries directly into your MATLAB programs. We provide source code and simple instructions on how to compile and integrate CULA directly into MATLAB.  Please see our CULA developer's blog series on MATLAB for more information.

A = rand(N);
[q,r] = culaqr(A);

Python

Using the Python ctypes library, Python users can easily integrate CULA into their Python code. This library provides C compatible data types, and allows calling functions in DLLs or shared libraries. It can be used to wrap these libraries in pure Python. Future releases of CULA will provide direct Python support including the ability to use the built in Python matrix and vector types. Please see the Python documentation on ctypes for more information.

import ctypes

libculaC=ctypes.CDLL("libcula.so")
libculaC.culaGetStatusString.restype=ctypes.c_char_p

info=libculaC.culaInitialize()

Atype = ctypes.c_float*(N*N)
A = Atype()
TAUtype = ctypes.c_float*N
TAU = TAUtype()

info = libculaC.culaSsyev(ctypes.c_int(M),ctypes.c_int(N),
    A,ctypes.c_int(N),TAU)

libculaC.culaShutdown()