[llvm] [OFFLOAD] Add support for indexed per-thread containers (PR #164263)
Kevin Sala Penades via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 16 20:57:09 PST 2025
================
@@ -91,24 +177,114 @@ template <typename ContainerType, typename ObjectType> struct PerThreadTable {
// Iterators to traverse objects owned by
// the current thread
iterator begin() {
- auto &Entry = getThreadEntry();
+ ContainerType &Entry = getThreadEntry();
return Entry.begin();
}
iterator end() {
- auto &Entry = getThreadEntry();
+ ContainerType &Entry = getThreadEntry();
return Entry.end();
}
- template <class F> void clear(F f) {
- std::lock_guard<std::mutex> Lock(Mtx);
- for (auto ThData : ThreadDataList) {
- if (!ThData->ThEntry || ThData->NElements == 0)
+ template <class ClearFuncTy> void clear(ClearFuncTy ClearFunc) {
+ assert(Mutex.try_lock() && (Mutex.unlock(), true) &&
+ "Clear cannot be called while other threads are adding entries");
+ for (std::shared_ptr<PerThreadData> ThreadData : ThreadDataList) {
+ if (!ThreadData->ThreadEntry || ThreadData->NElements == 0)
continue;
- ThData->ThEntry->clear(f);
- ThData->NElements = 0;
+ if constexpr (has_clearAll<ContainerType>::value) {
+ ThreadData->ThreadEntry->clearAll(ClearFunc);
----------------
kevinsala wrote:
What's `clearAll`? I guess that's not part of any STL container, and I don't see any container in the L0Plugin defining that method.
https://github.com/llvm/llvm-project/pull/164263
More information about the llvm-commits
mailing list