diff --git a/host-configs/LLNL/quartz-base.cmake b/host-configs/LLNL/quartz-base.cmake index 2554789edd6..25dc4b54bde 100644 --- a/host-configs/LLNL/quartz-base.cmake +++ b/host-configs/LLNL/quartz-base.cmake @@ -29,5 +29,6 @@ set(ENABLE_OPENMP ON CACHE BOOL "") set(ENABLE_PAMELA ON CACHE BOOL "") set(ENABLE_PVTPackage ON CACHE BOOL "") set(ENABLE_PETSC OFF CACHE BOOL "Enables PETSc." FORCE) +set(ENABLE_JITTI ON CACHE BOOL "Enables kernel JIT compilation." FORCE) include(${CMAKE_CURRENT_LIST_DIR}/../tpls.cmake) diff --git a/src/cmake/GeosxOptions.cmake b/src/cmake/GeosxOptions.cmake index 22ac9e77e68..b9089743067 100644 --- a/src/cmake/GeosxOptions.cmake +++ b/src/cmake/GeosxOptions.cmake @@ -93,6 +93,16 @@ endif(NOT BLT_CXX_STD STREQUAL c++14) message("CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}") +option( ENABLE_JITTI "Build all compute kernels just-in-time at runtime." OFF ) + +if ( ENABLE_JITTI ) + message( "JITTI is ENABLED") + set( JITTI_DEFINES "JITTI=1" ) +else ( ) + set( JITTI_DEFINES "JITTI=0" ) + message( "JITTI is DISABLED") +endif ( ) + blt_append_custom_compiler_flag( FLAGS_VAR CMAKE_CXX_FLAGS DEFAULT "${OpenMP_CXX_FLAGS}") blt_append_custom_compiler_flag( FLAGS_VAR CMAKE_CXX_FLAGS GNU "-Wall -Wextra -Wpedantic -pedantic-errors -Wshadow -Wfloat-equal -Wcast-align -Wcast-qual" diff --git a/src/coreComponents/LvArray b/src/coreComponents/LvArray index ab0d3025d29..48e8365b078 160000 --- a/src/coreComponents/LvArray +++ b/src/coreComponents/LvArray @@ -1 +1 @@ -Subproject commit ab0d3025d2962aad10457b7bf7f5b6d266232276 +Subproject commit 48e8365b0785eb436ac82bd8212dcae3577184d0 diff --git a/src/coreComponents/finiteElement/CMakeLists.txt b/src/coreComponents/finiteElement/CMakeLists.txt index 9293f1a56d9..eec281bdf3d 100644 --- a/src/coreComponents/finiteElement/CMakeLists.txt +++ b/src/coreComponents/finiteElement/CMakeLists.txt @@ -19,6 +19,7 @@ set( finiteElement_headers elementFormulations/H1_Wedge_Lagrange1_Gauss6.hpp elementFormulations/LagrangeBasis1.hpp elementFormulations/LagrangeBasis2.hpp + ${CMAKE_BINARY_DIR}/include/kernelJITCompileCommands.hpp ) # # Specify all sources @@ -26,6 +27,7 @@ set( finiteElement_headers set( finiteElement_sources FiniteElementDiscretization.cpp FiniteElementDiscretizationManager.cpp + kernelInterface/kernelJIT.cpp ) set( dependencyList dataRepository ) @@ -37,12 +39,22 @@ endif() blt_add_library( NAME finiteElement SOURCES ${finiteElement_sources} HEADERS ${finiteElement_headers} - DEPENDS_ON ${dependencyList} + DEFINES JITTI_OUTPUT_DIR=${CMAKE_BINARY_DIR}/lib/jitti ${JITTI_DEFINES} + DEPENDS_ON ${dependencyList} jitti OBJECT ${GEOSX_BUILD_OBJ_LIBS} ) target_include_directories( finiteElement PUBLIC ${CMAKE_SOURCE_DIR}/coreComponents) +add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/include/kernelJITCompileCommands.hpp + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMAND python ${CMAKE_CURRENT_LIST_DIR}/../LvArray/src/jitti/generateCompileCommandsHeader.py + ${CMAKE_BINARY_DIR}/compile_commands.json + --cpp ${CMAKE_CURRENT_LIST_DIR}/kernelInterface/kernelJIT.cpp + --hpp ${CMAKE_BINARY_DIR}/include/kernelJITCompileCommands.hpp + --include ${CMAKE_BINARY_DIR}/include + --linker ${CMAKE_CXX_COMPILER} ) + geosx_add_code_checks( PREFIX finiteElement ) add_subdirectory( unitTests ) diff --git a/src/coreComponents/finiteElement/kernelInterface/KernelBase.hpp b/src/coreComponents/finiteElement/kernelInterface/KernelBase.hpp index d2ada78c940..d97dafb5954 100644 --- a/src/coreComponents/finiteElement/kernelInterface/KernelBase.hpp +++ b/src/coreComponents/finiteElement/kernelInterface/KernelBase.hpp @@ -24,8 +24,11 @@ #include "common/TimingMacros.hpp" #include "constitutive/ConstitutivePassThru.hpp" #include "finiteElement/FiniteElementDispatch.hpp" +#include "mesh/MeshLevel.hpp" #include "mesh/ElementRegionManager.hpp" #include "common/GEOS_RAJA_Interface.hpp" +#include "common/MpiWrapper.hpp" +#include "LvArray/src/jitti/Cache.hpp" namespace geosx { @@ -258,52 +261,24 @@ class KernelBase FE_TYPE const & m_finiteElementSpace; }; -/** - * @class KernelFactory - * @brief Used to forward arguments to a class that implements the KernelBase interface. - * @tparam KERNEL_TYPE The template class to construct, should implement the KernelBase interface. - * @tparam ARGS The arguments used to construct a @p KERNEL_TYPE in addition to the standard arguments. - */ -template< template< typename SUBREGION_TYPE, - typename CONSTITUTIVE_TYPE, - typename FE_TYPE > class KERNEL_TYPE, - typename ... ARGS > -class KernelFactory -{ -public: - - /** - * @brief Initialize the factory. - * @param args The arguments used to construct a @p KERNEL_TYPE in addition to the standard arguments. - */ - KernelFactory( ARGS ... args ): - m_args( args ... ) - {} - - /** - * @brief Create a new kernel with the given standard arguments. - * @tparam SUBREGION_TYPE The type of @p elementSubRegion. - * @tparam CONSTITUTIVE_TYPE The type of @p inputConstitutiveType. - * @tparam FE_TYPE The type of @p finiteElementSpace. - * @param nodeManager The node manager. - * @param edgeManager The edge manager. - * @param faceManager The face manager. - * @param targetRegionIndex The target region index. - * @param elementSubRegion The subregion to execute on. - * @param finiteElementSpace The finite element space. - * @param inputConstitutiveType The constitutive relation. - * @return A new kernel constructed with the given arguments and @c ARGS. - */ - template< typename SUBREGION_TYPE, typename CONSTITUTIVE_TYPE, typename FE_TYPE > - KERNEL_TYPE< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE > createKernel( + template< typename POLICY, + typename SUBREGION_TYPE, + typename CONSTITUTIVE_TYPE, + typename FE_TYPE, + template< typename, typename, typename > class KERNEL_TEMPLATE, + typename KERNEL_CONSTRUCTOR_PARAMS > + real64 buildKernelAndInvoke( + localIndex const numElems, NodeManager & nodeManager, EdgeManager const & edgeManager, FaceManager const & faceManager, localIndex const targetRegionIndex, SUBREGION_TYPE const & elementSubRegion, FE_TYPE const & finiteElementSpace, - CONSTITUTIVE_TYPE & inputConstitutiveType ) + CONSTITUTIVE_TYPE & inputConstitutiveType, + KERNEL_CONSTRUCTOR_PARAMS const & kernelParamsTuple ) { + using KERNEL_TYPE = KERNEL_TEMPLATE< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE >; camp::tuple< NodeManager &, EdgeManager const &, FaceManager const &, @@ -317,16 +292,158 @@ class KernelFactory elementSubRegion, finiteElementSpace, inputConstitutiveType }; - - auto allArgs = camp::tuple_cat_pair( standardArgs, m_args ); - return camp::make_from_tuple< KERNEL_TYPE< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE > >( allArgs ); + auto allArgs = camp::tuple_cat_pair( standardArgs, kernelParamsTuple ); + KERNEL_TYPE kernel = camp::make_from_tuple< KERNEL_TYPE >( allArgs ); + return KERNEL_TYPE::template kernelLaunch< POLICY, KERNEL_TYPE >( numElems, kernel ); } -private: - /// The arguments to append to the standard kernel constructor arguments. - camp::tuple< ARGS ... > m_args; -}; + /** + * @class KernelTemplateDispatch + * @brief Used to forward arguments to a class that implements the KernelBase interface. + * @tparam KERNEL_TYPE The template class to construct, should implement the KernelBase interface. + * @tparam ARGS The arguments used to construct a @p KERNEL_TYPE in addition to the standard arguments. + */ + template < template < typename CONSTITUTIVE_TYPE, typename SUBREGION_TYPE, typename FE_TYPE > class KERNEL_TYPE, typename ... ARGS > + class KernelDispatchTemplate + { + public: + + /** + * @brief Initialize the factory. + * @param args The arguments used to construct a @p KERNEL_TYPE in addition to the standard arguments. + */ + KernelDispatchTemplate( ARGS ... args ): + m_args( args ... ) + {} + + template < typename POLICY, + typename SUBREGION_TYPE, + typename FE_TYPE, + typename CONSTITUTIVE_TYPE > + real64 invoke( localIndex const numElems, + NodeManager & nodeManager, + EdgeManager const & edgeManager, + FaceManager const & faceManager, + localIndex const targetRegionIndex, + SUBREGION_TYPE const & elementSubRegion, + FE_TYPE const & finiteElementSpace, + CONSTITUTIVE_TYPE & inputConstitutiveType ) + { + return buildKernelAndInvoke< POLICY, + SUBREGION_TYPE, + CONSTITUTIVE_TYPE, + FE_TYPE, + KERNEL_TYPE, + decltype( m_args )> ( numElems, + nodeManager, + edgeManager, + faceManager, + targetRegionIndex, + elementSubRegion, + finiteElementSpace, + inputConstitutiveType, + m_args ); + + } + + private: + + /// The arguments to append to the standard kernel constructor arguments. + camp::tuple< ARGS ... > m_args; + }; + + jitti::CompilationInfo getKernelCompilationInfo( const string & header ); + // compiles the kernel using jitti + template < const char * NAME, const char * HEADER, typename ... ARGS > + //template < template < const char * NAME, const char * HEADER > class constexpr_jitti_info< NAME, HEADER > CONSTEXPR_INFO, typename ... ARGS > + class KernelDispatchJIT + { + public: + /** + * @brief Initialize the factory. + * @param args The arguments used to construct a @p KERNEL_TYPE in addition to the standard arguments. + */ + KernelDispatchJIT( ARGS ... args ): + m_args( args ... ) + {} + + template < typename POLICY, + typename SUBREGION_TYPE, + typename FE_TYPE, + typename CONSTITUTIVE_TYPE > + real64 invoke( localIndex const numElems, + NodeManager & nodeManager, + EdgeManager const & edgeManager, + FaceManager const & faceManager, + localIndex const targetRegionIndex, + SUBREGION_TYPE const & elementSubRegion, + FE_TYPE const & finiteElementSpace, + CONSTITUTIVE_TYPE & inputConstitutiveType ) + { + string header( HEADER ); + jitti::CompilationInfo info = getKernelCompilationInfo( header ); + + info.templateParams = LvArray::system::demangleType< POLICY >() + ", " + + LvArray::system::demangleType< SUBREGION_TYPE >() + ", " + + LvArray::system::demangleType< CONSTITUTIVE_TYPE >() + ", " + + LvArray::system::demangleType< FE_TYPE >() + ", " + + string( NAME ) + ", " + + LvArray::system::demangleType< decltype( m_args ) >(); + + // Unfortunately can't just decltype(&buildKernelAndInvoke) since we can't fully specify the function template + using JIT_KERNEL_DISPATCH = real64 (*)( localIndex const, + NodeManager &, + EdgeManager const &, + FaceManager const &, + localIndex const, + SUBREGION_TYPE const &, + FE_TYPE const &, + CONSTITUTIVE_TYPE &, + decltype( m_args ) const & ); + string outputDir( STRINGIZE( JITTI_OUTPUT_DIR ) ); + outputDir += "/"; + static jitti::Cache< JIT_KERNEL_DISPATCH > buildCache( time(NULL), outputDir ); + + if( MpiWrapper::commRank( ) == 0 ) + { + buildCache.getOrLoadOrCompile( info ); + } + MpiWrapper::barrier( ); + // check if the library with the function is available + if ( buildCache.tryGet( info ) == nullptr ) + { + // if not, refresh by reading the filesystem to find the new library on the first iteration + buildCache.refresh( ); + } + auto & jitKernelDispatch = buildCache.getOrLoad( info ); + return jitKernelDispatch( numElems, + nodeManager, + edgeManager, + faceManager, + targetRegionIndex, + elementSubRegion, + finiteElementSpace, + inputConstitutiveType, + m_args ); + } + + private: + + /// The arguments to append to the standard kernel constructor arguments. + camp::tuple< ARGS ... > m_args; + }; +// Would VASTLY prefer to use template specialization on the above class(es) and allow JITTI_TPARAM to ultimately +// decide on whether to JIT or not.. but current language restrictions on templating and our in-code restrictions on +// the kernels due to the 'using' statements throughout the code to define specific kernel dispatchers make that +// devwork intractable. +// We can't use 'using' here due to differences in the above templates as well... nor a nice preprocessor macro... +// so we're basically left with only one option +#if JITTI == 1 + #define KernelDispatch KernelDispatchJIT +#else + #define KernelDispatch KernelDispatchTemplate +#endif //***************************************************************************** //***************************************************************************** @@ -357,13 +474,13 @@ class KernelFactory template< typename POLICY, typename CONSTITUTIVE_BASE, typename SUBREGION_TYPE, - typename KERNEL_FACTORY > + typename KERNEL_DISPATCH > static real64 regionBasedKernelApplication( MeshLevel & mesh, arrayView1d< string const > const & targetRegions, string const & finiteElementName, arrayView1d< string const > const & constitutiveNames, - KERNEL_FACTORY & kernelFactory ) + KERNEL_DISPATCH & kernelDispatch ) { GEOSX_MARK_FUNCTION; // save the maximum residual contribution for scaling residuals for convergence criteria. @@ -381,7 +498,7 @@ real64 regionBasedKernelApplication( MeshLevel & mesh, &nodeManager, &edgeManager, &faceManager, - &kernelFactory, + &kernelDispatch, &finiteElementName] ( localIndex const targetRegionIndex, auto & elementSubRegion ) { @@ -407,7 +524,7 @@ real64 regionBasedKernelApplication( MeshLevel & mesh, &edgeManager, &faceManager, targetRegionIndex, - &kernelFactory, + &kernelDispatch, &elementSubRegion, &finiteElementName, numElems] @@ -422,25 +539,20 @@ real64 regionBasedKernelApplication( MeshLevel & mesh, &edgeManager, &faceManager, targetRegionIndex, - &kernelFactory, + &kernelDispatch, &elementSubRegion, numElems, &castedConstitutiveRelation] ( auto const finiteElement ) { - auto kernel = kernelFactory.createKernel( nodeManager, - edgeManager, - faceManager, - targetRegionIndex, - elementSubRegion, - finiteElement, - castedConstitutiveRelation ); - - using KERNEL_TYPE = decltype( kernel ); - - // Call the kernelLaunch function, and store the maximum contribution to the residual. - maxResidualContribution = - std::max( maxResidualContribution, - KERNEL_TYPE::template kernelLaunch< POLICY, KERNEL_TYPE >( numElems, kernel ) ); + maxResidualContribution = std::max( maxResidualContribution, + kernelDispatch.template invoke< POLICY >( numElems, + nodeManager, + edgeManager, + faceManager, + targetRegionIndex, + elementSubRegion, + finiteElement, + castedConstitutiveRelation ) ); } ); } ); diff --git a/src/coreComponents/finiteElement/kernelInterface/SparsityKernelBase.hpp b/src/coreComponents/finiteElement/kernelInterface/SparsityKernelBase.hpp index ec137384c37..b9e93c5c394 100644 --- a/src/coreComponents/finiteElement/kernelInterface/SparsityKernelBase.hpp +++ b/src/coreComponents/finiteElement/kernelInterface/SparsityKernelBase.hpp @@ -171,6 +171,42 @@ class SparsityKernelBase : public ImplicitKernelBase< SUBREGION_TYPE, //***************************************************************************** //***************************************************************************** //***************************************************************************** + +template < typename POLICY, + typename SUBREGION_TYPE, + typename CONSTITUTIVE_TYPE, + typename FE_TYPE, + template < typename, typename, typename > class KERNEL_TEMPLATE > +real64 buildSparsityAndInvoke( localIndex const numElems, + NodeManager const & nodeManager, + EdgeManager const & edgeManager, + FaceManager const & faceManager, + localIndex const targetRegionIndex, + SUBREGION_TYPE const & elementSubRegion, + FE_TYPE const & finiteElementSpace, + CONSTITUTIVE_TYPE & inputConstitutiveType, + arrayView1d< globalIndex const > const & inputDofNumber, + globalIndex const rankOffset, + SparsityPattern< globalIndex > & inputSparsityPattern ) +{ + // this requires the underlying kernel be fully specified.. which should result in it compiling, thus sparsity needs to be jitted as well + // if we could move the numDofPerXXX out of the kernel classes and have a different mechanism to specify them without full specifying the kernel + // class we could get away without jitting the sparsity as well + using Kernel = KERNEL_TEMPLATE< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE >; + using SPARSITY_KERNEL_TYPE = SparsityKernelBase< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE, Kernel::numDofPerTestSupportPoint, Kernel::numDofPerTrialSupportPoint >; + SPARSITY_KERNEL_TYPE kernel ( nodeManager, + edgeManager, + faceManager, + targetRegionIndex, + elementSubRegion, + finiteElementSpace, + inputConstitutiveType, + inputDofNumber, + rankOffset, + inputSparsityPattern ); + return SPARSITY_KERNEL_TYPE::template kernelLaunch< POLICY, SPARSITY_KERNEL_TYPE >( numElems, kernel ); +} + /** * @brief Helper struct to define a specialization of * #::geosx::finiteElement::SparsityKernelBase that may be used to generate the sparsity pattern. @@ -180,7 +216,7 @@ class SparsityKernelBase : public ImplicitKernelBase< SUBREGION_TYPE, template< template< typename, typename, typename > class KERNEL_TEMPLATE > -class SparsityKernelFactory +class SparsityKernelDispatchTemplate { public: @@ -190,9 +226,9 @@ class SparsityKernelFactory * @param rankOffset The global rank offset. * @param inputSparsityPattern The local sparsity pattern. */ - SparsityKernelFactory( arrayView1d< globalIndex const > const & inputDofNumber, - globalIndex const rankOffset, - SparsityPattern< globalIndex > & inputSparsityPattern ): + SparsityKernelDispatchTemplate( arrayView1d< globalIndex const > const & inputDofNumber, + globalIndex const rankOffset, + SparsityPattern< globalIndex > & inputSparsityPattern ): m_inputDofNumber( inputDofNumber ), m_rankOffset( rankOffset ), m_inputSparsityPattern( inputSparsityPattern ) @@ -212,34 +248,152 @@ class SparsityKernelFactory * @param inputConstitutiveType The constitutive relation. * @return A new instance of @c SparsityKernelBase specialized for @c KERNEL_TEMPLATE. */ - template< typename SUBREGION_TYPE, typename CONSTITUTIVE_TYPE, typename FE_TYPE > - auto createKernel( NodeManager const & nodeManager, - EdgeManager const & edgeManager, - FaceManager const & faceManager, - localIndex const targetRegionIndex, - SUBREGION_TYPE const & elementSubRegion, - FE_TYPE const & finiteElementSpace, - CONSTITUTIVE_TYPE & inputConstitutiveType ) + template< typename POLICY, + typename SUBREGION_TYPE, + typename CONSTITUTIVE_TYPE, + typename FE_TYPE > + real64 invoke( localIndex const numElems, + NodeManager const & nodeManager, + EdgeManager const & edgeManager, + FaceManager const & faceManager, + localIndex const targetRegionIndex, + SUBREGION_TYPE const & elementSubRegion, + FE_TYPE const & finiteElementSpace, + CONSTITUTIVE_TYPE & inputConstitutiveType ) { - using Kernel = KERNEL_TEMPLATE< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE >; + return buildSparsityAndInvoke< POLICY, + SUBREGION_TYPE, + CONSTITUTIVE_TYPE, + FE_TYPE, + KERNEL_TEMPLATE >( numElems, + nodeManager, + edgeManager, + faceManager, + targetRegionIndex, + elementSubRegion, + finiteElementSpace, + inputConstitutiveType, + m_inputDofNumber, + m_rankOffset, + m_inputSparsityPattern ); + } + +private: + + /// The input degree of freedom numbers. + arrayView1d< globalIndex const > const & m_inputDofNumber; + /// The global rank offset. + globalIndex const m_rankOffset; + /// The local sparsity pattern. + SparsityPattern< globalIndex > & m_inputSparsityPattern; +}; + + +jitti::CompilationInfo getSparsityCompilationInfo( const string & ); + +/** + * @brief Helper struct to define a specialization of + * #::geosx::finiteElement::SparsityKernelBase that may be used to generate the sparsity pattern. + * @tparam KERNEL_TEMPLATE Templated class that defines the physics kernel. + * Most likely derives from SparsityKernelBase. + */ +template < const char * NAME, const char * HEADER > +class SparsityKernelDispatchJIT +{ +public: + + /** + * @brief Constructor. + * @param inputDofNumber An array containing the input degree of freedom numbers. + * @param rankOffset The global rank offset. + * @param inputSparsityPattern The local sparsity pattern. + */ + SparsityKernelDispatchJIT( arrayView1d< globalIndex const > const & inputDofNumber, + globalIndex const rankOffset, + SparsityPattern< globalIndex > & inputSparsityPattern ): + m_inputDofNumber( inputDofNumber ), + m_rankOffset( rankOffset ), + m_inputSparsityPattern( inputSparsityPattern ) + {} + + /** + * @brief Return a new instance of @c SparsityKernelBase specialized for @c KERNEL_TEMPLATE. + * @tparam SUBREGION_TYPE The type of of @p elementSubRegion. + * @tparam CONSTITUTIVE_TYPE The type of @p inputConstitutiveType. + * @tparam FE_TYPE The type of @p finiteElementSpace. + * @param nodeManager The node manager. + * @param edgeManager The edge manager. + * @param faceManager The face manager. + * @param targetRegionIndex The target region index. + * @param elementSubRegion The sub region on which to generate the sparsity. + * @param finiteElementSpace The finite element space. + * @param inputConstitutiveType The constitutive relation. + * @return A new instance of @c SparsityKernelBase specialized for @c KERNEL_TEMPLATE. + */ + template< typename POLICY, + typename SUBREGION_TYPE, + typename CONSTITUTIVE_TYPE, + typename FE_TYPE > + real64 invoke( localIndex const numElems, + NodeManager const & nodeManager, + EdgeManager const & edgeManager, + FaceManager const & faceManager, + localIndex const targetRegionIndex, + SUBREGION_TYPE const & elementSubRegion, + FE_TYPE const & finiteElementSpace, + CONSTITUTIVE_TYPE & inputConstitutiveType ) + { + string header( HEADER ); + jitti::CompilationInfo info = getSparsityCompilationInfo( header ); + info.templateParams = LvArray::system::demangleType< POLICY >() + ", " + + LvArray::system::demangleType< SUBREGION_TYPE >() + ", " + + LvArray::system::demangleType< CONSTITUTIVE_TYPE >() + ", " + + LvArray::system::demangleType< FE_TYPE >() + ", " + + string( NAME ); + // Unfortunately can't just decltype(&buildSparsityAndInvoke) since we can't fully specify the function template + using JIT_SPARSITY_DISPATCH = real64(*)( localIndex const, + NodeManager const &, + EdgeManager const &, + FaceManager const &, + localIndex const, + SUBREGION_TYPE const &, + FE_TYPE const &, + CONSTITUTIVE_TYPE &, + arrayView1d< globalIndex const > const &, + globalIndex const, + SparsityPattern< globalIndex > & ); + + string outputDir( STRINGIZE( JITTI_OUTPUT_DIR ) ); + outputDir += "/"; + static jitti::Cache< JIT_SPARSITY_DISPATCH > buildCache( time(NULL), outputDir ); + if ( MpiWrapper::commRank( ) == 0 ) + { + buildCache.getOrLoadOrCompile( info ); + } + MpiWrapper::barrier( ); + // check if the library with the function is available + if ( buildCache.tryGet( info ) == nullptr ) + { + // if not, refresh by reading the filesystem to find the new library on the first iteration + buildCache.refresh( ); + } + auto & jitSparsityDispatch = buildCache.getOrLoad( info ); + return jitSparsityDispatch( numElems, + nodeManager, + edgeManager, + faceManager, + targetRegionIndex, + elementSubRegion, + finiteElementSpace, + inputConstitutiveType, + m_inputDofNumber, + m_rankOffset, + m_inputSparsityPattern ); - return SparsityKernelBase< SUBREGION_TYPE, - CONSTITUTIVE_TYPE, - FE_TYPE, - Kernel::numDofPerTestSupportPoint, - Kernel::numDofPerTrialSupportPoint >( nodeManager, - edgeManager, - faceManager, - targetRegionIndex, - elementSubRegion, - finiteElementSpace, - inputConstitutiveType, - m_inputDofNumber, - m_rankOffset, - m_inputSparsityPattern ); } private: + /// The input degree of freedom numbers. arrayView1d< globalIndex const > const & m_inputDofNumber; /// The global rank offset. @@ -248,6 +402,12 @@ class SparsityKernelFactory SparsityPattern< globalIndex > & m_inputSparsityPattern; }; +#if JITTI == 1 + #define SparsityKernelDispatch SparsityKernelDispatchJIT +#else + #define SparsityKernelDispatch SparsityKernelDispatchTemplate +#endif + //***************************************************************************** //***************************************************************************** //***************************************************************************** @@ -273,9 +433,7 @@ class SparsityKernelFactory * pattern specified in the physics kernels. */ template< typename REGION_TYPE, - template< typename SUBREGION_TYPE, - typename CONSTITUTIVE_TYPE, - typename FE_TYPE > class KERNEL_TEMPLATE > + typename KERNEL_WRAPPER > static real64 fillSparsity( MeshLevel & mesh, arrayView1d< string const > const & targetRegions, @@ -286,7 +444,7 @@ real64 fillSparsity( MeshLevel & mesh, { GEOSX_MARK_FUNCTION; - SparsityKernelFactory< KERNEL_TEMPLATE > KernelFactory( inputDofNumber, rankOffset, inputSparsityPattern ); + KERNEL_WRAPPER kernelDispatch( inputDofNumber, rankOffset, inputSparsityPattern ); regionBasedKernelApplication< serialPolicy, constitutive::NullModel, @@ -294,7 +452,7 @@ real64 fillSparsity( MeshLevel & mesh, targetRegions, discretizationName, arrayView1d< string const >(), - KernelFactory ); + kernelDispatch ); return 0; } diff --git a/src/coreComponents/finiteElement/kernelInterface/kernelJIT.cpp b/src/coreComponents/finiteElement/kernelInterface/kernelJIT.cpp new file mode 100644 index 00000000000..aa6b3b473a3 --- /dev/null +++ b/src/coreComponents/finiteElement/kernelInterface/kernelJIT.cpp @@ -0,0 +1,40 @@ +#include "KernelBase.hpp" +#include "kernelJITCompileCommands.hpp" // generated by cmake / jit python script / contains needed macros + +namespace geosx +{ + namespace finiteElement + { + +#if defined( GEOSX_USE_CUDA ) + constexpr bool compilerIsNVCC = true; +#else + constexpr bool compilerIsNVCC = false; +#endif + + jitti::CompilationInfo getKernelCompilationInfo( const string & header ) + { + jitti::CompilationInfo info; + info.compileCommand = kernelJIT_COMPILE_COMMAND; + info.compilerIsNVCC = compilerIsNVCC; + info.linker = kernelJIT_LINKER; + info.linkArgs = kernelJIT_LINK_ARGS; + info.headerFile = header; + info.templateFunction = "geosx::finiteElement::buildKernelAndInvoke"; + return info; + } + + jitti::CompilationInfo getSparsityCompilationInfo( const string & header ) + { + jitti::CompilationInfo info; + info.compileCommand = kernelJIT_COMPILE_COMMAND; + info.compilerIsNVCC = compilerIsNVCC; + info.linker = kernelJIT_LINKER; + info.linkArgs = kernelJIT_LINK_ARGS; + info.headerFile = header; + info.templateFunction = "geosx::finiteElement::buildSparsityAndInvoke"; + return info; + } + } +} + diff --git a/src/coreComponents/physicsSolvers/CMakeLists.txt b/src/coreComponents/physicsSolvers/CMakeLists.txt index fe0e49b8eb8..55827a20a72 100644 --- a/src/coreComponents/physicsSolvers/CMakeLists.txt +++ b/src/coreComponents/physicsSolvers/CMakeLists.txt @@ -126,6 +126,7 @@ blt_add_library( NAME physicsSolvers SOURCES ${physicsSolvers_sources} HEADERS ${physicsSolvers_headers} DEPENDS_ON ${dependencyList} ${externalComponentDeps} + DEFINES ${JITTI_DEFINES} OBJECT ${GEOSX_BUILD_OBJ_LIBS} ) diff --git a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp index afa5f599eb4..59d3820ade3 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsKernel.hpp @@ -20,6 +20,7 @@ #define GEOSX_PHYSICSSOLVERS_MULTIPHYSICS_MULTIPHASEPOROMECHANICSKERNEL_HPP_ #include "finiteElement/kernelInterface/ImplicitKernelBase.hpp" #include "physicsSolvers/fluidFlow/CompositionalMultiphaseBase.hpp" +#include "constitutive/fluid/MultiFluidBase.hpp" namespace geosx { @@ -577,18 +578,19 @@ class Multiphase : localIndex const m_numPhases; }; -using MultiphaseKernelFactory = finiteElement::KernelFactory< Multiphase, - arrayView1d< globalIndex const > const &, - string const &, - globalIndex const, - real64 const (&)[3], - localIndex const, - localIndex const, - arrayView1d< string const > const, - CRSMatrixView< real64, globalIndex const > const &, - arrayView1d< real64 > const & >; - -} // namespace PoroelasticKernels +JITTI_DECL( multiphaseJIT, geosx::PoromechanicsKernels::Multiphase, __FILE__ ); +using MultiphaseKernelDispatch = finiteElement::KernelDispatch< JITTI_TPARAM( multiphaseJIT, geosx::PoromechanicsKernels::Multiphase ), + arrayView1d< globalIndex const > const &, + string const &, + globalIndex const, + real64 const (&)[3], + localIndex const, + localIndex const, + arrayView1d< string const > const, + CRSMatrixView< real64, globalIndex const > const &, + arrayView1d< real64 > const & >; + +} // namespace PoromechanicsKernels } // namespace geosx diff --git a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsSolver.cpp b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsSolver.cpp index 0619c251e76..9a443e736d5 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsSolver.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/MultiphasePoromechanicsSolver.cpp @@ -192,15 +192,15 @@ void MultiphasePoromechanicsSolver::assembleSystem( real64 const time_n, real64 const gravityVectorData[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( gravityVector() ); - PoromechanicsKernels::MultiphaseKernelFactory kernelFactory( displacementDofNumber, - flowDofKey, - dofManager.rankOffset(), - gravityVectorData, - numComponents, - numPhases, - m_flowSolver->fluidModelNames(), - localMatrix, - localRhs ); + PoromechanicsKernels::MultiphaseKernelDispatch kernelDispatch( displacementDofNumber, + flowDofKey, + dofManager.rankOffset(), + gravityVectorData, + numComponents, + numPhases, + m_flowSolver->fluidModelNames(), + localMatrix, + localRhs ); // Cell-based contributions m_solidSolver->getMaxForce() = @@ -211,7 +211,7 @@ void MultiphasePoromechanicsSolver::assembleSystem( real64 const time_n, targetRegionNames(), this->getDiscretizationName(), porousMaterialNames(), - kernelFactory ); + kernelDispatch ); diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsKernel.hpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsKernel.hpp index 4a1cffc23a7..ed0303e68f0 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsKernel.hpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsKernel.hpp @@ -20,6 +20,7 @@ #define GEOSX_PHYSICSSOLVERS_MULTIPHYSICS_SINGLEPHASEPOROMECHANICSKERNEL_HPP_ #include "finiteElement/kernelInterface/ImplicitKernelBase.hpp" #include "physicsSolvers/fluidFlow/SinglePhaseBase.hpp" +#include "constitutive/fluid/SingleFluidBase.hpp" namespace geosx @@ -404,16 +405,17 @@ class SinglePhase : }; -using SinglePhaseKernelFactory = finiteElement::KernelFactory< SinglePhase, - arrayView1d< globalIndex const > const &, - string const &, - globalIndex const, - CRSMatrixView< real64, globalIndex const > const &, - arrayView1d< real64 > const &, - real64 const (&)[3], - arrayView1d< string const > const >; - -} // namespace PoroelasticKernels +JITTI_DECL( singlePhaseJIT, geosx::PoromechanicsKernels::SinglePhase, __FILE__ ); +using SinglePhaseKernelDispatch = finiteElement::KernelDispatch< JITTI_TPARAM( singlePhaseJIT, geosx::PoromechanicsKernels::SinglePhase ), + arrayView1d< globalIndex const > const &, + string const &, + globalIndex const, + CRSMatrixView< real64, globalIndex const > const &, + arrayView1d< real64 > const &, + real64 const (&)[3], + arrayView1d< string const > const >; + +} // namespace PoromechanicsKernels } // namespace geosx diff --git a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolver.cpp b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolver.cpp index dadb3d54f3c..9404f5a8b28 100644 --- a/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolver.cpp +++ b/src/coreComponents/physicsSolvers/multiphysics/SinglePhasePoromechanicsSolver.cpp @@ -197,13 +197,13 @@ void SinglePhasePoromechanicsSolver::assembleSystem( real64 const time_n, real64 const gravityVectorData[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( gravityVector() ); - PoromechanicsKernels::SinglePhaseKernelFactory kernelFactory( dispDofNumber, - pDofKey, - dofManager.rankOffset(), - localMatrix, - localRhs, - gravityVectorData, - m_flowSolver->fluidModelNames() ); + PoromechanicsKernels::SinglePhaseKernelDispatch kernelDispatch( dispDofNumber, + pDofKey, + dofManager.rankOffset(), + localMatrix, + localRhs, + gravityVectorData, + m_flowSolver->fluidModelNames() ); // Cell-based contributions m_solidSolver->getMaxForce() = @@ -214,7 +214,7 @@ void SinglePhasePoromechanicsSolver::assembleSystem( real64 const time_n, targetRegionNames(), this->getDiscretizationName(), porousMaterialNames(), - kernelFactory ); + kernelDispatch ); // Face-based contributions m_flowSolver->assembleFluxTerms( time_n, dt, diff --git a/src/coreComponents/physicsSolvers/simplePDE/LaplaceFEM.cpp b/src/coreComponents/physicsSolvers/simplePDE/LaplaceFEM.cpp index 02f62c3c157..76751d87ca4 100644 --- a/src/coreComponents/physicsSolvers/simplePDE/LaplaceFEM.cpp +++ b/src/coreComponents/physicsSolvers/simplePDE/LaplaceFEM.cpp @@ -108,13 +108,13 @@ void LaplaceFEM::setupSystem( DomainPartition & domain, dofManager.numGlobalDofs(), 8*8*3 ); - finiteElement::fillSparsity< CellElementSubRegion, - LaplaceFEMKernel >( mesh, - targetRegionNames(), - this->getDiscretizationName(), - dofIndex, - dofManager.rankOffset(), - sparsityPattern ); + finiteElement::fillSparsity< CellElementSubRegion, + LaplaceSparsityDispatch >( mesh, + targetRegionNames(), + this->getDiscretizationName(), + dofIndex, + dofManager.rankOffset(), + sparsityPattern ); sparsityPattern.compress(); localMatrix.assimilate< parallelDevicePolicy<> >( std::move( sparsityPattern ) ); @@ -153,8 +153,12 @@ void LaplaceFEM::assembleSystem( real64 const GEOSX_UNUSED_PARAM( time_n ), arrayView1d< globalIndex const > const & dofIndex = nodeManager.getReference< array1d< globalIndex > >( dofKey ); + //LaplaceFEMKernelFactory kernelFactory( dofIndex, dofManager.rankOffset(), localMatrix, localRhs, m_fieldName ); + // finiteElement::KernelDispatch kernelDispatch< arrayView1d< globalIndex const > const &, + // globalIndex, CRSMatrixView< real64, globalIndex const > const &, + // arrayView1d< real64 > const &, string const & >( "geosx::LaplaceFEMKernel" ); - LaplaceFEMKernelFactory kernelFactory( dofIndex, dofManager.rankOffset(), localMatrix, localRhs, m_fieldName ); + LaplaceFEMKernelDispatch kernelDispatch( dofIndex, dofManager.rankOffset(), localMatrix, localRhs, m_fieldName ); finiteElement:: regionBasedKernelApplication< parallelDevicePolicy< 32 >, @@ -163,7 +167,7 @@ void LaplaceFEM::assembleSystem( real64 const GEOSX_UNUSED_PARAM( time_n ), targetRegionNames(), this->getDiscretizationName(), arrayView1d< string const >(), - kernelFactory ); + kernelDispatch ); } //END_SPHINX_INCLUDE_ASSEMBLY diff --git a/src/coreComponents/physicsSolvers/simplePDE/LaplaceFEMKernels.hpp b/src/coreComponents/physicsSolvers/simplePDE/LaplaceFEMKernels.hpp index e47f7b6c976..152e478c531 100644 --- a/src/coreComponents/physicsSolvers/simplePDE/LaplaceFEMKernels.hpp +++ b/src/coreComponents/physicsSolvers/simplePDE/LaplaceFEMKernels.hpp @@ -21,6 +21,7 @@ #define GEOSX_PHYSICSSOLVERS_SIMPLEPDE_LAPLACEFEMKERNELS_HPP_ #include "finiteElement/kernelInterface/ImplicitKernelBase.hpp" +#include "finiteElement/kernelInterface/SparsityKernelBase.hpp" namespace geosx { @@ -246,10 +247,16 @@ class LaplaceFEMKernel : }; /// The factory used to construct a LaplaceFEMKernel. -using LaplaceFEMKernelFactory = finiteElement::KernelFactory< LaplaceFEMKernel, - arrayView1d< globalIndex const > const &, - globalIndex, CRSMatrixView< real64, globalIndex const > const &, - arrayView1d< real64 > const &, string const & >; +JITTI_DECL( laplaceFEMKernelJIT, geosx::LaplaceFEMKernel, __FILE__ ); +using LaplaceFEMKernelDispatch = finiteElement::KernelDispatch< JITTI_TPARAM( laplaceFEMKernelJIT, geosx::LaplaceFEMKernel ), + arrayView1d< globalIndex const > const &, + globalIndex, + CRSMatrixView< real64, globalIndex const > const &, + arrayView1d< real64 > const &, + string const & >; + +using LaplaceSparsityDispatch = finiteElement::SparsityKernelDispatch< JITTI_TPARAM( laplaceFEMKernelJIT, geosx::LaplaceFEMKernel ) >; + } // namespace geosx diff --git a/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.cpp b/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.cpp index 3456ced566f..5ad2adf72c2 100644 --- a/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.cpp +++ b/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEM.cpp @@ -229,12 +229,12 @@ void PhaseFieldDamageFEM::assembleSystem( real64 const GEOSX_UNUSED_PARAM( time_ localMatrix.zero(); localRhs.zero(); - PhaseFieldDamageKernelFactory kernelFactory( dofIndex, - dofManager.rankOffset(), - localMatrix, - localRhs, - m_fieldName, - m_localDissipationOption=="Linear" ? 1 : 2 ); + PhaseFieldDamageKernelDispatch kernelDispatch( dofIndex, + dofManager.rankOffset(), + localMatrix, + localRhs, + m_fieldName, + m_localDissipationOption=="Linear" ? 1 : 2 ); finiteElement:: regionBasedKernelApplication< parallelDevicePolicy<>, @@ -243,7 +243,7 @@ void PhaseFieldDamageFEM::assembleSystem( real64 const GEOSX_UNUSED_PARAM( time_ targetRegionNames(), this->getDiscretizationName(), m_solidModelNames, - kernelFactory ); + kernelDispatch ); #else // this has your changes to the old base code matrix.zero(); rhs.zero(); diff --git a/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEMKernels.hpp b/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEMKernels.hpp index fc3472538c3..ab8ffd2d2a2 100644 --- a/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEMKernels.hpp +++ b/src/coreComponents/physicsSolvers/simplePDE/PhaseFieldDamageFEMKernels.hpp @@ -287,13 +287,14 @@ class PhaseFieldDamageKernel : }; -using PhaseFieldDamageKernelFactory = finiteElement::KernelFactory< PhaseFieldDamageKernel, - arrayView1d< globalIndex const > const &, - globalIndex, - CRSMatrixView< real64, globalIndex const > const &, - arrayView1d< real64 > const &, - string const &, - int >; +JITTI_DECL( phaseFieldDamageKernelJIT, geosx::PhaseFieldDamageKernel, __FILE__ ); +using PhaseFieldDamageKernelDispatch = finiteElement::KernelDispatch< JITTI_TPARAM( phaseFieldDamageKernelJIT, geosx::PhaseFieldDamageKernel ), + arrayView1d< globalIndex const > const &, + globalIndex, + CRSMatrixView< real64, globalIndex const > const &, + arrayView1d< real64 > const &, + string const &, + int >; } // namespace geosx diff --git a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsEFEMKernels.hpp b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsEFEMKernels.hpp index a7a2e05bd05..9d63018da23 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsEFEMKernels.hpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsEFEMKernels.hpp @@ -475,14 +475,15 @@ class QuasiStatic : }; /// The factory used to construct a QuasiStatic kernel. -using QuasiStaticFactory = finiteElement::KernelFactory< QuasiStatic, - EmbeddedSurfaceSubRegion const &, - arrayView1d< globalIndex const > const &, - arrayView1d< globalIndex const > const &, - globalIndex const, - CRSMatrixView< real64, globalIndex const > const &, - arrayView1d< real64 > const &, - real64 const (&) [3] >; +JITTI_DECL( quasiStaticJIT, geosx::SolidMechanicsEFEMKernels::QuasiStatic, __FILE__ ) +using QuasiStaticDispatch = finiteElement::KernelDispatch< JITTI_TPARAM( quasiStaticJIT, geosx::SolidMechanicsEFEMKernels::QuasiStatic ), + EmbeddedSurfaceSubRegion const &, + arrayView1d< globalIndex const > const &, + arrayView1d< globalIndex const > const &, + globalIndex const, + CRSMatrixView< real64, globalIndex const > const &, + arrayView1d< real64 > const &, + real64 const (&) [3] >; } // namespace SolidMechanicsEFEMKernels diff --git a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsEmbeddedFractures.cpp b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsEmbeddedFractures.cpp index 08240d937d9..a5d2f77bc68 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsEmbeddedFractures.cpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsEmbeddedFractures.cpp @@ -274,13 +274,13 @@ void SolidMechanicsEmbeddedFractures::assembleSystem( real64 const time, real64 const gravityVectorData[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( gravityVector() ); - SolidMechanicsEFEMKernels::QuasiStaticFactory kernelFactory( subRegion, - dispDofNumber, - jumpDofNumber, - dofManager.rankOffset(), - localMatrix, - localRhs, - gravityVectorData ); + SolidMechanicsEFEMKernels::QuasiStaticDispatch kernelDispatch( subRegion, + dispDofNumber, + jumpDofNumber, + dofManager.rankOffset(), + localMatrix, + localRhs, + gravityVectorData ); real64 maxTraction = finiteElement:: regionBasedKernelApplication @@ -290,7 +290,7 @@ void SolidMechanicsEmbeddedFractures::assembleSystem( real64 const time, targetRegionNames(), m_solidSolver->getDiscretizationName(), m_solidSolver->solidMaterialNames(), - kernelFactory ); + kernelDispatch ); GEOSX_UNUSED_VAR( maxTraction ); } diff --git a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsFiniteStrainExplicitNewmarkKernel.hpp b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsFiniteStrainExplicitNewmarkKernel.hpp index 714142db5f7..31f08983549 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsFiniteStrainExplicitNewmarkKernel.hpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsFiniteStrainExplicitNewmarkKernel.hpp @@ -200,9 +200,10 @@ class ExplicitFiniteStrain : public ExplicitSmallStrain< SUBREGION_TYPE, #undef UPDATE_STRESS /// The factory used to construct a ExplicitFiniteStrain kernel. -using ExplicitFiniteStrainFactory = finiteElement::KernelFactory< ExplicitFiniteStrain, - real64, - string const & >; +JITTI_DECL( explicitFiniteStrain, geosx::SolidMechanicsLagrangianFEMKernels::ExplicitFiniteStrain, __FILE__ ); +using ExplicitFiniteStrainDispatch = finiteElement::KernelDispatch< JITTI_TPARAM( explicitFiniteStrain, geosx::SolidMechanicsLagrangianFEMKernels::ExplicitFiniteStrain ), + real64, + string const & >; } // namespace SolidMechanicsLagrangianFEMKernels diff --git a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp index 9e5d085d4f7..79c3a2e00ec 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp @@ -267,7 +267,7 @@ real64 SolidMechanicsLagrangianFEM::explicitKernelDispatch( MeshLevel & mesh, real64 rval = 0; if( m_strainTheory==0 ) { - auto kernelFactory = SolidMechanicsLagrangianFEMKernels::ExplicitSmallStrainFactory( dt, elementListName ); + auto kernelDispatch = SolidMechanicsLagrangianFEMKernels::ExplicitSmallStrainDispatch( dt, elementListName ); rval = finiteElement:: regionBasedKernelApplication< parallelDevicePolicy< 32 >, constitutive::SolidBase, @@ -275,11 +275,11 @@ real64 SolidMechanicsLagrangianFEM::explicitKernelDispatch( MeshLevel & mesh, targetRegions, finiteElementName, constitutiveNames, - kernelFactory ); + kernelDispatch ); } else if( m_strainTheory==1 ) { - auto kernelFactory = SolidMechanicsLagrangianFEMKernels::ExplicitFiniteStrainFactory( dt, elementListName ); + auto kernelDispatch = SolidMechanicsLagrangianFEMKernels::ExplicitFiniteStrainDispatch( dt, elementListName ); rval = finiteElement:: regionBasedKernelApplication< parallelDevicePolicy< 32 >, constitutive::SolidBase, @@ -287,7 +287,7 @@ real64 SolidMechanicsLagrangianFEM::explicitKernelDispatch( MeshLevel & mesh, targetRegions, finiteElementName, constitutiveNames, - kernelFactory ); + kernelDispatch ); } else { @@ -951,23 +951,22 @@ void SolidMechanicsLagrangianFEM::setupSystem( DomainPartition & domain, } ); finiteElement:: - fillSparsity< FaceElementSubRegion, - SolidMechanicsLagrangianFEMKernels::QuasiStatic >( mesh, - allFaceElementRegions, - this->getDiscretizationName(), - dofNumber, - dofManager.rankOffset(), - sparsityPattern ); - + fillSparsity< FaceElementSubRegion, SolidMechanicsLagrangianFEMKernels::QuasiStaticSparsityDispatch > + ( mesh, + allFaceElementRegions, + this->getDiscretizationName(), + dofNumber, + dofManager.rankOffset(), + sparsityPattern ); } finiteElement:: - fillSparsity< CellElementSubRegion, - SolidMechanicsLagrangianFEMKernels::QuasiStatic >( mesh, - targetRegionNames(), - this->getDiscretizationName(), - dofNumber, - dofManager.rankOffset(), - sparsityPattern ); + fillSparsity< CellElementSubRegion, SolidMechanicsLagrangianFEMKernels::QuasiStaticSparsityDispatch > + ( mesh, + targetRegionNames(), + this->getDiscretizationName(), + dofNumber, + dofManager.rankOffset(), + sparsityPattern ); sparsityPattern.compress(); localMatrix.assimilate< parallelDevicePolicy<> >( std::move( sparsityPattern ) ); @@ -991,23 +990,23 @@ void SolidMechanicsLagrangianFEM::assembleSystem( real64 const GEOSX_UNUSED_PARA { GEOSX_UNUSED_VAR( dt ); assemblyLaunch< constitutive::SolidBase, - SolidMechanicsLagrangianFEMKernels::QuasiStaticFactory >( domain, - dofManager, - localMatrix, - localRhs ); + SolidMechanicsLagrangianFEMKernels::QuasiStaticDispatch >( domain, + dofManager, + localMatrix, + localRhs ); } else if( m_timeIntegrationOption == TimeIntegrationOption::ImplicitDynamic ) { assemblyLaunch< constitutive::SolidBase, - SolidMechanicsLagrangianFEMKernels::ImplicitNewmarkFactory >( domain, - dofManager, - localMatrix, - localRhs, - m_newmarkGamma, - m_newmarkBeta, - m_massDamping, - m_stiffnessDamping, - dt ); + SolidMechanicsLagrangianFEMKernels::ImplicitNewmarkDispatch >( domain, + dofManager, + localMatrix, + localRhs, + m_newmarkGamma, + m_newmarkBeta, + m_massDamping, + m_stiffnessDamping, + dt ); } if( getLogLevel() >= 2 ) diff --git a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainExplicitNewmarkKernel.hpp b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainExplicitNewmarkKernel.hpp index 3a480b1aed7..b12bdd3dc74 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainExplicitNewmarkKernel.hpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainExplicitNewmarkKernel.hpp @@ -340,9 +340,10 @@ class ExplicitSmallStrain : public finiteElement::KernelBase< SUBREGION_TYPE, #undef UPDATE_STRESS /// The factory used to construct a ExplicitSmallStrain kernel. -using ExplicitSmallStrainFactory = finiteElement::KernelFactory< ExplicitSmallStrain, - real64, - string const & >; +JITTI_DECL( explicitSmallStrainJIT, geosx::SolidMechanicsLagrangianFEMKernels::ExplicitSmallStrain, __FILE__ ); +using ExplicitSmallStrainDispatch = finiteElement::KernelDispatch< JITTI_TPARAM( explicitSmallStrainJIT, geosx::SolidMechanicsLagrangianFEMKernels::ExplicitSmallStrain ), + real64, + string const & >; } // namespace SolidMechanicsLagrangianFEMKernels diff --git a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainImplicitNewmarkKernel.hpp b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainImplicitNewmarkKernel.hpp index d9d968c55f8..7425da3e8f5 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainImplicitNewmarkKernel.hpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainImplicitNewmarkKernel.hpp @@ -292,17 +292,18 @@ class ImplicitNewmark : public QuasiStatic< SUBREGION_TYPE, }; /// The factory used to construct a ImplicitNewmark kernel. -using ImplicitNewmarkFactory = finiteElement::KernelFactory< ImplicitNewmark, - arrayView1d< globalIndex const > const &, - globalIndex, - CRSMatrixView< real64, globalIndex const > const &, - arrayView1d< real64 > const &, - real64 const (&)[3], - real64, - real64, - real64, - real64, - real64 >; +JITTI_DECL( implcitNewmarkJIT, geosx::SolidMechanicsLagrangianFEMKernels::ImplicitNewmark, __FILE__ ); +using ImplicitNewmarkDispatch = finiteElement::KernelDispatch< JITTI_TPARAM( implcitNewmarkJIT, geosx::SolidMechanicsLagrangianFEMKernels::ImplicitNewmark ), + arrayView1d< globalIndex const > const &, + globalIndex, + CRSMatrixView< real64, globalIndex const > const &, + arrayView1d< real64 > const &, + real64 const (&)[3], + real64, + real64, + real64, + real64, + real64 >; } // namespace SolidMechanicsLagrangianFEMKernels diff --git a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainQuasiStaticKernel.hpp b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainQuasiStaticKernel.hpp index a5fd9e9d7be..97d2b5b9478 100644 --- a/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainQuasiStaticKernel.hpp +++ b/src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsSmallStrainQuasiStaticKernel.hpp @@ -19,6 +19,7 @@ #ifndef GEOSX_PHYSICSSOLVERS_SOLIDMECHANICS_SOLIDMECHANICSSMALLSTRAINQUASISTATIC_HPP_ #define GEOSX_PHYSICSSOLVERS_SOLIDMECHANICS_SOLIDMECHANICSSMALLSTRAINQUASISTATIC_HPP_ #include "finiteElement/kernelInterface/ImplicitKernelBase.hpp" +#include "finiteElement/kernelInterface/SparsityKernelBase.hpp" namespace geosx { @@ -329,12 +330,15 @@ class QuasiStatic : }; /// The factory used to construct a QuasiStatic kernel. -using QuasiStaticFactory = finiteElement::KernelFactory< QuasiStatic, - arrayView1d< globalIndex const > const &, - globalIndex, - CRSMatrixView< real64, globalIndex const > const &, - arrayView1d< real64 > const &, - real64 const (&)[3] >; +JITTI_DECL( quasiStaticJIT, geosx::SolidMechanicsLagrangianFEMKernels::QuasiStatic, __FILE__ ); +using QuasiStaticDispatch = finiteElement::KernelDispatch< JITTI_TPARAM( quasiStaticJIT, geosx::SolidMechanicsLagrangianFEMKernels::QuasiStatic ), + arrayView1d< globalIndex const > const &, + globalIndex, + CRSMatrixView< real64, globalIndex const > const &, + arrayView1d< real64 > const &, + real64 const (&)[3] >; + +using QuasiStaticSparsityDispatch = finiteElement::SparsityKernelDispatch< JITTI_TPARAM( quasiStaticJIT, geosx::SolidMechanicsLagrangianFEMKernels::QuasiStatic ) >; } // namespace SolidMechanicsLagrangianFEMKernels