Skip to content

Commit

Permalink
Merge branch 'lehner-master' into features-mbruno
Browse files Browse the repository at this point in the history
  • Loading branch information
mbruno46 committed May 15, 2024
2 parents f2a3249 + fc724a3 commit 1bbe4d7
Show file tree
Hide file tree
Showing 19 changed files with 459 additions and 113 deletions.
76 changes: 38 additions & 38 deletions .github/workflows/github-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ env:
MPICH_CC: cc
MPICH_CXX: c++
# Note if this is changed, all caches will be not be valid anymore
CACHE_KEY: 2021-05-30
CACHE_KEY: 2024-05-11b

jobs:
build-grid:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
fail-fast: false
Expand All @@ -38,16 +38,16 @@ jobs:
- name: Install Ubuntu packages
run: |
sudo apt-get update
sudo apt-get install -y clang-9 libmpfr-dev libgmp-dev libssl-dev zlib1g-dev libmpich-dev libopenmpi-dev libfftw3-dev
sudo apt-get install -y clang libmpfr-dev libgmp-dev libssl-dev zlib1g-dev libmpich-dev libopenmpi-dev libfftw3-dev
- name: Set compiler alternatives to clang-9
- name: Set compiler alternatives to clang
if: matrix.compiler == 'clang'
run: |
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-9 1
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-9 1
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 1
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 1
sudo update-alternatives --set cc /usr/bin/clang-9
sudo update-alternatives --set c++ /usr/bin/clang++-9
sudo update-alternatives --set cc /usr/bin/clang
sudo update-alternatives --set c++ /usr/bin/clang++
- name: Set compiler to cc and c++
if: matrix.mpi == 'none'
Expand Down Expand Up @@ -156,12 +156,12 @@ jobs:
build-gpt:
needs: build-grid
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8']
python-version: ['3.8','3.9','3.10']
compiler: ['gcc', 'clang']
mpi: ['none', 'mpich', 'openmpi']

Expand All @@ -178,16 +178,16 @@ jobs:
- name: Install Ubuntu packages
run: |
sudo apt-get update
sudo apt-get install -y clang-9 libmpfr-dev libgmp-dev libssl-dev zlib1g-dev libmpich-dev libopenmpi-dev libfftw3-dev
sudo apt-get install -y clang libmpfr-dev libgmp-dev libssl-dev zlib1g-dev libmpich-dev libopenmpi-dev libfftw3-dev
- name: Set compiler alternatives to clang-9
- name: Set compiler alternatives to clang
if: matrix.compiler == 'clang'
run: |
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-9 1
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-9 1
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 1
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 1
sudo update-alternatives --set cc /usr/bin/clang-9
sudo update-alternatives --set c++ /usr/bin/clang++-9
sudo update-alternatives --set cc /usr/bin/clang
sudo update-alternatives --set c++ /usr/bin/clang++
- name: Set MPI alternatives to mpich
if: matrix.mpi == 'mpich'
Expand All @@ -197,7 +197,7 @@ jobs:
sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
Expand Down Expand Up @@ -335,12 +335,12 @@ jobs:

test-gpt:
needs: [build-grid, build-gpt]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8']
python-version: ['3.8','3.9','3.10']
compiler: ['gcc', 'clang']
mpi: ['none', 'mpich', 'openmpi']

