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