Skip to content

Commit

Permalink
Added insertions of LLVM-IR and AMDGCN codes vie env. vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ravil-mobile committed Jul 9, 2024
1 parent 13b20fe commit 4916575
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions third_party/amd/backend/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ def make_llir(src, metadata, options):
metadata["shared"] = src.get_int_attr("triton_gpu.shared")

amd.cleanup_bitcode_metadata(llvm_mod)
if "AMD_INSERT_LLVM_IR" in os.environ.keys():
insert_module_path = str(os.environ["AMD_INSERT_LLVM_IR"])
if not os.path.exists(insert_module_path):
raise RuntimeError(f'cannot find llvm ir file to insert. Given: `{insert_module_path}`')
with open(insert_module_path, "r") as file:
file_content = file.readlines()
file_content = ''.join(file_content)
return file_content

return str(llvm_mod)

@staticmethod
Expand All @@ -231,6 +240,14 @@ def make_amdgcn(src, metadata, options):
metadata["name"] = names[0]
# llvm -> hsaco
amdgcn = llvm.translate_to_asm(src, amd.TARGET_TRIPLE, options.arch, '', [], options.enable_fp_fusion, False)
if "AMD_INSERT_AMDGCN" in os.environ.keys():
insert_module_path = str(os.environ["AMD_INSERT_AMDGCN"])
if not os.path.exists(insert_module_path):
raise RuntimeError(f'cannot find amdgcn file to insert. Given: `{insert_module_path}`')
with open(insert_module_path, "r") as file:
file_content = file.readlines()
amdgcn = ''.join(file_content)

if os.environ.get("AMDGCN_ENABLE_DUMP", "0") == "1":
print("// -----// AMDGCN Dump //----- //")
print(amdgcn)
Expand Down

0 comments on commit 4916575

Please sign in to comment.