Skip to content

Commit 16abe8f

Browse files
committed
Add C API for GauXC
- provide C enums - add atom and molecule types - add basis set and shell definitions - add molecule grid and runtime environment - add load balancer to C API - add molecular weights for C API - add functional class wrapping ExchCXX - add xc integrator and matrix type - add references for functionals - add support for reading and writing from HDF5 in C
1 parent 62fea07 commit 16abe8f

48 files changed

Lines changed: 4008 additions & 55 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ endif()
2727

2828

2929
# GauXC Options
30+
option( GAUXC_ENABLE_C "Enable C API" ON )
3031
option( GAUXC_ENABLE_HOST "Enable Host Integrator" ON )
3132
option( GAUXC_ENABLE_CUDA "Enable CUDA Bindings" OFF )
3233
option( GAUXC_ENABLE_HIP "Enable HIP Bindings" OFF )
@@ -54,6 +55,7 @@ cmake_dependent_option( GAUXC_ENABLE_CUTLASS
5455
)
5556

5657
# Default the feature variables
58+
set( GAUXC_HAS_C FALSE CACHE BOOL "" FORCE )
5759
set( GAUXC_HAS_HOST FALSE CACHE BOOL "" FORCE )
5860
set( GAUXC_HAS_CUDA FALSE CACHE BOOL "" FORCE )
5961
set( GAUXC_HAS_HIP FALSE CACHE BOOL "" FORCE )
@@ -67,6 +69,7 @@ set( GAUXC_HAS_CUTLASS FALSE CACHE BOOL "" FORCE )
6769
set( GAUXC_BLAS_IS_LP64 FALSE CACHE BOOL "" FORCE )
6870

6971
mark_as_advanced( FORCE
72+
GAUXC_HAS_C
7073
GAUXC_HAS_HOST
7174
GAUXC_HAS_CUDA
7275
GAUXC_HAS_HIP

cmake/gauxc-config.cmake.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ include(CMakeFindDependencyMacro)
1010
find_dependency( ExchCXX )
1111
find_dependency( IntegratorXX )
1212

13+
set( GAUXC_HAS_C @GAUXC_HAS_C@ )
1314
set( GAUXC_HAS_HOST @GAUXC_HAS_HOST@ )
1415
set( GAUXC_HAS_CUDA @GAUXC_HAS_CUDA@ )
1516
set( GAUXC_HAS_HIP @GAUXC_HAS_HIP@ )

include/gauxc/atom.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* GauXC Copyright (c) 2020-2024, The Regents of the University of California,
3+
* through Lawrence Berkeley National Laboratory (subject to receipt of
4+
* any required approvals from the U.S. Dept. of Energy).
5+
*
6+
* (c) 2024-2025, Microsoft Corporation
7+
*
8+
* All rights reserved.
9+
*
10+
* See LICENSE.txt for details
11+
*/
12+
#pragma once
13+
14+
#ifdef __cplusplus
15+
#include <cstdint>
16+
#include <cstdbool>
17+
#include <cstddef>
18+
#else
19+
#include <stdint.h>
20+
#include <stdbool.h>
21+
#include <stddef.h>
22+
#endif
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
namespace GauXC::C {
27+
#endif
28+
29+
/**
30+
* @brief GauXC C API Atom representation.
31+
*/
32+
typedef struct GauXCAtom {
33+
int64_t Z; ///< Atomic number.
34+
double x; ///< X coordinate (Bohr).
35+
double y; ///< Y coordinate (Bohr).
36+
double z; ///< Z coordinate (Bohr).
37+
} GauXCAtom;
38+
39+
#ifdef __cplusplus
40+
} // namespace GauXC::C
41+
} // extern "C"
42+
#endif

