xref: /libCEED/README.md (revision 2e1816997a731fdd930255fd456f4b713cd656df)
1# libCEED: the CEED API Library
2
3[![Build Status](https://travis-ci.org/CEED/libCEED.svg?branch=master)](https://travis-ci.org/CEED/libCEED)
4[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause)
5[![Doxygen](https://codedocs.xyz/CEED/libCEED.svg)](https://codedocs.xyz/CEED/libCEED/)
6
7## Code for Efficient Extensible Discretization
8
9This repository contains an initial low-level API library for the efficient
10high-order discretization methods developed by the ECP co-design [Center for
11Efficient Exascale Discretizations (CEED)](http://ceed.exascaleproject.org).
12While our focus is on high-order finite elements, the approach is mostly
13algebraic and thus applicable to other discretizations in factored form, see the
14[API documentation](doc/libCEED.md).
15
16One of the challenges with high-order methods is that a global sparse matrix is
17no longer a good representation of a high-order linear operator, both with
18respect to the FLOPs needed for its evaluation, as well as the memory transfer
19needed for a matvec.  Thus, high-order methods require a new "format" that still
20represents a linear (or more generally non-linear) operator, but not through a
21sparse matrix.
22
23The goal of libCEED is to propose such a format, as well as supporting
24implementations and data structures, that enable efficient operator evaluation
25on a variety of computational device types (CPUs, GPUs, etc.). This new operator
26description is based on algebraically [factored form](doc/libCEED.md), which is
27easy to incorporate in a wide variety of applications, without significant
28refactoring of their own discretization infrastructure.
29
30The repository is part of the [CEED software suite][ceed-soft], a collection of
31software benchmarks, miniapps, libraries and APIs for efficient exascale
32discretizations based on high-order finite element and spectral element methods.
33See http://github.com/ceed for more information and source code availability.
34
35The CEED research is supported by the [Exascale Computing Project][ecp]
36(17-SC-20-SC), a collaborative effort of two U.S. Department of Energy
37organizations (Office of Science and the National Nuclear Security
38Administration) responsible for the planning and preparation of a [capable
39exascale ecosystem](https://exascaleproject.org/what-is-exascale), including
40software, applications, hardware, advanced system engineering and early testbed
41platforms, in support of the nation’s exascale computing imperative.
42
43For more details on the CEED API see http://ceed.exascaleproject.org/ceed-code/.
44
45## Building
46
47The CEED library, `libceed`, is a C99 library with no external dependencies.  It
48can be built using
49
50    make
51
52or, with optimization flags
53
54    make OPT='-O3 -march=skylake-avx512 -ffp-contract=fast'
55
56These optimization flags are used by all languages (C, C++, Fortran) and this
57makefile variable can also be set for testing and examples (below).
58
59## Testing
60
61The test suite produces [TAP](https://testanything.org) output and is run by:
62
63    make test
64
65or, using the `prove` tool distributed with Perl (recommended)
66
67    make prove
68
69## Examples
70
71libCEED comes with several examples of its usage, ranging from standalone C
72codes in the `/examples/ceed` directory to examples based on external packages,
73such as MFEM, PETSc and Nek5000.
74
75To build the examples, set the `MFEM_DIR`, `PETSC_DIR` and `NEK5K_DIR` variables
76and run:
77
78```console
79# libCEED examples on CPU and GPU
80cd examples/ceed
81make
82./ex1 -ceed /cpu/self
83./ex1 -ceed /gpu/occa
84cd ../..
85
86# MFEM+libCEED examples on CPU and GPU
87cd examples/mfem
88make
89./bp1 -ceed /cpu/self -no-vis
90./bp1 -ceed /gpu/occa -no-vis
91cd ../..
92
93# PETSc+libCEED examples on CPU and GPU
94cd examples/petsc
95make
96./bp1 -ceed /cpu/self
97./bp1 -ceed /gpu/occa
98cd ../..
99
100# Nek+libCEED examples on CPU and GPU
101cd examples/nek5000
102./make-nek-examples.sh
103./run-nek-example.sh -ceed /cpu/self -b 3
104./run-nek-example.sh -ceed /gpu/occa -b 3
105cd ../..
106```
107
108The above code assumes a GPU-capable machine enabled in the OCCA
109backend. Depending on the available backends, other Ceed resource specifiers can
110be provided with the `-ceed` option, for example:
111
112CEED resource (`-ceed`) | Backend
113----------------------- | ---------------------------------
114`/cpu/self/opt`         | Serial optimized implementation
115`/cpu/self/ref`         | Serial reference implementation
116`/cpu/self/tmpl`        | Backend template, dispatches to /cpu/self/opt
117`/cpu/occa`             | Serial OCCA kernels
118`/gpu/occa`             | CUDA OCCA kernels
119`/omp/occa`             | OpenMP OCCA kernels
120`/ocl/occa`             | OpenCL OCCA kernels
121`/gpu/magma`            | CUDA MAGMA kernels
122
123## Install
124
125To install libCEED, run
126
127    make install prefix=/usr/local
128
129or (e.g., if creating packages),
130
131    make install prefix=/usr DESTDIR=/packaging/path
132
133Note that along with the library, libCEED installs kernel sources, e.g. OCCA
134kernels are installed in `$prefix/lib/okl`. This allows the OCCA backend to
135build specialized kernels at run-time. In a normal setting, the kernel sources
136will be found automatically (relative to the library file `libceed.so`).
137However, if that fails (e.g. if `libceed.so` is moved), one can copy (cache) the
138kernel sources inside the user OCCA directory, `~/.occa` using
139
140    $(OCCA_DIR)/bin/occa cache ceed $(CEED_DIR)/lib/okl/*.okl
141
142This will allow OCCA to find the sources regardless of the location of the CEED
143library. One may occasionally need to clear the OCCA cache, which can be accomplished
144by removing the `~/.occa` directory or by calling `$(OCCA_DIR)/bin/occa clear -a`.
145
146### pkg-config
147
148In addition to library and header, libCEED provides a [pkg-config][pkg-config1]
149file that can be used to easily compile and link. [For example][pkg-config2], if
150`$prefix` is a standard location or you set the environment variable
151`PKG_CONFIG_PATH`,
152
153    cc `pkg-config --cflags --libs ceed` -o myapp myapp.c
154
155will build `myapp` with libCEED.  This can be used with the source or
156installed directories.  Most build systems have support for pkg-config.
157
158## Contact
159
160You can reach the libCEED team by emailing [ceed-users@llnl.gov](mailto:ceed-users@llnl.gov)
161or by leaving a comment in the [issue tracker](https://github.com/CEED/libCEED/issues).
162
163## Copyright
164
165The following copyright applies to each file in the CEED software suite, unless
166otherwise stated in the file:
167
168> Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at the
169> Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights reserved.
170
171See files LICENSE and NOTICE for details.
172
173[ceed-soft]:   http://ceed.exascaleproject.org/software/
174[ecp]:         https://exascaleproject.org/exascale-computing-project
175[pkg-config1]: https://en.wikipedia.org/wiki/Pkg-config
176[pkg-config2]: https://people.freedesktop.org/~dbn/pkg-config-guide.html#faq
177