qs-benchmarks / toolchain /create_dir_struct.py
Amit
Translator and toolchain added.
951488e
import os
sim_pack = 'braket'
task = 'hdyn'
com_cap = 'st'
prec = 'dp'
gen_path = '/data/user/gangap_a/{}_singular/gen_files/'.format(task)
sim_path = '/data/user/gangap_a/{}_singular/{}/'.format(task, sim_pack)
print(sim_path)
# os.chdir(sim_path)
print(' ############################ ')
print('### Create job scripts folder for package: {}, task: {}, compute cap: {}, precision: {}'.format(sim_pack, task, com_cap, prec))
job_scripts_path = sim_path+'job_scripts_{}_{}'.format(com_cap, prec)
print(job_scripts_path)
os.mkdir(job_scripts_path)
print('### Create job scripts')
os.chdir(job_scripts_path)
cjs = gen_path+'create_job_script.py {} {} {} {}'.format(sim_pack, task, com_cap, prec)
os.system('python3 {}'.format(cjs))
print(' ############################ ')
print('### Create bash scripts folder for package: {}, task: {}, compute cap: {}, precision: {}'.format(sim_pack, task, com_cap, prec))
bash_scripts_path = sim_path+'bash_scripts_{}_{}'.format(com_cap, prec)
os.mkdir(bash_scripts_path)
print('### Create bash scripts')
os.chdir(bash_scripts_path)
cbs = gen_path+'create_bash_script.py {} {} {} {}'.format(sim_pack, task, com_cap, prec)
os.system('python3 {}'.format(cbs))
print(' ############################ ')
print('### Create output folder')
os.mkdir(sim_path+'output_{}_{}'.format(com_cap, prec))
print('### Create error folder')
os.mkdir(sim_path+'error_{}_{}'.format(com_cap, prec))
print('### Create data folder')
os.mkdir(sim_path+'data_{}_{}'.format(com_cap, prec))
print(' ############################ ')
print('### Create run files folder package: {}, task: {}, compute cap: {}, precision: {}'.format(sim_pack, task, com_cap, prec))
run_files_path = sim_path+'run_files_{}_{}'.format(com_cap, prec)
os.mkdir(run_files_path)
sim_parser = input("Enter the python file including the path for the parser: ")
os.system('python3 {}'.format(sim_parser))
print(' ############################ ')
print('### Create bash scripts to run jobs')
os.chdir(sim_path)
with open('run_jobs_{}_{}.sh'.format(com_cap, prec), 'w') as f:
if sim_pack == 'quest':
# f.write('export APPTAINER_BIND=\"/data/user/gangap_a/{}_singular/quest/bash_scripts_{}_{}/:/brf,/data/user/gangap_a/{}_singular/quest/:/home\"\n'.format(task, com_cap, prec, task))
os.mkdir('/data/user/gangap_a/{}_singular/quest/build_{}_{}'.format(task, com_cap, prec))
# f.write('export APPTAINER_BIND=\"/data/user/gangap_a/{}_singular/quest/bash_scripts_{}_{}/:/brf,/data/user/gangap_a/hdyn_singular/quest/run_files_st_dp/:/sim_lib/quest/QuEST/hdyn/run_files_st_dp,/data/user/gangap_a/{}_singular/quest/build_{}_{}:/home\"\n'.format(task, com_cap, prec, task, com_cap, prec))
f.write('export APPTAINER_BIND=\"/data/user/gangap_a/{}_singular/quest/bash_scripts_{}_{}/:/brf,/data/user/gangap_a/{}_singular/quest/run_files_{}_{}/:/home,/data/user/gangap_a/{}_singular/quest/build_{}_{}:/sim_lib/quest/QuEST/build_{}_{}\"\n'.format(task, com_cap, prec, task, com_cap, prec, task, com_cap, prec, com_cap, prec))
if com_cap == 'st' or com_cap == 'mt':
f.write('singularity exec /data/user/gangap_a/singularity_images/qucos_sim.sif bash /brf/{}_{}_{}.sh\n'.format(task, com_cap, prec))
elif com_cap == 'gpu':
f.write('singularity exec --nv /data/user/gangap_a/singularity_images/qucos_gpu_sim.sif bash /brf/{}_{}_{}.sh\n'.format(task, com_cap, prec))
elif sim_pack == 'qrack_sch' or sim_pack == 'qrack_opt':
os.mkdir('/data/user/gangap_a/{}_singular/{}/bin_{}_{}'.format(task, sim_pack, com_cap, prec))
f.write('export APPTAINER_BIND=\"/data/user/gangap_a/{}_singular/{}/bash_scripts_{}_{}/:/brf,/data/user/gangap_a/{}_singular/{}/run_files_{}_{}/:/home,/data/user/gangap_a/{}_singular/{}/bin_{}_{}:/bin_{}_{}\"\n'.format(task, sim_pack, com_cap, prec, task, sim_pack, com_cap, prec, task, sim_pack, com_cap, prec, com_cap, prec))
if com_cap == 'st' or com_cap == 'mt':
f.write('singularity exec /data/user/gangap_a/singularity_images/qucos_sim.sif bash /brf/{}_{}_{}.sh\n'.format(task, com_cap, prec))
elif com_cap == 'gpu':
f.write('singularity exec --nv /data/user/gangap_a/singularity_images/qucos_gpu_sim.sif bash /brf/{}_{}_{}.sh\n'.format(task, com_cap, prec))
elif sim_pack == 'qpp':
os.mkdir('/data/user/gangap_a/{}_singular/{}/bin_{}_{}'.format(task, sim_pack, com_cap, prec))
f.write('export APPTAINER_BIND=\"/data/user/gangap_a/{}_singular/{}/bash_scripts_{}_{}/:/brf,/data/user/gangap_a/{}_singular/{}/run_files_{}_{}/:/home,/data/user/gangap_a/{}_singular/{}/bin_{}_{}:/bin_{}_{}\"\n'.format(task, sim_pack, com_cap, prec, task, sim_pack, com_cap, prec, task, sim_pack, com_cap, prec, com_cap, prec))
# if com_cap == 'st' or com_cap == 'mt':
# f.write('singularity exec /data/user/gangap_a/singularity_images/qucos_sim.sif bash /brf/{}_{}_{}.sh\n'.format(task, com_cap, prec))
# f.write('cd /psi/home/gangap_a\n')
# f.write('rm -rf CMakeCache.txt CMakeFiles cmake_install.cmake Makefile\n')
f.write('path=\"/data/user/gangap_a/{}_singular/{}/job_scripts_{}_{}\"\n'.format(task, sim_pack, com_cap, prec))
f.write('cd $path\n')
f.write('for job_script in *.sh; do\n')
f.write('echo $job_script;\n')
f.write('sbatch $job_script;\n')
# if sim_pack == 'quest':
# f.write('sleep 2.5\n')
f.write('done\n')