From 4ca110c5d4bdd5ca381acba6bed041af51b85464 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Fri, 25 Oct 2024 15:24:23 -0700 Subject: [PATCH 1/6] fixes for using shiva as submodule --- CMakeLists.txt | 13 +++++++------ cmake/shiva-config.cmake.in | 2 +- src/CMakeLists.txt | 4 ++-- src/common/CMakeLists.txt | 18 ++++++++---------- src/common/types.hpp | 2 +- src/common/unitTests/CMakeLists.txt | 3 ++- src/discretizations/CMakeLists.txt | 7 ++++--- src/functions/CMakeLists.txt | 6 ++++-- src/geometry/CMakeLists.txt | 9 ++++++--- tpl/camp | 2 +- 10 files changed, 36 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ead54c0..9183578 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ if( NOT is_submodule ) set( BLT_CXX_STD "c++17" CACHE STRING "Version of C++ standard" FORCE ) set( ENABLE_WARNINGS_AS_ERRORS "ON" CACHE PATH "" ) - option( SHIVA_ENABLE_UNIT_TESTS "Builds tests" ON ) + option( SHIVA_ENABLE_UNIT_TESTS "Builds tests" OFF ) option( SHIVA_ENABLE_EXAMPLES "Builds examples" ON ) option( SHIVA_ENABLE_BENCHMARKS "Builds benchmarks" ON ) option( SHIVA_ENABLE_DOCS "Builds documentation" ON ) @@ -57,7 +57,7 @@ if( NOT is_submodule ) #include( cmake/SetupTPL.cmake ) else() if( NOT BLT_LOADED ) - message( FATAL_ERROR "When using LvArray as a submodule you must have already loaded BLT." ) + message( FATAL_ERROR "When using Shiva as a submodule you must have already loaded BLT." ) endif() include( cmake/CMakeBasics.cmake ) endif() @@ -67,11 +67,12 @@ include( cmake/Config.cmake ) add_subdirectory( src ) +message( "PROJECT_BINARY_DIR: ${PROJECT_BINARY_DIR}" ) add_subdirectory( tpl/camp ) -target_compile_options( camp PRIVATE "-Wno-shadow") +#target_compile_options( camp PRIVATE "-Wno-shadow") -# if( SHIVA_ENABLE_DOCS ) - add_subdirectory( docs ) -# endif() +if( SHIVA_ENABLE_DOCS ) + add_subdirectory( docs ) +endif() diff --git a/cmake/shiva-config.cmake.in b/cmake/shiva-config.cmake.in index 035662e..b1cb6c3 100644 --- a/cmake/shiva-config.cmake.in +++ b/cmake/shiva-config.cmake.in @@ -1,5 +1,5 @@ if( NOT SHIVA_FOUND ) - include(${CMAKE_CURRENT_LIST_DIR}/../../../lib/cmake/shiva/shiva-targets.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/../../../lib/cmake/shiva/shiva.cmake) set(SHIVA_FOUND TRUE) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4c49f8a..ca02250 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,12 +31,12 @@ install( FILES ${shiva_headers} install( TARGETS shiva - EXPORT shiva-targets + EXPORT shiva ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib ) -install( EXPORT shiva-targets +install( EXPORT shiva DESTINATION lib/cmake/shiva ) shiva_add_code_checks( PREFIX shiva diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 395703c..ba2ea87 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -17,7 +17,7 @@ set( common_sources ) if( ENABLE_HIP ) - list( APPEND common_dependencies blt::hip ) + list( APPEND common_dependencies blt::hip camp ) endif() if( ENABLE_CUDA ) @@ -30,24 +30,22 @@ blt_add_library( NAME common DEPENDS_ON ${common_dependencies} ) + + target_include_directories( common INTERFACE $ - $ ) - -target_include_directories( common - SYSTEM INTERFACE - $ - $ ) - + $ ) install( FILES ${common_headers} DESTINATION include/common ) install( TARGETS common - EXPORT shiva-targets + EXPORT shiva ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib ) -add_subdirectory( unitTests ) +if( SHIVA_ENABLE_UNIT_TESTS ) + add_subdirectory( unitTests ) +endif() \ No newline at end of file diff --git a/src/common/types.hpp b/src/common/types.hpp index ff2afd0..48728fb 100644 --- a/src/common/types.hpp +++ b/src/common/types.hpp @@ -20,7 +20,7 @@ #include "common/ShivaMacros.hpp" /// @brief Macro to define whether or not to use camp. -#define SHIVA_USE_CAMP +//#define SHIVA_USE_CAMP #if defined(SHIVA_USE_CAMP) #include #else diff --git a/src/common/unitTests/CMakeLists.txt b/src/common/unitTests/CMakeLists.txt index db8bac0..0771ee0 100644 --- a/src/common/unitTests/CMakeLists.txt +++ b/src/common/unitTests/CMakeLists.txt @@ -27,9 +27,10 @@ foreach(test ${unit_tests_sources}) set( header ${test} ) string(REPLACE "test" "../" header ${header}) string(REPLACE ".cpp" ".hpp" header ${header}) -# message("header is ${header}") + message("header is ${header}") get_filename_component( test_name ${test} NAME_WE ) + message( "test_name is ${test_name}" ) blt_add_executable( NAME ${test_name} SOURCES ${test} HEADERS ${header} diff --git a/src/discretizations/CMakeLists.txt b/src/discretizations/CMakeLists.txt index a4c6741..03e3c80 100644 --- a/src/discretizations/CMakeLists.txt +++ b/src/discretizations/CMakeLists.txt @@ -21,10 +21,11 @@ install( FILES ${discretizations_headers} DESTINATION include/discretizations ) install( TARGETS discretizations - EXPORT shiva-targets + EXPORT shiva ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib ) - -add_subdirectory( unitTests ) +if( SHIVA_ENABLE_UNIT_TESTS ) + add_subdirectory( unitTests ) +endif() \ No newline at end of file diff --git a/src/functions/CMakeLists.txt b/src/functions/CMakeLists.txt index 2d2e73b..0c4c2ff 100644 --- a/src/functions/CMakeLists.txt +++ b/src/functions/CMakeLists.txt @@ -26,10 +26,12 @@ foreach( _header ${functions_headers} ) endforeach() install( TARGETS functions - EXPORT shiva-targets + EXPORT shiva ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib ) -add_subdirectory( unitTests ) +if( SHIVA_ENABLE_UNIT_TESTS ) + add_subdirectory( unitTests ) +endif() \ No newline at end of file diff --git a/src/geometry/CMakeLists.txt b/src/geometry/CMakeLists.txt index 10c5803..31a2380 100644 --- a/src/geometry/CMakeLists.txt +++ b/src/geometry/CMakeLists.txt @@ -33,10 +33,13 @@ endforeach() # DESTINATION include/geometry ) install( TARGETS geometry - EXPORT shiva-targets + EXPORT shiva ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib ) -add_subdirectory( mapping/unitTests ) -add_subdirectory( shapes/unitTests ) + +if( SHIVA_ENABLE_UNIT_TESTS ) + add_subdirectory( mapping/unitTests ) + add_subdirectory( shapes/unitTests ) +endif() \ No newline at end of file diff --git a/tpl/camp b/tpl/camp index ce29d32..0f07de4 160000 --- a/tpl/camp +++ b/tpl/camp @@ -1 +1 @@ -Subproject commit ce29d32b2174810bef4dd1a723cf05816520d2eb +Subproject commit 0f07de4240c42e0b38a8d872a20440cb4b33d9f5 From ed8ea35c29d6251563310c94b45c47a779161b79 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Fri, 25 Oct 2024 15:35:23 -0700 Subject: [PATCH 2/6] Apply suggestions from code review --- CMakeLists.txt | 4 ++-- src/common/unitTests/CMakeLists.txt | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9183578..68e805c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ if( NOT is_submodule ) set( BLT_CXX_STD "c++17" CACHE STRING "Version of C++ standard" FORCE ) set( ENABLE_WARNINGS_AS_ERRORS "ON" CACHE PATH "" ) - option( SHIVA_ENABLE_UNIT_TESTS "Builds tests" OFF ) + option( SHIVA_ENABLE_UNIT_TESTS "Builds tests" ON ) option( SHIVA_ENABLE_EXAMPLES "Builds examples" ON ) option( SHIVA_ENABLE_BENCHMARKS "Builds benchmarks" ON ) option( SHIVA_ENABLE_DOCS "Builds documentation" ON ) @@ -69,7 +69,7 @@ include( cmake/Config.cmake ) add_subdirectory( src ) message( "PROJECT_BINARY_DIR: ${PROJECT_BINARY_DIR}" ) add_subdirectory( tpl/camp ) -#target_compile_options( camp PRIVATE "-Wno-shadow") +target_compile_options( camp PRIVATE "-Wno-shadow") if( SHIVA_ENABLE_DOCS ) add_subdirectory( docs ) diff --git a/src/common/unitTests/CMakeLists.txt b/src/common/unitTests/CMakeLists.txt index 0771ee0..db8bac0 100644 --- a/src/common/unitTests/CMakeLists.txt +++ b/src/common/unitTests/CMakeLists.txt @@ -27,10 +27,9 @@ foreach(test ${unit_tests_sources}) set( header ${test} ) string(REPLACE "test" "../" header ${header}) string(REPLACE ".cpp" ".hpp" header ${header}) - message("header is ${header}") +# message("header is ${header}") get_filename_component( test_name ${test} NAME_WE ) - message( "test_name is ${test_name}" ) blt_add_executable( NAME ${test_name} SOURCES ${test} HEADERS ${header} From dad522b3436d7d873e41a5e70395072b4a6bf4d1 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Fri, 25 Oct 2024 16:11:21 -0700 Subject: [PATCH 3/6] put back the src include path --- src/common/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index ba2ea87..2350c90 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -35,6 +35,7 @@ blt_add_library( NAME common target_include_directories( common INTERFACE $ + $ $ ) install( FILES ${common_headers} From 9cb80936b20c47158b8199d0b40f65591fc07e8f Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Mon, 28 Oct 2024 14:03:34 -0700 Subject: [PATCH 4/6] reenable camp --- CMakeLists.txt | 1 - src/common/types.hpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68e805c..9993295 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,6 @@ include( cmake/Config.cmake ) add_subdirectory( src ) -message( "PROJECT_BINARY_DIR: ${PROJECT_BINARY_DIR}" ) add_subdirectory( tpl/camp ) target_compile_options( camp PRIVATE "-Wno-shadow") diff --git a/src/common/types.hpp b/src/common/types.hpp index 48728fb..ff2afd0 100644 --- a/src/common/types.hpp +++ b/src/common/types.hpp @@ -20,7 +20,7 @@ #include "common/ShivaMacros.hpp" /// @brief Macro to define whether or not to use camp. -//#define SHIVA_USE_CAMP +#define SHIVA_USE_CAMP #if defined(SHIVA_USE_CAMP) #include #else From f06f420e05b4a88a91d453a1d8cedade9741b8c0 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Mon, 28 Oct 2024 18:13:44 -0700 Subject: [PATCH 5/6] hack to create camp/config.hpp in the correct path when camp is a submodule --- CMakeLists.txt | 4 ++++ src/common/CMakeLists.txt | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9993295..ab43b11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,10 @@ add_subdirectory( src ) add_subdirectory( tpl/camp ) target_compile_options( camp PRIVATE "-Wno-shadow") +configure_file(tpl/camp/include/camp/config.in.hpp + ${PROJECT_BINARY_DIR}/include/camp/config.hpp) + + if( SHIVA_ENABLE_DOCS ) add_subdirectory( docs ) endif() diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 2350c90..9c684d5 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -38,6 +38,11 @@ target_include_directories( common $ $ ) +target_include_directories( common + SYSTEM INTERFACE + $ + $ ) + install( FILES ${common_headers} DESTINATION include/common ) From d3c2a8ee8c1885bc3a5e833a836302791a969d91 Mon Sep 17 00:00:00 2001 From: Randolph Settgast Date: Tue, 29 Oct 2024 11:53:43 -0700 Subject: [PATCH 6/6] fix LinearTransform::setData --- src/geometry/mapping/LinearTransform.hpp | 15 ++++++++--- .../mapping/unitTests/testLinearTransform.cpp | 26 ++++++++++--------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/geometry/mapping/LinearTransform.hpp b/src/geometry/mapping/LinearTransform.hpp index 8f1895e..c1aaa59 100644 --- a/src/geometry/mapping/LinearTransform.hpp +++ b/src/geometry/mapping/LinearTransform.hpp @@ -108,15 +108,22 @@ class LinearTransform * @brief Sets the coordinates of the vertices of the cell * @param[in] coords The coordinates of the vertices of the cell */ - constexpr SHIVA_HOST_DEVICE SHIVA_FORCE_INLINE void setData( DataType const & coords ) + template< typename T > + constexpr SHIVA_HOST_DEVICE SHIVA_FORCE_INLINE void setData( T const & coords ) { - for ( int a = 0; a < numVertices; ++a ) + + SupportIndexType index; + forRange( index = {0, 0, 0}, [&] ( auto const & aa ) { + int const a = aa.data[0]; + int const b = aa.data[1]; + int const c = aa.data[2]; + for ( int i = 0; i < numDims; ++i ) { - m_vertexCoords[a][i] = coords[a][i]; + m_vertexCoords(a,b,c,i) = coords[a + 2 * b + 4 * c][i]; } - } + }); } private: diff --git a/src/geometry/mapping/unitTests/testLinearTransform.cpp b/src/geometry/mapping/unitTests/testLinearTransform.cpp index 4b5e5f3..9e45ea3 100644 --- a/src/geometry/mapping/unitTests/testLinearTransform.cpp +++ b/src/geometry/mapping/unitTests/testLinearTransform.cpp @@ -109,21 +109,23 @@ SHIVA_HOST_DEVICE auto makeLinearTransform( REAL_TYPE const (&X)[8][3] ) LagrangeBasis< double, 1, EqualSpacing >, LagrangeBasis< double, 1, EqualSpacing > > > cell; - typename decltype(cell)::SupportIndexType index; +// typename decltype(cell)::SupportIndexType index; - auto & transformData = cell.getData(); +// auto & transformData = cell.getData(); - forRange( index = {0, 0, 0}, [&transformData, &X] ( auto const & i ) - { - int const a = i.data[0]; - int const b = i.data[1]; - int const c = i.data[2]; + cell.setData( X ); - for ( int j = 0; j < 3; ++j ) - { - transformData( a, b, c, j ) = X[ a + 2 * b + 4 * c ][j]; - } - } ); + // forRange( index = {0, 0, 0}, [&transformData, &X] ( auto const & i ) + // { + // int const a = i.data[0]; + // int const b = i.data[1]; + // int const c = i.data[2]; + + // for ( int j = 0; j < 3; ++j ) + // { + // transformData( a, b, c, j ) = X[ a + 2 * b + 4 * c ][j]; + // } + // } ); return cell; }