From 9c0f64cd9b0179534b027c5e136efe0b3f69278c Mon Sep 17 00:00:00 2001 From: Emilien Bauer Date: Wed, 4 Oct 2023 15:26:13 +0100 Subject: [PATCH] Small local run scripts, wave_2d Operator type fix. --- .gitignore | 3 ++- fast/openmp.sh | 31 +++++++++++++++++++++++++++++++ fast/single_thread.sh | 22 ++++++++++++++++++++++ fast/wave2d_b.py | 4 +--- 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100755 fast/openmp.sh create mode 100755 fast/single_thread.sh diff --git a/.gitignore b/.gitignore index 622771c167..2438162976 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.pyc *.npy +*.npz *.json @@ -11,4 +12,4 @@ docs/_build .ipynb_checkpoints devito.egg-info/* -venv +venv \ No newline at end of file diff --git a/fast/openmp.sh b/fast/openmp.sh new file mode 100755 index 0000000000..960b35a830 --- /dev/null +++ b/fast/openmp.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +export DEVITO_LANGUAGE=openmp +export DEVITO_ARCH=cray +export DEVITO_LOGGING=DEBUG +unset DEVITO_AUTOTUNING + +export OMP_PLACES=cores +export OMP_PROC_BIND=true + +get_runtime() { + $@ |& grep 'Operator.*ran' | rev | cut -d ' ' -f2 | rev +} + +echo bench_name,so,threads,Devito,xDSL +for bench in "wave2d_b.py -d 2048 2048 --nt 512" "wave3d_b.py -d 512 512 512 --nt 512" "diffusion_3D_wBCs.py -d 512 512 512 --nt 512" "diffusion_2D_wBCs.py -d 2048 2048 --nt 512" +do + bench_name=$(echo $bench | cut -d ' ' -f1) + for so in 2 4 8 + do + for threads in 1 2 4 8 16 32 + do + export OMP_NUM_THREADS=$threads + # echo OMP_NUM_THREADS=$threads + # python $bench -so $so --devito 1 + devito_time=$(get_runtime python $bench -so $so --devito 1) + xdsl_time=$(get_runtime python $bench -so $so --xdsl 1) + echo $bench_name,$so,$threads,$devito_time,$xdsl_time + done + done +done diff --git a/fast/single_thread.sh b/fast/single_thread.sh new file mode 100755 index 0000000000..263b5be104 --- /dev/null +++ b/fast/single_thread.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +unset DEVITO_LANGUAGE +export DEVITO_ARCH=cray +export DEVITO_LOGGING=DEBUG +export DEVITO_AUTOTUNING=aggressive + +get_runtime() { + $@ |& grep 'Operator.*ran' | rev | cut -d ' ' -f2 | rev +} + +echo bench_name,so,Devito,xDSL +for bench in "wave2d_b.py -d 2048 2048 --nt 512" "wave3d_b.py -d 512 512 512 --nt 512" "diffusion_3D_wBCs.py -d 512 512 512 --nt 512" "diffusion_2D_wBCs.py -d 2048 2048 --nt 512" +do + bench_name=$(echo $bench | cut -d ' ' -f1) + for so in 2 4 8 + do + devito_time=$(get_runtime python $bench -so $so --devito 1) + xdsl_time=$(get_runtime python $bench -so $so --xdsl 1) + echo $bench_name,$so,$devito_time,$xdsl_time + done +done diff --git a/fast/wave2d_b.py b/fast/wave2d_b.py index 411d61ef14..54afd28794 100644 --- a/fast/wave2d_b.py +++ b/fast/wave2d_b.py @@ -5,8 +5,6 @@ from devito import (TimeFunction, Eq, Operator, solve, norm, XDSLOperator, configuration, Grid) -from examples.seismic import RickerSource -from examples.seismic import Model, TimeAxis, plot_image from fast.bench_utils import plot_2dfunc from devito.tools import as_tuple @@ -116,7 +114,7 @@ # print("XDSL init linalg norm:", np.linalg.norm(u.data[2])) # Run more with no sources now (Not supported in xdsl) - xdslop = Operator([stencil], name='xDSLOperator') + xdslop = XDSLOperator([stencil], name='xDSLOperator') xdslop.apply(time=nt, dt=dt) if len(shape) == 2 and args.plot: