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
58 changes: 8 additions & 50 deletions .github/workflows/continuousIntegration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ jobs:
lfs: false
- name: code_checks
env:
DOCKER_REPOSITORY: geosx/ubuntu:22.04-${{ needs.get_docker_image_tag_hash.outputs.DOCKER_IMAGE_TAG_HASH }}
# Cppcheck 2.13 and LLVM 20 support the project's required C++20 syntax.
DOCKER_REPOSITORY: geosx/ubuntu:24.04-clang20-1c3c049b3f629d9d44838656fd306b2a0c04c9e8
HOST_CONFIG: hostconfigs/environment.cmake
CMAKE_CXX_COMPILER: /usr/bin/clang++
CMAKE_C_COMPILER: /usr/bin/clang
CMAKE_CXX_COMPILER: /usr/lib/llvm-20/bin/clang++
CMAKE_C_COMPILER: /usr/lib/llvm-20/bin/clang
CMAKE_BUILD_TYPE: Release
BUILD_AND_TEST_ARGS: --code-checks
DOCKER_RUN_ARGS: --env PATH=/usr/lib/llvm-20/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
run: ./scripts/ci_build_and_test.sh

linux_builds:
Expand Down Expand Up @@ -154,51 +156,7 @@ jobs:
CMAKE_C_COMPILER: /usr/bin/gcc
CMAKE_BUILD_TYPE: Debug

- name: ubuntu22-gcc11-cuda11-rel (ubuntu-22, gcc 11.4.0, cuda-11.8.0, Release)
DOCKER_REPOSITORY: geosx/ubuntu:22.04-cuda11.8
RUNS_ON: streak2
CMAKE_CXX_COMPILER: /usr/bin/g++
CMAKE_C_COMPILER: /usr/bin/gcc
CMAKE_BUILD_TYPE: Release
ENABLE_CUDA: ON
CMAKE_CUDA_ARCHITECTURES: "86"
NPROC: 1
DOCKER_RUN_ARGS: "--cpus=1 --memory=64g --runtime=nvidia --gpus all"

- name: ubuntu22-gcc11-cuda11-dbg (ubuntu-22, gcc 11.4.0, cuda-11.8.0, Debug)
DOCKER_REPOSITORY: geosx/ubuntu:22.04-cuda11.8
RUNS_ON: streak2
CMAKE_CXX_COMPILER: /usr/bin/g++
CMAKE_C_COMPILER: /usr/bin/gcc
CMAKE_BUILD_TYPE: Debug
ENABLE_CUDA: ON
CMAKE_CUDA_ARCHITECTURES: "86"
NPROC: 1
DOCKER_RUN_ARGS: "--cpus=1 --memory=64g --runtime=nvidia --gpus all"

- name: ubuntu22-clang14-cuda11-rel (ubuntu-22, clang-14.0.0, cuda-11.8.0, Release)
DOCKER_REPOSITORY: geosx/ubuntu:22.04-cuda11.8
RUNS_ON: streak2
CMAKE_CXX_COMPILER: /usr/bin/clang++
CMAKE_C_COMPILER: /usr/bin/clang
CMAKE_BUILD_TYPE: Release
ENABLE_CUDA: ON
CMAKE_CUDA_ARCHITECTURES: "86"
NPROC: 1
DOCKER_RUN_ARGS: "--cpus=1 --memory=64g --runtime=nvidia --gpus all"

- name: ubuntu22-clang14-cuda11-dbg (ubuntu-22, clang-14.0.0, cuda-11.8.0, Debug)
DOCKER_REPOSITORY: geosx/ubuntu:22.04-cuda11.8
RUNS_ON: streak2
CMAKE_CXX_COMPILER: /usr/bin/clang++
CMAKE_C_COMPILER: /usr/bin/clang
CMAKE_BUILD_TYPE: Debug
ENABLE_CUDA: ON
CMAKE_CUDA_ARCHITECTURES: "86"
NPROC: 1
DOCKER_RUN_ARGS: "--cpus=1 --memory=64g --runtime=nvidia --gpus all"

