diff --git a/examples/qed_bench_tape.jl b/examples/qed_bench_tape.jl index 01e80e6..223828a 100644 --- a/examples/qed_bench_tape.jl +++ b/examples/qed_bench_tape.jl @@ -200,7 +200,7 @@ bench_qed("ke->kkke") bench_qed("ke->kkkke") bench_qed("ke->kkkkke") bench_qed("ke->kkkkkke") -bench_qed("ke->kkkkkkke", true) +bench_qed("ke->kkkkkkke") bench_abc("AB->AB") bench_abc("AB->ABBB") diff --git a/examples/qed_gen_bench.jl b/examples/qed_gen_bench.jl index 71827df..ed512da 100644 --- a/examples/qed_gen_bench.jl +++ b/examples/qed_gen_bench.jl @@ -4,7 +4,7 @@ using CSV using BenchmarkTools using StatsBase -results_filename = "qed_gen_results.csv" +results_filename = "qed_gen_results_$(Threads.nthreads()).csv" df = DataFrame( process_name = String[], @@ -29,26 +29,10 @@ df = DataFrame( graph_edges_reduced = Int[], graph_mem = Float64[], graph_mem_reduced = Float64[], + graph_elapsed_reduce = Float64[], ) -# if they exist, read existing results and append new ones -if isfile(results_filename) - df = CSV.read(results_filename, DataFrame) -end - -processes = [ - "ke->ke", - "ke->kke", - "ke->kkke", - "ke->kkkke", - "ke->kkkkke", - "ke->kkkkkke", - "ke->kkkkkkke", - "ke->kkkkkkkke", - #"ke->kkkkkkkkke", -] - -function bench_process(process::AbstractString) +function bench_process(process::AbstractString; warmup = false, optimize = true) println("Benchmarking $process...") model = QEDModel() @@ -62,12 +46,21 @@ function bench_process(process::AbstractString) node_dict = countmap(typeof.(graph.nodes)) graph_size = Base.summarysize(graph) - optim = ReductionOptimizer() - optimize_to_fixpoint!(optim, graph) + reduce_elapsed = -1.0 + node_dict_reduced = Dict() + graph_size_reduced = -1.0 + props_reduced = GraphProperties() + if optimize + reduce_elapsed = @elapsed optimize_to_fixpoint!(ReductionOptimizer(), graph) - props_reduced = GraphProperties(graph) - node_dict_reduced = countmap(typeof.(graph.nodes)) - graph_size_reduced = Base.summarysize(graph) + props_reduced = GraphProperties(graph) + node_dict_reduced = countmap(typeof.(graph.nodes)) + graph_size_reduced = Base.summarysize(graph) + end + + if warmup + return nothing + end push!( df, @@ -94,13 +87,58 @@ function bench_process(process::AbstractString) :graph_edges_reduced => props_reduced.noEdges, :graph_mem => graph_size, :graph_mem_reduced => graph_size_reduced, + :graph_elapsed_reduce => reduce_elapsed, ), ) return nothing end -for process in processes - bench_process(process) +processes = [ + ("ke->ke", true), + ("ke->kke", true), + ("ke->kkke", true), + ("ke->kkkke", true), + ("ke->kkkkke", true), + ("ke->kkkkkke", true), + ("ke->kkkkkkke", true), + ("ke->kkkkkkkke", false), + ("ke->kkkkkkkkke", false), +] + +df = DataFrame( + process_name = String[], + cpu_threads = Int[], + graph_gen_samples = Int[], + graph_gen_mean = Float64[], + graph_gen_std = Float64[], + graph_gen_median = Float64[], + graph_nodes = Int[], + graph_data_nodes = Int[], + graph_u_nodes = Int[], + graph_v_nodes = Int[], + graph_s1_nodes = Int[], + graph_s2_nodes = Int[], + graph_edges = Int[], + graph_nodes_reduced = Int[], + graph_data_nodes_reduced = Int[], + graph_u_nodes_reduced = Int[], + graph_v_nodes_reduced = Int[], + graph_s1_nodes_reduced = Int[], + graph_s2_nodes_reduced = Int[], + graph_edges_reduced = Int[], + graph_mem = Float64[], + graph_mem_reduced = Float64[], + graph_elapsed_reduce = Float64[], +) + +# if they exist, read existing results and append new ones +if isfile(results_filename) + df = CSV.read(results_filename, DataFrame) end -CSV.write(results_filename, df) +bench_process("ke->kke", warmup = true) + +for (process, opt) in processes + bench_process(process, optimize = opt) + CSV.write(results_filename, df) +end diff --git a/experiments/gen_diagram_hemera.sh b/experiments/gen_diagram_hemera.sh new file mode 100755 index 0000000..a4ab449 --- /dev/null +++ b/experiments/gen_diagram_hemera.sh @@ -0,0 +1,17 @@ +#!/bin/bash +#SBATCH --array=1-8 +#SBATCH --job-name=qed_diag_gen +#SBATCH --partition=intel +#SBATCH --time=4:00:00 +#SBATCH --nodes=1 +#SBATCH --ntasks=1 +#SBATCH --cpus-per-task=8 +#SBATCH --mem=64GB +#SBATCH --output=simulation-%A-%a.out +#SBATCH --error=simulation-%A-%a.err + +cd $HOME/repos/metagraph_optimization + +module load singularity + +singularity exec experiments/CUDA_container.sif ./experiments/run_gen_diagram.sh $SLURM_ARRAY_TASK_ID diff --git a/experiments/run.sh b/experiments/run.sh deleted file mode 100755 index 65ab1f8..0000000 --- a/experiments/run.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -LOG_FILE="$SCRIPT_DIR/../julia.log" - -cd $SCRIPT_DIR/.. - -echo "Initiating julia..." -julia --project=./ -e 'using Pkg; Pkg.instantiate(); Pkg.add(url="https://github.com/QEDjl-project/QEDprocesses.jl/")' > $LOG_FILE 2>&1 || exit 1 # need current dev version of QEDprocesses -julia -e 'using Pkg; Pkg.add("CSV"); Pkg.add("DataFrames"); Pkg.add("LIKWID"); Pkg.add("CUDA"); Pkg.add("Random")' >> $LOG_FILE 2>&1 || exit 1 # add requirements for the bench script - -echo "Benchmarking..." - -# -#for i in {1..20} -#do -# echo "$i Threads" -# julia --project --threads=$i examples/qed_bench.jl >> $LOG_FILE 2>&1 || echo "-- Something went wrong, check logs --" -#done - -echo "Benchmarking Tape variant..." - -for i in {1..20} -do - echo "$i Threads" - julia --project --threads=$i examples/qed_bench_tape.jl >> $LOG_FILE 2>&1 || echo "-- Something went wrong, check logs --" -done diff --git a/experiments/run_gen_diagram.sh b/experiments/run_gen_diagram.sh new file mode 100755 index 0000000..de9bdc7 --- /dev/null +++ b/experiments/run_gen_diagram.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# first arg = number of threads +i=$1 + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +LOG_FILE="$SCRIPT_DIR/../julia.log" + +cd $SCRIPT_DIR/.. + +echo "Writing system info..." + +printf "Current git commit hash: " > $LOG_FILE +git rev-parse HEAD >> $LOG_FILE +git status >> $LOG_FILE + +# collect some information of the used node and system +uname -a > results/system.txt +julia --version > results/julia.txt +lscpu > results/cpu.txt +lsblk > results/storage.txt +lspci > results/pci.txt + +echo "Initiating julia..." +julia --threads=8 --project=./ -e 'using Pkg; Pkg.instantiate(); Pkg.add(url="https://github.com/QEDjl-project/QEDprocesses.jl/")' >> $LOG_FILE 2>&1 || exit 1 # need current dev version of QEDprocesses +julia --threads=8 -e 'using Pkg; Pkg.add("CSV"); Pkg.add("DataFrames"); Pkg.add("BenchmarkTools"); Pkg.add("StatsBase")' >> $LOG_FILE 2>&1 || exit 1 # add requirements for the bench script + +echo "Benchmarking with $i threads..." + +julia --project --threads=$i examples/qed_gen_bench.jl >> $LOG_FILE 2>&1 || echo "-- Something went wrong, check logs --" diff --git a/experiments/run_qed_exec.sh b/experiments/run_qed_exec.sh new file mode 100755 index 0000000..885ba51 --- /dev/null +++ b/experiments/run_qed_exec.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# first arg = number of threads +$i = $1 + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +LOG_FILE="$SCRIPT_DIR/../julia.log" + +cd $SCRIPT_DIR/.. + +echo "Writing system info..." + +printf "Current git commit hash: " > $LOG_FILE +git rev-parse HEAD >> $LOG_FILE +git status >> $LOG_FILE + +# collect some information of the used node and system +uname -a > results/system.txt +julia --version > results/julia.txt +lscpu > results/cpu.txt +nvidia-smi > results/cuda_gpu.txt +lsblk > results/storage.txt +lspci > results/pci.txt + +echo "Initiating julia..." +julia --project=./ -e 'using Pkg; Pkg.instantiate(); Pkg.add(url="https://github.com/QEDjl-project/QEDprocesses.jl/")' >> $LOG_FILE 2>&1 || exit 1 # need current dev version of QEDprocesses +julia -e 'using Pkg; Pkg.add("CSV"); Pkg.add("DataFrames"); Pkg.add("LIKWID"); Pkg.add("CUDA"); Pkg.add("Random")' >> $LOG_FILE 2>&1 || exit 1 # add requirements for the bench script + +echo "Benchmarking..." +echo "$i Threads" +julia --project --threads=$i examples/qed_bench.jl >> $LOG_FILE 2>&1 || echo "-- Something went wrong, check logs --" + +echo "Benchmarking Tape variant..." +echo "$i Threads" +julia --project --threads=$i examples/qed_bench_tape.jl >> $LOG_FILE 2>&1 || echo "-- Something went wrong, check logs --"