qs-benchmarks / toolchain /create_bash_script.py
Amit
Translator and toolchain added.
951488e
import sys
import os
import subprocess
# sim_pack = 'qiskit'
# task = 'hdyn'
# com_cap = 'st'
# prec = 'dp'
sim_pack = sys.argv[1]
task = sys.argv[2]
com_cap = sys.argv[3]
prec = sys.argv[4]
N_arr = range(6, 36, 2)
if sim_pack == 'hiq':
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('#!/bin/bash -l\n')
job_file.write('. /app/etc/profile.d/conda.sh\n')
job_file.write('conda activate sim_{}\n'.format(sim_pack))
job_file.write('python3 /sim_lib/hiq/HiQsimulator/examples/run_files_{}_{}/{}_n{}.py\n'.format(com_cap, prec, task, N))
elif sim_pack == 'intel_qs_cpp':
if com_cap == 'st':
with open('{}_{}_{}.sh'.format(task, com_cap, prec), 'a') as job_file:
job_file.write('#!/bin/bash -l\n')
job_file.write('export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/sim_lib/intel_qs_cpp/intel-qs/build/lib\n')
job_file.write('export LIBRARY_PATH=$LIBRARY_PATH:/sim_lib/intel_qs_cpp/intel-qs/build/lib\n')
job_file.write('cd /home\n')
job_file.write('cmake .\n')
job_file.write('cmake --build ./\n')
job_file.write('make\n')
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('#!/bin/bash -l\n')
job_file.write('export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/sim_lib/intel_qs_cpp/intel-qs/build/lib\n')
job_file.write('export LIBRARY_PATH=$LIBRARY_PATH:/sim_lib/intel_qs_cpp/intel-qs/build/lib\n')
job_file.write('cd /home/bin_st_{}\n'.format(prec))
job_file.write('./{}_{}_st_{}_n{}\n'.format(sim_pack, task, prec, N))
elif sim_pack == 'quest':
# with open('{}_{}_{}.sh'.format(task, com_cap, prec), 'a') as job_file:
# job_file.write('#!/bin/bash -l\n')
# job_file.write('cd /home\n')
# if com_cap == 'st':
# job_file.write('cmake .\n')
# elif com_cap == 'mt':
# job_file.write('cmake -DMULTITHREADED=1 .\n')
# elif com_cap == 'gpu':
# job_file.write('cmake -DGPUACCELERATED=1 -DGPU_COMPUTE_CAPABILITY=80 .\n')
# job_file.write('cmake --build ./\n')
# job_file.write('make\n')
with open('{}_{}_{}.sh'.format(task, com_cap, prec), 'a') as job_file:
for N in N_arr:
# bdir = "/sim_lib/quest/QuEST/build_{}_{}_{}".format(task, com_cap, prec)
job_file.write('#!/bin/bash -l\n')
# fn_c = "/sim_lib/quest/QuEST/{}/run_files_{}_{}/{}_n{}.c".format(task, com_cap, prec, task, N)
fn_c = "/home/{}_n{}.c".format(task, N)
fn = "{}_{}_{}_{}_n{}".format(sim_pack, task, com_cap, prec, N)
if com_cap == 'st':
# job_file.write('export QuEST_LIB_PATH=/sim_lib/quest/QuEST/build_st/QuEST\n')
# job_file.write('export QuEST_LIB_EXACT=/sim_lib/quest/QuEST/build_st/QuEST/libQuEST.so\n')
job_file.write('cd /sim_lib/quest/QuEST/build_{}_{}\n'.format(com_cap, prec))
if prec == 'sp':
job_file.write('cmake .. -DUSER_SOURCE=\"{}\" -DOUTPUT_EXE=\"{}\" -DPRECISION=1\n'.format(fn_c, fn))
elif prec == 'dp':
job_file.write('cmake .. -DUSER_SOURCE=\"{}\" -DOUTPUT_EXE=\"{}\"\n'.format(fn_c, fn))
job_file.write('make\n')
elif com_cap == 'mt':
# job_file.write('export QuEST_LIB_PATH=/sim_lib/quest/QuEST/build_mt/QuEST\n')
# job_file.write('export QuEST_LIB_EXACT=/sim_lib/quest/QuEST/build_mt/QuEST/libQuEST.so\n')
job_file.write('cd /sim_lib/quest/QuEST/build_{}_{}\n'.format(com_cap, prec))
if prec == 'sp':
job_file.write('cmake .. -DUSER_SOURCE=\"{}\" -DOUTPUT_EXE=\"{}\" -DMULTITHREADED=1 -DPRECISION=1\n'.format(fn_c, fn))
elif prec == 'dp':
job_file.write('cmake .. -DUSER_SOURCE=\"{}\" -DOUTPUT_EXE=\"{}\" -DMULTITHREADED=1\n'.format(fn_c, fn))
job_file.write('make\n')
elif com_cap == 'gpu':
# job_file.write('export QuEST_LIB_PATH=/sim_lib/quest/QuEST/build_gpu/QuEST\n')
# job_file.write('export QuEST_LIB_EXACT=/sim_lib/quest/QuEST/build_gpu/QuEST/libQuEST.so\n')
job_file.write('cd /sim_lib/quest/QuEST/build_{}_{}\n'.format(com_cap, prec))
job_file.write('cmake .. -DUSER_SOURCE=\"{}\" -DOUTPUT_EXE=\"{}\" -DGPUACCELERATED=1 -DGPU_COMPUTE_CAPABILITY=80\n'.format(fn_c, fn))
job_file.write('make\n')
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
# job_file.write('cd /home/bin_{}_{}\n'.format(com_cap, prec))
job_file.write('cd /sim_lib/quest/QuEST/build_{}_{}\n'.format(com_cap, prec))
job_file.write('./{}_{}_{}_{}_n{}\n'.format(sim_pack, task, com_cap, prec, N))
elif sim_pack == 'qrack_sch' or sim_pack == 'qrack_opt':
with open('{}_{}_{}.sh'.format(task, com_cap, prec), 'a') as job_file:
job_file.write('#!/bin/bash -l\n')
job_file.write('cd /bin_{}_{}\n'.format(com_cap, prec))
job_file.write('export LIBRARY_PATH=$LIBRARY_PATH:/usr/lib/x86_64-linux-gnu\n')
for N in N_arr:
# job_file.write('#!/bin/bash -l\n')
fn_c = "/home/{}_n{}.cpp".format(task, N)
fn = "{}_{}_{}_{}_n{}".format(sim_pack, task, com_cap, prec, N)
if com_cap == 'st': # or com_cap == 'mt':
if prec == 'sp':
job_file.write('g++ -std=c++11 -march=native -Wall -Werror {} -I/sim_lib/qrack/qrack/build_st_sp/include -L/sim_lib/qrack/qrack/build_st_sp -lqrack -lpthread -o {}\n'.format(fn_c, fn))
elif prec == 'dp':
job_file.write('g++ -std=c++11 -march=native -Wall -Werror {} -I/sim_lib/qrack/qrack/build_st_dp/include -L/sim_lib/qrack/qrack/build_st_dp -lqrack -lpthread -o {}\n'.format(fn_c, fn))
elif com_cap == 'gpu':
# job_file.write('export LIBRARY_PATH=$LIBRARY_PATH:/usr/lib/x86_64-linux-gnu\n')
if prec == 'sp':
job_file.write('g++ -std=c++11 -march=native -Wall -Werror {} -I/sim_lib/qrack/qrack/build_gpu_sp/include -L/sim_lib/qrack/qrack/build_gpu_sp -lqrack -lOpenCL -lpthread -o {}\n'.format(fn_c, fn))
elif prec == 'dp':
job_file.write('g++ -std=c++11 -march=native -Wall -Werror {} -I/sim_lib/qrack/qrack/build_gpu_dp/include -L/sim_lib/qrack/qrack/build_gpu_dp -lqrack -lOpenCL -lpthread -o {}\n'.format(fn_c, fn))
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
if com_cap == 'st' or com_cap == 'mt':
job_file.write('cd /bin_st_{}\n'.format(prec))
job_file.write('./{}_{}_st_{}_n{}\n'.format(sim_pack, task, prec, N))
elif com_cap == 'gpu':
job_file.write('cd /bin_gpu_{}\n'.format(prec))
job_file.write('./{}_{}_gpu_{}_n{}\n'.format(sim_pack, task, prec, N))
elif sim_pack == 'qpp':
# with open('{}_{}_{}.sh'.format(task, com_cap, prec), 'a') as job_file:
# job_file.write('#!/bin/bash -l\n')
# job_file.write('cd /bin_{}_{}\n'.format(com_cap, prec))
# for N in N_arr:
# fn_c = "/home/{}_n{}.cpp".format(task, N)
# fn = "{}_{}_{}_{}_n{}".format(sim_pack, task, com_cap, prec, N)
# if com_cap == 'st': # or com_cap == 'mt':
# job_file.write('c++ -pedantic -std=c++17 -Wall -Wextra -Weffc++ -fopenmp -isystem /usr/local/include/eigen3 -I /sim_lib/qpp/qpp/include -I /sim_lib/qpp/qpp/qasmtools/include {} -o {}\n'.format(fn_c, fn))
for N in N_arr:
fn_c = "/home/{}_n{}.cpp".format(task, N)
fn = "{}_{}_{}_{}_n{}".format(sim_pack, task, com_cap, prec, N)
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
if com_cap == 'st':
job_file.write('cd /bin_st_{}\n'.format(prec))
job_file.write('c++ -pedantic -std=c++17 -Wall -Wextra -Weffc++ -fopenmp -isystem /usr/local/include/eigen3 -I /sim_lib/qpp/qpp/include -I /sim_lib/qpp/qpp/qasmtools/include {} -o {}\n'.format(fn_c, fn))
job_file.write('./{}_{}_st_{}_n{}\n'.format(sim_pack, task, prec, N))
elif com_cap == 'mt':
job_file.write('cd /bin_st_{}\n'.format(prec))
job_file.write('./{}_{}_st_{}_n{}\n'.format(sim_pack, task, prec, N))
elif sim_pack == 'yao':
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
if com_cap == 'st' or com_cap == 'mt':
job_file.write('/julia/julia-1.8.5/bin/julia /home/{}_n{}.jl\n'.format(task, N))
elif com_cap == 'gpu':
job_file.write('/data/user/gangap_a/julia-1.8.5/bin/julia /data/user/gangap_a/{}_singular/yao/run_files_{}_{}/{}_n{}.jl'.format(task, com_cap, prec, task, N))
elif sim_pack == 'pennylane_l' and com_cap == 'gpu':
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('python3 /data/user/gangap_a/{}_singular/pennylane_l/run_files_{}_{}/{}_n{}.py'.format(task, com_cap, prec, task, N))
elif sim_pack == 'qsimcirq' and com_cap == 'gpu':
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('python3 /data/user/gangap_a/{}_singular/qsimcirq/run_files_{}_{}/{}_n{}.py'.format(task, com_cap, prec, task, N))
elif sim_pack == 'qpanda' and com_cap == 'gpu':
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('python3 /data/user/gangap_a/{}_singular/qpanda/run_files_{}_{}/{}_n{}.py'.format(task, com_cap, prec, task, N))
elif sim_pack == 'cuquantum_qiskit' and com_cap == 'gpu':
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('python3 /home/{}_n{}.py\n'.format(task, N))
elif sim_pack == 'cuquantum_qiskit' and (com_cap == 'gpu1' or com_cap == 'gpu2' or com_cap == 'gpu4' or com_cap == 'gpu8'):
ngpus = int(com_cap[-1])
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('mpirun -n {} python3 /home/{}_n{}.py\n'.format(ngpus, task, N))
elif sim_pack == 'cuquantum_qsimcirq' and (com_cap == 'gpu' or com_cap == "gpu1" or com_cap == "gpu2" or com_cap == "gpu4" or com_cap == "gpu8"):
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('python3 /home/{}_n{}.py\n'.format(task, N))
elif sim_pack == 'cuda_quantum':# and (com_cap == 'gpu' or com_cap == "gpu1" or com_cap == "gpu2" or com_cap == "gpu4" or com_cap == "gpu8"):
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('python3 /home/{}_n{}.py\n'.format(task, N))
elif sim_pack == 'qibojit' and (com_cap == "gpu1" or com_cap == "gpu2" or com_cap == "gpu4" or com_cap == "gpu8"):
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('#!/bin/bash -l\n')
job_file.write('. /app/etc/profile.d/conda.sh\n')
job_file.write('conda activate sim_{}_gpu\n'.format(sim_pack))
job_file.write('python3 /home/{}_n{}.py\n'.format(task, N))
# elif sim_pack == 'pennylane_l' and com_cap == 'gpu':
# for N in N_arr:
# with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
# job_file.write('#!/bin/bash -l\n')
# job_file.write('. /app/etc/profile.d/conda.sh\n')
# job_file.write('export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/cuda_lib\n')
# job_file.write('export LIBRARY_PATH=$LIBRARY_PATH:/cuda_lib\n')
# job_file.write('conda activate sim_{}_gpu\n'.format(sim_pack))
# job_file.write('python3 /home/{}_n{}.py\n'.format(task, N))
else:
for N in N_arr:
with open('{}_{}_{}_{}.sh'.format(task, com_cap, prec, N), 'a') as job_file:
job_file.write('#!/bin/bash -l\n')
job_file.write('. /app/etc/profile.d/conda.sh\n')
if com_cap == 'st' or com_cap == 'mt':
job_file.write('conda activate sim_{}\n'.format(sim_pack))
elif com_cap == 'gpu':
# job_file.write('module load cuda/11.5.1\n')
job_file.write('conda activate sim_{}_gpu\n'.format(sim_pack))
job_file.write('python3 /home/{}_n{}.py\n'.format(task, N))