Added support for multiple cores
This commit is contained in:
parent
abd4b43a58
commit
7fa68e2302
@ -21,6 +21,7 @@ parser.add_argument('baseline_delay_s', type=int)
|
|||||||
parser.add_argument('-m', '--matrix_dir', type=str)
|
parser.add_argument('-m', '--matrix_dir', type=str)
|
||||||
parser.add_argument('-ss', '--synthetic_size', nargs="+", type=int)
|
parser.add_argument('-ss', '--synthetic_size', nargs="+", type=int)
|
||||||
parser.add_argument('-sd', '--synthetic_density', nargs="+", type=float)
|
parser.add_argument('-sd', '--synthetic_density', nargs="+", type=float)
|
||||||
|
parser.add_argument('-c', '--cores', type=int)
|
||||||
parser.add_argument('--power', action='store_const', const='--power')
|
parser.add_argument('--power', action='store_const', const='--power')
|
||||||
parser.add_argument('--distribute', action='store_true')
|
parser.add_argument('--distribute', action='store_true')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -92,6 +93,10 @@ def run(
|
|||||||
exit("Unrecognized matrix type!")
|
exit("Unrecognized matrix type!")
|
||||||
# if args.perf is not None:
|
# if args.perf is not None:
|
||||||
# run_args_list += [args.perf]
|
# run_args_list += [args.perf]
|
||||||
|
|
||||||
|
if args.cores is not None:
|
||||||
|
run_args_list += ['-c', args.cores]
|
||||||
|
|
||||||
if args.power is not None:
|
if args.power is not None:
|
||||||
run_args_list += [args.power]
|
run_args_list += [args.power]
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ parser.add_argument('baseline_delay_s', type=int)
|
|||||||
parser.add_argument('-m', '--matrix_file', type=str)
|
parser.add_argument('-m', '--matrix_file', type=str)
|
||||||
parser.add_argument('-ss', '--synthetic_size', type=int)
|
parser.add_argument('-ss', '--synthetic_size', type=int)
|
||||||
parser.add_argument('-sd', '--synthetic_density', type=float)
|
parser.add_argument('-sd', '--synthetic_density', type=float)
|
||||||
|
parser.add_argument('-c', '--cores', type=int)
|
||||||
parser.add_argument('--power', action='store_true')
|
parser.add_argument('--power', action='store_true')
|
||||||
parser.add_argument('-d', '--debug', action='store_true')
|
parser.add_argument('-d', '--debug', action='store_true')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -44,8 +45,10 @@ perf_args = {
|
|||||||
['-M', 'l2_cache_miss_ratio,l2_tlb_miss_ratio,ll_cache_read_miss_ratio']]
|
['-M', 'l2_cache_miss_ratio,l2_tlb_miss_ratio,ll_cache_read_miss_ratio']]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
power = ['taskset', '-c', '0', './power.sh']
|
||||||
def program(
|
def program(
|
||||||
cpu: Cpu,
|
cpu: Cpu,
|
||||||
|
cores: int,
|
||||||
matrix_type: MatrixType,
|
matrix_type: MatrixType,
|
||||||
fmt: Format,
|
fmt: Format,
|
||||||
iterations: int,
|
iterations: int,
|
||||||
@ -53,6 +56,12 @@ def program(
|
|||||||
synthetic_size: int,
|
synthetic_size: int,
|
||||||
synthetic_density: float
|
synthetic_density: float
|
||||||
) -> list:
|
) -> list:
|
||||||
|
apptainer = ['apptainer', 'run']
|
||||||
|
if cores is not None:
|
||||||
|
apptainer += [ '--env', 'OMP_PROC_BIND=true',
|
||||||
|
'--env', 'OMP_PLACES={0:' + f'{cores}' + '}']
|
||||||
|
apptainer = ['apptainer', 'run']
|
||||||
|
|
||||||
spmv = f'python3 spmv.py {matrix_type.name.lower()} {fmt.name.lower()} '
|
spmv = f'python3 spmv.py {matrix_type.name.lower()} {fmt.name.lower()} '
|
||||||
spmv += f'{iterations} '
|
spmv += f'{iterations} '
|
||||||
if matrix_type == MatrixType.SUITESPARSE:
|
if matrix_type == MatrixType.SUITESPARSE:
|
||||||
@ -61,25 +70,20 @@ def program(
|
|||||||
spmv += f'-ss {synthetic_size} -sd {synthetic_density}'
|
spmv += f'-ss {synthetic_size} -sd {synthetic_density}'
|
||||||
else:
|
else:
|
||||||
exit("Unrecognized matrix type!")
|
exit("Unrecognized matrix type!")
|
||||||
|
if cores is not None:
|
||||||
|
spmv += f'-c {cores}'
|
||||||
|
|
||||||
if cpu == Cpu.ALTRA:
|
if cpu == Cpu.ALTRA:
|
||||||
return [
|
return apptainer + ['pytorch-altra.sif', '-c',
|
||||||
'apptainer', 'run', 'pytorch-altra.sif', '-c',
|
|
||||||
'numactl --cpunodebind=0 --membind=0 ' + spmv]
|
'numactl --cpunodebind=0 --membind=0 ' + spmv]
|
||||||
#+ f'python3 spmv.py {matrix_type.name.lower()} '
|
|
||||||
#+ f'csr {iterations} -m {matrix_file}']
|
|
||||||
elif cpu == Cpu.EPYC_7313P:
|
elif cpu == Cpu.EPYC_7313P:
|
||||||
return ['apptainer', 'run', 'pytorch-epyc_7313p.sif'] + spmv.split(' ')
|
return apptainer + ['pytorch-epyc_7313p.sif'] + spmv.split(' ')
|
||||||
#'python3', 'spmv.py', f'{iterations}', 'csr', '-m', f'{matrix_file}']
|
|
||||||
elif cpu == Cpu.XEON_4216:
|
elif cpu == Cpu.XEON_4216:
|
||||||
return [
|
return apptainer + ['pytorch-xeon_4216.sif',
|
||||||
'apptainer', 'run', 'pytorch-xeon_4216.sif',
|
'numactl', '--cpunodebind=0', '--membind=0'] + spmv.split(' ')
|
||||||
'numactl', '--cpunodebind=0', '--membind=0'
|
|
||||||
] + spmv.split(' ')
|
|
||||||
#'python3', 'spmv.py', f'{iterations}', 'csr', '-m', f'{matrix_file}']
|
|
||||||
|
|
||||||
def baseline_power(cpu: Cpu, baseline_time_s: int) -> list:
|
def baseline_power(cpu: Cpu, baseline_time_s: int) -> list:
|
||||||
power_process = subprocess.Popen(['./power.sh', str(baseline_time_s)],
|
power_process = subprocess.Popen(power + [str(baseline_time_s)],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)
|
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)
|
||||||
return [float(x) for x in power_process.communicate()[0].strip().split('\n') if len(x) != 0]
|
return [float(x) for x in power_process.communicate()[0].strip().split('\n') if len(x) != 0]
|
||||||
|
|
||||||
@ -113,7 +117,7 @@ result[Stat.CPU.name] = args.cpu.value
|
|||||||
|
|
||||||
iterations = args.base_iterations
|
iterations = args.base_iterations
|
||||||
program_result = run_program(program(
|
program_result = run_program(program(
|
||||||
args.cpu, args.matrix_type, args.format, iterations,
|
args.cpu, args.cores, args.matrix_type, args.format, iterations,
|
||||||
args.matrix_file, args.synthetic_size, args.synthetic_density))
|
args.matrix_file, args.synthetic_size, args.synthetic_density))
|
||||||
while program_result[0][Stat.TIME_S.name] < args.min_time_s:
|
while program_result[0][Stat.TIME_S.name] < args.min_time_s:
|
||||||
# Increase the number of iterations by difference between the current time taken and the desired time.
|
# Increase the number of iterations by difference between the current time taken and the desired time.
|
||||||
@ -122,7 +126,7 @@ while program_result[0][Stat.TIME_S.name] < args.min_time_s:
|
|||||||
iterations += iterations * 0.05
|
iterations += iterations * 0.05
|
||||||
iterations = int(iterations)
|
iterations = int(iterations)
|
||||||
program_result = run_program(program(
|
program_result = run_program(program(
|
||||||
args.cpu, args.matrix_type, args.format, iterations,
|
args.cpu, args.cores, args.matrix_type, args.format, iterations,
|
||||||
args.matrix_file, args.synthetic_size, args.synthetic_density))
|
args.matrix_file, args.synthetic_size, args.synthetic_density))
|
||||||
|
|
||||||
result[Stat.ITERATIONS.name] = iterations
|
result[Stat.ITERATIONS.name] = iterations
|
||||||
@ -147,8 +151,8 @@ if args.power:
|
|||||||
|
|
||||||
# Power Collection
|
# Power Collection
|
||||||
power_process = subprocess.run(
|
power_process = subprocess.run(
|
||||||
['./power.sh', '-1'] + program(
|
power + ['-1'] + program(
|
||||||
args.cpu, args.matrix_type, args.format,
|
args.cpu, args.cores, args.matrix_type, args.format,
|
||||||
result[Stat.ITERATIONS.name],
|
result[Stat.ITERATIONS.name],
|
||||||
args.matrix_file, args.synthetic_size, args.synthetic_density),
|
args.matrix_file, args.synthetic_size, args.synthetic_density),
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||||
|
@ -7,6 +7,8 @@ import time
|
|||||||
import json
|
import json
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
|
device = 'cpu'
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('matrix_type', type=str,
|
parser.add_argument('matrix_type', type=str,
|
||||||
choices=[t.name.lower() for t in MatrixType],
|
choices=[t.name.lower() for t in MatrixType],
|
||||||
@ -21,11 +23,14 @@ parser.add_argument('-ss', '--synthetic_size', type=int,
|
|||||||
help='the synthetic matrix parameters size (rows)')
|
help='the synthetic matrix parameters size (rows)')
|
||||||
parser.add_argument('-sd', '--synthetic_density', type=float,
|
parser.add_argument('-sd', '--synthetic_density', type=float,
|
||||||
help='the synthetic matrix density')
|
help='the synthetic matrix density')
|
||||||
|
parser.add_argument('-c', '--cores', type=int,
|
||||||
|
help='the number of cores to use')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
args.matrix_type = MatrixType[args.matrix_type.upper()]
|
args.matrix_type = MatrixType[args.matrix_type.upper()]
|
||||||
args.format = Format[args.format.upper()]
|
args.format = Format[args.format.upper()]
|
||||||
|
|
||||||
device = 'cpu'
|
if args.cores is not None:
|
||||||
|
torch.set_num_threads(args.cores)
|
||||||
|
|
||||||
if args.matrix_type == MatrixType.SUITESPARSE:
|
if args.matrix_type == MatrixType.SUITESPARSE:
|
||||||
if args.matrix_file is None:
|
if args.matrix_file is None:
|
||||||
|
@ -1 +0,0 @@
|
|||||||
{"MATRIX_FILE": "as-caida", "MATRIX_SHAPE": [31379, 31379], "MATRIX_SIZE": 984641641, "MATRIX_NNZ": 106762, "MATRIX_DENSITY": 0.00010842726485909405, "TIME_S_T": 2.6111819744110107}
|
|
Loading…
Reference in New Issue
Block a user