1# libCEED: the CEED API Library 2 3[](https://travis-ci.org/CEED/libCEED) 4[](https://opensource.org/licenses/BSD-2-Clause) 5 6## Code for Efficient Extensible Discretization 7 8This repository contains an initial low-level API library for the efficient 9high-order discretization methods developed by the ECP co-design [Center for 10Efficient Exascale Discretizations (CEED)](http://ceed.exascaleproject.org). 11While our focus is on high-order finite elements, the approach is mostly 12algebraic and thus applicable to other discretizations in factored form, see the 13[API documentation](doc/libCEED.md). 14 15One of the challenges with high-order methods is that a global sparse matrix is 16no longer a good representation of a high-order linear operator, both with 17respect to the FLOPs needed for its evaluation, as well as the memory transfer 18needed for a matvec. Thus, high-order methods require a new "format" that still 19represents a linear (or more generally non-linear) operator, but not through a 20sparse matrix. 21 22The goal of libCEED is to propose such a format, as well as supporting 23implementations and data structures, that enable efficient operator evaluation 24on a variety of computational device types (CPUs, GPUs, etc.). This new operator 25description is based on algebraically [factored form](doc/libCEED.md), which is 26easy to incorporate in a wide variety of applications, without significant 27refactoring of their own discretization infrastructure. 28 29The repository is part of the [CEED software suite][ceed-soft], a collection of 30software benchmarks, miniapps, libraries and APIs for efficient exascale 31discretizations based on high-order finite element and spectral element methods. 32See http://github.com/ceed for more information and source code availability. 33 34The CEED research is supported by the [Exascale Computing Project][ecp] 35(17-SC-20-SC), a collaborative effort of two U.S. Department of Energy 36organizations (Office of Science and the National Nuclear Security 37Administration) responsible for the planning and preparation of a [capable 38exascale ecosystem](https://exascaleproject.org/what-is-exascale), including 39software, applications, hardware, advanced system engineering and early testbed 40platforms, in support of the nation’s exascale computing imperative. 41 42For more details on the CEED API see http://ceed.exascaleproject.org/ceed-code/. 43 44## Building 45 46The CEED library, `libceed`, is a C99 library with no external dependencies. 47It can be built using 48 49 make 50 51## Testing 52 53The test suite produces [TAP](https://testanything.org) output and is run by: 54 55 make test 56 57or, using the `prove` tool distributed with Perl (recommended) 58 59 make prove 60 61## Examples 62 63libCEED comes with several examples of its usage, ranging from standalone C 64codes in the `/examples/ceed` directory to examples based on external packages, 65such as MFEM, PETSc and Nek5000. 66 67To build the examples, set the `MFEM_DIR`, `PETSC_DIR` and `NEK5K_DIR` variables 68and run: 69 70``` 71# libCEED examples on CPU and GPU 72cd examples/ceed 73make 74./ex1 -ceed /cpu/self 75./ex1 -ceed /gpu/occa 76cd ../.. 77 78# MFEM+libCEED examples on CPU and GPU 79cd examples/mfem 80make 81./bp1 -ceed /cpu/self -no-vis 82./bp1 -ceed /gpu/occa -no-vis 83cd ../.. 84 85# PETSc+libCEED examples on CPU and GPU 86cd examples/petsc 87make 88./bp1 -ceed /cpu/self 89./bp1 -ceed /gpu/occa 90cd ../.. 91 92# Nek+libCEED examples on CPU and GPU 93cd examples/nek5000 94./generate-boxes.sh 2 4 95./make-nek-examples.sh 96./run-nek-example.sh -ceed /cpu/self -b b3 97./run-nek-example.sh -ceed /gpu/occa -b b3 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