Skip to content

Commit

Permalink
Merge Pull Request #13185 from kuberry/Trilinos/compadre_v159
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: b'Update Compadre to version 1.5.9'
PR Author: kuberry
  • Loading branch information
trilinos-autotester authored Jul 1, 2024
2 parents 795e2d1 + 6e37e22 commit bd7c4f7
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 25 deletions.
45 changes: 29 additions & 16 deletions packages/compadre/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ else() # Raw CMake Project

PROJECT(Compadre VERSION ${Compadre_VERSION} LANGUAGES CXX)
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
Expand Down Expand Up @@ -133,6 +133,17 @@ else() # Raw CMake Project
#
# TPLS
#
# Three choices for providing TPLs:
#
# a.) None
# - Trilinos_PREFIX, KokkosCore_PREFIX, and KokkosKernels_PREFIX
# not specified
# b.) Trilinos installation with Kokkos AND KokkosKernels
# - Trilinos_PREFIX specified
# c.) Kokkos AND KokkosKernels standalone installations
# - KokkosCore_PREFIX and KokkosKernels_PREFIX specified
#
# For option a, vendored Kokkos and KokkosKernels built for user
#
##########

Expand Down Expand Up @@ -173,7 +184,7 @@ else() # Raw CMake Project
set(KOKKOS_MIN "3.3.01")

if (Trilinos_PREFIX)
FIND_PACKAGE(Trilinos)
FIND_PACKAGE(Trilinos COMPONENTS Kokkos KokkosKernels OPTIONAL_COMPONENTS Gtest)

LIST(REVERSE Trilinos_INCLUDE_DIRS)
LIST(REMOVE_DUPLICATES Trilinos_INCLUDE_DIRS)
Expand Down Expand Up @@ -209,13 +220,17 @@ else() # Raw CMake Project
MESSAGE(" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS}")
MESSAGE(" Trilinos_CXX_FLAGS = ${Trilinos_CXX_COMPILER_FLAGS}")

LIST(FIND Trilinos_PACKAGE_LIST KokkosCore KokkosCoreID)
IF (KokkosCoreID GREATER -1 )
MESSAGE(STATUS "Found KokkosCore inside Trilinos!")
IF (Trilinos_VERSION VERSION_GREATER_EQUAL "14.1")
set(CompadreKokkosPackageName "Kokkos")
ELSE ()
set(CompadreKokkosPackageName "KokkosCore")
ENDIF()
LIST(FIND Trilinos_PACKAGE_LIST ${CompadreKokkosPackageName} ${CompadreKokkosPackageName}ID)
IF (${CompadreKokkosPackageName}ID GREATER -1 )
MESSAGE(STATUS "Found ${CompadreKokkosPackageName} inside Trilinos!")
set(KOKKOS_IN_TRILINOS ON)
set(KokkosCore_FOUND ON)
ELSE()
MESSAGE(FATAL_ERROR "Found Trilinos but could not find KokkosCore.")
MESSAGE(FATAL_ERROR "Found Trilinos but could not find ${CompadreKokkosPackageName}.")
ENDIF()

LIST(FIND Trilinos_PACKAGE_LIST KokkosKernels KokkosKernelsID)
Expand All @@ -227,21 +242,19 @@ else() # Raw CMake Project
MESSAGE(FATAL_ERROR "Found Trilinos but could not find KokkosKernels.")
ENDIF()

LIST(FIND Trilinos_PACKAGE_LIST Gtest GtestID)

if(KOKKOS_IN_TRILINOS AND NOT(KOKKOSKERNELS_IN_TRILINOS))
MESSAGE(FATAL_ERROR "Kokkos found in Trilinos, but not KokkosKernels")
endif()

# Detect KokkosCore functionality from Trilinos
include(${CMAKE_CURRENT_LIST_DIR}/cmake/detect_kokkos_opts.cmake)
# cmake/detect_kokkos_opts.cmake populates KokkosCore_HAS_*
detect_kokkos_opts()

# get kokkos settings, change our settings, error to user if we something they requested is not enabled
if (KokkosCore_HAS_CUDA)
if (NOT KokkosCore_HAS_CUDA_LAMBDA)
# Check that CUDA_LAMBDA is enabled if using CUDA in Kokkos
list(FIND Kokkos_DEVICES CUDA cuda_index)
if (NOT cuda_index EQUAL -1)
list(FIND Kokkos_OPTIONS CUDA_LAMBDA cuda_lambda_index)
if (cuda_lambda_index EQUAL -1)
message(FATAL_ERROR "Please reconfigure Trilinos with -DKokkos_ENABLE_CUDA_LAMBDA:BOOL=ON")
endif()
message(STATUS "CUDA enabled in KokkosCore in Trilinos, setting Compadre_USE_CUDA to ON")
set(Compadre_USE_CUDA ON)
endif()

