[all-commits] [llvm/llvm-project] b23227: [libc] Reduce reference counter to a 32-bit intege...
Joseph Huber via All-commits
all-commits at lists.llvm.org
Mon Jul 28 09:05:58 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b2322772f2ab97de60db906a591353a5ef77cdfe
https://github.com/llvm/llvm-project/commit/b2322772f2ab97de60db906a591353a5ef77cdfe
Author: Joseph Huber <huberjn at outlook.com>
Date: 2025-07-28 (Mon, 28 Jul 2025)
Changed paths:
M libc/src/__support/GPU/allocator.cpp
Log Message:
-----------
[libc] Reduce reference counter to a 32-bit integer (#150961)
Summary:
This reference counter tracks how many threads are using a given slab.
Currently it's a 64-bit integer, this patch reduces it to a 32-bit
integer. The benefit of this is that we save a few registers now that we
no longer need to use two for these operations. This increases the risk
of overflow, but given that the largest value we accept for a single
slab is ~131,000 it is a long way off of the maximum of four billion or
so. Obviously we can oversubscribe the reference count by having threads
attempt to claim the lock and then try to free it, but I assert that it
is exceedingly unlikely that we will somehow have over four billion GPU
threads stalled in the same place.
A later optimization could be done to split the reference counter and
pointers into a struct of arrays, that will save 128 KiB of static
memory (as we currently use 512 KiB for the slab array).
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list