xref: /libCEED/interface/ceed-config.c (revision 0016fb07e7c068f01d173a0b3c44fa5763051e70)
1 // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause
5 //
6 // This file is part of CEED:  http://github.com/ceed
7 
8 #include <ceed-impl.h>
9 
10 const char *CeedGitVersion         = CEED_GIT_VERSION;
11 const char *CeedBuildConfiguration = CEED_BUILD_CONFIGURATION;
12 
13 /// @addtogroup CeedUser
14 /// @{
15 
16 /**
17   @brief Get output of `git describe --dirty` from build time.
18 
19   While @ref CeedGetVersion() uniquely identifies the source code for release
20   builds, it does not identify builds from other commits.
21 
22   @param[out] git_version A static string containing the Git commit description.
23 
24   If `git describe --always --dirty` fails, the string `"unknown"` will be provided.
25   This could occur if Git is not installed or if libCEED is not being built from a repository, for example.`
26 
27   @ref Developer
28 
29   @sa CeedGetVersion() CeedGetBuildConfiguration()
30 
31   @return An error code: 0 - success, otherwise - failure
32 */
CeedGetGitVersion(const char ** git_version)33 int CeedGetGitVersion(const char **git_version) {
34   *git_version = CeedGitVersion;
35   return CEED_ERROR_SUCCESS;
36 }
37 
38 /**
39   @brief Set whether or not to use Clang when compiling for GPU (instead of nvrtc)
40 
41   @param[in,out]  ceed     `Ceed` context to set Clang GPU compilation flag
42   @param[in]      is_clang Flag to use clang for GPU compilation
43 
44   @ref Developer
45 
46   @sa CeedGetIsClang()
47 
48   @return An error code: 0 - success, otherwise - failure
49  */
CeedSetIsClang(Ceed ceed,bool is_clang)50 int CeedSetIsClang(Ceed ceed, bool is_clang) {
51   ceed->cuda_compile_with_clang = is_clang;
52   return CEED_ERROR_SUCCESS;
53 }
54 
55 /**
56   @brief Determine if the current `ceed` is set to compile with Clang for CPU
57 
58   @param[in]  ceed     `Ceed` context to get Clang GPU compilation flag
59   @param[out] is_clang Variable to store Clang GPU compilation flag
60 
61   @ref Developer
62 
63   @sa CeedSetIsClang()
64 
65   @return An error code: 0 - success, otherwise - failure
66  */
CeedGetIsClang(Ceed ceed,bool * is_clang)67 int CeedGetIsClang(Ceed ceed, bool *is_clang) {
68   *is_clang = ceed->cuda_compile_with_clang;
69   return CEED_ERROR_SUCCESS;
70 }
71 
72 /**
73   @brief Get build variables as a multi-line string.
74 
75   Each line of the string has the format `VARNAME = value`.
76 
77   @param[out] build_config A static string containing build variables
78 
79   @ref Developer
80 
81   @sa CeedGetVersion() CeedGetGitVersion()
82 
83   @return An error code: 0 - success, otherwise - failure
84 */
CeedGetBuildConfiguration(const char ** build_config)85 int CeedGetBuildConfiguration(const char **build_config) {
86   *build_config = CeedBuildConfiguration;
87   return CEED_ERROR_SUCCESS;
88 }
89 
90 /// @}
91