Expand Down
2 changes: 1 addition & 1 deletion packages/compadre/cmake/Compadre_Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.5
1.5.9
2 changes: 2 additions & 0 deletions packages/compadre/cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ tribits_package_define_dependencies(
Kokkos KokkosKernels
LIB_OPTIONAL_TPLS
MPI CUDA
TEST_REQUIRED_PACKAGES
Gtest
)
16 changes: 11 additions & 5 deletions packages/compadre/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,20 @@ if (Compadre_EXAMPLES)
add_exe_w_compadre(NeighborSearchTest NeighborSearchTest.cpp)

if (Compadre_TESTS)

add_exe_w_compadre(UnitTests Compadre_UnitTests.cpp)
if (Trilinos_PREFIX AND Trilinos_VERSION VERSION_GREATER_EQUAL 13.5)
TARGET_LINK_LIBRARIES(UnitTests PRIVATE Gtest::all_libs)
IF (GtestID GREATER -1 )
add_exe_w_compadre(UnitTests Compadre_UnitTests.cpp)
TARGET_LINK_LIBRARIES(UnitTests PRIVATE Gtest::all_libs)
ADD_TEST(CompadreGtests UnitTests)
ELSE()
ADD_TEST(NAME CompadreGtests COMMAND ${CMAKE_COMMAND} -E echo "MISSING_GTEST")
ENDIF()
else()
add_exe_w_compadre(UnitTests Compadre_UnitTests.cpp)
TARGET_LINK_LIBRARIES(UnitTests PRIVATE gtest)
ADD_TEST(CompadreGtests UnitTests)
endif()
ADD_TEST(UnitTests UnitTests)
SET_TESTS_PROPERTIES(UnitTests PROPERTIES LABELS "UnitTest;unittest;Unit;unit")
SET_TESTS_PROPERTIES(CompadreGtests PROPERTIES SKIP_REGULAR_EXPRESSION "MISSING_GTEST" LABELS "Gtest;UnitTest;unittest;Unit;unit")

# Host views tests for GMLS
ADD_TEST(NAME GMLS_Host_Dim3_QR COMMAND ${CMAKE_CURRENT_BINARY_DIR}/GMLS_Host_Test "--p" "4" "--nt" "200" "--d" "3" "${KOKKOS_THREADS_ARG}=2")
Expand Down Expand Up @@ -223,6 +228,7 @@ if (Compadre_EXAMPLES)
if (Compadre_USE_PYTHON AND PYTHON_EXECUTABLE)
FILE(COPY "${CMAKE_CURRENT_SOURCE_DIR}/../pycompadre/examples/test_pycompadre.py" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/../pycompadre/examples")
FILE(COPY "${CMAKE_CURRENT_SOURCE_DIR}/../pycompadre/examples/test_pycompadre_manifold.py" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/../pycompadre/examples")
FILE(COPY "${CMAKE_CURRENT_SOURCE_DIR}/../pycompadre/examples/test_tangent_planes_manifold.py" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/../pycompadre/examples")
FILE(COPY "${CMAKE_CURRENT_SOURCE_DIR}/../pycompadre/examples/kokkos_test_case.py" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/../pycompadre/examples")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/Python_3D_Convergence.py.in" "${CMAKE_CURRENT_BINARY_DIR}/Python_3D_Convergence.py" @ONLY)
ADD_TEST(NAME GMLS_Python_Convergence_Test_3d_Point_Reconstruction COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/Python_3D_Convergence.py" "${KOKKOS_THREADS_ARG}=4")
Expand Down
4 changes: 3 additions & 1 deletion packages/compadre/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ elseif (KOKKOS_IN_TRILINOS) # Kokkos found in Trilinos installation
target_include_directories(compadre PUBLIC ${Trilinos_INCLUDE_DIRS})
if(Trilinos_VERSION VERSION_LESS "13.5")
target_link_libraries(compadre PUBLIC kokkoscore)
else()
elseif(Trilinos_VERSION VERSION_LESS "14.1")
target_link_libraries(compadre PUBLIC KokkosCore::all_libs)
else()
target_link_libraries(compadre PUBLIC Kokkos::all_libs)
endif()
elseif (KOKKOS_BUILT_FOR_USER) # Kokkos built for user by this project
target_link_libraries(compadre PUBLIC Kokkos::kokkoscore)
Expand Down
3 changes: 3 additions & 0 deletions packages/compadre/src/Compadre_GMLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ void GMLS::generatePolynomialCoefficients(const int number_of_batches, const boo
if (!_orthonormal_tangent_space_provided) {
_T = Kokkos::View<double*>("tangent approximation",_pc._target_coordinates.extent(0)*_dimensions*_dimensions);
Kokkos::deep_copy(_T, 0.0);
} else {
compadre_assert_release(_T.extent(0)/(_dimensions*_dimensions)==_pc._target_coordinates.extent(0) &&
"Provided tangent_directions has number of targets different than target_coordinates");
}
_manifold_curvature_coefficients = Kokkos::View<double*>("manifold curvature coefficients",
_pc._target_coordinates.extent(0)*manifold_NP);
Expand Down
19 changes: 17 additions & 2 deletions packages/compadre/src/Compadre_GMLS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,14 @@ friend class Evaluator;
// invariant to p and n
double x = std::abs(r/h);
return ((1-x)+x*(1-x)*(1-2*x)) * double(x<=1.0);
} else if (weighting_type == WeightingFunctionType::CardinalCubicBSpline) {
// compactly supported on [0,h]
// invariant to p and n
// Calculate the value using a cardinal cubic b-spline kernel (often just called cubic b spline)
double x = std::abs(r/h);
if (x < 0.5) return 1.0 + 6.0 * x * x * (-1.0 + x);
if (x < 1.0) return 2.0 * (1.0 + x * (-3.0 + 3.0 * x - 1.0 * x * x));
return 0.0;
} else if (weighting_type == WeightingFunctionType::Cosine) {
// compactly supported on [0,h]
double pi = 3.14159265358979323846;
Expand Down Expand Up @@ -1035,15 +1043,18 @@ friend class Evaluator;
// this allows for nonstrided views on the device later

// allocate memory on device
_T = decltype(_T)("device tangent directions", _pc._target_coordinates.extent(0)*_dimensions*_dimensions);
compadre_assert_release( tangent_directions.size() % (_dimensions*_dimensions) == 0 &&
"tangent_directions must have cardinality #number of targets * #dimensions * #dimensions");
auto num_targets = tangent_directions.size() / (_dimensions*_dimensions);
_T = decltype(_T)("device tangent directions", num_targets*_dimensions*_dimensions);

compadre_assert_release( (std::is_same<decltype(_T)::memory_space, typename view_type::memory_space>::value) &&
"Memory space does not match between _T and tangent_directions");

auto this_dimensions = _dimensions;
auto this_T = _T;
// rearrange data on device from data given on host
Kokkos::parallel_for("copy tangent vectors", Kokkos::RangePolicy<device_execution_space>(0, _pc._target_coordinates.extent(0)), KOKKOS_LAMBDA(const int i) {
Kokkos::parallel_for("copy tangent vectors", Kokkos::RangePolicy<device_execution_space>(0, num_targets), KOKKOS_LAMBDA(const int i) {
scratch_matrix_right_type T(this_T.data() + i*this_dimensions*this_dimensions, this_dimensions, this_dimensions);
for (int j=0; j<this_dimensions; ++j) {
for (int k=0; k<this_dimensions; ++k) {
Expand Down Expand Up @@ -1158,6 +1169,8 @@ friend class Evaluator;
_weighting_type = WeightingFunctionType::Gaussian;
} else if (wt_to_lower == "cubicspline") {
_weighting_type = WeightingFunctionType::CubicSpline;
} else if (wt_to_lower == "cardinalcubicbspline") {
_weighting_type = WeightingFunctionType::CardinalCubicBSpline;
} else if (wt_to_lower == "cosine") {
_weighting_type = WeightingFunctionType::Cosine;
} else if (wt_to_lower == "sigmoid") {
Expand Down Expand Up @@ -1185,6 +1198,8 @@ friend class Evaluator;
_curvature_weighting_type = WeightingFunctionType::Gaussian;
} else if (wt_to_lower == "cubicspline") {
_curvature_weighting_type = WeightingFunctionType::CubicSpline;
} else if (wt_to_lower == "cardinalcubicbspline") {
_curvature_weighting_type = WeightingFunctionType::CardinalCubicBSpline;
} else if (wt_to_lower == "cosine") {
_curvature_weighting_type = WeightingFunctionType::Cosine;
} else if (wt_to_lower == "sigmoid") {
Expand Down
1 change: 1 addition & 0 deletions packages/compadre/src/Compadre_Operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ namespace Compadre {
Power,
Gaussian,
CubicSpline,
CardinalCubicBSpline,
Cosine,
Sigmoid
};
Expand Down

0 comments on commit bd7c4f7

Please sign in to comment.