#! /bin/python3 import argparse import os import subprocess, signal import json parser = argparse.ArgumentParser() parser.add_argument('output_dir') parser.add_argument('baseline_time_s') parser.add_argument('baseline_delay_s') parser.add_argument('matrix_file') parser.add_argument('iterations') parser.add_argument('-d', '--debug', action='store_true') args = parser.parse_args() result = dict() #baseline = subprocess.run( # ['./power.sh', args.baseline_time_s], # stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) #print(baseline) #for line in baseline.stdout.split('\n'): # print("line") # print(line) power_process = subprocess.Popen(['./power.py', '-s', args.baseline_time_s], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True) result['power_before'] = power_process.communicate()[0].strip().split('\n') if args.debug: print(result) power_process = subprocess.Popen(['./power.py'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True) # do thing main_process = subprocess.run( ['apptainer', 'run', 'pytorch-altra.sif', '-c', f'numactl --cpunodebind=0 --membind=0 python spmv.py {args.matrix_file} {args.iterations}' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) out = main_process.stdout err = main_process.stderr print(out) print(err) power_process.send_signal(signal.SIGINT) result['power'] = power_process.communicate()[0].strip().split('\n') if args.debug: print(result) import time time.sleep(args.baseline_delay_s) power_process = subprocess.Popen(['./power.py', '-s', args.baseline_time_s], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True) result['power_after'] = power_process.communicate()[0].strip().split('\n') if args.debug: print(result) #os.path.basename(args.matrix_file) #subprocess.run( # ['apptainer', 'run', 'pytorch-altra.sif', '-c', # f'"numactl --cpunodebind=0 --membind=0 python spmv.py {args.matrix_file} {args.iterations}"' # ], # stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)