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