xref: /libCEED/README.md (revision 2a8473592283e03ded13afe54b22c2648d2eb0c8)
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.
48It can be built using
49
50    make
51
52## Testing
53
54The test suite produces [TAP](https://testanything.org) output and is run by:
55
56    make test
57
58or, using the `prove` tool distributed with Perl (recommended)
59
60    make prove
61
62## Examples
63
64libCEED comes with several examples of its usage, ranging from standalone C
65codes in the `/examples/ceed` directory to examples based on external packages,
66such as MFEM, PETSc and Nek5000.
67
68To build the examples, set the `MFEM_DIR`, `PETSC_DIR` and `NEK5K_DIR` variables
69and run:
70
71```console
72# libCEED examples on CPU and GPU
73cd examples/ceed
74make
75./ex1 -ceed /cpu/self
76./ex1 -ceed /gpu/occa
77cd ../..
78
79# MFEM+libCEED examples on CPU and GPU
80cd examples/mfem
81make
82./bp1 -ceed /cpu/self -no-vis
83./bp1 -ceed /gpu/occa -no-vis
84cd ../..
85
86# PETSc+libCEED examples on CPU and GPU
87cd examples/petsc
88make
89./bp1 -ceed /cpu/self
90./bp1 -ceed /gpu/occa
91cd ../..
92
93# Nek+libCEED examples on CPU and GPU
94cd examples/nek5000
95./generate-boxes.sh 2 4
96./make-nek-examples.sh
97./run-nek-example.sh -ceed /cpu/self -b b3
98./run-nek-example.sh -ceed /gpu/occa -b b3
99cd ../..
100```
101
102The above code assumes a GPU-capable machine enabled in the OCCA
103backend. Depending on the availabl backends, other Ceed resource specifiers can
104be provided with the `-ceed` option, for example:
105
106CEED resource (`-ceed`) | Backend
107----------------------- | ---------------------------------
108`/cpu/self`             | Serial reference implementation
109`/cpu/occa`             | Serial OCCA kernels
110`/gpu/occa`             | CUDA OCCA kernels
111`/omp/occa`             | OpenMP OCCA kernels
112`/ocl/occa`             | OpenCL OCCA kernels
113`/gpu/magma`            | CUDA MAGMA kernels
114
115## Install
116
117To install libCEED, run
118
119    make install prefix=/usr/local
120
121or (e.g., if creating packages),
122
123    make install prefix=/usr DESTDIR=/packaging/path
124
125Note that along with the library, libCEED installs kernel sources, e.g. OCCA
126kernels are installed in `$prefix/lib/okl`. This allows the OCCA backend to
127build specialized kernels at run-time. In a normal setting, the kernel sources
128will be found automatically (relative to the library file `libceed.so`).
129However, if that fails (e.g. if `libceed.so` is moved), one can copy (cache) the
130kernel sources inside the user OCCA directory, `~/.occa` using
131
132    $(OCCA_DIR)/bin/occa cache ceed $(CEED_DIR)/lib/okl/*.okl
133
134This will allow OCCA to find the sources regardless of the location of the CEED
135library. One may occasionally need to clear the OCCA cache, which can be accomplished
136by removing the `~/.occa` directory or by calling `$(OCCA_DIR)/bin/occa clear -a`.
137
138### pkg-config
139
140In addition to library and header, libCEED provides a [pkg-config][pkg-config1]
141file that can be used to easily compile and link. [For example][pkg-config2], if
142`$prefix` is a standard location or you set the environment variable
143`PKG_CONFIG_PATH`,
144
145    cc `pkg-config --cflags --libs ceed` -o myapp myapp.c
146
147will build `myapp` with libCEED.  This can be used with the source or
148installed directories.  Most build systems have support for pkg-config.
149
150## Contact
151
152You can reach the libCEED team by emailing [ceed-users@llnl.gov](mailto:ceed-users@llnl.gov)
153or by leaving a comment in the [issue tracker](https://github.com/CEED/libCEED/issues).
154
155## Copyright
156
157The following copyright applies to each file in the CEED software suite, unless
158otherwise stated in the file:
159
160> Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at the
161> Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights reserved.
162
163See files LICENSE and NOTICE for details.
164
165[ceed-soft]:   http://ceed.exascaleproject.org/software/
166[ecp]:         https://exascaleproject.org/exascale-computing-project
167[pkg-config1]: https://en.wikipedia.org/wiki/Pkg-config
168[pkg-config2]: https://people.freedesktop.org/~dbn/pkg-config-guide.html#faq
169