- name: RHEL8.10-clang17-cuda12-rel (ubi8.10, clang-17.0.6, cuda-12.4.1, Release)
- name: RHEL8.10-clang17-cuda12-rel (ubi8.10, clang-17.0.6, cuda-12.8, Release)
DOCKER_REPOSITORY: geosx/ubi:8.10-cuda12.8
RUNS_ON: streak2
CMAKE_CXX_COMPILER: clang++
Expand All @@ -209,7 +167,7 @@ jobs:
NPROC: 1
DOCKER_RUN_ARGS: "--cpus=1 --memory=64g --runtime=nvidia --gpus all"

- name: RHEL8.10-gcc13-cuda12-rel (ubi8.10, gcc 13.2.1, cuda-12.4.1, Release)
- name: RHEL8.10-gcc13-cuda12-rel (ubi8.10, gcc 13.2.1, cuda-12.8, Release)
DOCKER_REPOSITORY: geosx/ubi:8.10-cuda12.8
RUNS_ON: streak2
CMAKE_CXX_COMPILER: /opt/rh/gcc-toolset-13/root/bin/g++
Expand Down Expand Up @@ -293,4 +251,4 @@ jobs:
run: "true"
- name: PR Failure
if: ${{ contains(env.RETURN_VAL, 'false') }}
run: "false"
run: "false"
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ target_include_directories( Shiva INTERFACE
"$<BUILD_INTERFACE:${SHIVA_BINARY_DIR}/include>" # build/include/shiva/ShivaConfig.hpp
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" )

target_compile_features(Shiva INTERFACE cxx_std_17)
target_compile_features(Shiva INTERFACE cxx_std_20 cuda_std_20)

# -------- BLT (optional; usable as top-level or submodule) ---------------------
if( SHIVA_ENABLE_BLT )
set( BLT_CXX_STD "c++17" )
set( BLT_CXX_STD "c++20" )
# Load BLT if Shiva is standalone
if( SHIVA_IS_TOPLEVEL )
set(BLT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/cmake/blt" CACHE PATH "Path to BLT")
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@
# Shiva
Shiva Discretization Library

Requirements: a C++20 compiler. CUDA builds require CUDA 12 or newer.

HIP consumers must explicitly require C++20 on each target that compiles HIP sources using Shiva. The Shiva interface propagates the C++ and CUDA standards; HIP standard propagation is unavailable at the project's minimum CMake version. Replace `my_target` with your consuming target:

```cmake
set_target_properties(my_target PROPERTIES
HIP_STANDARD 20
HIP_STANDARD_REQUIRED ON)
```

# Project Goals
The goals are:

- Provide portable device callable functionality to enable the application of discrete numerical methods such as the Finite Element Method, and Finite Difference Method, etc.
- Provide compile time interface to functionality through use of templates and `constexpr` for the special case where compile time knowledge is available.
- Specialize for common use cases to achieve maximum performance. For example a Hexahedral element with 1st order Lagrange shape functions and Gauss-Legendre quadrature.
- Support wide range of base geometries (tet, prism, pyramid, hex, polyhedral, etc), and discretization methods ( FEM, FVM, MPM, etc. )
- Support wide range of base geometries (tet, prism, pyramid, hex, polyhedral, etc), and discretization methods ( FEM, FVM, MPM, etc. )
20 changes: 12 additions & 8 deletions cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@ macro(shiva_add_code_checks)
endforeach()
endif()

set( CPPCHECK_FLAGS --std=c++17
--enable=all
set( CPPCHECK_FLAGS --std=c++20
--enable=all
--quiet
# Use the existing SHIVA_HAS_BUILTIN fallback during analysis.
-U__has_builtin
# Omit the informational summary: testCppCheck rejects any stderr.
--suppress=checkersReport
--suppress=missingIncludeSystem
--suppress=unmatchedSuppression
--suppress=missingInclude
--suppress=noConstructor
--suppress=missingInclude
--suppress=noConstructor
--suppress=noExplicitConstructor
--suppress=unusedFunction
--suppress=constStatement
--suppress=unusedFunction
--suppress=constStatement
--suppress=unusedStructMember
--suppress=unknownMacro )

blt_add_code_checks( PREFIX ${arg_PREFIX}
SOURCES ${_sources}
UNCRUSTIFY_CFG_FILE ${PROJECT_SOURCE_DIR}/src/uncrustify.cfg
Expand All @@ -71,4 +75,4 @@ macro(shiva_add_code_checks)
RUNNER ctest -E 'blt_gtest_smoke|testCppCheck|testClangTidy|testUncrustifyCheck|testDoxygenCheck|testCppCheck|testClangTidy'
SOURCE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include )
endif()
endmacro(shiva_add_code_checks)
endmacro(shiva_add_code_checks)
12 changes: 0 additions & 12 deletions hostconfigs/LLNL/lassen-clang-13-cuda-11.cmake

This file was deleted.

13 changes: 0 additions & 13 deletions hostconfigs/LLNL/lassen-cuda-11-base.cmake

This file was deleted.

12 changes: 0 additions & 12 deletions hostconfigs/LLNL/lassen-gcc-8-cuda-11.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion hostconfigs/TTE/maple_rocky9.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(CUDA_TOOLKIT_ROOT_DIR /hrtc/apps/cuda/12.6.20/aarch64/rocky9 CACHE STRING ""
set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING "")
set(CMAKE_CUDA_COMPILER ${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc CACHE STRING "")
set(CMAKE_CUDA_ARCHITECTURES 90 CACHE STRING "")
set(CMAKE_CUDA_STANDARD 17 CACHE STRING "")
set(CMAKE_CUDA_STANDARD 20 CACHE STRING "")
set(CMAKE_CUDA_FLAGS "-restrict --expt-extended-lambda --expt-relaxed-constexpr -Werror cross-execution-space-call,reorder,deprecated-declarations" CACHE STRING "")
#set(CMAKE_CUDA_FLAGS_RELEASE "-O3 -DNDEBUG -Xcompiler -DNDEBUG -Xcompiler -O3 -Xcompiler -mcpu=powerpc64le -Xcompiler -mtune=powerpc64le" CACHE STRING "")
#set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "-g -lineinfo ${CMAKE_CUDA_FLAGS_RELEASE}" CACHE STRING "")
Expand Down
2 changes: 1 addition & 1 deletion include/shiva/common/ShivaMacros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void i_g_n_o_r_e( ARGS const & ... ) {}
* @brief Define SHIVA_IS_CONST_EVAL() depending on compiler/toolchain
*/
#if defined(__CUDA_ARCH__)
// Device code (nvcc, hipcc): no support in C++17
// Keep CUDA device checks on the runtime path.
#define SHIVA_IS_CONST_EVAL() (false)

#elif SHIVA_HAS_BUILTIN( __builtin_is_constant_evaluated )
Expand Down
54 changes: 11 additions & 43 deletions include/shiva/functions/bases/BasisProduct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct BasisProduct
* coordinate.
* @tparam BASIS_FUNCTION_INDICES Pack of indices of the basis function to
* evaluate in each dimension.
* @tparam COORD_TYPE Coordinate type supporting indexing in each dimension.
* @param parentCoord The parent coordinate at which to evaluate the basis
* function.
* @return The value of the basis function at the specified parent coordinate.
Expand All @@ -79,7 +80,7 @@ struct BasisProduct
* \Phi_{i_0 i_1 ... i_{(numDims-1)}}(\boldsymbol{\xi}) =
* \prod_{k=0}^{(numDims-1)} \phi_{i_k}(\xi_k)\text{, where } \\
* i_j \text{is index of the basis function in the jth dimension, and
* ranges from [0...(order+1)]}
* ranges from 0 to one less than the number of support points in that dimension.}
* \f]
*
*/
Expand All @@ -89,30 +90,19 @@ struct BasisProduct
{
static_assert( sizeof...(BASIS_FUNCTION_INDICES) == numDims, "Wrong number of basis function indicies specified" );


#if __cplusplus >= 202002L
// expand pack over number of dimensions
return executeSequence< numDims >( [&]< int ... PRODUCT_TERM_INDEX > () constexpr
{
return ( BASIS_TYPE::template value< BASIS_FUNCTION_INDICES >( parentCoord[PRODUCT_TERM_INDEX] ) * ... );
} );
#else
// Integral-constant arguments preserve distinct coordinate indices in NVCC device code.
return executeSequence< numDims >( [&] ( auto ... PRODUCT_TERM_INDEX ) constexpr
{
// fold expression to multiply the value of each BASIS_TYPE in each
// dimension. In other words the fold expands on BASIS_TYPE...,
// BASIS_FUNCTION_INDICES..., and PRODUCT_TERM_INDEX... together.
return ( BASIS_TYPES::template value< BASIS_FUNCTION_INDICES >( parentCoord[decltype(PRODUCT_TERM_INDEX)::value] ) * ... );
} );

#endif
}

/**
* @brief Calculates the gradient of the basis function at the specified
* parent coordinate.
* @tparam BASIS_FUNCTION_INDICES Pack of indices of the basis function to
* evaluate in each dimension.
* @tparam COORD_TYPE Coordinate type supporting indexing in each dimension.
* @param parentCoord The parent coordinate at which to evaluate the basis
* function gradient.
* @return The gradient of the basis function at the specified parent
Expand All @@ -131,14 +121,12 @@ struct BasisProduct
gradient( COORD_TYPE const & parentCoord )
{
static_assert( sizeof...(BASIS_FUNCTION_INDICES) == numDims, "Wrong number of basis function indicies specified" );

#if __cplusplus >= 202002L
return executeSequence< numDims >( [&]< int ... i > () constexpr->CArrayNd< RealType, numDims >
{
auto gradientComponent = [&] ( auto const iGrad,
auto const ... PRODUCT_TERM_INDICES ) constexpr
{
// Ca
// Multiply the directional gradient by the values in every other dimension.
return ( gradientComponentHelper< BASIS_TYPES,
decltype(iGrad)::value,
BASIS_FUNCTION_INDICES,
Expand All @@ -147,46 +135,26 @@ struct BasisProduct

return { (executeSequence< numDims >( gradientComponent, std::integral_constant< int, i >{} ) )... };
} );
#else
// Expand over the dimensions.
return executeSequence< numDims >( [&] ( auto ... a ) constexpr->CArrayNd< RealType, numDims >
{
// define a lambda that calculates the gradient of the basis function in
// a single dimension/direction.
auto gradientComponent = [&] ( auto GRADIENT_COMPONENT, auto ... PRODUCT_TERM_INDICES ) constexpr
{
// fold expression calling gradientComponentHelper using expanding on
// BASIS_TYPE, BASIS_FUNCTION_INDICES, and PRODUCT_TERM_INDICES.
return ( gradientComponentHelper< BASIS_TYPES,
decltype(GRADIENT_COMPONENT)::value,
BASIS_FUNCTION_INDICES,
decltype(PRODUCT_TERM_INDICES)::value >( parentCoord ) * ... );
};

// execute the gradientComponent lambda on each direction, expand the
// pack on "i" corresponding to each direction of the gradient.
return { (executeSequence< numDims >( gradientComponent, a ) )... };
} );
#endif
}


private:
/**
* @brief Helper function to return the gradient of a basis function, or the
* value of the basis function depending on whether or not the index of the
* basis function (@p BASIS_FUNCTION) matches the index of the direction
* component index (@p GRADIENT_COMPONENT). This filter is illustrated in the
* value of the basis function depending on whether the coordinate dimension
* (@p COORD_INDEX) matches the gradient direction (@p GRADIENT_COMPONENT).
* This filter is illustrated in the
* documentation for the gradient function.
* @tparam BASIS_FUNCTION The basis function type
* @tparam GRADIENT_COMPONENT The dimension component of the gradient.
* @tparam BASIS_FUNCTION_INDEX The index of the basis function that is being
* evaluated.
* @tparam COORD_INDEX The dimension component of the coordinate.
* @tparam COORD_TYPE Coordinate type supporting indexing in each dimension.
* @param parentCoord The parent coordinate at which to evaluate the basis
* function gradient.
* @return The gradient component of the basis function at the specified
* parent coordinate.
* @return The one-dimensional basis derivative when the dimensions match,
* otherwise the one-dimensional basis value.
*/
template< typename BASIS_FUNCTION, int GRADIENT_COMPONENT, int BASIS_FUNCTION_INDEX, int COORD_INDEX, typename COORD_TYPE >
SHIVA_STATIC_CONSTEXPR_HOSTDEVICE_FORCEINLINE RealType
Expand Down
Loading
Loading