This is an archive of the discontinued LLVM Phabricator instance.

[mlir][GPU] Initialize LLVM exactly once during GPU compiles
ClosedPublic

Authored by krzysz00 on Jul 13 2023, 11:38 AM.

Details

Summary

No matter how one constructs their SerializeTo* pass, we want to
ensure that the LLVM initialization code runs once and only once. This
commit adds a static once_flag to ensure that.

I've run into mysterious segfaults when calling MLIR GPU compiles from
multiple threads, and this commit is a potential fix for the issue.

Diff Detail

Event Timeline

krzysz00 created this revision.Jul 13 2023, 11:38 AM
krzysz00 requested review of this revision.Jul 13 2023, 11:38 AM
tschuett added inline comments.
mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp
83

AMD or NVIDIA?

fmorac added inline comments.Jul 13 2023, 2:30 PM
mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp
79
mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
127

same here.

krzysz00 updated this revision to Diff 540425.Jul 14 2023, 8:06 AM

Fix typos, migration issues

fmorac accepted this revision.Jul 14 2023, 8:25 AM

Looks good to me.

This revision is now accepted and ready to land.Jul 14 2023, 8:25 AM
fmorac requested changes to this revision.Jul 14 2023, 8:26 AM

Please fix the git-clang-format fail on the build.

This revision now requires changes to proceed.Jul 14 2023, 8:26 AM
krzysz00 updated this revision to Diff 540453.Jul 14 2023, 9:17 AM

Fixed clang-format issue caused by using old clang-format version

fmorac accepted this revision.Jul 14 2023, 10:12 AM
This revision is now accepted and ready to land.Jul 14 2023, 10:12 AM