include/gauxc/basisset.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* GauXC Copyright (c) 2020-2024, The Regents of the University of California,
3+
* through Lawrence Berkeley National Laboratory (subject to receipt of
4+
* any required approvals from the U.S. Dept. of Energy).
5+
*
6+
* (c) 2024-2025, Microsoft Corporation
7+
*
8+
* All rights reserved.
9+
*
10+
* See LICENSE.txt for details
11+
*/
12+
#pragma once
13+
14+
#ifdef __cplusplus
15+
#include <cstdint>
16+
#include <cstdbool>
17+
#include <cstddef>
18+
#else
19+
#include <stdint.h>
20+
#include <stdbool.h>
21+
#include <stddef.h>
22+
#endif
23+
#include <gauxc/types.h>
24+
#include <gauxc/status.h>
25+
#include <gauxc/shell.h>
26+
27+
#ifdef __cplusplus
28+
extern "C" {
29+
namespace GauXC::C {
30+
#endif
31+
32+
/**
33+
* @brief GauXC C API BasisSet handle.
34+
*/
35+
typedef struct GauXCBasisSet {
36+
GauXCHeader hdr; ///< Header for internal use.
37+
void* ptr; ///< Pointer to the BasisSet instance.
38+
} GauXCBasisSet;
39+
40+
/**
41+
* @brief Create a new BasisSet instance.
42+
* @param status Status object to capture any errors.
43+
* @return Handle to the created BasisSet.
44+
*/
45+
extern GauXCBasisSet gauxc_basisset_new( GauXCStatus* status );
46+
47+
/**
48+
* @brief Create a new BasisSet instance from arrays of shells.
49+
* @param status Status object to capture any errors.
50+
* @param shells Pointer to an array of GauXCShell.
51+
* @param nshells Number of shells in the array.
52+
* @param normalize Whether to normalize the basis functions.
53+
* @return Handle to the created BasisSet.
54+
*/
55+
extern GauXCBasisSet gauxc_basisset_new_from_shells(
56+
GauXCStatus* status,
57+
GauXCShell* shells,
58+
size_t nshells,
59+
bool normalize
60+
);
61+
62+
/**
63+
* @brief Delete a BasisSet instance.
64+
* @param status Status object to capture any errors.
65+
* @param basis Handle to the BasisSet to delete.
66+
*/
67+
extern void gauxc_basisset_delete( GauXCStatus* status, GauXCBasisSet* basis );
68+
69+
#ifdef __cplusplus
70+
} // namespace GauXC::C
71+
} // extern "C"
72+
#endif

include/gauxc/enums.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* GauXC Copyright (c) 2020-2024, The Regents of the University of California,
3+
* through Lawrence Berkeley National Laboratory (subject to receipt of
4+
* any required approvals from the U.S. Dept. of Energy).
5+
*
6+
* (c) 2024-2025, Microsoft Corporation
7+
*
8+
* All rights reserved.
9+
*
10+
* See LICENSE.txt for details
11+
*/
12+
#pragma once
13+
14+
#ifdef __cplusplus
15+
extern "C" {
16+
namespace GauXC::C {
17+
#endif
18+
19+
/**
20+
* @brief GauXC specific enums for the specification of radial quadratures
21+
*
22+
* Generally mapped to equivalent enums in IntegratorXX
23+
*/
24+
enum GauXC_RadialQuad {
25+
GauXC_RadialQuad_Becke, ///< Becke radial quadrature
26+
GauXC_RadialQuad_MuraKnowles, ///< Mura-Knowles radial quadrature
27+
GauXC_RadialQuad_MurrayHandyLaming, ///< Murray-Handy-Laming radial quadrature
28+
GauXC_RadialQuad_TreutlerAhlrichs ///< Treutler-Ahlrichs radial quadrature
29+
};
30+
31+
/**
32+
* @brief Specifications of grid defaults for atomic integration
33+
*
34+
* See https://gaussian.com/integral for specification
35+
*/
36+
enum GauXC_AtomicGridSizeDefault {
37+
GauXC_AtomicGridSizeDefault_FineGrid, ///< Fine grid (least accurate)
38+
GauXC_AtomicGridSizeDefault_UltraFineGrid, ///< Ultrafine grid (appropriate accuracy)
39+
GauXC_AtomicGridSizeDefault_SuperFineGrid, ///< Superfine grid (most accurate)
40+
GauXC_AtomicGridSizeDefault_GM3, ///< Treutler-Ahlrichs GM3
41+
GauXC_AtomicGridSizeDefault_GM5 ///< Treutlet-Ahlrichs GM5
42+
};
43+
44+
/**
45+
* @brief Specifications of atomic partitioning scheme for the
46+
* molecular integration
47+
*/
48+
enum GauXC_XCWeightAlg {
49+
GauXC_XCWeightAlg_NOTPARTITIONED, ///< Not partitioned
50+
GauXC_XCWeightAlg_Becke, ///< The original Becke weighting scheme
51+
GauXC_XCWeightAlg_SSF, ///< The Stratmann-Scuseria-Frisch weighting scheme
52+
GauXC_XCWeightAlg_LKO ///< The Lauqua-Kuessman-Ochsenfeld weighting scheme
53+
};
54+
55+
/**
56+
* @brief Specification of the execution space for various operations
57+
*/
58+
enum GauXC_ExecutionSpace {
59+
GauXC_ExecutionSpace_Host, ///< Execute task on the host
60+
GauXC_ExecutionSpace_Device ///< Execute task on the device (e.g. GPU)
61+
};
62+
63+
/// Supported Algorithms / Integrands
64+
enum GauXC_SupportedAlg {
65+
GauXC_SupportedAlg_XC,
66+
GauXC_SupportedAlg_DEN,
67+
GauXC_SupportedAlg_SNLINK
68+
};
69+
70+
/// High-level specification of pruning schemes for atomic quadratures
71+
enum GauXC_PruningScheme {
72+
GauXC_PruningScheme_Unpruned, ///< Unpruned atomic quadrature
73+
GauXC_PruningScheme_Robust, ///< The "Robust" scheme of Psi4
74+
GauXC_PruningScheme_Treutler ///< The Treutler-Ahlrichs scheme
75+
};
76+
77+
78+
#ifdef __cplusplus
79+
} // namespace GauXC::C
80+
} // extern "C"
81+
#endif

