Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ option( EXCHCXX_ENABLE_BENCHMARK "Enable Performance Benchmark" OFF )
option( EXCHCXX_ENABLE_CUDA "Enable Device Code (CUDA)" OFF )
option( EXCHCXX_ENABLE_HIP "Enable Device Code (HIP)" OFF )
option( EXCHCXX_ENABLE_SYCL "Enable Device Code (SYCL)" OFF )
option( EXCHCXX_ENABLE_LIBXC "Enable Libxc Backend" ON )
option( BUILD_SHARED_LIBS "Build Shared Libs" OFF )


Expand Down Expand Up @@ -53,6 +54,7 @@ if( EXCHCXX_ENABLE_HIP )
endif()


if(EXCHCXX_ENABLE_LIBXC)

## Find LibXC
find_package( Libxc 6.2.0 CONFIG QUIET )
Expand Down Expand Up @@ -96,6 +98,10 @@ else()
set( BUILD_TESTING ${OLD_BUILD_TESTING} CACHE BOOL "" FORCE )

endif()

else( EXCHCXX_ENABLE_LIBXC )
set( Libxc_FOUND FALSE )
endif( EXCHCXX_ENABLE_LIBXC )

add_subdirectory( src )

Expand All @@ -105,13 +111,13 @@ if( NOT DEFINED EXCHCXX_ENABLE_TESTS )
endif()

if( CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND EXCHCXX_ENABLE_TESTS AND BUILD_TESTING )
if(${Libxc_FOUND})
if(${Libxc_FOUND} OR NOT EXCHCXX_ENABLE_LIBXC)
message(WARNING "ExchCXX Unit Tests Require Local Patch of Libxc - Disabling")
else()
add_subdirectory( test )
endif()
endif()

