Skip to content

Commit

Permalink
kernels(omp): add omp-elastic kernels (#40)
Browse files Browse the repository at this point in the history
* kernels(omp): add omp-elastic kernels

* gha: add test for omp elastic

* examples: bump kernels-elastic commit

* docker: attempt to fix build

* examples(kernels-elastic): bump submodule
  • Loading branch information
csegarragonz authored May 14, 2024
1 parent 269557d commit 428a11c
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 26 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ jobs:
run: ./bin/inv_wrapper.sh libpng imagemagick
- name: "Build Kernels"
run: ./bin/inv_wrapper.sh kernels kernels --native
- name: "Build Elastic Kernels"
run: ./bin/inv_wrapper.sh kernels --elastic kernels --elastic --native
- name: "Build LAMMPS"
run: ./bin/inv_wrapper.sh lammps lammps --native
- name: "Build LAMMPS with migration"
Expand Down Expand Up @@ -215,6 +217,12 @@ jobs:
# The random OpenMP kernel can not be cross-compiled due to a problem
# with the faasm_sm_reduce signature
# faasmctl invoke kernels-omp random --cmdline '32 20'
- name: "Run elastic OpenMP kernels"
if: "contains(env.FAASM_WASM_VM, 'wamr')"
timeout-minutes: 2
run: |
faasmctl invoke kernels-omp p2p --cmdline '2 10 1024 1024' --input-data "2"
faasmctl invoke kernels-omp sparse --cmdline '2 10 10 5' --input-data "2"
- name: "Run PolyBench/C"
timeout-minutes: 2
# We deliberately enumerate all the supported functions here and
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@
path = examples/lammps-migration-net
url = https://github.com/faasm/lammps.git
branch = faasm-migration-net
[submodule "examples/Kernels-elastic"]
path = examples/Kernels-elastic
url = https://github.com/faasm/Kernels
branch = faasm-elastic
1 change: 1 addition & 0 deletions examples/Kernels-elastic
Submodule Kernels-elastic added at c9651d
64 changes: 38 additions & 26 deletions tasks/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,7 @@
from tasks.env import EXAMPLES_DIR


@task(default=True)
def build(ctx, clean=False, native=False):
"""
Build the different kernels functions for OpenMP and MPI
Note that LAMMPS is a self-contained binary, and different workloads are
executed by passing different command line arguments. As a consequence,
we cross-compile it and copy the binary (lmp) to lammps/main/function.wasm
"""
kernels_dir = join(EXAMPLES_DIR, "Kernels")

if clean:
run("make clean", shell=True, check=True, cwd=kernels_dir)
if native:
rmtree(join(kernels_dir, "build", "native"))
else:
rmtree(join(kernels_dir, "build", "wasm"))

if native:
makedirs(join(kernels_dir, "build", "native"), exist_ok=True)
else:
makedirs(join(kernels_dir, "build", "wasm"), exist_ok=True)

def build_mpi_kernels(kernels_dir, native):
work_env = environ.copy()
if not native:
work_env.update(get_faasm_build_env_dict())
Expand Down Expand Up @@ -77,10 +55,8 @@ def build(ctx, clean=False, native=False):
),
)

# Clean MPI wasm files
run("make clean", shell=True, check=True, cwd=kernels_dir)

# Re-start the work environment to use the wasm32-wasi-threads target
def build_omp_kernels(kernels_dir, native):
work_env = environ.copy()
if not native:
work_env.update(get_faasm_build_env_dict(is_threads=True))
Expand Down Expand Up @@ -123,3 +99,39 @@ def build(ctx, clean=False, native=False):
"omp_{}.wasm".format(make_target),
),
)


@task(default=True)
def build(ctx, clean=False, native=False, elastic=False):
"""
Build the different kernels functions for OpenMP and MPI
Note that LAMMPS is a self-contained binary, and different workloads are
executed by passing different command line arguments. As a consequence,
we cross-compile it and copy the binary (lmp) to lammps/main/function.wasm
"""
if elastic:
kernels_dir = join(EXAMPLES_DIR, "Kernels-elastic")
else:
kernels_dir = join(EXAMPLES_DIR, "Kernels")

if native:
build_dir = join(kernels_dir, "build", "native")
else:
build_dir = join(kernels_dir, "build", "wasm")

if clean:
run("make clean", shell=True, check=True, cwd=kernels_dir)
rmtree(build_dir)

makedirs(join(kernels_dir, "build"), exist_ok=True)
makedirs(build_dir, exist_ok=True)

# When building the elastic kernels we only need to build the OpenMP ones
if elastic:
build_omp_kernels(kernels_dir, native)
else:
build_mpi_kernels(kernels_dir, native)
# Clean MPI wasm files
run("make clean", shell=True, check=True, cwd=kernels_dir)
build_omp_kernels(kernels_dir, native)
22 changes: 22 additions & 0 deletions tasks/wasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ def copy(ctx, clean=False):
"src": join(EXAMPLES_DIR, "LULESH", "build", "wasm", "lulesh2.0"),
"dst": join(WASM_DIR, "lulesh.wasm"),
},
{
"src": join(
EXAMPLES_DIR,
"Kernels-elastic",
"build",
"wasm",
"omp_p2p.wasm",
),
"dst": join(WASM_DIR, "omp_elastic_p2p.wasm"),
},
{
"src": join(
EXAMPLES_DIR,
"Kernels-elastic",
"build",
"wasm",
"omp_nstream.wasm",
),
"dst": join(WASM_DIR, "omp_elastic_nstream.wasm"),
},
]
for wasm_file in wasm_files:
copyfile(wasm_file["src"], wasm_file["dst"])
Expand Down Expand Up @@ -59,6 +79,8 @@ def upload(ctx):
for user in listdir(WASM_DIR):
for name in listdir(join(WASM_DIR, user)):
wasm_path = join(WASM_DIR, user, name, "function.wasm")
print("Uploading {}/{} (path: {})".format(user, name, wasm_path))

if exists(wasm_path):
if is_wavm and user in wavm_skip_users:
print("Skipping {}/{} for WAVM".format(user, name))
Expand Down

0 comments on commit 428a11c

Please sign in to comment.