Skip to content

Commit

Permalink
Simplify args, trim instruction counts
Browse files Browse the repository at this point in the history
  • Loading branch information
eagarvey-amd committed Oct 7, 2024
1 parent 37850b7 commit a8fb217
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions common_tools/instruction_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def count_instr_in_file(file_path):
if "Kernarg preload header" in line:
counting = True
# End when "---" is read
elif "---" in line and counting:
elif "s_endpgm" in line and counting:
break
if counting:
instr_count += 1
Expand Down Expand Up @@ -40,14 +40,14 @@ def write_results_to_csv(results, output_file):

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Data collection tool targeting HSA dumps.")
parser.add_argument("--search_dir", help="The directory from which to scan for ISA file dumps (.rocmasm).", type=str, default=None)
parser.add_argument("dir", help="The directory from which to scan for ISA file dumps (.rocmasm).", type=str, default=None)
args = parser.parse_args()
output_file = 'rocmasm_instr_counts.csv'

results = search_directory(args.search_dir)
results = search_directory(args.dir)

if results:
write_results_to_csv(results, output_file)
print(f"Results written to {output_file}")
print(f"\nResults written to {output_file}")
else:
print("No .rocmasm files found.")
print("\nNo .rocmasm files found.")
12 changes: 6 additions & 6 deletions gemmbench/gemm_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
from problems import get_gemm_configs, get_tk_gemm_configs, get_matching_configs


def compile_gemm(tag, config, kernel_dir, vmfb_dir, target, extra_compiler_args, tk, exec_dump_dir=None):
if exec_dump_dir:
def compile_gemm(tag, config, kernel_dir, vmfb_dir, target, extra_compiler_args, tk, dump_dir=None):
if dump_dir:
name = config.get_name()
dpath = os.path.join(exec_dump_dir, name)
dpath = os.path.join(dump_dir, name)
extra_compiler_args.extend([
f"--iree-hal-dump-executable-files-to={dpath}"
])
Expand Down Expand Up @@ -70,7 +70,7 @@ def compile_gemm(tag, config, kernel_dir, vmfb_dir, target, extra_compiler_args,
help="Run gemm kernels using Turbine Kernels",
)
parser.add_argument(
"--exec_dump_dir",
"--dump_dir",
type=str,
default=None,
help="Directory to which executable files will be dumped."
Expand Down Expand Up @@ -106,10 +106,10 @@ def compile_gemm(tag, config, kernel_dir, vmfb_dir, target, extra_compiler_args,
vmfb_dir.mkdir(parents=True, exist_ok=True)
target = args.target
extra_compiler_args = list(args.Xiree_compile)
exec_dump_dir = args.exec_dump_dir
dump_dir = args.dump_dir

args = itertools.starmap(
lambda tag, config: (tag, config, kernel_dir, vmfb_dir, target, extra_compiler_args, tk, exec_dump_dir), configs
lambda tag, config: (tag, config, kernel_dir, vmfb_dir, target, extra_compiler_args, tk, dump_dir), configs
)
with Pool(num_cpus) as pool:
compilation_results = list(tqdm(pool.starmap(compile_gemm, list(args))))
Expand Down

0 comments on commit a8fb217

Please sign in to comment.