[Mlir-commits] [mlir] [mlir] Use non thread-local allocator for DistinctAttr when threading is disabled (PR #128566)
Tobias Gysi
llvmlistbot at llvm.org
Tue Mar 4 23:02:39 PST 2025
================
@@ -411,12 +414,51 @@ class DistinctAttributeAllocator {
/// Allocates a distinct attribute storage using a thread local bump pointer
/// allocator to enable synchronization free parallel allocations.
DistinctAttrStorage *allocate(Attribute referencedAttr) {
- return new (allocatorCache.get().Allocate<DistinctAttrStorage>())
- DistinctAttrStorage(referencedAttr);
+ if (!useThreadLocalAllocator && threadingIsEnabled) {
+ std::scoped_lock<std::mutex> lock(allocatorMutex);
+ return allocateImpl(referencedAttr);
+ }
+ return allocateImpl(referencedAttr);
+ }
+
+ /// Sets flags to use thread local bump pointer allocators or a single
+ /// non-thread safe bump pointer allocator depending on if multi-threading is
+ /// enabled. Use this to disable the use of thread local storage and bypass
+ /// thread safety synchronization overhead.
----------------
gysit wrote:
nit: comment update.
https://github.com/llvm/llvm-project/pull/128566
More information about the Mlir-commits
mailing list