[mlir][GPU] Initialize LLVM exactly once during GPU compiles
authorKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Tue, 11 Jul 2023 20:28:29 +0000 (20:28 +0000)
committerKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Fri, 14 Jul 2023 19:10:52 +0000 (19:10 +0000)
commitdb647f5bd8fd337260bf636897f45ecfac8eb4cb
treeb439c38d46d2093a08d608965a059d582160759a
parent4df01dc27079b70d2fdec8d795e525b7955c60f7
[mlir][GPU] Initialize LLVM exactly once during GPU compiles

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.

Reviewed By: fmorac

Differential Revision: https://reviews.llvm.org/D155226
mlir/lib/Dialect/GPU/Transforms/SerializeToCubin.cpp
mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp