xref: /libCEED/README.md (revision baf4261b649150f2054ea0899b3d4c67ad83d3aa)
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./make-nek-examples.sh
96./run-nek-example.sh -ceed /cpu/self -b 3
97./run-nek-example.sh -ceed /gpu/occa -b 3
98cd ../..
99```
100
101The above code assumes a GPU-capable machine enabled in the OCCA
102backend. Depending on the available backends, other Ceed resource specifiers can
103be provided with the `-ceed` option, for example:
104
105CEED resource (`-ceed`) | Backend
106----------------------- | ---------------------------------
107`/cpu/self/opt`         | Serial optimized implementation
108`/cpu/self/ref`         | Serial reference implementation
109`/cpu/self/tmpl`        | Backend template, dispatches to /cpu/self/opt
110`/cpu/occa`             | Serial OCCA kernels
111`/gpu/occa`             | CUDA OCCA kernels
112`/omp/occa`             | OpenMP OCCA kernels
113`/ocl/occa`             | OpenCL OCCA kernels
114`/gpu/magma`            | CUDA MAGMA kernels
115
116## Install
117
118To install libCEED, run
119
120    make install prefix=/usr/local
121
122or (e.g., if creating packages),
123
124    make install prefix=/usr DESTDIR=/packaging/path
125
126Note that along with the library, libCEED installs kernel sources, e.g. OCCA
127kernels are installed in `$prefix/lib/okl`. This allows the OCCA backend to
128build specialized kernels at run-time. In a normal setting, the kernel sources
129will be found automatically (relative to the library file `libceed.so`).
130However, if that fails (e.g. if `libceed.so` is moved), one can copy (cache) the
131kernel sources inside the user OCCA directory, `~/.occa` using
132
133    $(OCCA_DIR)/bin/occa cache ceed $(CEED_DIR)/lib/okl/*.okl
134
135This will allow OCCA to find the sources regardless of the location of the CEED
136library. One may occasionally need to clear the OCCA cache, which can be accomplished
137by removing the `~/.occa` directory or by calling `$(OCCA_DIR)/bin/occa clear -a`.
138
139### pkg-config
140
141In addition to library and header, libCEED provides a [pkg-config][pkg-config1]
142file that can be used to easily compile and link. [For example][pkg-config2], if
143`$prefix` is a standard location or you set the environment variable
144`PKG_CONFIG_PATH`,
145
146    cc `pkg-config --cflags --libs ceed` -o myapp myapp.c
147
148will build `myapp` with libCEED.  This can be used with the source or
149installed directories.  Most build systems have support for pkg-config.
150
151## Contact
152
153You can reach the libCEED team by emailing [ceed-users@llnl.gov](mailto:ceed-users@llnl.gov)
154or by leaving a comment in the [issue tracker](https://github.com/CEED/libCEED/issues).
155
156## Copyright
157
158The following copyright applies to each file in the CEED software suite, unless
159otherwise stated in the file:
160
161> Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at the
162> Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights reserved.
163
164See files LICENSE and NOTICE for details.
165
166[ceed-soft]:   http://ceed.exascaleproject.org/software/
167[ecp]:         https://exascaleproject.org/exascale-computing-project
168[pkg-config1]: https://en.wikipedia.org/wiki/Pkg-config
169[pkg-config2]: https://people.freedesktop.org/~dbn/pkg-config-guide.html#faq
170