Files
TheRock/compiler/amd-llvm/llvm/examples/Kaleidoscope/MCJIT/complete/split-lib.py
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

110 lines
4.0 KiB
Python

#!/usr/bin/env python
from __future__ import print_function
class TimingScriptGenerator:
"""Used to generate a bash script which will invoke the toy and time it"""
def __init__(self, scriptname, outputname):
self.shfile = open(scriptname, "w")
self.timeFile = outputname
self.shfile.write('echo "" > %s\n' % self.timeFile)
def writeTimingCall(self, irname, callname):
"""Echo some comments and invoke both versions of toy"""
rootname = irname
if "." in irname:
rootname = irname[: irname.rfind(".")]
self.shfile.write(
'echo "%s: Calls %s" >> %s\n' % (callname, irname, self.timeFile)
)
self.shfile.write('echo "" >> %s\n' % self.timeFile)
self.shfile.write('echo "With MCJIT" >> %s\n' % self.timeFile)
self.shfile.write(
'/usr/bin/time -f "Command %C\\n\\tuser time: %U s\\n\\tsytem time: %S s\\n\\tmax set: %M kb"'
)
self.shfile.write(" -o %s -a " % self.timeFile)
self.shfile.write(
"./toy -suppress-prompts -use-mcjit=true -enable-lazy-compilation=true -use-object-cache -input-IR=%s < %s > %s-mcjit.out 2> %s-mcjit.err\n"
% (irname, callname, rootname, rootname)
)
self.shfile.write('echo "" >> %s\n' % self.timeFile)
self.shfile.write('echo "With MCJIT again" >> %s\n' % self.timeFile)
self.shfile.write(
'/usr/bin/time -f "Command %C\\n\\tuser time: %U s\\n\\tsytem time: %S s\\n\\tmax set: %M kb"'
)
self.shfile.write(" -o %s -a " % self.timeFile)
self.shfile.write(
"./toy -suppress-prompts -use-mcjit=true -enable-lazy-compilation=true -use-object-cache -input-IR=%s < %s > %s-mcjit.out 2> %s-mcjit.err\n"
% (irname, callname, rootname, rootname)
)
self.shfile.write('echo "" >> %s\n' % self.timeFile)
self.shfile.write('echo "With JIT" >> %s\n' % self.timeFile)
self.shfile.write(
'/usr/bin/time -f "Command %C\\n\\tuser time: %U s\\n\\tsytem time: %S s\\n\\tmax set: %M kb"'
)
self.shfile.write(" -o %s -a " % self.timeFile)
self.shfile.write(
"./toy -suppress-prompts -use-mcjit=false -input-IR=%s < %s > %s-mcjit.out 2> %s-mcjit.err\n"
% (irname, callname, rootname, rootname)
)
self.shfile.write('echo "" >> %s\n' % self.timeFile)
self.shfile.write('echo "" >> %s\n' % self.timeFile)
class LibScriptGenerator:
"""Used to generate a bash script which will invoke the toy and time it"""
def __init__(self, filename):
self.shfile = open(filename, "w")
def writeLibGenCall(self, libname, irname):
self.shfile.write(
"./toy -suppress-prompts -use-mcjit=false -dump-modules < %s 2> %s\n"
% (libname, irname)
)
def splitScript(inputname, libGenScript, timingScript):
rootname = inputname[:-2]
libname = rootname + "-lib.k"
irname = rootname + "-lib.ir"
callname = rootname + "-call.k"
infile = open(inputname, "r")
libfile = open(libname, "w")
callfile = open(callname, "w")
print("Splitting %s into %s and %s" % (inputname, callname, libname))
for line in infile:
if not line.startswith("#"):
if line.startswith("print"):
callfile.write(line)
else:
libfile.write(line)
libGenScript.writeLibGenCall(libname, irname)
timingScript.writeTimingCall(irname, callname)
# Execution begins here
libGenScript = LibScriptGenerator("make-libs.sh")
timingScript = TimingScriptGenerator("time-lib.sh", "lib-timing.txt")
script_list = [
"test-5000-3-50-50.k",
"test-5000-10-100-10.k",
"test-5000-10-5-10.k",
"test-5000-10-1-0.k",
"test-1000-3-10-50.k",
"test-1000-10-100-10.k",
"test-1000-10-5-10.k",
"test-1000-10-1-0.k",
"test-200-3-2-50.k",
"test-200-10-40-10.k",
"test-200-10-2-10.k",
"test-200-10-1-0.k",
]
for script in script_list:
splitScript(script, libGenScript, timingScript)
print("All done!")