Skip to content

Commit 5c604e4

Browse files
committed
feat(tool): improve ark_frequent_instructions.py script for the CI
1 parent 7218429 commit 5c604e4

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,8 @@ jobs:
272272
python-version: '3.13'
273273

274274
- run: |
275-
KO=0
276-
python3 tools/ark_frequent_instructions.py super_insts_usage > output.txt || KO=1
277-
echo "SUPER_INSTS_REPORT_KO=$KO" >> $GITHUB_ENV
278275
echo "SUPER_INSTS_REPORT<<EOF" >> $GITHUB_ENV
279-
cat output.txt >> $GITHUB_ENV
276+
python3 tools/ark_frequent_instructions.py super_insts_usage >> $GITHUB_ENV
280277
echo "EOF" >> $GITHUB_ENV
281278
282279
- uses: 8BitJonny/gh-get-current-pr@4.0.0

tools/ark_frequent_instructions.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,26 +149,30 @@ def print_most_freqs(data, max_percent=10):
149149
most = sorted(data.items(), key=lambda e: e[1], reverse=True)
150150
interesting = most[:(len(most) * max_percent) // 100]
151151
if compute_super_insts_usage:
152+
threshold = 10
153+
over, under = [(x, c) for (x, c) in most if c > threshold], [(x, c) for (x, c) in most if c <= threshold]
154+
155+
if under:
156+
print(f"Some Super Instructions are under the usage threshold ({threshold}).\n")
157+
print("| Super Instruction | Uses in compiled code |")
158+
print("\n".join(f"| {insts} | {count} |" for (insts, count) in under))
159+
160+
print("<details><summary>Super Instructions over the threshold</summary>\n")
152161
print("| Super Instruction | Uses in compiled code |")
153162
print("| ----------------- | --------------------- |")
154-
print("\n".join(f"| {insts} | {count} |" for (insts, count) in interesting))
163+
print("\n".join(f"| {insts} | {count} |" for (insts, count) in over))
164+
print("\n</details>")
155165
else:
156166
print("\n".join(f"{insts} -> {count}" for (insts, count) in interesting))
157167

158-
if compute_super_insts_usage:
159-
threshold = 10
160-
for (inst, count) in most:
161-
if count <= threshold:
162-
sys.exit(1)
163-
164-
165-
if not compute_super_insts_usage:
166-
print("Super instructions present:")
167-
print_most_freqs(super_insts_freqs, max_percent=100)
168168

169169
if compute_super_insts_usage:
170-
sys.exit(0)
170+
print_most_freqs(super_insts_freqs, max_percent=100)
171+
else:
172+
print("Super instructions present:")
173+
print_most_freqs(super_insts_freqs, max_percent=100)
171174

172-
for i in (2, 3, 4):
173-
print(f"\nPairs of {i}:")
174-
print_most_freqs(frequent[i])
175+
print("Potential pairs of instructions that could be optimized:")
176+
for i in (2, 3, 4):
177+
print(f"\nPairs of {i}:")
178+
print_most_freqs(frequent[i])

0 commit comments

Comments
 (0)