Getting Started


The CEED library, libceed, is a C99 library with no required dependencies, and with Fortran and Python interfaces. It can be built using:


or, with optimization flags:

make OPT='-O3 -march=skylake-avx512 -ffp-contract=fast'

These optimization flags are used by all languages (C, C++, Fortran) and this makefile variable can also be set for testing and examples (below). Python users can install using:

pip install libceed

or in a clone of the repository via pip install ..

The library attempts to automatically detect support for the AVX instruction set using gcc-style compiler options for the host. Support may need to be manually specified via:

make AVX=1


make AVX=0

if your compiler does not support gcc-style options, if you are cross compiling, etc.


The test suite produces TAP output and is run by:

make test

or, using the prove tool distributed with Perl (recommended):

make prove


There are multiple supported backends, which can be selected at runtime in the examples:

CEED resource


Deterministic Capable


Serial reference implementation



Blocked reference implementation



Memcheck backend, undefined value checks



Serial optimized C implementation



Blocked optimized C implementation



Serial AVX implementation



Blocked AVX implementation



Serial LIBXSMM implementation



Blocked LIBXSMM implementation



Selects backend based on available OCCA modes



Selects OCCA CPU backend



OCCA backend with serial CPU kernels



OCCA backend with OpenMP kernels



Selects OCCA GPU backend



OCCA backend with HIP kernels



OCCA backend with CUDA kernels



Reference pure CUDA kernels



Optimized pure CUDA kernels using shared memory



Optimized pure CUDA kernels using code generation



CUDA MAGMA kernels



CUDA MAGMA kernels



Reference pure HIP kernels


The /cpu/self/*/serial backends process one element at a time and are intended for meshes with a smaller number of high order elements. The /cpu/self/*/blocked backends process blocked batches of eight interlaced elements and are intended for meshes with higher numbers of elements.

The /cpu/self/ref/* backends are written in pure C and provide basic functionality.

The /cpu/self/opt/* backends are written in pure C and use partial e-vectors to improve performance.

The /cpu/self/avx/* backends rely upon AVX instructions to provide vectorized CPU performance.

The /cpu/self/xsmm/* backends rely upon the LIBXSMM package to provide vectorized CPU performance. If linking MKL and LIBXSMM is desired but the Makefile is not detecting MKLROOT, linking libCEED against MKL can be forced by setting the environment variable MKL=1.

The /cpu/self/memcheck/* backends rely upon the Valgrind Memcheck tool to help verify that user QFunctions have no undefined values. To use, run your code with Valgrind and the Memcheck backends, e.g. valgrind ./build/ex1 -ceed /cpu/self/ref/memcheck. A ‘development’ or ‘debugging’ version of Valgrind with headers is required to use this backend. This backend can be run in serial or blocked mode and defaults to running in the serial mode if /cpu/self/memcheck is selected at runtime.

The /*/occa backends rely upon the OCCA package to provide cross platform performance. To enable the OCCA backend, the environment variable OCCA_DIR must point to the top-level OCCA directory, with the OCCA library located in the ${OCCA_DIR}/lib (By default, OCCA_DIR is set to ../occa).