Expand All @@ -352,16 +352,16 @@ jobs:
- name: Install Ubuntu packages
run: |
sudo apt-get update
sudo apt-get install -y clang-9 libmpfr-dev libgmp-dev libssl-dev zlib1g-dev libmpich-dev libopenmpi-dev libfftw3-dev
sudo apt-get install -y clang libmpfr-dev libgmp-dev libssl-dev zlib1g-dev libmpich-dev libopenmpi-dev libfftw3-dev
- name: Set compiler alternatives to clang-9
- name: Set compiler alternatives to clang
if: matrix.compiler == 'clang'
run: |
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-9 1
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-9 1
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 1
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 1
sudo update-alternatives --set cc /usr/bin/clang-9
sudo update-alternatives --set c++ /usr/bin/clang++-9
sudo update-alternatives --set cc /usr/bin/clang
sudo update-alternatives --set c++ /usr/bin/clang++
- name: Set MPI alternatives to mpich
if: matrix.mpi == 'mpich'
Expand All @@ -371,7 +371,7 @@ jobs:
sudo update-alternatives --set mpi-x86_64-linux-gnu /usr/include/x86_64-linux-gnu/mpich
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
Expand Down Expand Up @@ -439,7 +439,7 @@ jobs:
run: |
cd gpt
if [ "${{ secrets.CODECOV_USERNAME }}" != "" ] \
&& [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/master" ]
&& [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/master" ] && 0
then
bash <(curl -s https://codecov.io/bash) \
-f ./coverage.xml
Expand All @@ -450,18 +450,18 @@ jobs:
build-gpt-doc:
needs: [build-grid, build-gpt]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Install Ubuntu packages
run: |
sudo apt-get update
sudo apt-get install -y clang-9 libmpfr-dev libgmp-dev libssl-dev zlib1g-dev libmpich-dev libopenmpi-dev
sudo apt-get install -y clang libmpfr-dev libgmp-dev libssl-dev zlib1g-dev libmpich-dev libopenmpi-dev
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: '3.10'
architecture: x64

- name: Setup python dependencies
Expand All @@ -471,11 +471,11 @@ jobs:
- name: Download prebuild python-gpt
uses: actions/download-artifact@v3
with:
name: python-gpt-${{ runner.os }}-python-3.8-gcc-none-${{ needs.build-gpt.outputs.python-gpt-version }}
name: python-gpt-${{ runner.os }}-python-3.10-gcc-none-${{ needs.build-gpt.outputs.python-gpt-version }}

- name: Install python-gpt
run: |
sudo dpkg -i python-gpt-${{ runner.os }}-python-3.8-gcc-none.deb
sudo dpkg -i python-gpt-${{ runner.os }}-python-3.10-gcc-none.deb
- name: Clone gpt
uses: actions/checkout@v3
Expand All @@ -485,7 +485,7 @@ jobs:
- name: Build documentation
id: build-documentation
env:
PYTHONPATH: /usr/local/lib/python3.8/site-packages:/usr/local/lib64/python3.8/site-packages
PYTHONPATH: /usr/local/lib/python3.10/site-packages:/usr/local/lib64/python3.10/site-packages
run: |
cd gpt/documentation
make html
Expand All @@ -497,7 +497,7 @@ jobs:

build-gpt-docker-base:
needs: [build-grid, build-gpt, test-gpt]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Check for rebuild
Expand Down Expand Up @@ -529,7 +529,7 @@ jobs:

build-gpt-docker:
needs: [build-grid, build-gpt, test-gpt, build-gpt-docker-base]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
fail-fast: false
Expand Down Expand Up @@ -558,12 +558,12 @@ jobs:
if: ${{ steps.check-build.outputs.build }}
uses: actions/download-artifact@v3
with:
name: python-gpt-${{ runner.os }}-python-3.8-${{ matrix.compiler }}-${{ matrix.mpi }}-${{ needs.build-gpt.outputs.python-gpt-version }}
name: python-gpt-${{ runner.os }}-python-3.10-${{ matrix.compiler }}-${{ matrix.mpi }}-${{ needs.build-gpt.outputs.python-gpt-version }}

- name: Move python-gpt package to docker folder
if: ${{ steps.check-build.outputs.build }}
run: |
mv python-gpt-${{ runner.os }}-python-3.8-${{ matrix.compiler }}-${{ matrix.mpi }}.deb docker/shell/gpt-packages
mv python-gpt-${{ runner.os }}-python-3.10-${{ matrix.compiler }}-${{ matrix.mpi }}.deb docker/shell/gpt-packages
cp -r documentation/tutorials/ docker/notebook
cp -r tests/ benchmarks/ applications/ docker/shell
Expand Down
79 changes: 79 additions & 0 deletions benchmarks/indexed_sum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env python3
#
# Authors: Christoph Lehner 2024
#
# Benchmark Indexed Sum
#
import gpt as g
import numpy as np
import cgpt


# mute random number generation
g.default.set_verbose("random", False)
rng = g.random("benchmark")

# main test loop
for precision in [g.single, g.double]:
grid = g.grid(g.default.get_ivec("--grid", [16, 16, 16, 32], 4), precision)
N = 100
Nwarmup = 5
g.message(
f"""
Indexed Sum Benchmark with
fdimensions : {grid.fdimensions}
precision : {precision.__name__}
"""
)

# coordinates
idx = g.complex(grid)
idx[:] = np.ascontiguousarray(g.coordinates(idx)[:, 3].astype(np.complex128))

# Source and destination
for tp in [g.ot_singlet(), g.ot_vector_spin_color(4, 3), g.ot_matrix_spin_color(4, 3)]:
for n in [1, 4, 16]:
one = [g.lattice(grid, tp) for i in range(n)]
rng.cnormal(one)

# Rank inner product
nbytes = (one[0].global_bytes() * n + idx.global_bytes()) * N

# Time global
dt = 0.0
cgpt.timer_begin()
for it in range(N + Nwarmup):
if it >= Nwarmup:
dt -= g.time()
ip = g.indexed_sum(one, idx, grid.gdimensions[3])
if it >= Nwarmup:
dt += g.time()

# Time local
rank_dt = 0.0
for it in range(N + Nwarmup):
if it >= Nwarmup:
rank_dt -= g.time()
g.slice(one, 3)
if it >= Nwarmup:
rank_dt += g.time()


# Report
GBPerSec = nbytes / dt / 1e9
rank_GBPerSec = nbytes / rank_dt / 1e9
cgpt_t = g.timer("ris")
cgpt_t += cgpt.timer_end()
g.message(
f"""{N} indexed_sum
Object type : {tp.__name__}
Block : {n}
Time to complete : {dt:.2f} s (indexed_sum)
Time to complete : {rank_dt:.2f} s (slice)
Effective memory bandwidth : {GBPerSec:.2f} GB/s (indexed_sum)
Effective memory bandwidth : {rank_GBPerSec:.2f} GB/s (slice)
{cgpt_t}
"""
)

2 changes: 1 addition & 1 deletion benchmarks/matrix_multiply.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

# matrix multiply
nbytes = 3.0 * one.global_bytes() * N
n = (one.otype.nfloats // 2)**0.5
n = (one.otype.nfloats // 2) ** 0.5
flops_per_matrix_multiply = n * n * (n * 6 + (n - 1) * 2)
flops = flops_per_matrix_multiply = grid.gsites * N * flops_per_matrix_multiply

Expand Down
Loading

0 comments on commit 1bbe4d7

Please sign in to comment.