Skip to content

Commit

Permalink
regen
Browse files Browse the repository at this point in the history
  • Loading branch information
nimlgen committed Jan 26, 2024
1 parent eb2d26d commit 10bfe29
Show file tree
Hide file tree
Showing 2 changed files with 1,486 additions and 789 deletions.
25 changes: 0 additions & 25 deletions generate_hsa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,4 @@ clang2py \
--clang-args="-I/opt/rocm/include" \
-o gpuctypes/hsa.py -l /opt/rocm/lib/libhsa-runtime64.so

python3 -c $'import re
with open("gpuctypes/hsa.py", "r") as file:
txt = file.read()
def fix_anons(match):
filename = match.group(1)
line_number = match.group(2)
return f"_{filename}_h_{line_number}"
# Need to patch all unnamed and anon structs
pattern = r"\s+\\(unnamed at\s+.*/(.*?).h:(\\d+):\\d+\\)"
txt = re.sub(pattern, fix_anons, txt)
pattern = r"\s+\\(anonymous at\s+.*/(.*?).h:(\\d+):\\d+\\)"
txt = re.sub(pattern, fix_anons, txt)
# Put our lib insted of stubs
txt = txt.replace("_libraries[\'FIXME_STUB\'] = FunctionFactoryStub()", "_libraries[\'libhsa\'] = ctypes.CDLL(\'/opt/rocm/lib/libhsa-runtime64.so\')")
txt = txt.replace("_libraries[\'FIXME_STUB\'].", "_libraries[\'libhsa\'].")
with open("gpuctypes/hsa.py", "w") as file:
file.write(txt)
'

grep FIXME_STUB gpuctypes/hsa.py || true
Loading

0 comments on commit 10bfe29

Please sign in to comment.