Skip to content

Commit

Permalink
merged development
Browse files Browse the repository at this point in the history
  • Loading branch information
simonguichandut committed Jan 9, 2024
2 parents 4f1e2e9 + 518b421 commit 79de33f
Show file tree
Hide file tree
Showing 142 changed files with 183,412 additions and 48,691 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/burn_cell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
burn_cell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/burn_cell_primordial_chem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/burn_cell_sdc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
burn_cell_sdc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/c-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
cpp-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -34,13 +34,13 @@ jobs:
cppcheck_options: '-U_OPENMP -UAMREX_USE_GPU -UAMREX_USE_CUDA -UAMREX_USE_HIP -U_MSC_VER'

- name: Archive clang tidy report
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: clang-tidy-report
path: clang-tidy-report.txt

- name: Archive cppcheck report
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: cppcheck-report
path: cppcheck-report.txt
85 changes: 85 additions & 0 deletions .github/workflows/castro-development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Castro development

on: [push, pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-apps-dev
cancel-in-progress: true

jobs:
castro-development:
name: Castro development
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Castro
uses: actions/checkout@v4
with:
repository: 'AMReX-Astro/Castro'
ref: development
path: 'Castro'
- name: Download AMReX
uses: actions/checkout@v4
with:
repository: 'AMReX-Codes/amrex'
ref: development
path: 'amrex'
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_ccache.sh
- name: Set Up Cache
uses: actions/cache@v3
with:
path: ~/.cache/ccache
key: ccache-${{ github.workflow }}-${{ github.job }}-git-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-git-
- name: Build flame_wave
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=75M
export CCACHE_LOGFILE=${{ github.workspace }}/ccache.log.txt
ccache -z
export AMREX_HOME=${PWD}/amrex
export MICROPHYSICS_HOME=${PWD}
cd Castro/Exec/science/flame_wave/
make -j2 CCACHE=ccache USE_MPI=FALSE
ccache -s
du -hs ~/.cache/ccache
- name: Build subchandra
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=75M
export CCACHE_LOGFILE=${{ github.workspace }}/ccache.log.txt
ccache -z
export AMREX_HOME=${PWD}/amrex
export MICROPHYSICS_HOME=${PWD}
cd Castro/Exec/science/subchandra/
make -j2 CCACHE=ccache USE_MPI=FALSE
ccache -s
du -hs ~/.cache/ccache
save_pr_number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v3
with:
name: pr_number
path: pr_number.txt
retention-days: 1
6 changes: 3 additions & 3 deletions .github/workflows/castro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ jobs:
name: Castro
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get Latest Release Tag
run: |
AMREX_TAG=$(wget https://github.com/AMReX-Codes/amrex/releases/latest 2>&1 | grep Location: | awk '{print $2}' | awk -F/ '{print $NF}')
echo "AMREX_TAG=$AMREX_TAG" >> $GITHUB_ENV
- name: Download Castro
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: 'AMReX-Astro/Castro'
ref: development
path: 'Castro'
- name: Download AMReX
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: 'AMReX-Codes/amrex'
ref: ${{env.AMREX_TAG}}
Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/check-ifdefs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Cache pip
uses: actions/cache@v3
with:
# this path is specific to Ubuntu
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
python-version: '3.11'

- name: Run check-ifdefs
run: |
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/check_powi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import subprocess
import sys
import os
import re


def pow_to_powi(text):
# Finds all possible std::pow(x, n) or gcem::pow(x, n)
# where n is a potential integer to amrex::Math::powi<n>(x)

# Check for all positive and negative integer, whole float numbers
# with and without _rt
match_pattern = r"([^,]+),\s*(-?(?:\d+\.0*_rt?|\d))"

# Match fails when there is a nested pow, so only inner most pow is matched
negate_pattern = r"(?![\s\S]*(?:std|gcem)::pow\((?:[^,]+),\s*(?:-?(?:\d+\.0*_rt?|\d))\))"

# Final pattern
pattern = rf"(?:std|gcem)::pow\({negate_pattern}{match_pattern}\)"
# pattern = rf"(?:std|gcem)::pow\((?![\s\S]*(?:std|gcem)::pow\((?:[^,]+),\s*(?:-?(?:\d+\.0*_rt?|\d))\))([^,]+),\s*(-?(?:\d+\.0*_rt?|\d))\)"

def replacement(match):
x = match.group(1)
n = match.group(2)

# Only extracts out the integer part before decimal point
n = n.split('.')[0] if '.' in n else n
return f"amrex::Math::powi<{n}>({x})"

text = re.sub(pattern, replacement, text)
return text

def process_content(dir_path):
# This function processes all text in the given directory
for root, dirs, filenames in os.walk(dir_path):
for filename in filenames:
if filename.endswith(".H") or filename.endswith(".cpp"):
filepath = os.path.join(root, filename)

with open(filepath, 'r') as file:
old_content = file.read()

# Iterate over content until content is the same
# This is used to get rid of potential nested pow
new_content = pow_to_powi(old_content)
while new_content != old_content:
old_content = new_content
new_content = pow_to_powi(old_content)

with open(filepath, 'w') as file:
file.write(new_content)

def git_diff():
# Run git diff to see if there are any changes made

git_diff_output = subprocess.run(['git', 'diff', '--color=always'],
capture_output=True, text=True)

# Print out suggested change and raise error after detecting modification
if git_diff_output.stdout:
print("Detected potential usage to replace std::pow" +
"with integer powers via amrex::Math::powi\n")
print("Below are the suggested change:\n")
print(git_diff_output.stdout)

raise RuntimeError("Changes detected after modification")

if __name__ == '__main__':

# Get directory paths
directory_paths = sys.argv[1:]

# Modify the std::pow -> amrex::Math::powi if needed
for dir_path in directory_paths:
process_content(dir_path)

# Give suggested change if there are any modifications made
git_diff()
37 changes: 37 additions & 0 deletions .github/workflows/check_powi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: check powi

on:
push:
branches:
- development
- main
pull_request:
branches:
- development

jobs:
check-ifdefs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Cache pip
uses: actions/cache@v3
with:
# this path is specific to Ubuntu
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Run check_powi
run: |
python .github/workflows/check_powi.py .
2 changes: 1 addition & 1 deletion .github/workflows/cmake_build_cell_primordial_chem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
burn_cell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Cache pip
uses: actions/cache@v3
with:
# this path is specific to Ubuntu
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
python-version: '3.11'
cache: "pip"

- name: Install dependencies
run: pip install codespell
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/compile_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
compilation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -28,4 +28,4 @@ jobs:
- name: Compile problems
run: |
python3 .github/workflows/find_changed_files.py ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
python3 .github/workflows/find_changed_files.py ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
2 changes: 1 addition & 1 deletion .github/workflows/compiler-warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
compiler_warnings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get the version
id: get_version
Expand All @@ -33,4 +33,4 @@ jobs:
release_name: Release ${{ github.ref }}
body: ${{ env.RELEASE_TXT }}
draft: false
prerelease: false
prerelease: false
2 changes: 1 addition & 1 deletion .github/workflows/cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: CUDA@11.7 GCC
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Get AMReX
run: |
Expand Down
Loading

0 comments on commit 79de33f

Please sign in to comment.