if( EXCHCXX_ENABLE_BENCHMARK )
if( EXCHCXX_ENABLE_BENCHMARK AND EXCHCXX_ENABLE_LIBXC )
add_subdirectory( performance )
endif()
6 changes: 5 additions & 1 deletion cmake/ExchCXXConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ get_filename_component(ExchCXX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

list(APPEND CMAKE_MODULE_PATH ${ExchCXX_CMAKE_DIR})
include(CMakeFindDependencyMacro)
find_dependency( Libxc @Libxc_VERSION@ EXACT CONFIG )


set( EXCHCXX_ENABLE_CUDA @EXCHCXX_ENABLE_CUDA@ )
set( EXCHCXX_ENABLE_HIP @EXCHCXX_ENABLE_HIP@ )
set( EXCHCXX_ENABLE_SYCL @EXCHCXX_ENABLE_SYCL@ )
set( EXCHCXX_ENABLE_DEVICE @EXCHCXX_ENABLE_DEVICE@ )
set( EXCHCXX_ENABLE_LIBXC @EXCHCXX_ENABLE_LIBXC@ )

if( EXCHCXX_ENABLE_LIBXC )
find_dependency( Libxc @Libxc_VERSION@ EXACT CONFIG )
endif()

if( EXCHCXX_ENABLE_CUDA )
find_dependency( CUDAToolkit @CUDAToolkit_VERSION@ EXACT )
Expand Down
4 changes: 4 additions & 0 deletions include/exchcxx/enums/backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@
namespace ExchCXX {

enum class Backend {
#ifdef EXCHCXX_ENABLE_LIBXC
libxc,
#endif
builtin
};

#ifdef EXCHCXX_ENABLE_LIBXC
using libxc_name_string = detail::NamedType<std::string, struct LibxcNameString>;
#endif

}
1 change: 1 addition & 0 deletions include/exchcxx/exchcxx_config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#cmakedefine EXCHCXX_ENABLE_HIP
#cmakedefine EXCHCXX_ENABLE_SYCL
#cmakedefine EXCHCXX_ENABLE_DEVICE
#cmakedefine EXCHCXX_ENABLE_LIBXC


#ifdef EXCHCXX_ENABLE_CUDA
Expand Down
5 changes: 5 additions & 0 deletions include/exchcxx/factory/xc_kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,22 @@

namespace ExchCXX {

#ifdef EXCHCXX_ENABLE_LIBXC
XCKernel libxc_kernel_factory(const Kernel, const Spin );
XCKernel libxc_kernel_factory(const std::string xc_name, const Spin polar );
#endif

XCKernel builtin_kernel_factory( Kernel, Spin );

static inline XCKernel kernel_factory(
Backend backend, Kernel kern, Spin polar
) {

#ifdef EXCHCXX_ENABLE_LIBXC
if( backend == Backend::libxc )
return libxc_kernel_factory( kern, polar );
else
#endif
return builtin_kernel_factory( kern, polar );

}
Expand Down
4 changes: 4 additions & 0 deletions include/exchcxx/xc_functional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ class XCFunctional {

XCFunctional( const Backend, const Functional, const Spin );
XCFunctional( const Functional func, const Spin polar) :
#ifdef EXCHCXX_ENABLE_LIBXC
XCFunctional( Backend::libxc, func, polar) { };
#else
XCFunctional( Backend::builtin, func, polar) { };
#endif

XCFunctional( const XCFunctional& ) ;
XCFunctional( XCFunctional&& ) noexcept;
Expand Down
5 changes: 5 additions & 0 deletions include/exchcxx/xc_kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ class XCKernel {

XCKernel( const Backend backend, const Kernel kern,
const Spin polar );
#ifdef EXCHCXX_ENABLE_LIBXC
XCKernel( const libxc_name_string& xc_name,
const Spin polar );
XCKernel( const Kernel kern, const Spin polar ) :
XCKernel( Backend::libxc, kern, polar ){ };
#else
XCKernel( const Kernel kern, const Spin polar ) :
XCKernel( Backend::builtin, kern, polar ){ };
#endif

XCKernel( impl_ptr&& ptr ) ;
XCKernel( const XCKernel& ) ;
Expand Down
12 changes: 7 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@



set( EXCHCXX_SOURCES
xc_kernel.cxx
xc_functional.cxx
libxc.cxx
boilerplate.cxx
builtin.cxx
builtin_interface.cxx
builtin_kernel.cxx
)
if(EXCHCXX_ENABLE_LIBXC)
list(APPEND EXCHCXX_SOURCES libxc.cxx)
endif()
message(STATUS ${EXCHCXX_SOURCES})

add_library( exchcxx ${EXCHCXX_SOURCES} )

# TARGET properties

target_compile_features( exchcxx PUBLIC cxx_std_17 )
target_link_libraries( exchcxx PUBLIC Libxc::xc )
if( EXCHCXX_ENABLE_LIBXC )
target_link_libraries( exchcxx PUBLIC Libxc::xc )
endif()

# Generate exchcxx_config.hpp
configure_file(
Expand Down
4 changes: 3 additions & 1 deletion src/cuda/exchcxx_cuda.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
set( EXCHCXX_CUDA_SOURCES
cuda/xc_functional_device.cu
cuda/libxc_device.cxx
cuda/builtin.cu
)
if( EXCHCXX_ENABLE_LIBXC )
list(APPEND EXCHCXX_CUDA_SOURCES cuda/libxc_device.cxx)
endif()

find_package( CUDAToolkit REQUIRED )
#add_library( exchcxx_device OBJECT ${EXCHCXX_CUDA_SOURCES} )
Expand Down
4 changes: 3 additions & 1 deletion src/hip/exchcxx_hip.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
set( EXCHCXX_HIP_SOURCES
hip/xc_functional_device.hip
hip/libxc_device.hip
hip/builtin.hip
)
if( EXCHCXX_ENABLE_LIBXC )
list(APPEND EXCHCXX_HIP_SOURCES hip/libxc_device.hip)
endif()

find_package( hip REQUIRED )

Expand Down
4 changes: 3 additions & 1 deletion src/sycl/exchcxx_sycl.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
set( EXCHCXX_SYCL_SOURCES
sycl/xc_functional_device.cxx
sycl/libxc_device.cxx
sycl/builtin_sycl.cxx
)
if( EXCHCXX_ENABLE_LIBXC )
list(APPEND EXCHCXX_SYCL_SOURCES sycl/libxc_device.cxx)
endif()


target_sources( exchcxx PRIVATE ${EXCHCXX_SYCL_SOURCES} )
Expand Down
2 changes: 2 additions & 0 deletions src/xc_kernel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ XCKernel::XCKernel(
const Spin polar) :
XCKernel( kernel_factory( backend, kern, polar ) ) { }

#ifdef EXCHCXX_ENABLE_LIBXC
XCKernel::XCKernel(
const libxc_name_string& xc_name,
const Spin polar) :
XCKernel( libxc_kernel_factory( xc_name.get(), polar ) ) { }
#endif


XCKernel::XCKernel( impl_ptr&& ptr ) :
Expand Down
Loading