diff --git a/analysis/data_stat.py b/analysis/data_stat.py index 4758a69..04a7d87 100644 --- a/analysis/data_stat.py +++ b/analysis/data_stat.py @@ -5,7 +5,7 @@ from enum import Enum class Stat(Enum): CPU = 'cpu' - THREADS = 'threads' + CORES = 'cores' ITERATIONS = 'iterations' BASELINE_TIME_S = 'baseline time (sec)' BASELINE_DELAY_S = 'baseline delay (sec)' @@ -16,8 +16,10 @@ class Stat(Enum): MATRIX_FILE = 'matrix file' MATRIX_FORMAT = 'matrix format' MATRIX_SHAPE = 'matrix shape' + MATRIX_ROWS = 'matrix rows' MATRIX_SIZE = 'matrix size' MATRIX_NNZ = 'matrix nnz' + MATRIX_DENSITY_GROUP = 'matrix density group' MATRIX_DENSITY = 'matrix density' #POWER_BEFORE = 'power before' diff --git a/pytorch/batch.py b/pytorch/batch.py index a3d508b..187f1bd 100644 --- a/pytorch/batch.py +++ b/pytorch/batch.py @@ -83,7 +83,8 @@ def run( str(args.base_iterations), str(args.min_time_s), str(args.baseline_time_s), - str(args.baseline_delay_s)] + str(args.baseline_delay_s), + '-d'] if args.matrix_type == MatrixType.SUITESPARSE: run_args_list += ['-m', matrix_file] @@ -95,7 +96,7 @@ def run( # run_args_list += [args.perf] if args.cores is not None: - run_args_list += ['-c', args.cores] + run_args_list += ['-c', str(args.cores)] if args.power is not None: run_args_list += [args.power] @@ -115,7 +116,8 @@ if args.matrix_type == MatrixType.SUITESPARSE: elif args.matrix_type == MatrixType.SYNTHETIC: parameter_list = enumerate([(size, density) for size in args.synthetic_size - for density in args.synthetic_density]) + for density in args.synthetic_density + if size ** 2 * density < 100000000]) #for i, matrix in enumerate(glob.glob(f'{args.matrix_dir.rstrip("/")}/*.mtx')): for i, parameter in parameter_list: diff --git a/pytorch/run.py b/pytorch/run.py index 6566180..39520d6 100644 --- a/pytorch/run.py +++ b/pytorch/run.py @@ -60,7 +60,6 @@ def program( 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'{iterations} ' @@ -70,8 +69,9 @@ def program( spmv += f'-ss {synthetic_size} -sd {synthetic_density}' else: exit("Unrecognized matrix type!") + if cores is not None: - spmv += f'-c {cores}' + spmv += f' -c {cores}' if cpu == Cpu.ALTRA: return apptainer + ['pytorch-altra.sif', '-c', @@ -114,6 +114,15 @@ def trapezoidal_rule(power: list[float], time_s: float) -> float: result = dict() result[Stat.CPU.name] = args.cpu.value +if args.cores is not None: + result[Stat.CORES.name] = args.cores +else: + if args.cpu == Cpu.ALTRA: + result[Stat.CORES.name] = 80 + elif args.cpu == Cpu.EPYC_7313P: + result[Stat.CORES.name] = 16 + elif args.cpu == Cpu.XEON_4216: + result[Stat.CORES.name] = 16 iterations = args.base_iterations program_result = run_program(program( diff --git a/pytorch/spmv.py b/pytorch/spmv.py index 2ae02e6..f83f5f1 100644 --- a/pytorch/spmv.py +++ b/pytorch/spmv.py @@ -80,11 +80,13 @@ end = time.time() result = dict() result[Stat.MATRIX_TYPE.name] = args.matrix_type.value -print(f"Matrix: {result[Stat.MATRIX_TYPE.name]}", file=sys.stderr) +print(f"Matrix Type: {result[Stat.MATRIX_TYPE.name]}", file=sys.stderr) if args.matrix_type == MatrixType.SUITESPARSE: result[Stat.MATRIX_FILE.name] = os.path.splitext(os.path.basename(args.matrix_file))[0] print(f"Matrix: {result[Stat.MATRIX_FILE.name]}", file=sys.stderr) +elif args.matrix_type == MatrixType.SYNTHETIC: + result[Stat.MATRIX_DENSITY_GROUP.name] = args.synthetic_density result[Stat.MATRIX_FORMAT.name] = args.format.value print(f"Matrix: {result[Stat.MATRIX_FORMAT.name]}", file=sys.stderr) @@ -92,6 +94,9 @@ print(f"Matrix: {result[Stat.MATRIX_FORMAT.name]}", file=sys.stderr) result[Stat.MATRIX_SHAPE.name] = matrix.shape print(f"Shape: {result[Stat.MATRIX_SHAPE.name]}", file=sys.stderr) +result[Stat.MATRIX_ROWS.name] = matrix.shape[0] +print(f"Rows: {result[Stat.MATRIX_ROWS.name]}", file=sys.stderr) + result[Stat.MATRIX_SIZE.name] = matrix.shape[0] * matrix.shape[1] print(f"Size: {result[Stat.MATRIX_SIZE.name]}", file=sys.stderr)