include/gauxc/enums.hpp

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212
#pragma once
1313

14+
#include <gauxc/enums.h>
15+
1416
namespace GauXC {
1517

1618
/**
@@ -19,10 +21,10 @@ namespace GauXC {
1921
* Generally mapped to equivalent enums in IntegratorXX
2022
*/
2123
enum class RadialQuad {
22-
Becke, ///< Becke radial quadrature
23-
MuraKnowles, ///< Mura-Knowles radial quadrature
24-
MurrayHandyLaming, ///< Murray-Handy-Laming radial quadrature
25-
TreutlerAhlrichs ///< Treutler-Ahlrichs radial quadrature
24+
Becke = C::GauXC_RadialQuad_Becke, ///< Becke radial quadrature
25+
MuraKnowles = C::GauXC_RadialQuad_MuraKnowles, ///< Mura-Knowles radial quadrature
26+
MurrayHandyLaming = C::GauXC_RadialQuad_MurrayHandyLaming, ///< Murray-Handy-Laming radial quadrature
27+
TreutlerAhlrichs = C::GauXC_RadialQuad_TreutlerAhlrichs ///< Treutler-Ahlrichs radial quadrature
2628
};
2729

2830
/**
@@ -31,37 +33,45 @@ enum class RadialQuad {
3133
* See https://gaussian.com/integral for specification
3234
*/
3335
enum class AtomicGridSizeDefault {
34-
FineGrid, ///< Fine grid (least accurate)
35-
UltraFineGrid, ///< Ultrafine grid (appropriate accuracy)
36-
SuperFineGrid, ///< Superfine grid (most accurate)
37-
GM3, ///< Treutler-Ahlrichs GM3
38-
GM5 ///< Treutlet-Ahlrichs GM5
36+
FineGrid = C::GauXC_AtomicGridSizeDefault_FineGrid, ///< Fine grid (least accurate)
37+
UltraFineGrid = C::GauXC_AtomicGridSizeDefault_UltraFineGrid, ///< Ultrafine grid (appropriate accuracy)
38+
SuperFineGrid = C::GauXC_AtomicGridSizeDefault_SuperFineGrid, ///< Superfine grid (most accurate)
39+
GM3 = C::GauXC_AtomicGridSizeDefault_GM3, ///< Treutler-Ahlrichs GM3
40+
GM5 = C::GauXC_AtomicGridSizeDefault_GM5 ///< Treutlet-Ahlrichs GM5
3941
};
4042

4143
/**
4244
* @brief Specifications of atomic partitioning scheme for the
4345
* molecular integration
4446
*/
4547
enum class XCWeightAlg {
46-
NOTPARTITIONED, ///< Not partitioned
47-
Becke, ///< The original Becke weighting scheme
48-
SSF, ///< The Stratmann-Scuseria-Frisch weighting scheme
49-
LKO ///< The Lauqua-Kuessman-Ochsenfeld weighting scheme
48+
NOTPARTITIONED = C::GauXC_XCWeightAlg_NOTPARTITIONED, ///< Not partitioned
49+
Becke = C::GauXC_XCWeightAlg_Becke, ///< The original Becke weighting scheme
50+
SSF = C::GauXC_XCWeightAlg_SSF, ///< The Stratmann-Scuseria-Frisch weighting scheme
51+
LKO = C::GauXC_XCWeightAlg_LKO ///< The Lauqua-Kuessman-Ochsenfeld weighting scheme
5052
};
5153

5254
/**
5355
* @brief Specification of the execution space for various operations
5456
*/
5557
enum class ExecutionSpace {
56-
Host, ///< Execute task on the host
57-
Device ///< Execute task on the device (e.g. GPU)
58+
Host = C::GauXC_ExecutionSpace_Host, ///< Execute task on the host
59+
Device = C::GauXC_ExecutionSpace_Device ///< Execute task on the device (e.g. GPU)
5860
};
5961

6062
/// Supported Algorithms / Integrands
6163
enum class SupportedAlg {
62-
XC,
63-
DEN,
64-
SNLINK
64+
XC = C::GauXC_SupportedAlg_XC,
65+
DEN = C::GauXC_SupportedAlg_DEN,
66+
SNLINK = C::GauXC_SupportedAlg_SNLINK
67+
};
68+
69+
/// High-level specification of pruning schemes for atomic quadratures
70+
enum class PruningScheme {
71+
Unpruned = C::GauXC_PruningScheme_Unpruned, ///< Unpruned atomic quadrature
72+
Robust = C::GauXC_PruningScheme_Robust, ///< The "Robust" scheme of Psi4
73+
Treutler = C::GauXC_PruningScheme_Treutler ///< The Treutler-Ahlrichs scheme
6574
};
6675

76+
6777
} // namespace GauXC

0 commit comments

Comments
 (0)