Skip to content
CUDA Finite Difference Library
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

cuSten - CUDA Finite Difference Library

** Welcome to cuSten ** cuSten is a CUDA library under development by Andrew Gloster at University College Dublin. The idea behind the library is to simplify the development of code where we wish to apply stencil operations, for example a finite difference stencil, to a block of data in parallel. The user of this library simply has to provide basic details such as the stencil weights and stencil size to the library and then cuSten will handle the rest. Including calling the kernel with the correct block/thread structure, assign local memory and loading the data on/off the device asynchronously.

Getting started

Examples of how to use the library are found in examples/src. See section below for how to compile.

The naming convention is as follows

dimension = dimension of the data 2d or 3d (3d under developent) direction = List of directions in which the stencil will be applied, for example an x direction in 2D will apply the stencil in only the x direction periodicity = Apply the stencil periodically to the data or not, p for periodic, np for non-periodic

The extra 'fun' seen on some files are examples of how the user can use a function pointer to implement a broader range of operations on their data, such as raising to a power, source terms etc.


Use the Makefile in the cuSten/ directory followed by the examples/ directory. In order to use the library in your own code simply include the cuSten.h header and link to the static library stored in cuSten/lib. The compiled examples are found in /examples/bin after compiling.

In addition to this a sample Cahn-Hilliard solver can be compiled by running the Makefile in cuPentCahnADI. This requires the HDF5 library to be installed and linked to the correct path in the Makefile. Several python scripts are also included to analyise the output.

The Makefiles used in this project assume the CUDA compiler nvcc is installed and the parameter --gpu-architecture=sm_61 is set, this may need to be changed appropiately for other generations of NVIDIA GPUs, this is user dependant so we reccomend checking the correct setting of this parameter for your system.


Run the command make doc in the cuSten directory.

Where is cuSten used

cuSten is currently used in the following academic papers:

You can’t perform that action at this time.