diff --git a/scripts/margin.sh b/scripts/margin.sh new file mode 100755 index 0000000..d5c9138 --- /dev/null +++ b/scripts/margin.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -x + +HOST="test" + +export KMP_AFFINITY="respect,noreset,granularity=fine,balanced" +export OMP_NUM_THREADS=$(grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}') +echo "Cores configured $OMP_NUM_THREADS" +export ONEDNN_VERBOSE=0 + +for i in 1 2 3 4 5 6 7 +do + CNNS=(resnet50) + for COMPILER in ipex_onednn_graph + do + for DTYPE in float32 bfloat16 + do + for BS in 0001 0032 + do + for name in "${CNNS[@]}" + do + echo "Benchmark $name with BS=$BS and DTYPE=$DTYPE" + numactl -m 0 --physcpubind=0-31 benchmark-run -b cnn -p "name='${name}',batch_size='$BS'" --dtype "${DTYPE}" --benchmark_desc "${name}_bs$BS" --host "${HOST}" -c "${COMPILER}" --skip_verification + done + done + done + done + + + LLMS=(gptj llama2-7b) + for COMPILER in ipex + do + for BS in 1 8 + do + for DTYPE in bfloat16 + do + for name in "${LLMS[@]}" + do + echo "Benchmark $name with DTYPE=$DTYPE" + numactl -m 0 --physcpubind=0-31 benchmark-run -b llm -p "name='${name}',batch_size=${BS}" --dtype "${DTYPE}" --benchmark_desc "${name}_bs$BS" --host "${HOST}" -c "${COMPILER}" --skip_verification + done + done + done + done +done diff --git a/scripts/margin2.sh b/scripts/margin2.sh new file mode 100755 index 0000000..76c6aee --- /dev/null +++ b/scripts/margin2.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +set -x + +HOST="test" + +export KMP_AFFINITY="respect,noreset,granularity=fine,balanced" +export OMP_NUM_THREADS=4 +echo "Cores configured $OMP_NUM_THREADS" +export ONEDNN_VERBOSE=0 + +for i in 1 2 3 4 5 6 7 +do + CNNS=(resnet50) + for COMPILER in ipex_onednn_graph + do + for DTYPE in float32 bfloat16 + do + for BS in 0001 + do + for name in "${CNNS[@]}" + do + echo "Benchmark $name with BS=$BS and DTYPE=$DTYPE" + export BENCH_COMMAND="benchmark-run -b cnn -p name='${name}',batch_size='$BS' --dtype ${DTYPE} --benchmark_desc ${name}_bs${BS}each4 --host ${HOST} -c ${COMPILER} --skip_verification" + numactl -m 0 --physcpubind=0-3 $BENCH_COMMAND & + numactl -m 0 --physcpubind=4-7 $BENCH_COMMAND & + numactl -m 0 --physcpubind=8-11 $BENCH_COMMAND & + numactl -m 0 --physcpubind=12-15 $BENCH_COMMAND & + numactl -m 0 --physcpubind=16-19 $BENCH_COMMAND & + numactl -m 0 --physcpubind=20-23 $BENCH_COMMAND & + numactl -m 0 --physcpubind=24-27 $BENCH_COMMAND & + numactl -m 0 --physcpubind=28-31 $BENCH_COMMAND & + numactl -m 0 --physcpubind=32-35 $BENCH_COMMAND & + numactl -m 0 --physcpubind=36-39 $BENCH_COMMAND & + numactl -m 0 --physcpubind=40-43 $BENCH_COMMAND & + numactl -m 0 --physcpubind=44-47 $BENCH_COMMAND & + numactl -m 0 --physcpubind=48-51 $BENCH_COMMAND & + numactl -m 0 --physcpubind=52-55 $BENCH_COMMAND & + wait $(jobs -p) + done + done + done + done + + + LLMS=(gptj llama2-7b) + for COMPILER in ipex + do + for BS in 1 + do + for DTYPE in bfloat16 + do + for name in "${LLMS[@]}" + do + echo "Benchmark $name with DTYPE=$DTYPE" + export BENCH_COMMAND="benchmark-run -b llm -p name='${name}',batch_size='$BS' --dtype ${DTYPE} --benchmark_desc ${name}_bs${BS}each4 --host ${HOST} -c ${COMPILER} --skip_verification" + numactl -m 0 --physcpubind=0-3 $BENCH_COMMAND & + numactl -m 0 --physcpubind=4-7 $BENCH_COMMAND & + numactl -m 0 --physcpubind=8-11 $BENCH_COMMAND & + numactl -m 0 --physcpubind=12-15 $BENCH_COMMAND & + numactl -m 0 --physcpubind=16-19 $BENCH_COMMAND & + numactl -m 0 --physcpubind=20-23 $BENCH_COMMAND & + numactl -m 0 --physcpubind=24-27 $BENCH_COMMAND & + numactl -m 0 --physcpubind=28-31 $BENCH_COMMAND & + numactl -m 0 --physcpubind=32-35 $BENCH_COMMAND & + numactl -m 0 --physcpubind=36-39 $BENCH_COMMAND & + numactl -m 0 --physcpubind=40-43 $BENCH_COMMAND & + numactl -m 0 --physcpubind=44-47 $BENCH_COMMAND & + numactl -m 0 --physcpubind=48-51 $BENCH_COMMAND & + numactl -m 0 --physcpubind=52-55 $BENCH_COMMAND & + wait $(jobs -p) + done + done + done + done +done diff --git a/scripts/margin_setup.sh b/scripts/margin_setup.sh new file mode 100755 index 0000000..3482f57 --- /dev/null +++ b/scripts/margin_setup.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# We expect to have this repo present and this script run as +# ./scripts/margin.sh + +# install miniconda +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh +curl -o Miniconda3-latest-Linux-x86_64.sh -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ + sh Miniconda3-latest-Linux-x86_64.sh -u -b -p ./miniconda && \ + rm -f Miniconda3-latest-Linux-x86_64.sh +source ./miniconda/bin/activate + +# set up env +conda create -y -n margin python=3.11 +conda activate margin +# Install ipex & pytorch +python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu +python -m pip install intel-extension-for-pytorch +python -m pip install transformers==4.35.2 +python -m pip install oneccl_bind_pt --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/cpu/us/ + +# Install benchmarks +pip install -e .