Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into jgfouca/measure_fa…
Browse files Browse the repository at this point in the history
…stilu

* origin/develop: (179 commits)
  Framework: Update `detect-mpi-comm-world` GitHub action (trilinos#12199)
  Ifpack2: fix dashboard failures in MDF unit tests (trilinos#12217)
  teuchos(cleaning): remove old type traits is_same
  Use ternary in conditionals involving is_contiguous.
  Extract diagonal blocks from a CRS matrix into separate CRS matrices
  Tpetra: Update Building.rst
  Zoltan2: fix shadow warning
  Stokhos: fix KokkosKernels trilinos#1959
  NOX: fix font in screen output
  Tpetra: fix TAFC changes for UVM enabled
  Tpetra: remove unnecessary exception test
  MueLu: remove deep_copy timers
  Tpetra: fix unit tests, eliminate more deep copies
  Tpetra: remove obsolete TAFC method
  Tpetra: merge two TAFC methods
  MueLu: update lumped diagonal code
  Tpetra: replace device type of resulting view
  Belos: Remove use of hardcoded MPI_COMM_WORLD
  Stokhos: update for new KokkosSparse::spmv overloads
  Tpetra: Removing the incorrect ETI_DEVICES
  ...
  • Loading branch information
jgfouca authored and sebrowne committed Sep 11, 2023
2 parents 3d15ed1 + 0131a63 commit 81ccf43
Show file tree
Hide file tree
Showing 1,723 changed files with 12,305 additions and 406,930 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/detect-mpi-comm-world.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Check MPI_COMM_WORLD

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Search for MPI_COMM_WORLD in modified lines
run: |
python $GITHUB_WORKSPACE/commonTools/test/utilities/check-mpi-comm-world-usage.py \
--base origin/${{ github.event.pull_request.base.ref }} \
--head ${{ github.event.pull_request.head.sha }}
13 changes: 6 additions & 7 deletions commonTools/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ ENDFUNCTION()


set(ALL_TOPLEVEL_PACKAGES_REGEX
"TrilinosFrameworkTests TrilinosATDMConfigTests .*Kokkos Teuchos KokkosKernels .*EpetraExt Tpetra .*Domi Thyra .*SEACAS .*Teko Intrepid .*MueLu .*ShyLU_DD ShyLU .*Tempus Stokhos ROL Piro Panzer Adelus TrilinosCouplings Pike TrilinosBuildStats TrilinosInstallTests")

"TrilinosFrameworkTests TrilinosATDMConfigTests .*Kokkos Teuchos KokkosKernels .*EpetraExt Tpetra .*Thyra .*SEACAS .*Teko Intrepid .*MueLu .*ShyLU_DD ShyLU .*Tempus Stokhos ROL Piro Panzer Adelus TrilinosCouplings TrilinosBuildStats TrilinosInstallTests")

create_get_changed_trilinos_packages_test(ProjectsList_TeuchosCore
"ProjectsList.cmake\npackages/teuchos/core/CMakeLists.txt"
Expand All @@ -146,8 +145,8 @@ create_get_changed_trilinos_packages_test(ProjectsList_TeuchosCore
# The above test ensures that it can detect global build files as well as
# package files. Above, we check several of the parent packages in Trilinos
# and we want to ensure that no subpackages are listed in the array
# CTEST_LABELS_FOR_SUBPROJECTS. We also check to confirm that excluded
# packages TriKota and PyTrilinos are excluded. To do that, we list non EX
# CTEST_LABELS_FOR_SUBPROJECTS. We also check to confirm that
# PyTrilinos is excluded. To do that, we list non EX
# packages before and after them as they currently appear in the
# Trilinos/PackagesList.cmake file. If the PackagesList.cmake file changes,
# then this test may have to change to accomidate that. Therefore, we don't
Expand All @@ -166,9 +165,9 @@ create_get_changed_trilinos_packages_test(cmake_std_atdm_TeuchosCore_PyTrilinos_
# get enabled (but excluded ST package PyTrilinos does not get included).


create_get_changed_trilinos_packages_test(TeuchosCore_TriKota_NewPackage_Pliris
"packages/teuchos/core/CMakeLists.txt\npackages/TriKota/anything\npackages/new_package/anything\npackages/pliris/a.txt"
"TeuchosCore,TriKota,NewPackage,Pliris"
create_get_changed_trilinos_packages_test(TeuchosCore_NewPackage_Pliris
"packages/teuchos/core/CMakeLists.txt\npackages/new_package/anything\npackages/pliris/a.txt"
"TeuchosCore,NewPackage,Pliris"
"TeuchosCore,Pliris"
"Setting Trilinos_ENABLE_TeuchosCore = ON;Setting Trilinos_ENABLE_Pliris = ON"
"${ALL_TOPLEVEL_PACKAGES_REGEX}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ test_trilinos_filter_packages_to_test() {
filtered_packages=$(trilinos_filter_packages_to_test "Teuchos,Tpetra,PyTrilinos,Panzer")
${_ASSERT_EQUALS_} "${filtered_packages}" "Teuchos,Tpetra,PyTrilinos,Panzer"

filtered_packages=$(trilinos_filter_packages_to_test "TriKota,Teuchos,Tpetra,PyTrilinos,Panzer")
${_ASSERT_EQUALS_} "${filtered_packages}" "TriKota,Teuchos,Tpetra,PyTrilinos,Panzer"
filtered_packages=$(trilinos_filter_packages_to_test "Teuchos,Tpetra,PyTrilinos,Panzer")
${_ASSERT_EQUALS_} "${filtered_packages}" "Teuchos,Tpetra,PyTrilinos,Panzer"

TRILINOS_EXCLUDE_PACKAGES_FROM_PR_TESTING=(TriKota PyTrilinos)
TRILINOS_EXCLUDE_PACKAGES_FROM_PR_TESTING=(PyTrilinos)

filtered_packages=$(trilinos_filter_packages_to_test "")
assertEquals "${filtered_packages}" ""
Expand All @@ -123,7 +123,7 @@ test_trilinos_filter_packages_to_test() {
filtered_packages=$(trilinos_filter_packages_to_test "Teuchos,Tpetra,PyTrilinos,Panzer")
${_ASSERT_EQUALS_} "${filtered_packages}" "Teuchos,Tpetra,Panzer"

filtered_packages=$(trilinos_filter_packages_to_test "TriKota,Teuchos,Tpetra,PyTrilinos,Panzer")
filtered_packages=$(trilinos_filter_packages_to_test "Teuchos,Tpetra,PyTrilinos,Panzer")
${_ASSERT_EQUALS_} "${filtered_packages}" "Teuchos,Tpetra,Panzer"

}
Expand All @@ -139,7 +139,6 @@ test_trilinos_filter_packages_to_test() {
assertContains "${all_toplevel_packages}" ",TrilinosATDMConfigTests,"
assertContains "${all_toplevel_packages}" ",Teuchos,"
assertContains "${all_toplevel_packages}" ",Tpetra,"
assertContains "${all_toplevel_packages}" ",TriKota,"
assertContains "${all_toplevel_packages}" ",PyTrilinos,"
assertContains "${all_toplevel_packages}" ",NewPackage,"
assertContains "${all_toplevel_packages}" ",Panzer,"
Expand Down
5 changes: 1 addition & 4 deletions commonTools/framework/get-changed-trilinos-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
# A) Data that may change
#

TRILINOS_EXCLUDE_PACKAGES_FROM_PR_TESTING=(
TriKota
PyTrilinos
)
TRILINOS_EXCLUDE_PACKAGES_FROM_PR_TESTING=(PyTrilinos)


#
Expand Down
128 changes: 128 additions & 0 deletions commonTools/test/utilities/check-mpi-comm-world-usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import sys
import subprocess
import re
import argparse


def parse_diff_output(changed_files):
# Regex to capture filename and the line numbers of the changes
file_pattern = re.compile(r"^\+\+\+ b/(.*?)$", re.MULTILINE)
line_pattern = re.compile(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@", re.MULTILINE)

files = {}
for match in file_pattern.finditer(changed_files):
file_name = match.group(1)

# Filtering for C/C++ files and excluding certain directories
if file_name.endswith((".c", ".cpp", ".h", ".hpp")) and all(
excluded not in file_name
for excluded in [
"doc/",
"test_utils/",
"test/",
"tests/",
"unit_test",
"perf_test",
"example/",
"examples/",
]
):
# Find the lines that changed for this file
lines_start_at = match.end()
next_file_match = file_pattern.search(changed_files, pos=match.span(0)[1])

# Slice out the part of the diff that pertains to this file
file_diff = changed_files[
lines_start_at : next_file_match.span(0)[0] if next_file_match else None
]

# Extract line numbers of the changes
changed_lines = []
for line_match in line_pattern.finditer(file_diff):
start_line = int(line_match.group(1))
num_lines = int(line_match.group(2) or 1)

# The start and end positions for this chunk of diff
chunk_start = line_match.end()
next_chunk = line_pattern.search(file_diff, pos=line_match.span(0)[1])
chunk_diff = file_diff[
chunk_start : next_chunk.span(0)[0] if next_chunk else None
]

lines = chunk_diff.splitlines()
line_counter = 0
for line in lines:
if line.startswith("+"):
if (
"MPI_COMM_WORLD" in line
and not "CHECK: ALLOW MPI_COMM_WORLD" in line
):
# Only include lines where "MPI_COMM_WORLD" is added
# and "CHECK: ALLOW MPI_COMM_WORLD" is not present
changed_lines.append(start_line + line_counter)

line_counter += 1

if changed_lines:
files[file_name] = changed_lines

return files


def get_common_ancestor(target_branch, feature_branch):
cmd = ["git", "merge-base", target_branch, feature_branch]
return subprocess.check_output(cmd).decode("utf-8").strip()


def get_changed_files(target_branch, feature_branch):
"""Get a dictionary of files and their changed lines between the common ancestor and feature_branch."""
start_commit = get_common_ancestor(target_branch, feature_branch)
cmd = [
"git",
"diff",
"-U0",
"--ignore-all-space",
start_commit,
feature_branch
]
result = subprocess.check_output(cmd).decode("utf-8")

return parse_diff_output(result)


def print_occurences(changed_files, title):
print(title)
for file_name, lines in changed_files.items():
print("-----")
print(f"File: {file_name}")
print("Changed Lines:", ", ".join(map(str, lines)))
print("-----")


if __name__ == "__main__":
parser = argparse.ArgumentParser()

parser.add_argument(
"--base", default="origin/develop", help="BASE commit (default: %(default)s)"
)
parser.add_argument(
"--head", default="HEAD", help="HEAD commit (default: %(default)s)"
)

start_commit = parser.parse_args().base
print(f"Start commit: {start_commit}")

end_commit = parser.parse_args().head
print(f"End commit: {end_commit}")

mpi_comm_world_detected = get_changed_files(start_commit, end_commit)

if mpi_comm_world_detected:
print_occurences(
mpi_comm_world_detected, "Detected MPI_COMM_WORLD in the following files:"
)

sys.exit(1) # Exit with an error code to fail the GitHub Action
else:
print("No addition of MPI_COMM_WORLD detected.")
sys.exit(0)
1 change: 0 additions & 1 deletion packages/TriKota/.gitignore

This file was deleted.

139 changes: 0 additions & 139 deletions packages/TriKota/CMakeLists.txt

This file was deleted.

19 changes: 0 additions & 19 deletions packages/TriKota/README.CMAKE_CONFIG

This file was deleted.

Loading

0 comments on commit 81ccf43

Please sign in to comment.