Skip to content

Conversation

@cwpearson
Copy link
Collaborator

@cwpearson cwpearson commented Jun 17, 2025

Add the machinery TriBITS needs to treat Kokkos Comm as a Trilinos package.

  • Trilinos build instructions in docs
  • (optional, non-blocking) Trilinos integration PR test

The idea is you will be able to link kokkos-comm into the Trilinos packages directory

ln -s $(realpath kokkos-comm) $(realpath Trilinos)/packages/kokkos-comm

And configure Trilinos with

  -DTPL_ENABLE_MPI=ON \
  -DTrilinos_ENABLE_KokkosComm=ON \

I am definitely not a TriBITS expert.

Patch needed on top of Trilinos f532ad8d3c49fa5143138b365bf04473b4ab2a27
diff --git a/PackagesList.cmake b/PackagesList.cmake
index 948854bb8f3..d66e66843a1 100644
--- a/PackagesList.cmake
+++ b/PackagesList.cmake
@@ -26,6 +26,7 @@ TRIBITS_REPOSITORY_DEFINE_PACKAGES(
   Shards                packages/shards                   PT
   Triutils              packages/triutils                 ST
   EpetraExt             packages/epetraext                ST
+  KokkosComm            packages/kokkos-comm              EX
   Tpetra                packages/tpetra                   PT
   TrilinosSS            packages/common/auxiliarySoftware/SuiteSparse PT # Auxiliary software.
   Domi                  packages/domi                     PT
@@ -121,6 +122,7 @@ TRIBITS_ALLOW_MISSING_EXTERNAL_PACKAGES(xSDKTrilinos)
 TRIBITS_ALLOW_MISSING_EXTERNAL_PACKAGES(SGM)
 TRIBITS_ALLOW_MISSING_EXTERNAL_PACKAGES(UMR)
 TRIBITS_ALLOW_MISSING_EXTERNAL_PACKAGES(TrilinosLinearSolvers)
+TRIBITS_ALLOW_MISSING_EXTERNAL_PACKAGES(KokkosComm)
 
 # TRILFRAME-500
 TRIBITS_ALLOW_MISSING_EXTERNAL_PACKAGES(Rythmos)    # 27115 targets
diff --git a/packages/tpetra/CMakeLists.txt b/packages/tpetra/CMakeLists.txt
index c71af6269c2..cd2f3997dc2 100644
--- a/packages/tpetra/CMakeLists.txt
+++ b/packages/tpetra/CMakeLists.txt
@@ -816,6 +816,21 @@ IF (NOT DEFINED ${PACKAGE_NAME}_ENABLE_mpi_advance)
 ENDIF ()
 ASSERT_DEFINED (${PACKAGE_NAME}_ENABLE_mpi_advance)
 
+# ============================================================
+# Kokkos Comm
+# ============================================================
+
+IF (NOT DEFINED ${PACKAGE_NAME}_ENABLE_KokkosComm)
+  IF (DEFINED TpetraCore_ENABLE_KokkosComm)
+    SET (${PACKAGE_NAME}_ENABLE_KokkosComm "${TpetraCore_ENABLE_KokkosComm}")
+  ELSEIF (DEFINED TPL_ENABLE_KokkosComm)
+    SET (${PACKAGE_NAME}_ENABLE_KokkosComm "${TPL_ENABLE_KokkosComm}")
+  ELSE ()
+    SET (${PACKAGE_NAME}_ENABLE_KokkosComm OFF)
+  ENDIF ()
+ENDIF ()
+ASSERT_DEFINED (${PACKAGE_NAME}_ENABLE_KokkosComm)
+
 # ============================================================
 # Scalar types
 # ============================================================
diff --git a/packages/tpetra/core/cmake/Dependencies.cmake b/packages/tpetra/core/cmake/Dependencies.cmake
index 7f483312feb..26ab5564275 100644
--- a/packages/tpetra/core/cmake/Dependencies.cmake
+++ b/packages/tpetra/core/cmake/Dependencies.cmake
@@ -1,5 +1,5 @@
 TRIBITS_PACKAGE_DEFINE_DEPENDENCIES(
   LIB_REQUIRED_PACKAGES Teuchos Kokkos TeuchosKokkosCompat TeuchosKokkosComm KokkosKernels
-  LIB_OPTIONAL_PACKAGES Epetra TpetraTSQR TeuchosNumerics
+  LIB_OPTIONAL_PACKAGES Epetra TpetraTSQR TeuchosNumerics KokkosComm
   LIB_OPTIONAL_TPLS MPI CUDA QD quadmath mpi_advance
 )
diff --git a/packages/tpetra/core/cmake/TpetraCore_config.h.in b/packages/tpetra/core/cmake/TpetraCore_config.h.in
index f2980a394ff..a66977670f3 100644
--- a/packages/tpetra/core/cmake/TpetraCore_config.h.in
+++ b/packages/tpetra/core/cmake/TpetraCore_config.h.in
@@ -34,6 +34,9 @@
 /* Determine if we have the mpi_advance TPL */
 #cmakedefine HAVE_TPETRACORE_MPI_ADVANCE
 
+/* Determine if we have the KokkosComm TPL */
+#cmakedefine HAVE_TPETRACORE_KOKKOSCOMM
+
 /* Determine if we have QD */
 #cmakedefine HAVE_TPETRACORE_QD
 #ifdef HAVE_TPETRACORE_QD
diff --git a/packages/tpetra/core/test/CMakeLists.txt b/packages/tpetra/core/test/CMakeLists.txt
index a53e978403c..3ae1934874f 100644
--- a/packages/tpetra/core/test/CMakeLists.txt
+++ b/packages/tpetra/core/test/CMakeLists.txt
@@ -22,6 +22,7 @@ ADD_SUBDIRECTORIES(
   ImportExport
   ImportExport2
   inout
+  KokkosComm
   LinearProblem
   Map
   MatrixMatrix
diff --git a/packages/tpetra/core/test/KokkosComm/CMakeLists.txt b/packages/tpetra/core/test/KokkosComm/CMakeLists.txt
new file mode 100644
index 00000000000..6e55de9b502
--- /dev/null
+++ b/packages/tpetra/core/test/KokkosComm/CMakeLists.txt
@@ -0,0 +1,11 @@
+TRIBITS_SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
+IF (${PACKAGE_NAME}_ENABLE_KokkosComm)
+
+  TRIBITS_ADD_EXECUTABLE_AND_TEST(
+    KokkosComm_include
+    SOURCES
+      KokkosComm_include.cpp
+    STANDARD_PASS_OUTPUT
+    )
+ENDIF()
\ No newline at end of file
diff --git a/packages/tpetra/core/test/KokkosComm/KokkosComm_include.cpp b/packages/tpetra/core/test/KokkosComm/KokkosComm_include.cpp
new file mode 100644
index 00000000000..d9d90e9a717
--- /dev/null
+++ b/packages/tpetra/core/test/KokkosComm/KokkosComm_include.cpp
@@ -0,0 +1,15 @@
+// @HEADER
+// *****************************************************************************
+//          Tpetra: Templated Linear Algebra Services Package
+//
+// Copyright 2008 NTESS and the Tpetra contributors.
+// SPDX-License-Identifier: BSD-3-Clause
+// *****************************************************************************
+// @HEADER
+
+#include <KokkosComm/KokkosComm.hpp>
+
+int main(int argc, char* argv[])
+{
+  return 0;
+}
\ No newline at end of file

@cwpearson cwpearson marked this pull request as ready for review June 18, 2025 18:14
@cwpearson cwpearson force-pushed the feature/trilinos-package branch 4 times, most recently from 1db1b13 to 8721f3e Compare June 18, 2025 19:06
@cwpearson cwpearson added the SNL-CI-SPECIAL-APPROVAL Needed for changes to `.github` to run at SNL label Jun 18, 2025
@cwpearson cwpearson force-pushed the feature/trilinos-package branch 3 times, most recently from 09cb752 to 6616734 Compare June 18, 2025 19:20
@cwpearson cwpearson requested a review from nicoleavans June 18, 2025 19:20
@cwpearson cwpearson assigned cwpearson and unassigned cwpearson and nicoleavans Jun 18, 2025
nicoleavans
nicoleavans previously approved these changes Jun 18, 2025
Copy link
Contributor

@nicoleavans nicoleavans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me as discussed prior, though it's important to point out I'm unfamiliar with tribits.

@cwpearson cwpearson force-pushed the feature/trilinos-package branch from 95c8deb to fe68e54 Compare June 18, 2025 19:50
@cwpearson
Copy link
Collaborator Author

cwpearson commented Jun 18, 2025

@nicoleavans could you please try following along with the instructions this PR adds to the docs in combination with trilinos/Trilinos#14135 and see if it seems to work together for you?

Copy link
Member

@cedricchevalier19 cedricchevalier19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK.

Comment on lines +168 to +173
# install(
# TARGETS KokkosComm_all_libs
# EXPORT KokkosCommTargets
# COMPONENT KokkosComm
# )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# install(
# TARGETS KokkosComm_all_libs
# EXPORT KokkosCommTargets
# COMPONENT KokkosComm
# )

Comment on lines +129 to +145
install(
TARGETS KokkosComm KokkosCommFlags
EXPORT KokkosComm
FILE_SET
kokkoscomm_public_headers
FILE_SET
kokkoscomm_impl_headers
FILE_SET
kokkoscomm_mpi_headers
FILE_SET
kokkoscomm_mpi_impl_headers
FILE_SET
kokkoscomm_config_headers
COMPONENT
KokkosComm
)

Copy link
Collaborator

@dssgabriel dssgabriel Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the COMPONENT KokkosComm lines, this section looks to be duplicated from the one below (lines 146-154). I can't seem to highlight the full line range in this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SNL-CI-SPECIAL-APPROVAL Needed for changes to `.github` to run at SNL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants