mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 14:06:10 +00:00
[libc] Change the starting port index to use the SMID (#79200)
Summary: The RPC interface uses several ports to provide parallel access. Right now we begin the search at the beginning, which heavily contests the early ports. Using the SMID allows us to stagger the starting index based off of the cluster identifier that is executing the current warp. Multiple warps can share an SM, but it will guaruntee that the contention for the low indices is lower. This also increases the maximum port size to around 4096, this is because 512 isn't enough to cover the full hardare parallelism needed to guarantee this doesdn't deadlock.
This commit is contained in:
parent
f2a78e68ee
commit
5470ea4e36
@ -179,6 +179,14 @@ LIBC_INLINE uint64_t fixed_frequency_clock() {
|
||||
/// Terminates execution of the associated wavefront.
|
||||
[[noreturn]] LIBC_INLINE void end_program() { __builtin_amdgcn_endpgm(); }
|
||||
|
||||
/// Returns a unique identifier for the process cluster the current wavefront is
|
||||
/// executing on. Here we use the identifier for the compute unit (CU) and
|
||||
/// shader engine.
|
||||
/// FIXME: Currently unimplemented on AMDGPU until we have a simpler interface
|
||||
/// than the one at
|
||||
/// https://github.com/ROCm/clr/blob/develop/hipamd/include/hip/amd_detail/amd_device_functions.h#L899
|
||||
LIBC_INLINE uint32_t get_cluster_id() { return 0; }
|
||||
|
||||
} // namespace gpu
|
||||
} // namespace LIBC_NAMESPACE
|
||||
|
||||
|
@ -75,6 +75,8 @@ LIBC_INLINE uint64_t fixed_frequency_clock() { return 0; }
|
||||
|
||||
[[noreturn]] LIBC_INLINE void end_program() { __builtin_unreachable(); }
|
||||
|
||||
LIBC_INLINE uint32_t get_cluster_id() { return 0; }
|
||||
|
||||
} // namespace gpu
|
||||
} // namespace LIBC_NAMESPACE
|
||||
|
||||
|
@ -150,6 +150,10 @@ LIBC_INLINE uint64_t fixed_frequency_clock() {
|
||||
/// Terminates execution of the calling thread.
|
||||
[[noreturn]] LIBC_INLINE void end_program() { __nvvm_exit(); }
|
||||
|
||||
/// Returns a unique identifier for the process cluster the current warp is
|
||||
/// executing on. Here we use the identifier for the symmetric multiprocessor.
|
||||
LIBC_INLINE uint32_t get_cluster_id() { return __nvvm_read_ptx_sreg_smid(); }
|
||||
|
||||
} // namespace gpu
|
||||
} // namespace LIBC_NAMESPACE
|
||||
|
||||
|
@ -57,7 +57,7 @@ template <uint32_t lane_size = gpu::LANE_SIZE> struct alignas(64) Packet {
|
||||
};
|
||||
|
||||
/// The maximum number of parallel ports that the RPC interface can support.
|
||||
constexpr uint64_t MAX_PORT_COUNT = 512;
|
||||
constexpr uint64_t MAX_PORT_COUNT = 4096;
|
||||
|
||||
/// A common process used to synchronize communication between a client and a
|
||||
/// server. The process contains a read-only inbox and a write-only outbox used
|
||||
@ -519,7 +519,7 @@ LIBC_INLINE void Port<T, S>::recv_n(void **dst, uint64_t *size, A &&alloc) {
|
||||
template <uint16_t opcode> LIBC_INLINE Client::Port Client::open() {
|
||||
// Repeatedly perform a naive linear scan for a port that can be opened to
|
||||
// send data.
|
||||
for (uint32_t index = 0;; ++index) {
|
||||
for (uint32_t index = gpu::get_cluster_id();; ++index) {
|
||||
// Start from the beginning if we run out of ports to check.
|
||||
if (index >= process.port_count)
|
||||
index = 0;
|
||||
|
@ -18,7 +18,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/// The maximum number of ports that can be opened for any server.
|
||||
const uint64_t RPC_MAXIMUM_PORT_COUNT = 512;
|
||||
const uint64_t RPC_MAXIMUM_PORT_COUNT = 4096;
|
||||
|
||||
/// The symbol name associated with the client for use with the LLVM C library
|
||||
/// implementation.
|
||||
|
Loading…
x
Reference in New Issue
Block a user