Skip to content

Commit

Permalink
Add Bittree CI
Browse files Browse the repository at this point in the history
Also fix some clang-tidy warnings.

Note that the 3D test does not actually work as expected. It has zero
cells. We will try to fix in the future, because it's out of the scope of
this PR adding CI.
  • Loading branch information
WeiqunZhang committed Oct 1, 2023
1 parent 8515ea8 commit 847a905
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 88 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/bittree.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: bittree

on: [push, pull_request]

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

jobs:
bittree-2d:
name: Bittree 2D
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 15
.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: Check out Bittree
uses: actions/checkout@v4
with:
repository: Flash-X/Bittree
path: bittree
- name: Build Bittree
run: |
cd ${{ github.workspace }}/bittree
python setup.py library --dim 2 --prefix ${{ github.workspace }}/libbittree
cd build
make -j2
make install
- name: Build and Run Test
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=80M
export CCACHE_EXTRAFILES=${{ github.workspace }}/.clang-tidy
export CCACHE_LOGFILE=${{ github.workspace }}/ccache.log.txt
ccache -z
export AMREX_BITTREE_HOME=${{ github.workspace }}/libbittree
cd ${{ github.workspace }}/Tests/Amr/Advection_AmrCore/Exec
make -j2 USE_MPI=TRUE USE_BITTREE=TRUE DIM=2 TEST=TRUE \
CCACHE=ccache
mpiexec -n 2 ./main2d.gnu.TEST.MPI.ex inputs_bittree amr.plot_int=1000
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j2 -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-15 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
ccache -s
du -hs ~/.cache/ccache
bittree-3d:
name: Bittree 3D
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Dependencies
run: |
.github/workflows/dependencies/dependencies.sh
.github/workflows/dependencies/dependencies_clang-tidy.sh 15
.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: Check out Bittree
uses: actions/checkout@v4
with:
repository: Flash-X/Bittree
path: bittree
- name: Build Bittree
run: |
cd ${{ github.workspace }}/bittree
python setup.py library --dim 3 --prefix ${{ github.workspace }}/libbittree
cd build
make -j2
make install
- name: Build and Run Test
run: |
export CCACHE_COMPRESS=1
export CCACHE_COMPRESSLEVEL=10
export CCACHE_MAXSIZE=80M
export CCACHE_EXTRAFILES=${{ github.workspace }}/.clang-tidy
export CCACHE_LOGFILE=${{ github.workspace }}/ccache.log.txt
ccache -z
export AMREX_BITTREE_HOME=${{ github.workspace }}/libbittree
cd ${{ github.workspace }}/Tests/Amr/Advection_AmrCore/Exec
make -j2 USE_MPI=TRUE USE_BITTREE=TRUE DIM=3 TEST=TRUE BL_NO_FORT=TRUE\
CCACHE=ccache
mpiexec -n 2 ./main3d.gnu.TEST.MPI.ex inputs_bittree max_step=10
${{github.workspace}}/Tools/C_scripts/mmclt.py --input ${{github.workspace}}/ccache.log.txt
make -j2 -f clang-tidy-ccache-misses.mak \
CLANG_TIDY=clang-tidy-15 \
CLANG_TIDY_ARGS="--config-file=${{github.workspace}}/.clang-tidy --warnings-as-errors=*"
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
67 changes: 33 additions & 34 deletions Src/Extern/Bittree/AMReX_Bittree.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,46 @@ amr.use_bittree = true
class btUnit {
// Functions used in AmrMesh
public:
static int btRefine(bittree::BittreeAmr* const mesh,
std::vector<int>& btTags,
int max_crse, int lbase,
Vector<BoxArray>& grids, Vector<DistributionMapping>& dmap,
MPI_Comm comm);
static void btCalculateGrids(bittree::BittreeAmr* const mesh,
int lbase,
int& new_finest,
Vector<BoxArray>& new_grids,
Vector<IntVect> const& max_grid_size);
static void btCalculateLevel(bittree::BittreeAmr* const mesh,
int lev,
BoxArray& ba,
IntVect const& max_grid_size);
static int btRefine (bittree::BittreeAmr* mesh,
std::vector<int>& btTags,
int max_crse, int lbase,
Vector<BoxArray>& grids, Vector<DistributionMapping>& dmap,
MPI_Comm comm);
static void btCalculateGrids (bittree::BittreeAmr* mesh,
int lbase,
int& new_finest,
Vector<BoxArray>& new_grids,
Vector<IntVect> const& max_grid_size);
static void btCalculateLevel (bittree::BittreeAmr* mesh,
int lev,
BoxArray& ba,
IntVect const& max_grid_size);
// Utils
public:
static int getBitid(bittree::BittreeAmr* const mesh, bool updated,
int lev, int idx_on_lev);
static int getIndex(bittree::BittreeAmr* const mesh, bool updated,
int lev, int bitid);
static int getBitid (bittree::BittreeAmr* mesh, bool updated,
int lev, int idx_on_lev);
static int getIndex (bittree::BittreeAmr* mesh, bool updated,
int lev, int bitid);

// Functions to implement strict octree logic
private:
static void btCheckRefine(bittree::BittreeAmr* const mesh,
std::vector<int>& btTags,
int max_crse, int lbase,
Vector<BoxArray>& grids, Vector<DistributionMapping>& dmap,
MPI_Comm comm);
static void btCheckRefine (bittree::BittreeAmr* mesh,
std::vector<int>& btTags,
int max_crse, int lbase,
Vector<BoxArray>& grids, Vector<DistributionMapping>& dmap,
MPI_Comm comm);

static void btCheckDerefine(bittree::BittreeAmr* const mesh,
std::vector<int>& btTags,
int max_crse, int lbase,
Vector<BoxArray>& grids, Vector<DistributionMapping>& dmap,
MPI_Comm comm);
static void btCheckDerefine (bittree::BittreeAmr* mesh,
std::vector<int>& btTags,
int max_crse, int lbase,
Vector<BoxArray>& grids, Vector<DistributionMapping>& dmap,
MPI_Comm comm);

// Utility Functions
static bool checkNeighborsRefine(bittree::BittreeAmr* const mesh,
bittree::MortonTree::Block b);
static std::vector<int> neighIntCoords(bittree::BittreeAmr* const mesh,
unsigned lev, unsigned* lcoord,
int* gCell);
static bool checkNeighborsRefine (bittree::BittreeAmr* mesh,
bittree::MortonTree::Block b);
static std::vector<int> neighIntCoords (bittree::BittreeAmr* mesh,
unsigned lev, unsigned const* lcoord,
int const* gCell);

public:
// Represents whether domain has periodic BC in each direction
Expand Down
Loading

0 comments on commit 847a905

Please sign in to comment.