diff --git a/projects/rocprofiler-systems/.github/workflows/containers.yml b/projects/rocprofiler-systems/.github/workflows/containers.yml index 66e795a447..0135914772 100644 --- a/projects/rocprofiler-systems/.github/workflows/containers.yml +++ b/projects/rocprofiler-systems/.github/workflows/containers.yml @@ -3,6 +3,7 @@ run-name: ci-containers # nightly build on: + workflow_dispatch: schedule: - cron: 0 5 * * * @@ -54,12 +55,16 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build CI Container - if: ${{ matrix.rocm-version == 0 }} timeout-minutes: 45 - run: | - pushd docker - ./build-docker-ci.sh --distro ${{ matrix.distro }} --versions ${{ matrix.version }} --user ${{ secrets.DOCKERHUB_USERNAME }} --push --jobs 2 --elfutils-version 0.186 --boost-version 1.79.0 - popd + uses: nick-fields/retry@v2 + with: + retry_wait_seconds: 60 + timeout_minutes: 45 + max_attempts: 3 + command: | + pushd docker + ./build-docker-ci.sh --distro ${{ matrix.distro }} --versions ${{ matrix.version }} --user ${{ secrets.DOCKERHUB_USERNAME }} --push --jobs 2 --elfutils-version 0.186 --boost-version 1.79.0 + popd omnitrace-release: if: github.repository == 'AMDResearch/omnitrace' @@ -165,7 +170,12 @@ jobs: - name: Build Base Container timeout-minutes: 45 - run: | - pushd docker - ./build-docker.sh --distro ${{ matrix.os-distro }} --versions ${{ matrix.os-version }} --rocm-versions ${{ matrix.rocm-version }} --user ${{ secrets.DOCKERHUB_USERNAME }} --push - popd + uses: nick-fields/retry@v2 + with: + retry_wait_seconds: 60 + timeout_minutes: 45 + max_attempts: 3 + command: | + pushd docker + ./build-docker.sh --distro ${{ matrix.os-distro }} --versions ${{ matrix.os-version }} --rocm-versions ${{ matrix.rocm-version }} --user ${{ secrets.DOCKERHUB_USERNAME }} --push + popd diff --git a/projects/rocprofiler-systems/.github/workflows/cpack.yml b/projects/rocprofiler-systems/.github/workflows/cpack.yml index 35c882c304..f4a9b01a18 100644 --- a/projects/rocprofiler-systems/.github/workflows/cpack.yml +++ b/projects/rocprofiler-systems/.github/workflows/cpack.yml @@ -2,9 +2,14 @@ name: Installer Packaging (CPack) run-name: cpack on: + workflow_dispatch: push: branches: [main, releases/**] - tags: [] + tags: + - v* + paths-ignore: + - '*.md' + - 'source/docs/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -15,7 +20,7 @@ env: jobs: release: - if: github.repository == 'AMDResearch/omnitrace' + if: github.repository == 'AMDResearch/omnitrace' && startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-20.04 permissions: contents: write @@ -25,11 +30,36 @@ jobs: uses: actions/checkout@v3 - name: Generate Release uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') with: draft: True generate_release_notes: True + release-docs: + if: github.repository == 'AMDResearch/omnitrace' && startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-20.04 + permissions: + contents: write + packages: write + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: gh-pages + - name: Update Docs + uses: s-weigand/setup-conda@v1 + working-directory: source/docs + run: | + conda env create -n omnitrace-docs -f environment.yml + conda activate omnitrace-docs + git config --global user.name 'Jonathan R. Madsen' + git config --global user.email 'jrmadsen@users.noreply.github.com' + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + git pull --rebase=true origin ${{ github.ref }} + ./update-docs.sh + git add ../../docs + git commit -m "Update HTML (automated)" + git push -f + ubuntu: runs-on: ubuntu-20.04 strategy: @@ -131,10 +161,15 @@ jobs: - name: Build Base Container timeout-minutes: 20 - run: | - pushd docker - ./build-docker.sh --distro ${{ matrix.os-distro }} --versions ${{ matrix.os-version }} --rocm-versions ${{ matrix.rocm-version }} - popd + uses: nick-fields/retry@v2 + with: + retry_wait_seconds: 120 + timeout_minutes: 20 + max_attempts: 5 + command: | + pushd docker + ./build-docker.sh --distro ${{ matrix.os-distro }} --versions ${{ matrix.os-version }} --rocm-versions ${{ matrix.rocm-version }} + popd - name: Build Release timeout-minutes: 150 diff --git a/projects/rocprofiler-systems/.github/workflows/formatting.yml b/projects/rocprofiler-systems/.github/workflows/formatting.yml index fcb642defd..14927fe338 100644 --- a/projects/rocprofiler-systems/.github/workflows/formatting.yml +++ b/projects/rocprofiler-systems/.github/workflows/formatting.yml @@ -5,8 +5,14 @@ run-name: formatting on: push: branches: [ main, develop ] + paths-ignore: + - '*.md' + - 'source/docs/**' pull_request: branches: [ main, develop ] + paths-ignore: + - '*.md' + - 'source/docs/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -75,7 +81,7 @@ jobs: - name: clang-format run: | set +e - FILES=$(find source examples -type f | egrep '\.hpp$|\.cpp$|\.cpp\.in$') + FILES=$(find source examples tests -type f | egrep '\.(h|hpp|c|cpp)(|\.in)$') FORMAT_OUT=$(clang-format-11 -output-replacements-xml ${FILES}) RET=$(echo ${FORMAT_OUT} | grep -c '> $GITHUB_PATH && echo "LD_LIBRARY_PATH=/opt/omnitrace/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV - - name: Configure CMake + - name: Configure, Build, and Test timeout-minutes: 115 shell: bash run: git config --global --add safe.directory ${PWD} && cmake --version && - ./scripts/run-ci.sh -B build + python3 ./scripts/run-ci.py -B build --name ${{ github.repository_owner }}-${{ github.ref_name }}-opensuse-${{ matrix.os-release }}-${{ matrix.compiler }}-nompi-python --build-jobs 2 --site GitHub - --cmake-args + -- -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} - -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} + -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DCMAKE_INSTALL_PREFIX=/opt/omnitrace -DOMNITRACE_BUILD_TESTING=ON -DOMNITRACE_USE_MPI=OFF diff --git a/projects/rocprofiler-systems/.github/workflows/ubuntu-bionic.yml b/projects/rocprofiler-systems/.github/workflows/ubuntu-bionic.yml index ae799d0cab..7f8de83cc2 100644 --- a/projects/rocprofiler-systems/.github/workflows/ubuntu-bionic.yml +++ b/projects/rocprofiler-systems/.github/workflows/ubuntu-bionic.yml @@ -4,8 +4,14 @@ run-name: ubuntu-bionic on: push: branches: [ main, develop ] + paths-ignore: + - '*.md' + - 'source/docs/**' pull_request: branches: [ main, develop ] + paths-ignore: + - '*.md' + - 'source/docs/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -46,17 +52,22 @@ jobs: - name: Install Packages timeout-minutes: 10 - run: - apt-get update && - apt-get upgrade -y && - apt-get install -y build-essential m4 autoconf libtool python3-pip ${{ matrix.compiler }} && - if [ "${{ matrix.mpi }}" = "mpich" ]; then apt-get install -y libmpich-dev mpich; fi && - if [ "${{ matrix.mpi }}" = "openmpi" ]; then apt-get install -y libopenmpi-dev openmpi-bin libfabric-dev; fi && - python3 -m pip install --upgrade pip && - python3 -m pip install numpy && - python3 -m pip install perfetto && - python3 -m pip install 'cmake==3.16.3' && - for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done + uses: nick-fields/retry@v2 + with: + retry_wait_seconds: 30 + timeout_minutes: 10 + max_attempts: 5 + command: | + apt-get update && + apt-get upgrade -y && + apt-get install -y build-essential m4 autoconf libtool python3-pip ${{ matrix.compiler }} && + if [ "${{ matrix.mpi }}" = "mpich" ]; then apt-get install -y libmpich-dev mpich; fi && + if [ "${{ matrix.mpi }}" = "openmpi" ]; then apt-get install -y libopenmpi-dev openmpi-bin libfabric-dev; fi && + python3 -m pip install --upgrade pip && + python3 -m pip install numpy && + python3 -m pip install perfetto && + python3 -m pip install 'cmake==3.16.3' && + for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done - name: Install Kokkos timeout-minutes: 10 @@ -82,11 +93,11 @@ jobs: cmake --version && if [ "${{ matrix.mpi }}" = "nompi" ]; then USE_MPI=OFF; else USE_MPI=ON; fi && append-tagname() { if [ "${1}" == "ON" ]; then TAG="${TAG}-${2}"; fi; } && - ./scripts/run-ci.sh -B build + python3 ./scripts/run-ci.py -B build --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-bionic-${{ matrix.compiler }}-${{ matrix.mpi }}-python --build-jobs 2 --site GitHub - --cmake-args + -- -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} diff --git a/projects/rocprofiler-systems/.github/workflows/ubuntu-focal.yml b/projects/rocprofiler-systems/.github/workflows/ubuntu-focal.yml index 9d8b9aa816..eb1168bfe5 100644 --- a/projects/rocprofiler-systems/.github/workflows/ubuntu-focal.yml +++ b/projects/rocprofiler-systems/.github/workflows/ubuntu-focal.yml @@ -4,8 +4,14 @@ run-name: ubuntu-focal on: push: branches: [ main, develop ] + paths-ignore: + - '*.md' + - 'source/docs/**' pull_request: branches: [ main, develop ] + paths-ignore: + - '*.md' + - 'source/docs/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -62,18 +68,23 @@ jobs: - name: Install Packages timeout-minutes: 10 - run: - apt-get update && - apt-get install -y software-properties-common && - add-apt-repository -y ppa:ubuntu-toolchain-r/test && - apt-get update && - apt-get upgrade -y && - apt-get install -y build-essential m4 autoconf libtool python3-pip libiberty-dev clang libomp-dev libmpich-dev mpich environment-modules ${{ matrix.compiler }} && - python3 -m pip install --upgrade pip && - python3 -m pip install numpy && - python3 -m pip install perfetto && - python3 -m pip install 'cmake==3.16.3' && - for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done + uses: nick-fields/retry@v2 + with: + retry_wait_seconds: 30 + timeout_minutes: 10 + max_attempts: 5 + command: | + apt-get update && + apt-get install -y software-properties-common && + add-apt-repository -y ppa:ubuntu-toolchain-r/test && + apt-get update && + apt-get upgrade -y && + apt-get install -y build-essential m4 autoconf libtool python3-pip libiberty-dev clang libomp-dev libmpich-dev mpich environment-modules ${{ matrix.compiler }} && + python3 -m pip install --upgrade pip && + python3 -m pip install numpy && + python3 -m pip install perfetto && + python3 -m pip install 'cmake==3.16.3' && + for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done - name: Test Environment Modules timeout-minutes: 15 @@ -102,11 +113,11 @@ jobs: append-tagname ${{ matrix.static-libgcc }} libgcc && append-tagname ${{ matrix.static-libstdcxx }} libstdcxx && cmake --version && - ./scripts/run-ci.sh -B build + python3 ./scripts/run-ci.py -B build --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-focal-${{ matrix.compiler }}${TAG} --build-jobs 2 --site GitHub - --cmake-args + -- -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} @@ -127,6 +138,7 @@ jobs: -DOMNITRACE_MAX_THREADS=32 -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} + -DMPI_HEADERS_ALLOW_MPICH=OFF - name: Test Build-Tree Module timeout-minutes: 45 @@ -233,16 +245,21 @@ jobs: - name: Install Packages timeout-minutes: 10 - run: - apt-get update && - apt-get install -y software-properties-common wget gnupg2 && - wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - && - echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${{ matrix.rocm-version }}/ ubuntu main" | tee /etc/apt/sources.list.d/rocm.list && - apt-get update && - apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev ${{ matrix.compiler }} libudev1 libnuma1 rocm-dev rocm-utils rocm-smi-lib roctracer-dev rocprofiler-dev hip-base hsa-amd-aqlprofile hsa-rocr-dev hsakmt-roct-dev libpapi-dev curl libopenmpi-dev openmpi-bin libfabric-dev && - python3 -m pip install --upgrade pip && - python3 -m pip install 'cmake==3.21.4' && - for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done + uses: nick-fields/retry@v2 + with: + retry_wait_seconds: 30 + timeout_minutes: 10 + max_attempts: 5 + command: | + apt-get update && + apt-get install -y software-properties-common wget gnupg2 && + wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - && + echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${{ matrix.rocm-version }}/ ubuntu main" | tee /etc/apt/sources.list.d/rocm.list && + apt-get update && + apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev ${{ matrix.compiler }} libudev1 libnuma1 rocm-dev rocm-utils rocm-smi-lib roctracer-dev rocprofiler-dev hip-base hsa-amd-aqlprofile hsa-rocr-dev hsakmt-roct-dev libpapi-dev curl libopenmpi-dev openmpi-bin libfabric-dev && + python3 -m pip install --upgrade pip && + python3 -m pip install 'cmake==3.21.4' && + for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done - name: Install RCCL if: ${{ matrix.rocm-version != '4.3' }} @@ -283,11 +300,11 @@ jobs: cmake --version && TAG="-rocm-${{ matrix.rocm-version }}" && TAG="$(echo ${TAG} | sed 's/debian/latest/g')" && - ./scripts/run-ci.sh -B build + python3 ./scripts/run-ci.py -B build --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-focal-rocm-${{ matrix.compiler }}${TAG} --build-jobs 2 --site GitHub - --cmake-args + -- -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} @@ -311,7 +328,7 @@ jobs: -DOMNITRACE_CI_GPU=OFF -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=OFF -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} - --ctest-args + -- ${{ matrix.ctest-exclude }} - name: Install @@ -392,15 +409,20 @@ jobs: - name: Install Packages timeout-minutes: 10 - run: - sudo apt-get update && - sudo apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev environment-modules ${{ matrix.deps }} ${{ matrix.compiler }} && - if [ "${{ matrix.mpi }}" = "mpich" ]; then sudo apt-get install -y libmpich-dev mpich; fi && - if [ "${{ matrix.mpi }}" = "openmpi" ]; then sudo apt-get install -y libopenmpi-dev openmpi-bin libfabric-dev; fi && - python3 -m pip install --upgrade pip && - python3 -m pip install numpy && - python3 -m pip install perfetto && - python3 -m pip install 'cmake==3.16.3' + uses: nick-fields/retry@v2 + with: + retry_wait_seconds: 30 + timeout_minutes: 10 + max_attempts: 5 + command: | + sudo apt-get update && + sudo apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev environment-modules ${{ matrix.deps }} ${{ matrix.compiler }} && + if [ "${{ matrix.mpi }}" = "mpich" ]; then sudo apt-get install -y libmpich-dev mpich; fi && + if [ "${{ matrix.mpi }}" = "openmpi" ]; then sudo apt-get install -y libopenmpi-dev openmpi-bin libfabric-dev; fi && + python3 -m pip install --upgrade pip && + python3 -m pip install numpy && + python3 -m pip install perfetto && + python3 -m pip install 'cmake==3.16.3' - name: Test Environment Modules timeout-minutes: 15 @@ -422,11 +444,11 @@ jobs: cmake --version && if [ "${{ matrix.mpi }}" = "nompi" ]; then USE_MPI=OFF; else USE_MPI=ON; fi && if [ -z "${{ matrix.deps }}" ]; then TAG=""; else TAG="-external-deps"; fi && - ./scripts/run-ci.sh -B ${{ github.workspace }}/build + python3 ./scripts/run-ci.py -B ${{ github.workspace }}/build --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-focal-${{ matrix.compiler }}-${{ matrix.mpi }}${TAG} --build-jobs 2 --site GitHub - --cmake-args + -- -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} @@ -448,6 +470,7 @@ jobs: -DOMNITRACE_MAX_THREADS=32 -DOMNITRACE_DISABLE_EXAMPLES="transpose;rccl" -DOMNITRACE_BUILD_NUMBER=${{ github.run_attempt }} + -DMPI_HEADERS_ALLOW_MPICH=ON - name: Test Build-Tree Env timeout-minutes: 60 @@ -533,19 +556,22 @@ jobs: - name: Install Packages timeout-minutes: 10 - run: - apt-get update && - apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev environment-modules gcc g++ mpich libmpich-dev texinfo && - python3 -m pip install --upgrade pip && - python3 -m pip install numpy && - python3 -m pip install perfetto && - python3 -m pip install 'cmake==3.24.1' && - for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done + uses: nick-fields/retry@v2 + with: + retry_wait_seconds: 30 + timeout_minutes: 10 + max_attempts: 5 + command: | + apt-get update && + apt-get install -y build-essential m4 autoconf libtool python3-pip clang libomp-dev environment-modules gcc g++ mpich libmpich-dev texinfo && + python3 -m pip install --upgrade pip && + python3 -m pip install numpy && + python3 -m pip install perfetto && + python3 -m pip install 'cmake==3.24.1' && + for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done - name: Configure Env run: - echo "CC=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g')" >> $GITHUB_ENV && - echo "CXX=${{ matrix.compiler }}" >> $GITHUB_ENV && echo "${HOME}/.local/bin" >> $GITHUB_PATH - name: Configure, Build, and Test @@ -554,12 +580,12 @@ jobs: run: git config --global --add safe.directory ${PWD} && cmake --version && - ./scripts/run-ci.sh -B build + python3 ./scripts/run-ci.py -B build --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-focal-codecov-mpi-python-ompt-papi --build-jobs 2 --site GitHub --coverage - --cmake-args + -- -DCMAKE_INSTALL_PREFIX=/opt/omnitrace -DOMNITRACE_BUILD_CI=OFF -DOMNITRACE_BUILD_TESTING=ON diff --git a/projects/rocprofiler-systems/.github/workflows/ubuntu-jammy.yml b/projects/rocprofiler-systems/.github/workflows/ubuntu-jammy.yml index 26c7c5ec5c..d40563be2c 100644 --- a/projects/rocprofiler-systems/.github/workflows/ubuntu-jammy.yml +++ b/projects/rocprofiler-systems/.github/workflows/ubuntu-jammy.yml @@ -4,8 +4,14 @@ run-name: ubuntu-jammy on: push: branches: [ main, develop ] + paths-ignore: + - '*.md' + - 'source/docs/**' pull_request: branches: [ main, develop ] + paths-ignore: + - '*.md' + - 'source/docs/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -65,29 +71,39 @@ jobs: - name: Install Packages timeout-minutes: 10 - run: - apt-get update && - apt-get install -y software-properties-common && - apt-get upgrade -y && - apt-get install -y build-essential m4 autoconf libtool python3-pip libiberty-dev clang libomp-dev libopenmpi-dev libfabric-dev openmpi-bin environment-modules ${{ matrix.compiler }} && - python3 -m pip install --upgrade pip && - python3 -m pip install numpy && - python3 -m pip install 'cmake==3.21.4' && - for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done + uses: nick-fields/retry@v2 + with: + retry_wait_seconds: 30 + timeout_minutes: 10 + max_attempts: 5 + command: | + apt-get update && + apt-get install -y software-properties-common && + apt-get upgrade -y && + apt-get install -y build-essential m4 autoconf libtool python3-pip libiberty-dev clang libomp-dev libopenmpi-dev libfabric-dev openmpi-bin environment-modules ${{ matrix.compiler }} && + python3 -m pip install --upgrade pip && + python3 -m pip install numpy && + python3 -m pip install 'cmake==3.21.4' && + for i in 6 7 8 9 10; do /opt/conda/envs/py3.${i}/bin/python -m pip install numpy perfetto dataclasses; done - name: Install ROCm Packages timeout-minutes: 10 if: ${{ matrix.rocm-version != '0.0' }} - shell: bash - run: | - wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - - echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${{ matrix.rocm-version }}/ jammy main" | tee /etc/apt/sources.list.d/rocm.list - apt-get update - apt-get install -y {rocm-hip-sdk,roctracer-dev,rocprofiler-dev,rocm-smi-lib,rocminfo}${{ matrix.rocm-version }}.0 - echo "/opt/rocm/bin" >> $GITHUB_PATH - echo "ROCM_PATH=/opt/rocm" >> $GITHUB_ENV - echo "LD_LIBRARY_PATH=/opt/rocm/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV - /opt/rocm/bin/hipcc -O3 -c ./examples/transpose/transpose.cpp -o /tmp/transpose.o + uses: nick-fields/retry@v2 + with: + retry_wait_seconds: 30 + timeout_minutes: 10 + max_attempts: 5 + shell: bash + command: | + wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - + echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${{ matrix.rocm-version }}/ jammy main" | tee /etc/apt/sources.list.d/rocm.list + apt-get update + apt-get install -y {rocm-hip-sdk,roctracer-dev,rocprofiler-dev,rocm-smi-lib,rocminfo}${{ matrix.rocm-version }}.0 + echo "/opt/rocm/bin" >> $GITHUB_PATH + echo "ROCM_PATH=/opt/rocm" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=/opt/rocm/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV + /opt/rocm/bin/hipcc -O3 -c ./examples/transpose/transpose.cpp -o /tmp/transpose.o - name: Test Environment Modules timeout-minutes: 15 @@ -122,11 +138,11 @@ jobs: append-tagname ${{ matrix.hidden }} hidden-viz && append-tagname ${{ matrix.static-libgcc }} libgcc && append-tagname ${{ matrix.static-libstdcxx }} libstdcxx && - ./scripts/run-ci.sh -B build + python3 ./scripts/run-ci.py -B build --name ${{ github.repository_owner }}-${{ github.ref_name }}-ubuntu-jammy-${{ matrix.compiler }}${TAG} --build-jobs 2 --site GitHub - --cmake-args + -- -DCMAKE_C_COMPILER=$(echo '${{ matrix.compiler }}' | sed 's/+/c/g') -DCMAKE_CXX_COMPILER=${{ matrix.compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} diff --git a/projects/rocprofiler-systems/cmake/Formatting.cmake b/projects/rocprofiler-systems/cmake/Formatting.cmake index d4a6700bf2..a8df105042 100644 --- a/projects/rocprofiler-systems/cmake/Formatting.cmake +++ b/projects/rocprofiler-systems/cmake/Formatting.cmake @@ -56,12 +56,14 @@ endforeach() if(OMNITRACE_CLANG_FORMAT_EXE OR OMNITRACE_BLACK_FORMAT_EXE OR OMNITRACE_CMAKE_FORMAT_EXE) - file(GLOB_RECURSE sources ${PROJECT_SOURCE_DIR}/source/*.cpp) + file(GLOB_RECURSE sources ${PROJECT_SOURCE_DIR}/source/*.cpp + ${PROJECT_SOURCE_DIR}/source/*.c) file(GLOB_RECURSE headers ${PROJECT_SOURCE_DIR}/source/*.hpp ${PROJECT_SOURCE_DIR}/source/*.hpp.in ${PROJECT_SOURCE_DIR}/source/*.h ${PROJECT_SOURCE_DIR}/source/*.h.in) file(GLOB_RECURSE examples ${PROJECT_SOURCE_DIR}/examples/*.cpp - ${PROJECT_SOURCE_DIR}/examples/*.c ${PROJECT_SOURCE_DIR}/examples/*.hpp) + ${PROJECT_SOURCE_DIR}/examples/*.c ${PROJECT_SOURCE_DIR}/examples/*.hpp + ${PROJECT_SOURCE_DIR}/examples/*.h) file(GLOB_RECURSE external ${PROJECT_SOURCE_DIR}/examples/lulesh/external/kokkos/*) file( GLOB_RECURSE diff --git a/projects/rocprofiler-systems/cmake/Packages.cmake b/projects/rocprofiler-systems/cmake/Packages.cmake index e1d50a68a1..7adfac2cf0 100644 --- a/projects/rocprofiler-systems/cmake/Packages.cmake +++ b/projects/rocprofiler-systems/cmake/Packages.cmake @@ -234,6 +234,9 @@ endif() # # ----------------------------------------------------------------------------------------# +# suppress warning during CI that MPI_HEADERS_ALLOW_MPICH was unused +set(_OMNITRACE_MPI_HEADERS_ALLOW_MPICH ${MPI_HEADERS_ALLOW_MPICH}) + if(OMNITRACE_USE_MPI) find_package(MPI ${omnitrace_FIND_QUIETLY} REQUIRED) target_link_libraries(omnitrace-mpi INTERFACE MPI::MPI_C MPI::MPI_CXX) diff --git a/projects/rocprofiler-systems/examples/lulesh/lulesh.h b/projects/rocprofiler-systems/examples/lulesh/lulesh.h index e48e8edd3f..4ff3dffa1a 100644 --- a/projects/rocprofiler-systems/examples/lulesh/lulesh.h +++ b/projects/rocprofiler-systems/examples/lulesh/lulesh.h @@ -1,6 +1,6 @@ #if !defined(USE_MPI) -#error "You should specify USE_MPI=0 or USE_MPI=1 on the compile line" +# error "You should specify USE_MPI=0 or USE_MPI=1 on the compile line" #endif // OpenMP will be compiled in if this flag is set to 1 AND the compiler beging @@ -8,7 +8,7 @@ #define USE_OMP 1 #if USE_MPI -#include +# include /* define one of these three symbols: @@ -18,12 +18,12 @@ SEDOV_SYNC_POS_VEL_LATE */ -#define SEDOV_SYNC_POS_VEL_EARLY 1 +# define SEDOV_SYNC_POS_VEL_EARLY 1 #endif #include -#include #include +#include #include #include @@ -35,64 +35,104 @@ #define MAX(a, b) (((a) > (b)) ? (a) : (b)) // Precision specification -typedef float real4; -typedef double real8; -typedef long double real10; // 10 bytes on x86 +typedef float real4; +typedef double real8; +typedef long double real10; // 10 bytes on x86 -typedef int Index_t; // array subscript and loop index -typedef real8 Real_t; // floating point representation -typedef int Int_t; // integer representation +typedef int Index_t; // array subscript and loop index +typedef real8 Real_t; // floating point representation +typedef int Int_t; // integer representation -enum { VolumeError = -1, QStopError = -2 }; +enum +{ + VolumeError = -1, + QStopError = -2 +}; -KOKKOS_INLINE_FUNCTION real4 SQRT(real4 arg) { return sqrtf(arg); } -KOKKOS_INLINE_FUNCTION real8 SQRT(real8 arg) { return sqrt(arg); } -KOKKOS_INLINE_FUNCTION real10 SQRT(real10 arg) { return sqrtl(arg); } +KOKKOS_INLINE_FUNCTION real4 +SQRT(real4 arg) +{ + return sqrtf(arg); +} +KOKKOS_INLINE_FUNCTION real8 +SQRT(real8 arg) +{ + return sqrt(arg); +} +KOKKOS_INLINE_FUNCTION real10 +SQRT(real10 arg) +{ + return sqrtl(arg); +} -KOKKOS_INLINE_FUNCTION real4 CBRT(real4 arg) { return cbrtf(arg); } -KOKKOS_INLINE_FUNCTION real8 CBRT(real8 arg) { return cbrt(arg); } -KOKKOS_INLINE_FUNCTION real10 CBRT(real10 arg) { return cbrtl(arg); } +KOKKOS_INLINE_FUNCTION real4 +CBRT(real4 arg) +{ + return cbrtf(arg); +} +KOKKOS_INLINE_FUNCTION real8 +CBRT(real8 arg) +{ + return cbrt(arg); +} +KOKKOS_INLINE_FUNCTION real10 +CBRT(real10 arg) +{ + return cbrtl(arg); +} -KOKKOS_INLINE_FUNCTION real4 FABS(real4 arg) { return fabsf(arg); } -KOKKOS_INLINE_FUNCTION real8 FABS(real8 arg) { return fabs(arg); } -KOKKOS_INLINE_FUNCTION real10 FABS(real10 arg) { return fabsl(arg); } +KOKKOS_INLINE_FUNCTION real4 +FABS(real4 arg) +{ + return fabsf(arg); +} +KOKKOS_INLINE_FUNCTION real8 +FABS(real8 arg) +{ + return fabs(arg); +} +KOKKOS_INLINE_FUNCTION real10 +FABS(real10 arg) +{ + return fabsl(arg); +} // Stuff needed for boundary conditions // 2 BCs on each of 6 hexahedral faces (12 bits) -#define XI_M 0x00007 +#define XI_M 0x00007 #define XI_M_SYMM 0x00001 #define XI_M_FREE 0x00002 #define XI_M_COMM 0x00004 -#define XI_P 0x00038 +#define XI_P 0x00038 #define XI_P_SYMM 0x00008 #define XI_P_FREE 0x00010 #define XI_P_COMM 0x00020 -#define ETA_M 0x001c0 +#define ETA_M 0x001c0 #define ETA_M_SYMM 0x00040 #define ETA_M_FREE 0x00080 #define ETA_M_COMM 0x00100 -#define ETA_P 0x00e00 +#define ETA_P 0x00e00 #define ETA_P_SYMM 0x00200 #define ETA_P_FREE 0x00400 #define ETA_P_COMM 0x00800 -#define ZETA_M 0x07000 +#define ZETA_M 0x07000 #define ZETA_M_SYMM 0x01000 #define ZETA_M_FREE 0x02000 #define ZETA_M_COMM 0x04000 -#define ZETA_P 0x38000 +#define ZETA_P 0x38000 #define ZETA_P_SYMM 0x08000 #define ZETA_P_FREE 0x10000 #define ZETA_P_COMM 0x20000 // MPI Message Tags -#define MSG_COMM_SBN 1024 +#define MSG_COMM_SBN 1024 #define MSG_SYNC_POS_VEL 2048 -#define MSG_MONOQ 3072 +#define MSG_MONOQ 3072 #define MAX_FIELDS_PER_MPI_COMM 6 @@ -100,8 +140,8 @@ KOKKOS_INLINE_FUNCTION real10 FABS(real10 arg) { return fabsl(arg); } // Assume Real_t is an "integral power of 2" bytes wide #define CACHE_COHERENCE_PAD_REAL (128 / sizeof(Real_t)) -#define CACHE_ALIGN_REAL(n) \ - (((n) + (CACHE_COHERENCE_PAD_REAL - 1)) & ~(CACHE_COHERENCE_PAD_REAL - 1)) +#define CACHE_ALIGN_REAL(n) \ + (((n) + (CACHE_COHERENCE_PAD_REAL - 1)) & ~(CACHE_COHERENCE_PAD_REAL - 1)) ////////////////////////////////////////////////////// // Primary data structure @@ -126,598 +166,578 @@ KOKKOS_INLINE_FUNCTION real10 FABS(real10 arg) { return fabsl(arg); } * "Real_t &z(Index_t idx) { return m_coord[idx].z ; }" */ -class Domain { - +class Domain +{ public: - // Constructor - Domain(Int_t numRanks, Index_t colLoc, Index_t rowLoc, Index_t planeLoc, - Index_t nx, Int_t tp, Int_t nr, Int_t balance, Int_t cost); + // Constructor + Domain(Int_t numRanks, Index_t colLoc, Index_t rowLoc, Index_t planeLoc, Index_t nx, + Int_t tp, Int_t nr, Int_t balance, Int_t cost); - // Destructor - KOKKOS_FUNCTION ~Domain(); + // Destructor + KOKKOS_FUNCTION ~Domain(); - // - // ALLOCATION - // + // + // ALLOCATION + // - void AllocateNodePersistent(Int_t numNode) // Node-centered - { - Kokkos::resize(m_x,numNode); // coordinates - Kokkos::resize(m_y,numNode); - Kokkos::resize(m_z,numNode); + void AllocateNodePersistent(Int_t numNode) // Node-centered + { + Kokkos::resize(m_x, numNode); // coordinates + Kokkos::resize(m_y, numNode); + Kokkos::resize(m_z, numNode); - Kokkos::resize(m_xd,numNode); // velocities - Kokkos::resize(m_yd,numNode); - Kokkos::resize(m_zd,numNode); + Kokkos::resize(m_xd, numNode); // velocities + Kokkos::resize(m_yd, numNode); + Kokkos::resize(m_zd, numNode); - Kokkos::resize(m_xdd,numNode); // accelerations - Kokkos::resize(m_ydd,numNode); - Kokkos::resize(m_zdd,numNode); + Kokkos::resize(m_xdd, numNode); // accelerations + Kokkos::resize(m_ydd, numNode); + Kokkos::resize(m_zdd, numNode); - Kokkos::resize(m_fx,numNode); // forces - Kokkos::resize(m_fy,numNode); - Kokkos::resize(m_fz,numNode); + Kokkos::resize(m_fx, numNode); // forces + Kokkos::resize(m_fy, numNode); + Kokkos::resize(m_fz, numNode); - Kokkos::resize(m_nodalMass,numNode); // mass + Kokkos::resize(m_nodalMass, numNode); // mass - m_c_x = m_x; - m_c_y = m_y; - m_c_z = m_z; - m_c_xd = m_xd; - m_c_yd = m_yd; - m_c_zd = m_zd; - } + m_c_x = m_x; + m_c_y = m_y; + m_c_z = m_z; + m_c_xd = m_xd; + m_c_yd = m_yd; + m_c_zd = m_zd; + } - void AllocateElemPersistent(Int_t numElem) // Elem-centered - { - Kokkos::resize(m_nodelist,numElem); + void AllocateElemPersistent(Int_t numElem) // Elem-centered + { + Kokkos::resize(m_nodelist, numElem); + + // elem connectivities through face + Kokkos::resize(m_lxim, numElem); + Kokkos::resize(m_lxip, numElem); + Kokkos::resize(m_letam, numElem); + Kokkos::resize(m_letap, numElem); + Kokkos::resize(m_lzetam, numElem); + Kokkos::resize(m_lzetap, numElem); + + Kokkos::resize(m_elemBC, numElem); + + Kokkos::resize(m_e, numElem); + Kokkos::resize(m_p, numElem); + + Kokkos::resize(m_q, numElem); + Kokkos::resize(m_ql, numElem); + Kokkos::resize(m_qq, numElem); + + Kokkos::resize(m_v, numElem); + + Kokkos::resize(m_volo, numElem); + Kokkos::resize(m_delv, numElem); + Kokkos::resize(m_vdov, numElem); + + Kokkos::resize(m_arealg, numElem); + + Kokkos::resize(m_ss, numElem); + + Kokkos::resize(m_elemMass, numElem); + + Kokkos::resize(m_vnew, numElem); + + m_c_e = m_e; + m_c_p = m_p; + m_c_q = m_q; + m_c_ql = m_ql; + m_c_qq = m_qq; + m_c_delv = m_delv; + } + + void AllocateGradients(Int_t numElem, Int_t allElem) + { + // Position gradients + Kokkos::resize(m_delx_xi, numElem); + Kokkos::resize(m_delx_eta, numElem); + Kokkos::resize(m_delx_zeta, numElem); + + // Velocity gradients + Kokkos::resize(m_delv_xi, allElem); + Kokkos::resize(m_delv_eta, allElem); + Kokkos::resize(m_delv_zeta, allElem); + } + + void DeallocateGradients() + { + m_delx_zeta = Kokkos::View(); + m_delx_eta = Kokkos::View(); + m_delx_xi = Kokkos::View(); + + m_delv_zeta = Kokkos::View(); + m_delv_eta = Kokkos::View(); + m_delv_xi = Kokkos::View(); + } + + void AllocateStrains(Int_t numElem) + { + Kokkos::resize(m_dxx, numElem); + Kokkos::resize(m_dyy, numElem); + Kokkos::resize(m_dzz, numElem); + } + + void DeallocateStrains() + { + m_dzz = Kokkos::View(); + m_dyy = Kokkos::View(); + m_dxx = Kokkos::View(); + } + + // + // ACCESSORS + // + KOKKOS_INLINE_FUNCTION + const Kokkos::View& e_view() const { return m_e; } + + // Node-centered + + // Nodal coordinates + KOKKOS_INLINE_FUNCTION Real_t& x(const Index_t idx) const { return m_x[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& y(const Index_t idx) const { return m_y[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& z(const Index_t idx) const { return m_z[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_x(const Index_t idx) const { return m_c_x[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_y(const Index_t idx) const { return m_c_y[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_z(const Index_t idx) const { return m_c_z[idx]; } + + // Nodal velocities + KOKKOS_INLINE_FUNCTION Real_t& xd(const Index_t idx) const { return m_xd[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& yd(const Index_t idx) const { return m_yd[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& zd(const Index_t idx) const { return m_zd[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_xd(const Index_t idx) const { return m_c_xd[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_yd(const Index_t idx) const { return m_c_yd[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_zd(const Index_t idx) const { return m_c_zd[idx]; } + + // Nodal accelerations + KOKKOS_INLINE_FUNCTION Real_t& xdd(const Index_t idx) const { return m_xdd[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& ydd(const Index_t idx) const { return m_ydd[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& zdd(const Index_t idx) const { return m_zdd[idx]; } + + // Nodal forces + KOKKOS_INLINE_FUNCTION Real_t& fx(const Index_t idx) const { return m_fx[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& fy(const Index_t idx) const { return m_fy[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& fz(const Index_t idx) const { return m_fz[idx]; } + + // Nodal mass + KOKKOS_INLINE_FUNCTION Real_t& nodalMass(const Index_t idx) const + { + return m_nodalMass[idx]; + } + + // Nodes on symmertry planes + KOKKOS_INLINE_FUNCTION Index_t symmX(const Index_t idx) const { return m_symmX[idx]; } + KOKKOS_INLINE_FUNCTION Index_t symmY(const Index_t idx) const { return m_symmY[idx]; } + KOKKOS_INLINE_FUNCTION Index_t symmZ(const Index_t idx) const { return m_symmZ[idx]; } + KOKKOS_INLINE_FUNCTION bool symmXempty() { return m_symmX.data() == nullptr; } + KOKKOS_INLINE_FUNCTION bool symmYempty() { return m_symmY.data() == nullptr; } + KOKKOS_INLINE_FUNCTION bool symmZempty() { return m_symmZ.data() == nullptr; } + + // + // Element-centered + // + Index_t& regElemSize(Index_t idx) { return m_regElemSize[idx]; } + Index_t& regNumList(Index_t idx) { return m_regNumList[idx]; } + Index_t* regNumList() { return &m_regNumList[0]; } + Index_t* regElemlist(Int_t r) const + { + return &m_regElemlist.entries(m_regElemlist.row_map(r)); + } + KOKKOS_INLINE_FUNCTION Index_t regElemlist(const Int_t r, Index_t idx) const + { + return m_regElemlist.entries(m_regElemlist.row_map(r) + idx); + } + + KOKKOS_INLINE_FUNCTION Index_t& nodelist(Index_t i, Index_t j) const + { + return m_nodelist(i, j); + } // elem connectivities through face - Kokkos::resize(m_lxim,numElem); - Kokkos::resize(m_lxip,numElem); - Kokkos::resize(m_letam,numElem); - Kokkos::resize(m_letap,numElem); - Kokkos::resize(m_lzetam,numElem); - Kokkos::resize(m_lzetap,numElem); + KOKKOS_INLINE_FUNCTION Index_t& lxim(const Index_t idx) const { return m_lxim[idx]; } + KOKKOS_INLINE_FUNCTION Index_t& lxip(const Index_t idx) const { return m_lxip[idx]; } + KOKKOS_INLINE_FUNCTION Index_t& letam(const Index_t idx) const + { + return m_letam[idx]; + } + KOKKOS_INLINE_FUNCTION Index_t& letap(const Index_t idx) const + { + return m_letap[idx]; + } + KOKKOS_INLINE_FUNCTION Index_t& lzetam(const Index_t idx) const + { + return m_lzetam[idx]; + } + KOKKOS_INLINE_FUNCTION Index_t& lzetap(const Index_t idx) const + { + return m_lzetap[idx]; + } - Kokkos::resize(m_elemBC,numElem); + // elem face symm/free-surface flag + KOKKOS_INLINE_FUNCTION Int_t& elemBC(const Index_t idx) const + { + return m_elemBC[idx]; + } - Kokkos::resize(m_e,numElem); - Kokkos::resize(m_p,numElem); + // Principal strains - temporary + KOKKOS_INLINE_FUNCTION Real_t& dxx(const Index_t idx) const { return m_dxx[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& dyy(const Index_t idx) const { return m_dyy[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& dzz(const Index_t idx) const { return m_dzz[idx]; } - Kokkos::resize(m_q,numElem); - Kokkos::resize(m_ql,numElem); - Kokkos::resize(m_qq,numElem); + // New relative volume - temporary + KOKKOS_INLINE_FUNCTION Real_t& vnew(const Index_t idx) const { return m_vnew[idx]; } - Kokkos::resize(m_v,numElem); + // Velocity gradient - temporary + KOKKOS_INLINE_FUNCTION Real_t& delv_xi(const Index_t idx) const + { + return m_delv_xi[idx]; + } + KOKKOS_INLINE_FUNCTION Real_t& delv_eta(const Index_t idx) const + { + return m_delv_eta[idx]; + } + KOKKOS_INLINE_FUNCTION Real_t& delv_zeta(const Index_t idx) const + { + return m_delv_zeta[idx]; + } - Kokkos::resize(m_volo,numElem); - Kokkos::resize(m_delv,numElem); - Kokkos::resize(m_vdov,numElem); + // Position gradient - temporary + KOKKOS_INLINE_FUNCTION Real_t& delx_xi(const Index_t idx) const + { + return m_delx_xi[idx]; + } + KOKKOS_INLINE_FUNCTION Real_t& delx_eta(const Index_t idx) const + { + return m_delx_eta[idx]; + } + KOKKOS_INLINE_FUNCTION Real_t& delx_zeta(const Index_t idx) const + { + return m_delx_zeta[idx]; + } + // Energy + KOKKOS_INLINE_FUNCTION Real_t& e(const Index_t idx) const { return m_e[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_e(const Index_t idx) const { return m_c_e[idx]; } - Kokkos::resize(m_arealg,numElem); + // Pressure + KOKKOS_INLINE_FUNCTION Real_t& p(const Index_t idx) const { return m_p[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_p(const Index_t idx) const { return m_c_p[idx]; } - Kokkos::resize(m_ss,numElem); + // Artificial viscosity + KOKKOS_INLINE_FUNCTION Real_t& q(const Index_t idx) const { return m_q[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_q(const Index_t idx) const { return m_c_q[idx]; } - Kokkos::resize(m_elemMass,numElem); + // Linear term for q + KOKKOS_INLINE_FUNCTION Real_t& ql(const Index_t idx) const { return m_ql[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_ql(const Index_t idx) const { return m_c_ql[idx]; } + // Quadratic term for q + KOKKOS_INLINE_FUNCTION Real_t& qq(const Index_t idx) const { return m_qq[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_qq(const Index_t idx) const { return m_c_qq[idx]; } - Kokkos::resize(m_vnew,numElem); + // Relative volume + KOKKOS_INLINE_FUNCTION Real_t& v(const Index_t idx) const { return m_v[idx]; } + KOKKOS_INLINE_FUNCTION Real_t& delv(const Index_t idx) const { return m_delv[idx]; } + KOKKOS_INLINE_FUNCTION Real_t c_delv(const Index_t idx) const + { + return m_c_delv[idx]; + } - m_c_e = m_e; - m_c_p = m_p; - m_c_q = m_q; - m_c_ql = m_ql; - m_c_qq = m_qq; - m_c_delv = m_delv; - } + // Reference volume + KOKKOS_INLINE_FUNCTION Real_t& volo(Index_t idx) const { return m_volo[idx]; } - void AllocateGradients(Int_t numElem, Int_t allElem) { - // Position gradients - Kokkos::resize(m_delx_xi,numElem); - Kokkos::resize(m_delx_eta,numElem); - Kokkos::resize(m_delx_zeta,numElem); + // volume derivative over volume + KOKKOS_INLINE_FUNCTION Real_t& vdov(Index_t idx) const { return m_vdov[idx]; } - // Velocity gradients - Kokkos::resize(m_delv_xi,allElem); - Kokkos::resize(m_delv_eta,allElem); - Kokkos::resize(m_delv_zeta,allElem); - } + // Element characteristic length + KOKKOS_INLINE_FUNCTION Real_t& arealg(Index_t idx) const { return m_arealg[idx]; } - void DeallocateGradients() { - m_delx_zeta = Kokkos::View(); - m_delx_eta = Kokkos::View(); - m_delx_xi = Kokkos::View(); + // Sound speed + KOKKOS_INLINE_FUNCTION Real_t& ss(const Index_t idx) const { return m_ss[idx]; } - m_delv_zeta = Kokkos::View(); - m_delv_eta = Kokkos::View(); - m_delv_xi = Kokkos::View(); - } + // Element mass + KOKKOS_INLINE_FUNCTION Real_t& elemMass(const Index_t idx) const + { + return m_elemMass[idx]; + } - void AllocateStrains(Int_t numElem) { - Kokkos::resize(m_dxx,numElem); - Kokkos::resize(m_dyy,numElem); - Kokkos::resize(m_dzz,numElem); - } + KOKKOS_INLINE_FUNCTION Index_t nodeElemCount(Index_t idx) const + { + return m_nodeElemStart[idx + 1] - m_nodeElemStart[idx]; + } - void DeallocateStrains() { - m_dzz = Kokkos::View(); - m_dyy = Kokkos::View(); - m_dxx = Kokkos::View(); - } + KOKKOS_INLINE_FUNCTION Index_t* nodeElemCornerList(Index_t idx) const + { + return &m_nodeElemCornerList[m_nodeElemStart[idx]]; + } - // - // ACCESSORS - // - KOKKOS_INLINE_FUNCTION - const Kokkos::View& e_view() const { return m_e; } + // Parameters - // Node-centered + // Cutoffs + KOKKOS_INLINE_FUNCTION Real_t u_cut() const { return m_u_cut; } + KOKKOS_INLINE_FUNCTION Real_t e_cut() const { return m_e_cut; } + KOKKOS_INLINE_FUNCTION Real_t p_cut() const { return m_p_cut; } + KOKKOS_INLINE_FUNCTION Real_t q_cut() const { return m_q_cut; } + KOKKOS_INLINE_FUNCTION Real_t v_cut() const { return m_v_cut; } - // Nodal coordinates - KOKKOS_INLINE_FUNCTION Real_t &x(const Index_t idx) const { return m_x[idx]; } - KOKKOS_INLINE_FUNCTION Real_t &y(const Index_t idx) const { return m_y[idx]; } - KOKKOS_INLINE_FUNCTION Real_t &z(const Index_t idx) const { return m_z[idx]; } - KOKKOS_INLINE_FUNCTION Real_t c_x(const Index_t idx) const { - return m_c_x[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t c_y(const Index_t idx) const { - return m_c_y[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t c_z(const Index_t idx) const { - return m_c_z[idx]; - } + // Other constants (usually are settable via input file in real codes) + KOKKOS_INLINE_FUNCTION Real_t hgcoef() const { return m_hgcoef; } + KOKKOS_INLINE_FUNCTION Real_t qstop() const { return m_qstop; } + KOKKOS_INLINE_FUNCTION Real_t monoq_max_slope() const { return m_monoq_max_slope; } + KOKKOS_INLINE_FUNCTION Real_t monoq_limiter_mult() const + { + return m_monoq_limiter_mult; + } + KOKKOS_INLINE_FUNCTION Real_t ss4o3() const { return m_ss4o3; } + KOKKOS_INLINE_FUNCTION Real_t qlc_monoq() const { return m_qlc_monoq; } + KOKKOS_INLINE_FUNCTION Real_t qqc_monoq() const { return m_qqc_monoq; } + KOKKOS_INLINE_FUNCTION Real_t qqc() const { return m_qqc; } - // Nodal velocities - KOKKOS_INLINE_FUNCTION Real_t &xd(const Index_t idx) const { - return m_xd[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &yd(const Index_t idx) const { - return m_yd[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &zd(const Index_t idx) const { - return m_zd[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t c_xd(const Index_t idx) const { - return m_c_xd[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t c_yd(const Index_t idx) const { - return m_c_yd[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t c_zd(const Index_t idx) const { - return m_c_zd[idx]; - } + KOKKOS_INLINE_FUNCTION Real_t eosvmax() const { return m_eosvmax; } + KOKKOS_INLINE_FUNCTION Real_t eosvmin() const { return m_eosvmin; } + KOKKOS_INLINE_FUNCTION Real_t pmin() const { return m_pmin; } + KOKKOS_INLINE_FUNCTION Real_t emin() const { return m_emin; } + KOKKOS_INLINE_FUNCTION Real_t dvovmax() const { return m_dvovmax; } + KOKKOS_INLINE_FUNCTION Real_t refdens() const { return m_refdens; } - // Nodal accelerations - KOKKOS_INLINE_FUNCTION Real_t &xdd(const Index_t idx) const { - return m_xdd[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &ydd(const Index_t idx) const { - return m_ydd[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &zdd(const Index_t idx) const { - return m_zdd[idx]; - } + // Timestep controls, etc... + Real_t& time() { return m_time; } + Real_t& deltatime() { return m_deltatime; } + Real_t& deltatimemultlb() { return m_deltatimemultlb; } + Real_t& deltatimemultub() { return m_deltatimemultub; } + Real_t& stoptime() { return m_stoptime; } + Real_t& dtcourant() { return m_dtcourant; } + Real_t& dthydro() { return m_dthydro; } + Real_t& dtmax() { return m_dtmax; } + Real_t& dtfixed() { return m_dtfixed; } - // Nodal forces - KOKKOS_INLINE_FUNCTION Real_t &fx(const Index_t idx) const { - return m_fx[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &fy(const Index_t idx) const { - return m_fy[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &fz(const Index_t idx) const { - return m_fz[idx]; - } + Int_t& cycle() { return m_cycle; } + Index_t& numRanks() { return m_numRanks; } - // Nodal mass - KOKKOS_INLINE_FUNCTION Real_t &nodalMass(const Index_t idx) const { - return m_nodalMass[idx]; - } + Index_t& colLoc() { return m_colLoc; } + Index_t& rowLoc() { return m_rowLoc; } + Index_t& planeLoc() { return m_planeLoc; } + Index_t& tp() { return m_tp; } - // Nodes on symmertry planes - KOKKOS_INLINE_FUNCTION Index_t symmX(const Index_t idx) const { return m_symmX[idx]; } - KOKKOS_INLINE_FUNCTION Index_t symmY(const Index_t idx) const { return m_symmY[idx]; } - KOKKOS_INLINE_FUNCTION Index_t symmZ(const Index_t idx) const { return m_symmZ[idx]; } - KOKKOS_INLINE_FUNCTION bool symmXempty() { return m_symmX.data()==nullptr; } - KOKKOS_INLINE_FUNCTION bool symmYempty() { return m_symmY.data()==nullptr; } - KOKKOS_INLINE_FUNCTION bool symmZempty() { return m_symmZ.data()==nullptr; } + Index_t& sizeX() { return m_sizeX; } + Index_t& sizeY() { return m_sizeY; } + Index_t& sizeZ() { return m_sizeZ; } + Index_t& numReg() { return m_numReg; } + Int_t& cost() { return m_cost; } + Index_t& numElem() { return m_numElem; } + Index_t& numNode() { return m_numNode; } - // - // Element-centered - // - Index_t ®ElemSize(Index_t idx) { return m_regElemSize[idx]; } - Index_t ®NumList(Index_t idx) { return m_regNumList[idx]; } - Index_t *regNumList() { return &m_regNumList[0]; } - Index_t *regElemlist(Int_t r) const { return &m_regElemlist.entries(m_regElemlist.row_map(r)); } - KOKKOS_INLINE_FUNCTION Index_t regElemlist(const Int_t r, Index_t idx) const { - return m_regElemlist.entries(m_regElemlist.row_map(r)+idx); - } + Index_t& maxPlaneSize() { return m_maxPlaneSize; } + Index_t& maxEdgeSize() { return m_maxEdgeSize; } - KOKKOS_INLINE_FUNCTION Index_t &nodelist(Index_t i, Index_t j) const { return m_nodelist(i,j); } - - - // elem connectivities through face - KOKKOS_INLINE_FUNCTION Index_t &lxim(const Index_t idx) const { return m_lxim[idx]; } - KOKKOS_INLINE_FUNCTION Index_t &lxip(const Index_t idx) const { return m_lxip[idx]; } - KOKKOS_INLINE_FUNCTION Index_t &letam(const Index_t idx) const { return m_letam[idx]; } - KOKKOS_INLINE_FUNCTION Index_t &letap(const Index_t idx) const { return m_letap[idx]; } - KOKKOS_INLINE_FUNCTION Index_t &lzetam(const Index_t idx) const { return m_lzetam[idx]; } - KOKKOS_INLINE_FUNCTION Index_t &lzetap(const Index_t idx) const { return m_lzetap[idx]; } - - // elem face symm/free-surface flag - KOKKOS_INLINE_FUNCTION Int_t &elemBC(const Index_t idx) const { return m_elemBC[idx]; } - - // Principal strains - temporary - KOKKOS_INLINE_FUNCTION Real_t &dxx(const Index_t idx) const { - return m_dxx[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &dyy(const Index_t idx) const { - return m_dyy[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &dzz(const Index_t idx) const { - return m_dzz[idx]; - } - - // New relative volume - temporary - KOKKOS_INLINE_FUNCTION Real_t &vnew(const Index_t idx) const { - return m_vnew[idx]; - } - - // Velocity gradient - temporary - KOKKOS_INLINE_FUNCTION Real_t &delv_xi(const Index_t idx) const { - return m_delv_xi[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &delv_eta(const Index_t idx) const { - return m_delv_eta[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &delv_zeta(const Index_t idx) const { - return m_delv_zeta[idx]; - } - - // Position gradient - temporary - KOKKOS_INLINE_FUNCTION Real_t &delx_xi(const Index_t idx) const { - return m_delx_xi[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &delx_eta(const Index_t idx) const { - return m_delx_eta[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t &delx_zeta(const Index_t idx) const { - return m_delx_zeta[idx]; - } - // Energy - KOKKOS_INLINE_FUNCTION Real_t &e(const Index_t idx) const { return m_e[idx]; } - KOKKOS_INLINE_FUNCTION Real_t c_e(const Index_t idx) const { - return m_c_e[idx]; - } - - // Pressure - KOKKOS_INLINE_FUNCTION Real_t &p(const Index_t idx) const { return m_p[idx]; } - KOKKOS_INLINE_FUNCTION Real_t c_p(const Index_t idx) const { - return m_c_p[idx]; - } - - // Artificial viscosity - KOKKOS_INLINE_FUNCTION Real_t &q(const Index_t idx) const { return m_q[idx]; } - KOKKOS_INLINE_FUNCTION Real_t c_q(const Index_t idx) const { - return m_c_q[idx]; - } - - // Linear term for q - KOKKOS_INLINE_FUNCTION Real_t &ql(const Index_t idx) const { - return m_ql[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t c_ql(const Index_t idx) const { - return m_c_ql[idx]; - } - // Quadratic term for q - KOKKOS_INLINE_FUNCTION Real_t &qq(const Index_t idx) const { - return m_qq[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t c_qq(const Index_t idx) const { - return m_c_qq[idx]; - } - - // Relative volume - KOKKOS_INLINE_FUNCTION Real_t &v(const Index_t idx) const { return m_v[idx]; } - KOKKOS_INLINE_FUNCTION Real_t &delv(const Index_t idx) const { - return m_delv[idx]; - } - KOKKOS_INLINE_FUNCTION Real_t c_delv(const Index_t idx) const { - return m_c_delv[idx]; - } - - // Reference volume - KOKKOS_INLINE_FUNCTION Real_t &volo(Index_t idx) const { return m_volo[idx]; } - - // volume derivative over volume - KOKKOS_INLINE_FUNCTION Real_t &vdov(Index_t idx) const { return m_vdov[idx]; } - - // Element characteristic length - KOKKOS_INLINE_FUNCTION Real_t &arealg(Index_t idx) const { - return m_arealg[idx]; - } - - // Sound speed - KOKKOS_INLINE_FUNCTION Real_t &ss(const Index_t idx) const { - return m_ss[idx]; - } - - // Element mass - KOKKOS_INLINE_FUNCTION Real_t &elemMass(const Index_t idx) const { - return m_elemMass[idx]; - } - - KOKKOS_INLINE_FUNCTION Index_t nodeElemCount(Index_t idx) const { - return m_nodeElemStart[idx + 1] - m_nodeElemStart[idx]; - } - - KOKKOS_INLINE_FUNCTION Index_t *nodeElemCornerList(Index_t idx) const { - return &m_nodeElemCornerList[m_nodeElemStart[idx]]; - } - - // Parameters - - // Cutoffs - KOKKOS_INLINE_FUNCTION Real_t u_cut() const { return m_u_cut; } - KOKKOS_INLINE_FUNCTION Real_t e_cut() const { return m_e_cut; } - KOKKOS_INLINE_FUNCTION Real_t p_cut() const { return m_p_cut; } - KOKKOS_INLINE_FUNCTION Real_t q_cut() const { return m_q_cut; } - KOKKOS_INLINE_FUNCTION Real_t v_cut() const { return m_v_cut; } - - // Other constants (usually are settable via input file in real codes) - KOKKOS_INLINE_FUNCTION Real_t hgcoef() const { return m_hgcoef; } - KOKKOS_INLINE_FUNCTION Real_t qstop() const { return m_qstop; } - KOKKOS_INLINE_FUNCTION Real_t monoq_max_slope() const { - return m_monoq_max_slope; - } - KOKKOS_INLINE_FUNCTION Real_t monoq_limiter_mult() const { - return m_monoq_limiter_mult; - } - KOKKOS_INLINE_FUNCTION Real_t ss4o3() const { return m_ss4o3; } - KOKKOS_INLINE_FUNCTION Real_t qlc_monoq() const { return m_qlc_monoq; } - KOKKOS_INLINE_FUNCTION Real_t qqc_monoq() const { return m_qqc_monoq; } - KOKKOS_INLINE_FUNCTION Real_t qqc() const { return m_qqc; } - - KOKKOS_INLINE_FUNCTION Real_t eosvmax() const { return m_eosvmax; } - KOKKOS_INLINE_FUNCTION Real_t eosvmin() const { return m_eosvmin; } - KOKKOS_INLINE_FUNCTION Real_t pmin() const { return m_pmin; } - KOKKOS_INLINE_FUNCTION Real_t emin() const { return m_emin; } - KOKKOS_INLINE_FUNCTION Real_t dvovmax() const { return m_dvovmax; } - KOKKOS_INLINE_FUNCTION Real_t refdens() const { return m_refdens; } - - // Timestep controls, etc... - Real_t &time() { return m_time; } - Real_t &deltatime() { return m_deltatime; } - Real_t &deltatimemultlb() { return m_deltatimemultlb; } - Real_t &deltatimemultub() { return m_deltatimemultub; } - Real_t &stoptime() { return m_stoptime; } - Real_t &dtcourant() { return m_dtcourant; } - Real_t &dthydro() { return m_dthydro; } - Real_t &dtmax() { return m_dtmax; } - Real_t &dtfixed() { return m_dtfixed; } - - Int_t &cycle() { return m_cycle; } - Index_t &numRanks() { return m_numRanks; } - - Index_t &colLoc() { return m_colLoc; } - Index_t &rowLoc() { return m_rowLoc; } - Index_t &planeLoc() { return m_planeLoc; } - Index_t &tp() { return m_tp; } - - Index_t &sizeX() { return m_sizeX; } - Index_t &sizeY() { return m_sizeY; } - Index_t &sizeZ() { return m_sizeZ; } - Index_t &numReg() { return m_numReg; } - Int_t &cost() { return m_cost; } - Index_t &numElem() { return m_numElem; } - Index_t &numNode() { return m_numNode; } - - Index_t &maxPlaneSize() { return m_maxPlaneSize; } - Index_t &maxEdgeSize() { return m_maxEdgeSize; } - -// -// MPI-Related additional data -// + // + // MPI-Related additional data + // #if USE_MPI - // Communication Work space - Real_t *commDataSend; - Real_t *commDataRecv; + // Communication Work space + Real_t* commDataSend; + Real_t* commDataRecv; - // Maximum number of block neighbors - MPI_Request recvRequest[26]; // 6 faces + 12 edges + 8 corners - MPI_Request sendRequest[26]; // 6 faces + 12 edges + 8 corners + // Maximum number of block neighbors + MPI_Request recvRequest[26]; // 6 faces + 12 edges + 8 corners + MPI_Request sendRequest[26]; // 6 faces + 12 edges + 8 corners #endif private: - void BuildMesh(Int_t nx, Int_t edgeNodes, Int_t edgeElems); - void SetupThreadSupportStructures(); - void CreateRegionIndexSets(Int_t nreg, Int_t balance); - void SetupCommBuffers(Int_t edgeNodes); - void SetupSymmetryPlanes(Int_t edgeNodes); - void SetupElementConnectivities(Int_t edgeElems); - void SetupBoundaryConditions(Int_t edgeElems); + void BuildMesh(Int_t nx, Int_t edgeNodes, Int_t edgeElems); + void SetupThreadSupportStructures(); + void CreateRegionIndexSets(Int_t nreg, Int_t balance); + void SetupCommBuffers(Int_t edgeNodes); + void SetupSymmetryPlanes(Int_t edgeNodes); + void SetupElementConnectivities(Int_t edgeElems); + void SetupBoundaryConditions(Int_t edgeElems); - // - // IMPLEMENTATION - // + // + // IMPLEMENTATION + // - /* Node-centered */ - Kokkos::View m_x; /* coordinates */ - Kokkos::View m_y; - Kokkos::View m_z; - Kokkos::View> - m_c_x; /* coordinates */ - Kokkos::View> - m_c_y; /* coordinates */ - Kokkos::View> - m_c_z; /* coordinates */ + /* Node-centered */ + Kokkos::View m_x; /* coordinates */ + Kokkos::View m_y; + Kokkos::View m_z; + Kokkos::View> + m_c_x; /* coordinates */ + Kokkos::View> + m_c_y; /* coordinates */ + Kokkos::View> + m_c_z; /* coordinates */ - Kokkos::View m_xd; /* velocities */ - Kokkos::View m_yd; - Kokkos::View m_zd; - Kokkos::View> - m_c_xd; /* coordinates */ - Kokkos::View> - m_c_yd; /* coordinates */ - Kokkos::View> - m_c_zd; /* coordinates */ + Kokkos::View m_xd; /* velocities */ + Kokkos::View m_yd; + Kokkos::View m_zd; + Kokkos::View> + m_c_xd; /* coordinates */ + Kokkos::View> + m_c_yd; /* coordinates */ + Kokkos::View> + m_c_zd; /* coordinates */ - Kokkos::View m_xdd; /* accelerations */ - Kokkos::View m_ydd; - Kokkos::View m_zdd; + Kokkos::View m_xdd; /* accelerations */ + Kokkos::View m_ydd; + Kokkos::View m_zdd; - Kokkos::View m_fx; /* forces */ - Kokkos::View m_fy; - Kokkos::View m_fz; + Kokkos::View m_fx; /* forces */ + Kokkos::View m_fy; + Kokkos::View m_fz; - Kokkos::View m_nodalMass; /* mass */ + Kokkos::View m_nodalMass; /* mass */ - Kokkos::View m_symmX; /* symmetry plane nodesets */ - Kokkos::View m_symmY; - Kokkos::View m_symmZ; + Kokkos::View m_symmX; /* symmetry plane nodesets */ + Kokkos::View m_symmY; + Kokkos::View m_symmZ; - // Element-centered + // Element-centered - // Region information - Int_t m_numReg; - Int_t m_cost; // imbalance cost - Index_t *m_regElemSize; // Size of region sets - Index_t *m_regNumList; // Region number per domain element - //Index_t **m_regElemlist; // region indexset - using t_regElemlist = Kokkos::StaticCrsGraph,Index_t>; - t_regElemlist m_regElemlist; + // Region information + Int_t m_numReg; + Int_t m_cost; // imbalance cost + Index_t* m_regElemSize; // Size of region sets + Index_t* m_regNumList; // Region number per domain element + // Index_t **m_regElemlist; // region indexset + using t_regElemlist = + Kokkos::StaticCrsGraph, Index_t>; + t_regElemlist m_regElemlist; - Kokkos::View m_nodelist; /* elemToNode connectivity */ + Kokkos::View + m_nodelist; /* elemToNode connectivity */ - Kokkos::View m_lxim; /* element connectivity across each face */ - Kokkos::View m_lxip; - Kokkos::View m_letam; - Kokkos::View m_letap; - Kokkos::View m_lzetam; - Kokkos::View m_lzetap; + Kokkos::View m_lxim; /* element connectivity across each face */ + Kokkos::View m_lxip; + Kokkos::View m_letam; + Kokkos::View m_letap; + Kokkos::View m_lzetam; + Kokkos::View m_lzetap; - Kokkos::View - m_elemBC; /* symmetry/free-surface flags for each elem face */ + Kokkos::View m_elemBC; /* symmetry/free-surface flags for each elem face */ - Kokkos::View m_dxx; /* principal strains -- temporary */ - Kokkos::View m_dyy; - Kokkos::View m_dzz; + Kokkos::View m_dxx; /* principal strains -- temporary */ + Kokkos::View m_dyy; + Kokkos::View m_dzz; - Kokkos::View m_delv_xi; /* velocity gradient -- temporary */ - Kokkos::View m_delv_eta; - Kokkos::View m_delv_zeta; + Kokkos::View m_delv_xi; /* velocity gradient -- temporary */ + Kokkos::View m_delv_eta; + Kokkos::View m_delv_zeta; - Kokkos::View m_delx_xi; /* coordinate gradient -- temporary */ - Kokkos::View m_delx_eta; - Kokkos::View m_delx_zeta; + Kokkos::View m_delx_xi; /* coordinate gradient -- temporary */ + Kokkos::View m_delx_eta; + Kokkos::View m_delx_zeta; - Kokkos::View m_e; /* energy */ + Kokkos::View m_e; /* energy */ - Kokkos::View m_p; /* pressure */ - Kokkos::View m_q; /* q */ - Kokkos::View m_ql; /* linear term for q */ - Kokkos::View m_qq; /* quadratic term for q */ + Kokkos::View m_p; /* pressure */ + Kokkos::View m_q; /* q */ + Kokkos::View m_ql; /* linear term for q */ + Kokkos::View m_qq; /* quadratic term for q */ - Kokkos::View m_v; /* relative volume */ - Kokkos::View m_volo; /* reference volume */ - Kokkos::View m_vnew; /* new relative volume -- temporary */ - Kokkos::View m_delv; /* m_vnew - m_v */ - Kokkos::View m_vdov; /* volume derivative over volume */ + Kokkos::View m_v; /* relative volume */ + Kokkos::View m_volo; /* reference volume */ + Kokkos::View m_vnew; /* new relative volume -- temporary */ + Kokkos::View m_delv; /* m_vnew - m_v */ + Kokkos::View m_vdov; /* volume derivative over volume */ - Kokkos::View> - m_c_e; /* coordinates */ - Kokkos::View> - m_c_p; /* coordinates */ - Kokkos::View> - m_c_q; /* coordinates */ - Kokkos::View> - m_c_ql; /* coordinates */ - Kokkos::View> - m_c_qq; /* coordinates */ - Kokkos::View> - m_c_delv; /* coordinates */ + Kokkos::View> + m_c_e; /* coordinates */ + Kokkos::View> + m_c_p; /* coordinates */ + Kokkos::View> + m_c_q; /* coordinates */ + Kokkos::View> + m_c_ql; /* coordinates */ + Kokkos::View> + m_c_qq; /* coordinates */ + Kokkos::View> + m_c_delv; /* coordinates */ - Kokkos::View m_arealg; /* characteristic length of an element */ + Kokkos::View m_arealg; /* characteristic length of an element */ - Kokkos::View m_ss; /* "sound speed" */ + Kokkos::View m_ss; /* "sound speed" */ - Kokkos::View m_elemMass; /* mass */ + Kokkos::View m_elemMass; /* mass */ - // Cutoffs (treat as constants) - const Real_t m_e_cut; // energy tolerance - const Real_t m_p_cut; // pressure tolerance - const Real_t m_q_cut; // q tolerance - const Real_t m_v_cut; // relative volume tolerance - const Real_t m_u_cut; // velocity tolerance + // Cutoffs (treat as constants) + const Real_t m_e_cut; // energy tolerance + const Real_t m_p_cut; // pressure tolerance + const Real_t m_q_cut; // q tolerance + const Real_t m_v_cut; // relative volume tolerance + const Real_t m_u_cut; // velocity tolerance - // Other constants (usually setable, but hardcoded in this proxy app) + // Other constants (usually setable, but hardcoded in this proxy app) - const Real_t m_hgcoef; // hourglass control - const Real_t m_ss4o3; - const Real_t m_qstop; // excessive q indicator - const Real_t m_monoq_max_slope; - const Real_t m_monoq_limiter_mult; - const Real_t m_qlc_monoq; // linear term coef for q - const Real_t m_qqc_monoq; // quadratic term coef for q - const Real_t m_qqc; - const Real_t m_eosvmax; - const Real_t m_eosvmin; - const Real_t m_pmin; // pressure floor - const Real_t m_emin; // energy floor - const Real_t m_dvovmax; // maximum allowable volume change - const Real_t m_refdens; // reference density + const Real_t m_hgcoef; // hourglass control + const Real_t m_ss4o3; + const Real_t m_qstop; // excessive q indicator + const Real_t m_monoq_max_slope; + const Real_t m_monoq_limiter_mult; + const Real_t m_qlc_monoq; // linear term coef for q + const Real_t m_qqc_monoq; // quadratic term coef for q + const Real_t m_qqc; + const Real_t m_eosvmax; + const Real_t m_eosvmin; + const Real_t m_pmin; // pressure floor + const Real_t m_emin; // energy floor + const Real_t m_dvovmax; // maximum allowable volume change + const Real_t m_refdens; // reference density - // Variables to keep track of timestep, simulation time, and cycle - Real_t m_dtcourant; // courant constraint - Real_t m_dthydro; // volume change constraint - Int_t m_cycle; // iteration count for simulation - Real_t m_dtfixed; // fixed time increment - Real_t m_time; // current time - Real_t m_deltatime; // variable time increment - Real_t m_deltatimemultlb; - Real_t m_deltatimemultub; - Real_t m_dtmax; // maximum allowable time increment - Real_t m_stoptime; // end time for simulation + // Variables to keep track of timestep, simulation time, and cycle + Real_t m_dtcourant; // courant constraint + Real_t m_dthydro; // volume change constraint + Int_t m_cycle; // iteration count for simulation + Real_t m_dtfixed; // fixed time increment + Real_t m_time; // current time + Real_t m_deltatime; // variable time increment + Real_t m_deltatimemultlb; + Real_t m_deltatimemultub; + Real_t m_dtmax; // maximum allowable time increment + Real_t m_stoptime; // end time for simulation - Int_t m_numRanks; + Int_t m_numRanks; - Index_t m_colLoc; - Index_t m_rowLoc; - Index_t m_planeLoc; - Index_t m_tp; + Index_t m_colLoc; + Index_t m_rowLoc; + Index_t m_planeLoc; + Index_t m_tp; - Index_t m_sizeX; - Index_t m_sizeY; - Index_t m_sizeZ; - Index_t m_numElem; - Index_t m_numNode; + Index_t m_sizeX; + Index_t m_sizeY; + Index_t m_sizeZ; + Index_t m_numElem; + Index_t m_numNode; - Index_t m_maxPlaneSize; - Index_t m_maxEdgeSize; + Index_t m_maxPlaneSize; + Index_t m_maxEdgeSize; - // OMP hack - Kokkos::View m_nodeElemStart; - Kokkos::View m_nodeElemCornerList; + // OMP hack + Kokkos::View m_nodeElemStart; + Kokkos::View m_nodeElemCornerList; - // Used in setup - Index_t m_rowMin, m_rowMax; - Index_t m_colMin, m_colMax; - Index_t m_planeMin, m_planeMax; + // Used in setup + Index_t m_rowMin, m_rowMax; + Index_t m_colMin, m_colMax; + Index_t m_planeMin, m_planeMax; }; -typedef Real_t &(Domain::*Domain_member)(Index_t) const; +typedef Real_t& (Domain::*Domain_member)(Index_t) const; -struct cmdLineOpts { - Int_t its; // -i - Int_t nx; // -s - Int_t numReg; // -r - Int_t numFiles; // -f - Int_t showProg; // -p - Int_t quiet; // -q - Int_t viz; // -v - Int_t cost; // -c - Int_t balance; // -b - Int_t do_atomic; // -a +struct cmdLineOpts +{ + Int_t its; // -i + Int_t nx; // -s + Int_t numReg; // -r + Int_t numFiles; // -f + Int_t showProg; // -p + Int_t quiet; // -q + Int_t viz; // -v + Int_t cost; // -c + Int_t balance; // -b + Int_t do_atomic; // -a }; // Function Prototypes @@ -728,27 +748,33 @@ struct cmdLineOpts { const Real_t z[8]);*/ // lulesh-util -void ParseCommandLineOptions(int argc, char *argv[], Int_t myRank, - struct cmdLineOpts *opts); -void VerifyAndWriteFinalOutput(Real_t elapsed_time, Domain &locDom, Int_t nx, - Int_t numRanks); +void +ParseCommandLineOptions(int argc, char* argv[], Int_t myRank, struct cmdLineOpts* opts); +void +VerifyAndWriteFinalOutput(Real_t elapsed_time, Domain& locDom, Int_t nx, Int_t numRanks); // lulesh-viz -void DumpToVisit(Domain &domain, int numFiles, int myRank, int numRanks); +void +DumpToVisit(Domain& domain, int numFiles, int myRank, int numRanks); // lulesh-comm -void CommRecv(Domain &domain, Int_t msgType, Index_t xferFields, Index_t dx, - Index_t dy, Index_t dz, bool doRecv, bool planeOnly); -void CommSend(Domain &domain, Int_t msgType, Index_t xferFields, - Domain_member *fieldData, Index_t dx, Index_t dy, Index_t dz, - bool doSend, bool planeOnly); -void CommSBN(Domain &domain, Int_t xferFields, Domain_member *fieldData); -void CommSyncPosVel(Domain &domain); -void CommMonoQ(Domain &domain); +void +CommRecv(Domain& domain, Int_t msgType, Index_t xferFields, Index_t dx, Index_t dy, + Index_t dz, bool doRecv, bool planeOnly); +void +CommSend(Domain& domain, Int_t msgType, Index_t xferFields, Domain_member* fieldData, + Index_t dx, Index_t dy, Index_t dz, bool doSend, bool planeOnly); +void +CommSBN(Domain& domain, Int_t xferFields, Domain_member* fieldData); +void +CommSyncPosVel(Domain& domain); +void +CommMonoQ(Domain& domain); // lulesh-init -void InitMeshDecomp(Int_t numRanks, Int_t myRank, Int_t *col, Int_t *row, - Int_t *plane, Int_t *side); +void +InitMeshDecomp(Int_t numRanks, Int_t myRank, Int_t* col, Int_t* row, Int_t* plane, + Int_t* side); /*********************************/ /* Data structure implementation */ @@ -757,65 +783,91 @@ void InitMeshDecomp(Int_t numRanks, Int_t myRank, Int_t *col, Int_t *row, /* might want to add access methods so that memory can be */ /* better managed, as in luleshFT */ -template T *Allocate(size_t size) { - return static_cast(Kokkos::kokkos_malloc(sizeof(T) * size + 8)); +template +T* +Allocate(size_t size) +{ + return static_cast( + Kokkos::kokkos_malloc(sizeof(T) * size + 8)); } -template void Release(T **ptr) { - if (*ptr != NULL) { - Kokkos::kokkos_free(*ptr); - *ptr = NULL; - } +template +void +Release(T** ptr) +{ + if(*ptr != NULL) + { + Kokkos::kokkos_free(*ptr); + *ptr = NULL; + } } -struct MinFinder { - Real_t val; - int i; - KOKKOS_INLINE_FUNCTION +struct MinFinder +{ + Real_t val; + int i; + KOKKOS_INLINE_FUNCTION - MinFinder() : val(100000000000000000000.0000), i(-1) {} + MinFinder() + : val(100000000000000000000.0000) + , i(-1) + {} - KOKKOS_INLINE_FUNCTION - MinFinder(const double &val_, const int &i_) : val(val_), i(i_) {} + KOKKOS_INLINE_FUNCTION + MinFinder(const double& val_, const int& i_) + : val(val_) + , i(i_) + {} - KOKKOS_INLINE_FUNCTION - MinFinder(const MinFinder &src) : val(src.val), i(src.i) {} + KOKKOS_INLINE_FUNCTION + MinFinder(const MinFinder& src) + : val(src.val) + , i(src.i) + {} - // overloading += operator to do the max assignment - KOKKOS_INLINE_FUNCTION - void operator+=(MinFinder &src) { - if (src.val < val) { - val = src.val; - i = src.i; + // overloading += operator to do the max assignment + KOKKOS_INLINE_FUNCTION + void operator+=(MinFinder& src) + { + if(src.val < val) + { + val = src.val; + i = src.i; + } } - } - KOKKOS_INLINE_FUNCTION - void operator+=(const volatile MinFinder &src) volatile { - if (src.val < val) { - val = src.val; - i = src.i; + KOKKOS_INLINE_FUNCTION + void operator+=(const volatile MinFinder& src) volatile + { + if(src.val < val) + { + val = src.val; + i = src.i; + } } - } }; -struct reduce_double3 { - double x, y, z; - KOKKOS_INLINE_FUNCTION - reduce_double3() { - x = 0.0; - y = 0.0; - z = 0.0; - } - KOKKOS_INLINE_FUNCTION - void operator+=(const volatile reduce_double3 &src) volatile { - x += src.x; - y += src.y; - z += src.z; - } - KOKKOS_INLINE_FUNCTION - void operator+=(const reduce_double3 &src) { - x += src.x; - y += src.y; - z += src.z; - } +struct reduce_double3 +{ + double x, y, z; + KOKKOS_INLINE_FUNCTION + reduce_double3() + { + x = 0.0; + y = 0.0; + z = 0.0; + } + KOKKOS_INLINE_FUNCTION + void operator+=(const volatile reduce_double3& src) volatile + { + x += src.x; + y += src.y; + z += src.z; + } + KOKKOS_INLINE_FUNCTION + void operator+=(const reduce_double3& src) + { + x += src.x; + y += src.y; + z += src.z; + } }; diff --git a/projects/rocprofiler-systems/examples/lulesh/lulesh_tuple.h b/projects/rocprofiler-systems/examples/lulesh/lulesh_tuple.h index 172ec017a6..922ae91fe3 100644 --- a/projects/rocprofiler-systems/examples/lulesh/lulesh_tuple.h +++ b/projects/rocprofiler-systems/examples/lulesh/lulesh_tuple.h @@ -1,14 +1,13 @@ #if !defined(USE_MPI) -# error "You should specify USE_MPI=0 or USE_MPI=1 on the compile line" +# error "You should specify USE_MPI=0 or USE_MPI=1 on the compile line" #endif - // OpenMP will be compiled in if this flag is set to 1 AND the compiler beging // used supports it (i.e. the _OPENMP symbol is defined) #define USE_OMP 1 #if USE_MPI -#include +# include #endif #include @@ -27,57 +26,95 @@ #include //************************************************** -// Allow flexibility for arithmetic representations +// Allow flexibility for arithmetic representations //************************************************** -#define MAX(a, b) ( ((a) > (b)) ? (a) : (b)) - +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) // Precision specification -typedef float real4 ; -typedef double real8 ; -typedef long double real10 ; // 10 bytes on x86 +typedef float real4; +typedef double real8; +typedef long double real10; // 10 bytes on x86 -typedef int Index_t ; // array subscript and loop index -typedef real8 Real_t ; // floating point representation -typedef int Int_t ; // integer representation +typedef int Index_t; // array subscript and loop index +typedef real8 Real_t; // floating point representation +typedef int Int_t; // integer representation -enum { VolumeError = -1, QStopError = -2 } ; +enum +{ + VolumeError = -1, + QStopError = -2 +}; -inline real4 SQRT(real4 arg) { return sqrtf(arg) ; } -inline real8 SQRT(real8 arg) { return sqrt(arg) ; } -inline real10 SQRT(real10 arg) { return sqrtl(arg) ; } +inline real4 +SQRT(real4 arg) +{ + return sqrtf(arg); +} +inline real8 +SQRT(real8 arg) +{ + return sqrt(arg); +} +inline real10 +SQRT(real10 arg) +{ + return sqrtl(arg); +} -inline real4 CBRT(real4 arg) { return cbrtf(arg) ; } -inline real8 CBRT(real8 arg) { return cbrt(arg) ; } -inline real10 CBRT(real10 arg) { return cbrtl(arg) ; } - -inline real4 FABS(real4 arg) { return fabsf(arg) ; } -inline real8 FABS(real8 arg) { return fabs(arg) ; } -inline real10 FABS(real10 arg) { return fabsl(arg) ; } +inline real4 +CBRT(real4 arg) +{ + return cbrtf(arg); +} +inline real8 +CBRT(real8 arg) +{ + return cbrt(arg); +} +inline real10 +CBRT(real10 arg) +{ + return cbrtl(arg); +} +inline real4 +FABS(real4 arg) +{ + return fabsf(arg); +} +inline real8 +FABS(real8 arg) +{ + return fabs(arg); +} +inline real10 +FABS(real10 arg) +{ + return fabsl(arg); +} // Stuff needed for boundary conditions // 2 BCs on each of 6 hexahedral faces (12 bits) -#define XI_M 0x00007 -#define XI_M_SYMM 0x00001 -#define XI_M_FREE 0x00002 -#define XI_M_COMM 0x00004 +#define XI_M 0x00007 +#define XI_M_SYMM 0x00001 +#define XI_M_FREE 0x00002 +#define XI_M_COMM 0x00004 -#define XI_P 0x00038 -#define XI_P_SYMM 0x00008 -#define XI_P_FREE 0x00010 -#define XI_P_COMM 0x00020 +#define XI_P 0x00038 +#define XI_P_SYMM 0x00008 +#define XI_P_FREE 0x00010 +#define XI_P_COMM 0x00020 -#define ETA_M 0x001c0 -#define ETA_M_SYMM 0x00040 -#define ETA_M_FREE 0x00080 -#define ETA_M_COMM 0x00100 +#define ETA_M 0x001c0 +#define ETA_M_SYMM 0x00040 +#define ETA_M_FREE 0x00080 +#define ETA_M_COMM 0x00100 -#define ETA_P 0x00e00 -#define ETA_P_SYMM 0x00200 -#define ETA_P_FREE 0x00400 -#define ETA_P_COMM 0x00800 +#define ETA_P 0x00e00 +#define ETA_P_SYMM 0x00200 +#define ETA_P_FREE 0x00400 +#define ETA_P_COMM 0x00800 #define ZETA_M 0x07000 #define ZETA_M_SYMM 0x01000 @@ -90,9 +127,9 @@ inline real10 FABS(real10 arg) { return fabsl(arg) ; } #define ZETA_P_COMM 0x20000 // MPI Message Tags -#define MSG_COMM_SBN 1024 -#define MSG_SYNC_POS_VEL 2048 -#define MSG_MONOQ 3072 +#define MSG_COMM_SBN 1024 +#define MSG_SYNC_POS_VEL 2048 +#define MSG_MONOQ 3072 #define MAX_FIELDS_PER_MPI_COMM 6 @@ -100,8 +137,8 @@ inline real10 FABS(real10 arg) { return fabsl(arg) ; } // Assume Real_t is an "integral power of 2" bytes wide #define CACHE_COHERENCE_PAD_REAL (128 / sizeof(Real_t)) -#define CACHE_ALIGN_REAL(n) \ - (((n) + (CACHE_COHERENCE_PAD_REAL - 1)) & ~(CACHE_COHERENCE_PAD_REAL-1)) +#define CACHE_ALIGN_REAL(n) \ + (((n) + (CACHE_COHERENCE_PAD_REAL - 1)) & ~(CACHE_COHERENCE_PAD_REAL - 1)) ////////////////////////////////////////////////////// // Primary data structure @@ -126,485 +163,489 @@ inline real10 FABS(real10 arg) { return fabsl(arg) ; } * "Real_t &z(Index_t idx) { return m_coord[idx].z ; }" */ -class Domain { +class Domain +{ +public: + // Constructor + Domain(Int_t numRanks, Index_t colLoc, Index_t rowLoc, Index_t planeLoc, Index_t nx, + Int_t tp, Int_t nr, Int_t balance, Int_t cost); - public: + // + // ALLOCATION + // - // Constructor - Domain(Int_t numRanks, Index_t colLoc, - Index_t rowLoc, Index_t planeLoc, - Index_t nx, Int_t tp, Int_t nr, Int_t balance, Int_t cost); + void AllocateNodePersistent(Int_t numNode) // Node-centered + { + m_coord.resize(numNode); // coordinates - // - // ALLOCATION - // + m_vel.resize(numNode); // velocities - void AllocateNodePersistent(Int_t numNode) // Node-centered - { - m_coord.resize(numNode); // coordinates + m_acc.resize(numNode); // accelerations - m_vel.resize(numNode); // velocities + m_force.resize(numNode); // forces - m_acc.resize(numNode); // accelerations + m_nodalMass.resize(numNode); // mass + } - m_force.resize(numNode); // forces + void AllocateElemPersistent(Int_t numElem) // Elem-centered + { + m_nodelist.resize(8 * numElem); - m_nodalMass.resize(numNode); // mass - } + // elem connectivities through face + m_faceToElem.resize(numElem); - void AllocateElemPersistent(Int_t numElem) // Elem-centered - { - m_nodelist.resize(8*numElem); + m_elemBC.resize(numElem); - // elem connectivities through face - m_faceToElem.resize(numElem); + m_e.resize(numElem); - m_elemBC.resize(numElem); + m_pq.resize(numElem); - m_e.resize(numElem); + m_qlqq.resize(numElem); - m_pq.resize(numElem); + m_vol.resize(numElem); - m_qlqq.resize(numElem); + m_delv.resize(numElem); + m_vdov.resize(numElem); - m_vol.resize(numElem); + m_arealg.resize(numElem); - m_delv.resize(numElem); - m_vdov.resize(numElem); + m_ss.resize(numElem); - m_arealg.resize(numElem); + m_elemMass.resize(numElem); + } - m_ss.resize(numElem); + void AllocateGradients(Int_t numElem, Int_t allElem) + { + // Position gradients + m_delx_xi.resize(numElem); + m_delx_eta.resize(numElem); + m_delx_zeta.resize(numElem); - m_elemMass.resize(numElem); - } + // Velocity gradients + m_delv_xi.resize(allElem); + m_delv_eta.resize(allElem); + m_delv_zeta.resize(allElem); + } - void AllocateGradients(Int_t numElem, Int_t allElem) - { - // Position gradients - m_delx_xi.resize(numElem) ; - m_delx_eta.resize(numElem) ; - m_delx_zeta.resize(numElem) ; + void DeallocateGradients() + { + m_delx_zeta.clear(); + m_delx_eta.clear(); + m_delx_xi.clear(); - // Velocity gradients - m_delv_xi.resize(allElem) ; - m_delv_eta.resize(allElem); - m_delv_zeta.resize(allElem) ; - } + m_delv_zeta.clear(); + m_delv_eta.clear(); + m_delv_xi.clear(); + } - void DeallocateGradients() - { - m_delx_zeta.clear() ; - m_delx_eta.clear() ; - m_delx_xi.clear() ; + void AllocateStrains(Int_t numElem) + { + m_dxx.resize(numElem); + m_dyy.resize(numElem); + m_dzz.resize(numElem); + } - m_delv_zeta.clear() ; - m_delv_eta.clear() ; - m_delv_xi.clear() ; - } + void DeallocateStrains() + { + m_dzz.clear(); + m_dyy.clear(); + m_dxx.clear(); + } - void AllocateStrains(Int_t numElem) - { - m_dxx.resize(numElem) ; - m_dyy.resize(numElem) ; - m_dzz.resize(numElem) ; - } + // + // ACCESSORS + // - void DeallocateStrains() - { - m_dzz.clear() ; - m_dyy.clear() ; - m_dxx.clear() ; - } - - // - // ACCESSORS - // + // Node-centered - // Node-centered + // Nodal coordinates + Real_t& x(Index_t idx) { return m_coord[idx].x; } + Real_t& y(Index_t idx) { return m_coord[idx].y; } + Real_t& z(Index_t idx) { return m_coord[idx].z; } - // Nodal coordinates - Real_t& x(Index_t idx) { return m_coord[idx].x ; } - Real_t& y(Index_t idx) { return m_coord[idx].y ; } - Real_t& z(Index_t idx) { return m_coord[idx].z ; } + // Nodal velocities + Real_t& xd(Index_t idx) { return m_vel[idx].x; } + Real_t& yd(Index_t idx) { return m_vel[idx].y; } + Real_t& zd(Index_t idx) { return m_vel[idx].z; } - // Nodal velocities - Real_t& xd(Index_t idx) { return m_vel[idx].x ; } - Real_t& yd(Index_t idx) { return m_vel[idx].y ; } - Real_t& zd(Index_t idx) { return m_vel[idx].z ; } + // Nodal accelerations + Real_t& xdd(Index_t idx) { return m_acc[idx].x; } + Real_t& ydd(Index_t idx) { return m_acc[idx].y; } + Real_t& zdd(Index_t idx) { return m_acc[idx].z; } - // Nodal accelerations - Real_t& xdd(Index_t idx) { return m_acc[idx].x ; } - Real_t& ydd(Index_t idx) { return m_acc[idx].y ; } - Real_t& zdd(Index_t idx) { return m_acc[idx].z ; } + // Nodal forces + Real_t& fx(Index_t idx) { return m_force[idx].x; } + Real_t& fy(Index_t idx) { return m_force[idx].y; } + Real_t& fz(Index_t idx) { return m_force[idx].z; } - // Nodal forces - Real_t& fx(Index_t idx) { return m_force[idx].x ; } - Real_t& fy(Index_t idx) { return m_force[idx].y ; } - Real_t& fz(Index_t idx) { return m_force[idx].z ; } + // Nodal mass + Real_t& nodalMass(Index_t idx) { return m_nodalMass[idx]; } - // Nodal mass - Real_t& nodalMass(Index_t idx) { return m_nodalMass[idx] ; } + // Nodes on symmertry planes + Index_t symmX(Index_t idx) { return m_symmX[idx]; } + Index_t symmY(Index_t idx) { return m_symmY[idx]; } + Index_t symmZ(Index_t idx) { return m_symmZ[idx]; } + bool symmXempty() { return m_symmX.empty(); } + bool symmYempty() { return m_symmY.empty(); } + bool symmZempty() { return m_symmZ.empty(); } - // Nodes on symmertry planes - Index_t symmX(Index_t idx) { return m_symmX[idx] ; } - Index_t symmY(Index_t idx) { return m_symmY[idx] ; } - Index_t symmZ(Index_t idx) { return m_symmZ[idx] ; } - bool symmXempty() { return m_symmX.empty(); } - bool symmYempty() { return m_symmY.empty(); } - bool symmZempty() { return m_symmZ.empty(); } + // + // Element-centered + // + Index_t& regElemSize(Index_t idx) { return m_regElemSize[idx]; } + Index_t& regNumList(Index_t idx) { return m_regNumList[idx]; } + Index_t* regNumList() { return &m_regNumList[0]; } + Index_t* regElemlist(Int_t r) { return m_regElemlist[r]; } + Index_t& regElemlist(Int_t r, Index_t idx) { return m_regElemlist[r][idx]; } - // - // Element-centered - // - Index_t& regElemSize(Index_t idx) { return m_regElemSize[idx] ; } - Index_t& regNumList(Index_t idx) { return m_regNumList[idx] ; } - Index_t* regNumList() { return &m_regNumList[0] ; } - Index_t* regElemlist(Int_t r) { return m_regElemlist[r] ; } - Index_t& regElemlist(Int_t r, Index_t idx) { return m_regElemlist[r][idx] ; } + Index_t* nodelist(Index_t idx) { return &m_nodelist[Index_t(8) * idx]; } - Index_t* nodelist(Index_t idx) { return &m_nodelist[Index_t(8)*idx] ; } + // elem connectivities through face + Index_t& lxim(Index_t idx) { return m_faceToElem[idx].lxim; } + Index_t& lxip(Index_t idx) { return m_faceToElem[idx].lxip; } + Index_t& letam(Index_t idx) { return m_faceToElem[idx].letam; } + Index_t& letap(Index_t idx) { return m_faceToElem[idx].letap; } + Index_t& lzetam(Index_t idx) { return m_faceToElem[idx].lzetam; } + Index_t& lzetap(Index_t idx) { return m_faceToElem[idx].lzetap; } - // elem connectivities through face - Index_t& lxim(Index_t idx) { return m_faceToElem[idx].lxim ; } - Index_t& lxip(Index_t idx) { return m_faceToElem[idx].lxip ; } - Index_t& letam(Index_t idx) { return m_faceToElem[idx].letam ; } - Index_t& letap(Index_t idx) { return m_faceToElem[idx].letap ; } - Index_t& lzetam(Index_t idx) { return m_faceToElem[idx].lzetam ; } - Index_t& lzetap(Index_t idx) { return m_faceToElem[idx].lzetap ; } + // elem face symm/free-surface flag + Int_t& elemBC(Index_t idx) { return m_elemBC[idx]; } - // elem face symm/free-surface flag - Int_t& elemBC(Index_t idx) { return m_elemBC[idx] ; } + // Principal strains - temporary + Real_t& dxx(Index_t idx) { return m_dxx[idx]; } + Real_t& dyy(Index_t idx) { return m_dyy[idx]; } + Real_t& dzz(Index_t idx) { return m_dzz[idx]; } - // Principal strains - temporary - Real_t& dxx(Index_t idx) { return m_dxx[idx] ; } - Real_t& dyy(Index_t idx) { return m_dyy[idx] ; } - Real_t& dzz(Index_t idx) { return m_dzz[idx] ; } + // Velocity gradient - temporary + Real_t& delv_xi(Index_t idx) { return m_delv_xi[idx]; } + Real_t& delv_eta(Index_t idx) { return m_delv_eta[idx]; } + Real_t& delv_zeta(Index_t idx) { return m_delv_zeta[idx]; } - // Velocity gradient - temporary - Real_t& delv_xi(Index_t idx) { return m_delv_xi[idx] ; } - Real_t& delv_eta(Index_t idx) { return m_delv_eta[idx] ; } - Real_t& delv_zeta(Index_t idx) { return m_delv_zeta[idx] ; } + // Position gradient - temporary + Real_t& delx_xi(Index_t idx) { return m_delx_xi[idx]; } + Real_t& delx_eta(Index_t idx) { return m_delx_eta[idx]; } + Real_t& delx_zeta(Index_t idx) { return m_delx_zeta[idx]; } - // Position gradient - temporary - Real_t& delx_xi(Index_t idx) { return m_delx_xi[idx] ; } - Real_t& delx_eta(Index_t idx) { return m_delx_eta[idx] ; } - Real_t& delx_zeta(Index_t idx) { return m_delx_zeta[idx] ; } + // Energy + Real_t& e(Index_t idx) { return m_e[idx]; } - // Energy - Real_t& e(Index_t idx) { return m_e[idx] ; } + // Pressure + Real_t& p(Index_t idx) { return m_pq[idx].p; } - // Pressure - Real_t& p(Index_t idx) { return m_pq[idx].p ; } + // Artificial viscosity + Real_t& q(Index_t idx) { return m_pq[idx].q; } - // Artificial viscosity - Real_t& q(Index_t idx) { return m_pq[idx].q ; } + // Linear term for q + Real_t& ql(Index_t idx) { return m_qlqq[idx].ql; } + // Quadratic term for q + Real_t& qq(Index_t idx) { return m_qlqq[idx].qq; } - // Linear term for q - Real_t& ql(Index_t idx) { return m_qlqq[idx].ql ; } - // Quadratic term for q - Real_t& qq(Index_t idx) { return m_qlqq[idx].qq ; } + Real_t& delv(Index_t idx) { return m_delv[idx]; } - Real_t& delv(Index_t idx) { return m_delv[idx] ; } + // Relative volume + Real_t& v(Index_t idx) { return m_vol[idx].v; } + // Reference volume + Real_t& volo(Index_t idx) { return m_vol[idx].volo; } - // Relative volume - Real_t& v(Index_t idx) { return m_vol[idx].v ; } - // Reference volume - Real_t& volo(Index_t idx) { return m_vol[idx].volo ; } + // volume derivative over volume + Real_t& vdov(Index_t idx) { return m_vdov[idx]; } - // volume derivative over volume - Real_t& vdov(Index_t idx) { return m_vdov[idx] ; } + // Element characteristic length + Real_t& arealg(Index_t idx) { return m_arealg[idx]; } - // Element characteristic length - Real_t& arealg(Index_t idx) { return m_arealg[idx] ; } + // Sound speed + Real_t& ss(Index_t idx) { return m_ss[idx]; } - // Sound speed - Real_t& ss(Index_t idx) { return m_ss[idx] ; } + // Element mass + Real_t& elemMass(Index_t idx) { return m_elemMass[idx]; } - // Element mass - Real_t& elemMass(Index_t idx) { return m_elemMass[idx] ; } + Index_t nodeElemCount(Index_t idx) + { + return m_nodeElemStart[idx + 1] - m_nodeElemStart[idx]; + } - Index_t nodeElemCount(Index_t idx) - { return m_nodeElemStart[idx+1] - m_nodeElemStart[idx] ; } + Index_t* nodeElemCornerList(Index_t idx) + { + return &m_nodeElemCornerList[m_nodeElemStart[idx]]; + } - Index_t *nodeElemCornerList(Index_t idx) - { return &m_nodeElemCornerList[m_nodeElemStart[idx]] ; } + // Parameters - // Parameters + // Cutoffs + Real_t u_cut() const { return m_u_cut; } + Real_t e_cut() const { return m_e_cut; } + Real_t p_cut() const { return m_p_cut; } + Real_t q_cut() const { return m_q_cut; } + Real_t v_cut() const { return m_v_cut; } - // Cutoffs - Real_t u_cut() const { return m_u_cut ; } - Real_t e_cut() const { return m_e_cut ; } - Real_t p_cut() const { return m_p_cut ; } - Real_t q_cut() const { return m_q_cut ; } - Real_t v_cut() const { return m_v_cut ; } + // Other constants (usually are settable via input file in real codes) + Real_t hgcoef() const { return m_hgcoef; } + Real_t qstop() const { return m_qstop; } + Real_t monoq_max_slope() const { return m_monoq_max_slope; } + Real_t monoq_limiter_mult() const { return m_monoq_limiter_mult; } + Real_t ss4o3() const { return m_ss4o3; } + Real_t qlc_monoq() const { return m_qlc_monoq; } + Real_t qqc_monoq() const { return m_qqc_monoq; } + Real_t qqc() const { return m_qqc; } - // Other constants (usually are settable via input file in real codes) - Real_t hgcoef() const { return m_hgcoef ; } - Real_t qstop() const { return m_qstop ; } - Real_t monoq_max_slope() const { return m_monoq_max_slope ; } - Real_t monoq_limiter_mult() const { return m_monoq_limiter_mult ; } - Real_t ss4o3() const { return m_ss4o3 ; } - Real_t qlc_monoq() const { return m_qlc_monoq ; } - Real_t qqc_monoq() const { return m_qqc_monoq ; } - Real_t qqc() const { return m_qqc ; } + Real_t eosvmax() const { return m_eosvmax; } + Real_t eosvmin() const { return m_eosvmin; } + Real_t pmin() const { return m_pmin; } + Real_t emin() const { return m_emin; } + Real_t dvovmax() const { return m_dvovmax; } + Real_t refdens() const { return m_refdens; } - Real_t eosvmax() const { return m_eosvmax ; } - Real_t eosvmin() const { return m_eosvmin ; } - Real_t pmin() const { return m_pmin ; } - Real_t emin() const { return m_emin ; } - Real_t dvovmax() const { return m_dvovmax ; } - Real_t refdens() const { return m_refdens ; } + // Timestep controls, etc... + Real_t& time() { return m_time; } + Real_t& deltatime() { return m_deltatime; } + Real_t& deltatimemultlb() { return m_deltatimemultlb; } + Real_t& deltatimemultub() { return m_deltatimemultub; } + Real_t& stoptime() { return m_stoptime; } + Real_t& dtcourant() { return m_dtcourant; } + Real_t& dthydro() { return m_dthydro; } + Real_t& dtmax() { return m_dtmax; } + Real_t& dtfixed() { return m_dtfixed; } - // Timestep controls, etc... - Real_t& time() { return m_time ; } - Real_t& deltatime() { return m_deltatime ; } - Real_t& deltatimemultlb() { return m_deltatimemultlb ; } - Real_t& deltatimemultub() { return m_deltatimemultub ; } - Real_t& stoptime() { return m_stoptime ; } - Real_t& dtcourant() { return m_dtcourant ; } - Real_t& dthydro() { return m_dthydro ; } - Real_t& dtmax() { return m_dtmax ; } - Real_t& dtfixed() { return m_dtfixed ; } + Int_t& cycle() { return m_cycle; } + Index_t& numRanks() { return m_numRanks; } - Int_t& cycle() { return m_cycle ; } - Index_t& numRanks() { return m_numRanks ; } + Index_t& colLoc() { return m_colLoc; } + Index_t& rowLoc() { return m_rowLoc; } + Index_t& planeLoc() { return m_planeLoc; } + Index_t& tp() { return m_tp; } - Index_t& colLoc() { return m_colLoc ; } - Index_t& rowLoc() { return m_rowLoc ; } - Index_t& planeLoc() { return m_planeLoc ; } - Index_t& tp() { return m_tp ; } + Index_t& sizeX() { return m_sizeX; } + Index_t& sizeY() { return m_sizeY; } + Index_t& sizeZ() { return m_sizeZ; } + Index_t& numReg() { return m_numReg; } + Int_t& cost() { return m_cost; } + Index_t& numElem() { return m_numElem; } + Index_t& numNode() { return m_numNode; } - Index_t& sizeX() { return m_sizeX ; } - Index_t& sizeY() { return m_sizeY ; } - Index_t& sizeZ() { return m_sizeZ ; } - Index_t& numReg() { return m_numReg ; } - Int_t& cost() { return m_cost ; } - Index_t& numElem() { return m_numElem ; } - Index_t& numNode() { return m_numNode ; } - - Index_t& maxPlaneSize() { return m_maxPlaneSize ; } - Index_t& maxEdgeSize() { return m_maxEdgeSize ; } - - // - // MPI-Related additional data - // + Index_t& maxPlaneSize() { return m_maxPlaneSize; } + Index_t& maxEdgeSize() { return m_maxEdgeSize; } -#if USE_MPI - // Communication Work space - Real_t *commDataSend ; - Real_t *commDataRecv ; - - // Maximum number of block neighbors - MPI_Request recvRequest[26] ; // 6 faces + 12 edges + 8 corners - MPI_Request sendRequest[26] ; // 6 faces + 12 edges + 8 corners + // + // MPI-Related additional data + // + +#if USE_MPI + // Communication Work space + Real_t* commDataSend; + Real_t* commDataRecv; + + // Maximum number of block neighbors + MPI_Request recvRequest[26]; // 6 faces + 12 edges + 8 corners + MPI_Request sendRequest[26]; // 6 faces + 12 edges + 8 corners #endif - private: +private: + void BuildMesh(Int_t nx, Int_t edgeNodes, Int_t edgeElems); + void SetupThreadSupportStructures(); + void CreateRegionIndexSets(Int_t nreg, Int_t balance); + void SetupCommBuffers(Int_t edgeNodes); + void SetupSymmetryPlanes(Int_t edgeNodes); + void SetupElementConnectivities(Int_t edgeElems); + void SetupBoundaryConditions(Int_t edgeElems); - void BuildMesh(Int_t nx, Int_t edgeNodes, Int_t edgeElems); - void SetupThreadSupportStructures(); - void CreateRegionIndexSets(Int_t nreg, Int_t balance); - void SetupCommBuffers(Int_t edgeNodes); - void SetupSymmetryPlanes(Int_t edgeNodes); - void SetupElementConnectivities(Int_t edgeElems); - void SetupBoundaryConditions(Int_t edgeElems); + // + // IMPLEMENTATION + // - // - // IMPLEMENTATION - // + /* Node-centered */ - /* Node-centered */ + struct Tuple3 + { + Real_t x, y, z; + }; - struct Tuple3 { - Real_t x, y, z ; - } ; + Kokkos::View m_coord; /* coordinates */ - Kokkos::View m_coord ; /* coordinates */ + Kokkos::View m_vel; /* velocities */ - Kokkos::View m_vel ; /* velocities */ + Kokkos::View m_acc; /* accelerations */ - Kokkos::View m_acc ; /* accelerations */ + Kokkos::View m_force; /* forces */ - Kokkos::View m_force ; /* forces */ + Kokkos::View m_nodalMass; /* mass */ - Kokkos::View m_nodalMass ; /* mass */ + Kokkos::View m_symmX; /* symmetry plane nodesets */ + Kokkos::View m_symmY; + Kokkos::View m_symmZ; - Kokkos::View m_symmX ; /* symmetry plane nodesets */ - Kokkos::View m_symmY ; - Kokkos::View m_symmZ ; + // Element-centered - // Element-centered + // Region information + Int_t m_numReg; + Int_t m_cost; // imbalance cost + Index_t* m_regElemSize; // Size of region sets + Index_t* m_regNumList; // Region number per domain element + Index_t** m_regElemlist; // region indexset - // Region information - Int_t m_numReg ; - Int_t m_cost; //imbalance cost - Index_t *m_regElemSize ; // Size of region sets - Index_t *m_regNumList ; // Region number per domain element - Index_t **m_regElemlist ; // region indexset + Kokkos::View m_nodelist; /* elemToNode connectivity */ - Kokkos::View m_nodelist ; /* elemToNode connectivity */ + struct FaceElemConn + { + Index_t lxim, lxip, letam, letap, lzetam, lzetap; + }; - struct FaceElemConn { - Index_t lxim, lxip, letam, letap, lzetam, lzetap ; - } ; + Kokkos::View m_faceToElem; /* element conn across faces */ - Kokkos::View m_faceToElem ; /* element conn across faces */ + Kokkos::View m_elemBC; /* symmetry/free-surface flags for each elem face */ - Kokkos::View m_elemBC ; /* symmetry/free-surface flags for each elem face */ + Kokkos::View m_dxx; /* principal strains -- temporary */ + Kokkos::View m_dyy; + Kokkos::View m_dzz; - Kokkos::View m_dxx ; /* principal strains -- temporary */ - Kokkos::View m_dyy ; - Kokkos::View m_dzz ; + Kokkos::View m_delv_xi; /* velocity gradient -- temporary */ + Kokkos::View m_delv_eta; + Kokkos::View m_delv_zeta; - Kokkos::View m_delv_xi ; /* velocity gradient -- temporary */ - Kokkos::View m_delv_eta ; - Kokkos::View m_delv_zeta ; + Kokkos::View m_delx_xi; /* coordinate gradient -- temporary */ + Kokkos::View m_delx_eta; + Kokkos::View m_delx_zeta; - Kokkos::View m_delx_xi ; /* coordinate gradient -- temporary */ - Kokkos::View m_delx_eta ; - Kokkos::View m_delx_zeta ; - - Kokkos::View m_e ; /* energy */ + Kokkos::View m_e; /* energy */ - struct Pcomponents { - Real_t p, q ; - } ; + struct Pcomponents + { + Real_t p, q; + }; - Kokkos::View m_pq ; /* pressure and artificial viscosity */ + Kokkos::View m_pq; /* pressure and artificial viscosity */ - struct Qcomponents { - Real_t ql, qq ; - } ; + struct Qcomponents + { + Real_t ql, qq; + }; - Kokkos::View m_qlqq ; /* linear and quadratic terms for q */ + Kokkos::View m_qlqq; /* linear and quadratic terms for q */ - struct Volume { - Real_t v, volo ; - } ; + struct Volume + { + Real_t v, volo; + }; - Kokkos::View m_vol ; /* relative and reference volume */ + Kokkos::View m_vol; /* relative and reference volume */ - Kokkos::View m_vnew ; /* new relative volume -- temporary */ - Kokkos::View m_delv ; /* m_vnew - m_v */ - Kokkos::View m_vdov ; /* volume derivative over volume */ + Kokkos::View m_vnew; /* new relative volume -- temporary */ + Kokkos::View m_delv; /* m_vnew - m_v */ + Kokkos::View m_vdov; /* volume derivative over volume */ - Kokkos::View m_arealg ; /* characteristic length of an element */ - - Kokkos::View m_ss ; /* "sound speed" */ + Kokkos::View m_arealg; /* characteristic length of an element */ - Kokkos::View m_elemMass ; /* mass */ + Kokkos::View m_ss; /* "sound speed" */ - // Cutoffs (treat as constants) - const Real_t m_e_cut ; // energy tolerance - const Real_t m_p_cut ; // pressure tolerance - const Real_t m_q_cut ; // q tolerance - const Real_t m_v_cut ; // relative volume tolerance - const Real_t m_u_cut ; // velocity tolerance + Kokkos::View m_elemMass; /* mass */ - // Other constants (usually setable, but hardcoded in this proxy app) + // Cutoffs (treat as constants) + const Real_t m_e_cut; // energy tolerance + const Real_t m_p_cut; // pressure tolerance + const Real_t m_q_cut; // q tolerance + const Real_t m_v_cut; // relative volume tolerance + const Real_t m_u_cut; // velocity tolerance - const Real_t m_hgcoef ; // hourglass control - const Real_t m_ss4o3 ; - const Real_t m_qstop ; // excessive q indicator - const Real_t m_monoq_max_slope ; - const Real_t m_monoq_limiter_mult ; - const Real_t m_qlc_monoq ; // linear term coef for q - const Real_t m_qqc_monoq ; // quadratic term coef for q - const Real_t m_qqc ; - const Real_t m_eosvmax ; - const Real_t m_eosvmin ; - const Real_t m_pmin ; // pressure floor - const Real_t m_emin ; // energy floor - const Real_t m_dvovmax ; // maximum allowable volume change - const Real_t m_refdens ; // reference density + // Other constants (usually setable, but hardcoded in this proxy app) - // Variables to keep track of timestep, simulation time, and cycle - Real_t m_dtcourant ; // courant constraint - Real_t m_dthydro ; // volume change constraint - Int_t m_cycle ; // iteration count for simulation - Real_t m_dtfixed ; // fixed time increment - Real_t m_time ; // current time - Real_t m_deltatime ; // variable time increment - Real_t m_deltatimemultlb ; - Real_t m_deltatimemultub ; - Real_t m_dtmax ; // maximum allowable time increment - Real_t m_stoptime ; // end time for simulation + const Real_t m_hgcoef; // hourglass control + const Real_t m_ss4o3; + const Real_t m_qstop; // excessive q indicator + const Real_t m_monoq_max_slope; + const Real_t m_monoq_limiter_mult; + const Real_t m_qlc_monoq; // linear term coef for q + const Real_t m_qqc_monoq; // quadratic term coef for q + const Real_t m_qqc; + const Real_t m_eosvmax; + const Real_t m_eosvmin; + const Real_t m_pmin; // pressure floor + const Real_t m_emin; // energy floor + const Real_t m_dvovmax; // maximum allowable volume change + const Real_t m_refdens; // reference density + // Variables to keep track of timestep, simulation time, and cycle + Real_t m_dtcourant; // courant constraint + Real_t m_dthydro; // volume change constraint + Int_t m_cycle; // iteration count for simulation + Real_t m_dtfixed; // fixed time increment + Real_t m_time; // current time + Real_t m_deltatime; // variable time increment + Real_t m_deltatimemultlb; + Real_t m_deltatimemultub; + Real_t m_dtmax; // maximum allowable time increment + Real_t m_stoptime; // end time for simulation - Int_t m_numRanks ; + Int_t m_numRanks; - Index_t m_colLoc ; - Index_t m_rowLoc ; - Index_t m_planeLoc ; - Index_t m_tp ; + Index_t m_colLoc; + Index_t m_rowLoc; + Index_t m_planeLoc; + Index_t m_tp; - Index_t m_sizeX ; - Index_t m_sizeY ; - Index_t m_sizeZ ; - Index_t m_numElem ; - Index_t m_numNode ; + Index_t m_sizeX; + Index_t m_sizeY; + Index_t m_sizeZ; + Index_t m_numElem; + Index_t m_numNode; - Index_t m_maxPlaneSize ; - Index_t m_maxEdgeSize ; + Index_t m_maxPlaneSize; + Index_t m_maxEdgeSize; - // OMP hack - Index_t *m_nodeElemStart ; - Index_t *m_nodeElemCornerList ; + // OMP hack + Index_t* m_nodeElemStart; + Index_t* m_nodeElemCornerList; - // Used in setup - Index_t m_rowMin, m_rowMax; - Index_t m_colMin, m_colMax; - Index_t m_planeMin, m_planeMax ; - -} ; - -typedef Real_t &(Domain::* Domain_member )(Index_t) ; - -struct cmdLineOpts { - Int_t its; // -i - Int_t nx; // -s - Int_t numReg; // -r - Int_t numFiles; // -f - Int_t showProg; // -p - Int_t quiet; // -q - Int_t viz; // -v - Int_t cost; // -c - Int_t balance; // -b + // Used in setup + Index_t m_rowMin, m_rowMax; + Index_t m_colMin, m_colMax; + Index_t m_planeMin, m_planeMax; }; +typedef Real_t& (Domain::*Domain_member)(Index_t); +struct cmdLineOpts +{ + Int_t its; // -i + Int_t nx; // -s + Int_t numReg; // -r + Int_t numFiles; // -f + Int_t showProg; // -p + Int_t quiet; // -q + Int_t viz; // -v + Int_t cost; // -c + Int_t balance; // -b +}; // Function Prototypes // lulesh-par -Real_t CalcElemVolume( const Real_t x[8], - const Real_t y[8], - const Real_t z[8]); +Real_t +CalcElemVolume(const Real_t x[8], const Real_t y[8], const Real_t z[8]); // lulesh-util -void ParseCommandLineOptions(int argc, char *argv[], - Int_t myRank, struct cmdLineOpts *opts); -void VerifyAndWriteFinalOutput(Real_t elapsed_time, - Domain& locDom, - Int_t nx, - Int_t numRanks); +void +ParseCommandLineOptions(int argc, char* argv[], Int_t myRank, struct cmdLineOpts* opts); +void +VerifyAndWriteFinalOutput(Real_t elapsed_time, Domain& locDom, Int_t nx, Int_t numRanks); // lulesh-viz -void DumpToVisit(Domain& domain, int numFiles, int myRank, int numRanks); +void +DumpToVisit(Domain& domain, int numFiles, int myRank, int numRanks); // lulesh-comm -void CommRecv(Domain& domain, Int_t msgType, Index_t xferFields, - Index_t dx, Index_t dy, Index_t dz, - bool doRecv, bool planeOnly); -void CommSend(Domain& domain, Int_t msgType, - Index_t xferFields, Domain_member *fieldData, - Index_t dx, Index_t dy, Index_t dz, - bool doSend, bool planeOnly); -void CommSBN(Domain& domain, Int_t xferFields, Domain_member *fieldData); -void CommSyncPosVel(Domain& domain); -void CommMonoQ(Domain& domain); +void +CommRecv(Domain& domain, Int_t msgType, Index_t xferFields, Index_t dx, Index_t dy, + Index_t dz, bool doRecv, bool planeOnly); +void +CommSend(Domain& domain, Int_t msgType, Index_t xferFields, Domain_member* fieldData, + Index_t dx, Index_t dy, Index_t dz, bool doSend, bool planeOnly); +void +CommSBN(Domain& domain, Int_t xferFields, Domain_member* fieldData); +void +CommSyncPosVel(Domain& domain); +void +CommMonoQ(Domain& domain); // lulesh-init -void InitMeshDecomp(Int_t numRanks, Int_t myRank, - Int_t *col, Int_t *row, Int_t *plane, Int_t *side); +void +InitMeshDecomp(Int_t numRanks, Int_t myRank, Int_t* col, Int_t* row, Int_t* plane, + Int_t* side); diff --git a/projects/rocprofiler-systems/scripts/run-ci.py b/projects/rocprofiler-systems/scripts/run-ci.py new file mode 100755 index 0000000000..1e07efb5d1 --- /dev/null +++ b/projects/rocprofiler-systems/scripts/run-ci.py @@ -0,0 +1,254 @@ +#!/usr/bin/env python3 + + +import os +import re +import sys +import socket +import shutil +import argparse +import multiprocessing + + +def which(cmd, require): + v = shutil.which(cmd) + if require and v is None: + raise RuntimeError(f"{cmd} not found") + return v if v is not None else "" + + +def generate_custom(args, cmake_args, ctest_args): + + if not os.path.exists(args.binary_dir): + os.makedirs(args.binary_dir) + + NAME = args.name + SITE = args.site + BUILD_JOBS = args.build_jobs + SUBMIT_URL = args.submit_url + SOURCE_DIR = os.path.realpath(args.source_dir) + BINARY_DIR = os.path.realpath(args.binary_dir) + CMAKE_ARGS = " ".join(cmake_args) + CTEST_ARGS = " ".join(ctest_args) + + GIT_CMD = which("git", require=True) + GCOV_CMD = which("gcov", require=False) + CMAKE_CMD = which("cmake", require=True) + CTEST_CMD = which("ctest", require=True) + + NAME = re.sub(r"(.*)-([0-9]+)/merge", "PR_\\2_\\1", NAME) + + return f""" + set(CTEST_PROJECT_NAME "Omnitrace") + set(CTEST_NIGHTLY_START_TIME "05:00:00 UTC") + + set(CTEST_DROP_METHOD "http") + set(CTEST_DROP_SITE_CDASH TRUE) + set(CTEST_SUBMIT_URL "https://{SUBMIT_URL}") + + set(CTEST_UPDATE_TYPE git) + set(CTEST_UPDATE_VERSION_ONLY TRUE) + set(CTEST_GIT_INIT_SUBMODULES TRUE) + + set(CTEST_OUTPUT_ON_FAILURE TRUE) + set(CTEST_USE_LAUNCHERS TRUE) + set(CMAKE_CTEST_ARGUMENTS --output-on-failure {CTEST_ARGS}) + + set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS "100") + set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS "100") + set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "51200") + set(CTEST_CUSTOM_COVERAGE_EXCLUDE "/usr/.*;.*external/.*;.*examples/.*") + + set(CTEST_SITE "{SITE}") + set(CTEST_BUILD_NAME "{NAME}") + + set(CTEST_SOURCE_DIRECTORY {SOURCE_DIR}) + set(CTEST_BINARY_DIRECTORY {BINARY_DIR}) + + set(CTEST_UPDATE_COMMAND {GIT_CMD}) + set(CTEST_CONFIGURE_COMMAND "{CMAKE_CMD} -B {BINARY_DIR} {SOURCE_DIR} -DOMNITRACE_BUILD_CI=ON {CMAKE_ARGS}") + set(CTEST_BUILD_COMMAND "{CMAKE_CMD} --build {BINARY_DIR} --target all --parallel {BUILD_JOBS}") + set(CTEST_COVERAGE_COMMAND {GCOV_CMD}) + """ + + +def generate_dashboard_script(args): + + CODECOV = 1 if args.coverage else 0 + DASHBOARD_MODE = args.mode + SOURCE_DIR = os.path.realpath(args.source_dir) + BINARY_DIR = os.path.realpath(args.binary_dir) + + _script = """ + + include("${CMAKE_CURRENT_LIST_DIR}/CTestCustom.cmake") + + macro(handle_error _message _ret) + if(NOT ${${_ret}} EQUAL 0) + ctest_submit(PARTS Done RETURN_VALUE _submit_ret) + message(FATAL_ERROR "${_message} failed: ${${_ret}}") + endif() + endmacro() + """ + + _script += f""" + ctest_start({DASHBOARD_MODE}) + ctest_update(SOURCE "{SOURCE_DIR}") + ctest_configure(BUILD "{BINARY_DIR}" RETURN_VALUE _configure_ret) + ctest_submit(PARTS Start Update Configure RETURN_VALUE _submit_ret) + + handle_error("Configure" _configure_ret) + + ctest_build(BUILD "{BINARY_DIR}" RETURN_VALUE _build_ret) + ctest_submit(PARTS Build RETURN_VALUE _submit_ret) + + handle_error("Build" _build_ret) + + ctest_test(BUILD "{BINARY_DIR}" RETURN_VALUE _test_ret) + ctest_submit(PARTS Test RETURN_VALUE _submit_ret) + + if("{CODECOV}" GREATER 0) + ctest_coverage( + BUILD "{BINARY_DIR}" + RETURN_VALUE _coverage_ret + CAPTURE_CMAKE_ERROR _coverage_err) + ctest_submit(PARTS Coverage RETURN_VALUE _submit_ret) + endif() + + handle_error("Testing" _test_ret) + + ctest_submit(PARTS Done RETURN_VALUE _submit_ret) + """ + return _script + + +def parse_cdash_args(args): + BUILD_JOBS = multiprocessing.cpu_count() + DASHBOARD_MODE = "Continuous" + DASHBOARD_STAGES = [ + "Start", + "Update", + "Configure", + "Build", + "Test", + "MemCheck", + "Coverage", + "Submit", + ] + SOURCE_DIR = os.getcwd() + BINARY_DIR = os.path.join(SOURCE_DIR, "build") + SITE = socket.gethostname() + NAME = None + SUBMIT_URL = "my.cdash.org/submit.php?project=Omnitrace" + CODECOV = False + + parser = argparse.ArgumentParser() + + parser.add_argument( + "-n", "--name", help="Job name", default=None, type=str, required=True + ) + parser.add_argument("-s", "--site", help="Site name", default=SITE, type=str) + parser.add_argument( + "-c", "--coverage", help="Enable code coverage", action="store_true" + ) + parser.add_argument( + "-j", "--build-jobs", help="Number of build tasks", default=BUILD_JOBS, type=int + ) + parser.add_argument( + "-B", "--binary-dir", help="Build directory", default=BINARY_DIR, type=str + ) + parser.add_argument( + "-S", "--source-dir", help="Source directory", default=SOURCE_DIR, type=str + ) + parser.add_argument( + "-M", + "--mode", + help="Dashboard mode", + default=DASHBOARD_MODE, + choices=("Continuous", "Nightly", "Experimental"), + type=str, + ) + parser.add_argument( + "-T", + "--stages", + help="Dashboard stages", + nargs="+", + default=DASHBOARD_STAGES, + choices=DASHBOARD_STAGES, + type=str, + ) + parser.add_argument( + "--submit-url", help="CDash submission site", default=SUBMIT_URL, type=str + ) + + return parser.parse_args(args) + + +def parse_args(args=None): + if args is None: + args = sys.argv[1:] + + index = 0 + input_args = [] + ctest_args = [] + cmake_args = [] + data = [input_args, cmake_args, ctest_args] + + for itr in args: + if itr == "--": + index += 1 + if index > 2: + raise RuntimeError("Usage: -- -- ") + else: + data[index].append(itr) + + cdash_args = parse_cdash_args(input_args) + + if cdash_args.coverage: + cmake_args += ["-DOMNITRACE_BUILD_CODECOV=ON", "-DOMNITRACE_STRIP_LIBRARIES=OFF"] + + return [cdash_args, cmake_args, ctest_args] + + +def run(*args, **kwargs): + import subprocess + + return subprocess.run(*args, **kwargs) + + +if __name__ == "__main__": + + args, cmake_args, ctest_args = parse_args() + + if not os.path.exists(args.binary_dir): + os.makedirs(args.binary_dir) + + from textwrap import dedent + + _config = dedent(generate_custom(args, cmake_args, ctest_args)) + _script = dedent(generate_dashboard_script(args)) + + with open(os.path.join(args.binary_dir, "CTestCustom.cmake"), "w") as f: + f.write(f"{_config}\n") + + with open(os.path.join(args.binary_dir, "dashboard.cmake"), "w") as f: + f.write(f"{_script}\n") + + CTEST_CMD = which("ctest", require=True) + + dashboard_args = ["-D"] + for itr in args.stages: + dashboard_args.append(f"{args.mode}{itr}") + + run( + [CTEST_CMD] + + dashboard_args + + [ + "-S", + os.path.join(args.binary_dir, "dashboard.cmake"), + "--output-on-failure", + "-V", + ] + + ctest_args, + check=True, + ) diff --git a/projects/rocprofiler-systems/source/bin/tests/CMakeLists.txt b/projects/rocprofiler-systems/source/bin/tests/CMakeLists.txt index 02d63aa5dd..c2e8f1c815 100644 --- a/projects/rocprofiler-systems/source/bin/tests/CMakeLists.txt +++ b/projects/rocprofiler-systems/source/bin/tests/CMakeLists.txt @@ -34,7 +34,7 @@ function(OMNITRACE_ADD_BIN_TEST) # common list(APPEND TEST_ENVIRONMENT "OMNITRACE_CI=ON" "OMNITRACE_CONFIG_FILE=" - "OMNITRACE_OUTPUT_PATH=omnitrace-tests-output") + "OMNITRACE_OUTPUT_PATH=omnitrace-tests-output" "TWD=${TEST_WORKING_DIRECTORY}") # copy for inverse set(TEST_ENVIRONMENT_INV "${TEST_ENVIRONMENT}") @@ -225,6 +225,25 @@ omnitrace_add_bin_test( LABELS "omnitrace-avail" TIMEOUT 45) +omnitrace_add_bin_test( + NAME omnitrace-avail-all-expand-keys + TARGET omnitrace-avail + ARGS --all --expand-keys + LABELS "omnitrace-avail" + TIMEOUT 45 + FAIL_REGEX "%[a-zA-Z_]%") + +omnitrace_add_bin_test( + NAME omnitrace-avail-all-only-available-alphabetical + TARGET omnitrace-avail + ARGS --all --available --alphabetical --debug --output + ${CMAKE_CURRENT_BINARY_DIR}/omnitrace-avail-all-only-available-alphabetical.log + LABELS "omnitrace-avail" + TIMEOUT 45 + PROPERTIES + ATTACHED_FILES + ${CMAKE_CURRENT_BINARY_DIR}/omnitrace-avail-all-only-available-alphabetical.log) + omnitrace_add_bin_test( NAME omnitrace-avail-all-csv TARGET omnitrace-avail @@ -288,11 +307,20 @@ omnitrace_add_bin_test( string(REPLACE "+" "\\\+" _AVAIL_CFG_PATH "${PROJECT_BINARY_DIR}/omnitrace-tests-output/omnitrace-avail/omnitrace-") +# use of TWD == Test Working Directory (added by function) omnitrace_add_bin_test( NAME omnitrace-avail-write-config TARGET omnitrace-avail - ARGS -G %env{PWD}%/omnitrace-tests-output/omnitrace-avail/omnitrace-test.cfg -F txt - json xml --force --all + ARGS -G + %env{TWD}%/omnitrace-tests-output/omnitrace-avail/omnitrace-test.cfg + -F + txt + json + xml + --force + --all + -c + omnitrace TIMEOUT 45 LABELS "omnitrace-avail" PASS_REGEX @@ -302,7 +330,7 @@ omnitrace_add_bin_test( omnitrace_add_bin_test( NAME omnitrace-avail-write-config-tweak TARGET omnitrace-avail - ARGS -G %env{PWD}%/omnitrace-tests-output/omnitrace-avail/omnitrace-tweak.cfg -F txt + ARGS -G %env{TWD}%/omnitrace-tests-output/omnitrace-avail/omnitrace-tweak.cfg -F txt json xml --force TIMEOUT 45 LABELS "omnitrace-avail" @@ -310,3 +338,37 @@ omnitrace_add_bin_test( PASS_REGEX "Outputting JSON configuration file '${_AVAIL_CFG_PATH}tweak\\\.json'(.*)Outputting XML configuration file '${_AVAIL_CFG_PATH}tweak\\\.xml'(.*)Outputting text configuration file '${_AVAIL_CFG_PATH}tweak\\\.cfg'(.*)" ) + +omnitrace_add_bin_test( + NAME omnitrace-avail-list-keys + TARGET omnitrace-avail + ARGS --list-keys --expand-keys + TIMEOUT 45 + LABELS "omnitrace-avail" + PASS_REGEX "Output Keys:\n(.*)%argv%(.*)%argv_hash%") + +omnitrace_add_bin_test( + NAME omnitrace-avail-list-keys-markdown + TARGET omnitrace-avail + ARGS --list-keys --expand-keys --markdown + TIMEOUT 45 + LABELS "omnitrace-avail;markdown" + PASS_REGEX "(.*)`%argv%`(.*)`%argv_hash%`") + +omnitrace_add_bin_test( + NAME omnitrace-avail-list-categories + TARGET omnitrace-avail + ARGS --list-categories + TIMEOUT 45 + LABELS "omnitrace-avail" + PASS_REGEX " component::(.*) hw_counters::(.*) settings::") + +omnitrace_add_bin_test( + NAME omnitrace-avail-core-categories + TARGET omnitrace-avail + ARGS -c core + TIMEOUT 45 + LABELS "omnitrace-avail" + PASS_REGEX + "OMNITRACE_CONFIG_FILE(.*)OMNITRACE_ENABLED(.*)OMNITRACE_SUPPRESS_CONFIG(.*)OMNITRACE_SUPPRESS_PARSING(.*)OMNITRACE_VERBOSE" + ) diff --git a/projects/rocprofiler-systems/source/lib/omnitrace-dl/main.c b/projects/rocprofiler-systems/source/lib/omnitrace-dl/main.c index 53ff0828b2..bf882eaaa1 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace-dl/main.c +++ b/projects/rocprofiler-systems/source/lib/omnitrace-dl/main.c @@ -26,11 +26,11 @@ #define OMNITRACE_HIDDEN_API __attribute__((visibility("hidden"))); #include +#include #include -#include #include #include -#include +#include // // local type definitions @@ -52,8 +52,8 @@ omnitrace_main(int, char**, char**) OMNITRACE_HIDDEN_API; int omnitrace_libc_start_main(int (*)(int, char**, char**), int, char**, - int (*)(int, char**, char**), void (*)(void), void (*)(void), - void*) OMNITRACE_HIDDEN_API; + int (*)(int, char**, char**), void (*)(void), void (*)(void), + void*) OMNITRACE_HIDDEN_API; int __libc_start_main(int (*)(int, char**, char**), int, char**, int (*)(int, char**, char**), @@ -109,8 +109,8 @@ omnitrace_main(int argc, char** argv, char** envp) int omnitrace_libc_start_main(int (*_main)(int, char**, char**), int _argc, char** _argv, - int (*_init)(int, char**, char**), void (*_fini)(void), - void (*_rtld_fini)(void), void* _stack_end) + int (*_init)(int, char**, char**), void (*_fini)(void), + void (*_rtld_fini)(void), void* _stack_end) { int _preload = omnitrace_preload_library(); @@ -159,5 +159,5 @@ __libc_start_main(int (*_main)(int, char**, char**), int _argc, char** _argv, void (*_rtld_fini)(void), void* _stack_end) { return omnitrace_libc_start_main(_main, _argc, _argv, _init, _fini, _rtld_fini, - _stack_end); + _stack_end); } diff --git a/projects/rocprofiler-systems/source/lib/omnitrace-user/omnitrace/user.h b/projects/rocprofiler-systems/source/lib/omnitrace-user/omnitrace/user.h index bdb7f3900a..385df0612a 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace-user/omnitrace/user.h +++ b/projects/rocprofiler-systems/source/lib/omnitrace-user/omnitrace/user.h @@ -105,7 +105,8 @@ extern "C" /// @fn int omnitrace_user_configure(omnitrace_user_configure_mode_t cfg, /// omnitrace_user_callbacks_t new_callbacks, /// omnitrace_user_callbacks_t* old_callbacks) - /// @param[in] config Specifies how the new callbacks are merged with the old callbacks + /// @param[in] config Specifies how the new callbacks are merged with the old + /// callbacks /// @param[in] new_callbacks An @ref omnitrace_user_callbacks_t instance specifying /// the callbacks which should be invoked by the user API. /// @param[out] old_callbacks Pointer to @ref omnitrace_user_callbacks_t which,