Additionally, users can pass specific OCCA device properties after setting the CEED resource. For example:

  • “/*/occa:mode=’CUDA’,device_id=0”

The /gpu/cuda/* backends provide GPU performance strictly using CUDA.

The /gpu/magma/* backends rely upon the MAGMA package. To enable the MAGMA backends, the environment variable MAGMA_DIR must point to the top-level MAGMA directory, with the MAGMA library located in $(MAGMA_DIR)/lib/. By default, MAGMA_DIR is set to ../magma; to build the MAGMA backend with a MAGMA installation located elsewhere, create a link to magma/ in libCEED’s parent directory, or set MAGMA_DIR to the proper location. MAGMA version 2.5.0 or newer is required.

The /gpu/hip/ref backend provides GPU performance strictly using HIP. It is based on the /gpu/cuda/ref backend. ROCm version 3.5 or newer is required.

Bit-for-bit reproducibility is important in some applications. However, some libCEED backends use non-deterministic operations, such as atomicAdd for increased performance. The backends which are capable of generating reproducible results, with the proper compilation options, are highlighted in the list above.


libCEED comes with several examples of its usage, ranging from standalone C codes in the /examples/ceed directory to examples based on external packages, such as MFEM, PETSc, and Nek5000. Nek5000 v18.0 or greater is required.

To build the examples, set the MFEM_DIR, PETSC_DIR, and NEK5K_DIR variables and run:

cd examples/
# libCEED examples on CPU and GPU
cd ceed/
./ex1-volume -ceed /cpu/self
./ex1-volume -ceed /gpu/occa
./ex2-surface -ceed /cpu/self
./ex2-surface -ceed /gpu/occa
cd ..

# MFEM+libCEED examples on CPU and GPU
cd mfem/
./bp1 -ceed /cpu/self -no-vis
./bp3 -ceed /gpu/occa -no-vis
cd ..

# Nek5000+libCEED examples on CPU and GPU
cd nek/
./ -e bp1 -ceed /cpu/self -b 3
./ -e bp3 -ceed /gpu/occa -b 3
cd ..

# PETSc+libCEED examples on CPU and GPU
cd petsc/
./bps -problem bp1 -ceed /cpu/self
./bps -problem bp2 -ceed /gpu/occa
./bps -problem bp3 -ceed /cpu/self
./bps -problem bp4 -ceed /gpu/occa
./bps -problem bp5 -ceed /cpu/self
./bps -problem bp6 -ceed /gpu/occa
cd ..

cd petsc/
./bpsraw -problem bp1 -ceed /cpu/self
./bpsraw -problem bp2 -ceed /gpu/occa
./bpsraw -problem bp3 -ceed /cpu/self
./bpsraw -problem bp4 -ceed /gpu/occa
./bpsraw -problem bp5 -ceed /cpu/self
./bpsraw -problem bp6 -ceed /gpu/occa
cd ..

cd petsc/
./bpssphere -problem bp1 -ceed /cpu/self
./bpssphere -problem bp2 -ceed /gpu/occa
./bpssphere -problem bp3 -ceed /cpu/self
./bpssphere -problem bp4 -ceed /gpu/occa
./bpssphere -problem bp5 -ceed /cpu/self
./bpssphere -problem bp6 -ceed /gpu/occa
cd ..

cd petsc/
./area -problem cube -ceed /cpu/self -petscspace_degree 3
./area -problem cube -ceed /gpu/occa -petscspace_degree 3
./area -problem sphere -ceed /cpu/self -petscspace_degree 3 -dm_refine 2
./area -problem sphere -ceed /gpu/occa -petscspace_degree 3 -dm_refine 2

cd fluids/
./navierstokes -ceed /cpu/self -petscspace_degree 1
./navierstokes -ceed /gpu/occa -petscspace_degree 1
cd ..

cd solids/
./elasticity -ceed /cpu/self -mesh [.exo file] -degree 2 -E 1 -nu 0.3 -problem linElas -forcing mms
./elasticity -ceed /gpu/occa -mesh [.exo file] -degree 2 -E 1 -nu 0.3 -problem linElas -forcing mms
cd ..

For the last example shown, sample meshes to be used in place of [.exo file] can be found at

The above code assumes a GPU-capable machine with the OCCA backend enabled. Depending on the available backends, other CEED resource specifiers can be provided with the -ceed option. Other command line arguments can be found in the petsc folder.


A sequence of benchmarks for all enabled backends can be run using:

make benchmarks

The results from the benchmarks are stored inside the benchmarks/ directory and they can be viewed using the commands (requires python with matplotlib):

cd benchmarks
python petsc-bps-bp1-*-output.txt
python petsc-bps-bp3-*-output.txt

Using the benchmarks target runs a comprehensive set of benchmarks which may take some time to run. Subsets of the benchmarks can be run using the scripts in the benchmarks folder.

For more details about the benchmarks, see the benchmarks/ file.


To install libCEED, run:

make install prefix=/usr/local

or (e.g., if creating packages):

make install prefix=/usr DESTDIR=/packaging/path

To install libCEED for Python, run:

pip install libceed

with the desired setuptools options, such as –user.


In addition to library and header, libCEED provides a pkg-config file that can be used to easily compile and link. For example, if $prefix is a standard location or you set the environment variable PKG_CONFIG_PATH:

cc `pkg-config --cflags --libs ceed` -o myapp myapp.c

will build myapp with libCEED. This can be used with the source or installed directories. Most build systems have support for pkg-config.


You can reach the libCEED team by emailing or by leaving a comment in the issue tracker.

How to Cite

If you utilize libCEED please cite:

  title =  {lib{CEED} development site},
  url =    {},
  howpublished = {\url{}},
  year = 2020

For libCEED’s Python interface please cite:

  author    = {{V}aleria {B}arra and {J}ed {B}rown and {J}eremy {T}hompson and {Y}ohann {D}udouit},
  title     = {{H}igh-performance operator evaluations with ease of use: lib{C}{E}{E}{D}'s {P}ython interface},
  booktitle = {{P}roceedings of the 19th {P}ython in {S}cience {C}onference},
  pages     = {85 - 90},
  year      = {2020},
  editor    = {{M}eghann {A}garwal and {C}hris {C}alloway and {D}illon {N}iederhut and {D}avid {S}hupe},
  doi       = {10.25080/Majora-342d178e-00c},
  url       = {}

The BiBTeX entries for these references can be found in the doc/bib/references.bib file.