Skip to content

[fix] mlir: specify the mtriple in llvm target - #144

Merged
guillon merged 1 commit into
xtc-tools:mainfrom
liamsemeria:dev/sliam/llvm-llc-triple-fix
Sep 17, 2026
Merged

guillon merged 1 commit into
xtc-tools:mainfrom
liamsemeria:dev/sliam/llvm-llc-triple-fix

Conversation

@liamsemeria

@liamsemeria liamsemeria commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Motivation

#137 and #138 Revealed a regression in the mlir performance. The regression was due to the llvm update from 21 to 22 now requiring us to specify --mtriple in llc, in order for the memset() for the linalg.fill to lower optimally. With the old llvm, llc correctly lowered a large llvm.memset to a call to memset(). With the new llvm, the same input lowers to an inlined scalar byte-at-a-time store loop.

Description

The fix is explicitly passing -mtriple to llc for the native case too, queried from the LLVM install itself via llvm-config --host-target.

Using the Example from the Issue #137:

tvm performance: (same for both)

loop-explore  --threads 1 --peak-flops 65.6e9 --operator conv2d --backends tvm --use-tensor --strategy tile_prp --test 1 1 1 64 --save-temps
Schedule: tvm: [1; 1; 1; 64]: time: 1.63 msecs, peak perf: 110.28%

mlir peformance before:

loop-explore  --threads 1 --peak-flops 65.6e9 --operator conv2d --backends mlir --use-tensor --strategy tile_prp --test 1 1 1 64 --save-temps
Schedule: mlir: [1; 1; 1; 64]: time: 2.49 msecs, peak perf: 72.38%

mlir performance after:

loop-explore  --threads 1 --peak-flops 65.6e9 --operator conv2d --backends mlir --use-tensor --strategy tile_prp --test 1 1 1 64 --save-temps
Schedule: mlir: [1; 1; 1; 64]: time: 1.79 msecs, peak perf: 100.72%

For the compile time example in #138
tvm:

loop-explore  --threads 1 --peak-flops 65.6e9 --operator conv2d --backends tvm  --strategy tile7d --test 1 1 1 2 2 1 7 4 4 2 1 16 1 7 3 --save-temps --use-tensor
Schedule: tvm: [1; 1; 1; 2; 2; 1; 7; 4; 4; 2; 1; 16; 1; 7; 3]: time: 1.71 msecs, peak perf: 105.46%

mlir before:

loop-explore  --threads 1 --peak-flops 65.6e9 --operator conv2d --backends mlir  --strategy tile7d --test 1 1 1 2 2 1 7 4 4 2 1 16 1 7 3 --save-temps --use-tensor
Schedule: mlir: [1; 1; 1; 2; 2; 1; 7; 4; 4; 2; 1; 16; 1; 7; 3]: time: 2.46 msecs, peak perf: 73.07%

mlir after:

loop-explore  --threads 1 --peak-flops 65.6e9 --operator conv2d --backends mlir  --strategy tile7d --test 1 1 1 2 2 1 7 4 4 2 1 16 1 7 3 --save-temps --use-tensor
Schedule: mlir: [1; 1; 1; 2; 2; 1; 7; 4; 4; 2; 1; 16; 1; 7; 3]: time: 1.79 msecs, peak perf: 100.33%

@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.58824% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/xtc/backends/mlir/MlirTarget/MlirLLVMTarget.py 70.58% 3 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@guillon guillon added the enhancement New feature or request label Sep 17, 2026
@guillon

guillon commented Sep 17, 2026

Copy link
Copy Markdown
Member

Fixes issue #137

@guillon

guillon commented Sep 17, 2026

Copy link
Copy Markdown
Member

Just to clarify, this does not fix the compile time issue #138 mentionned above.

@guillon
guillon merged commit 003bbc5 into xtc-tools:main Sep 17, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants