Update(DeviceProxy): Dynamically Determine Memory Allocation Size & Remove Compile-Time size Calculations (#48)

* Update(DeviceProxy): Dynamically Determine Memory Allocation Size & Remove Compile-Time size Calculations

- Modified the Device proxy class to determine memory allocation size at runtime.
- Updated all classes that include the Device proxy to use dynamic memory allocation.
- Removed compile-time memory size calculations.
- Ensured the allocated number of backend queue data structures matches the number of RO device contexts.

[ROCm/rocshmem commit: eb5a38e806]
This commit is contained in:
Avinash Kethineedi
2025-02-24 15:11:46 -06:00
committed by GitHub
parent 95c4c0d428
commit 1831a1b33c
23 changed files with 302 additions and 118 deletions
@@ -45,7 +45,7 @@ namespace rocshmem {
extern rocshmem_ctx_t ROCSHMEM_HOST_CTX_DEFAULT;
ROBackend::ROBackend(MPI_Comm comm)
: profiler_proxy_(MAX_NUM_BLOCKS), Backend() {
: Backend() {
type = BackendType::RO_BACKEND;
if (auto maximum_num_contexts_str = getenv("ROCSHMEM_MAX_NUM_CONTEXTS")) {
@@ -54,6 +54,18 @@ ROBackend::ROBackend(MPI_Comm comm)
}
poll_block_count_ = maximum_num_contexts_;
profiler_proxy_ = ProfilerProxyT(maximum_num_contexts_);
int device_id;
hipDeviceProp_t device_props;
CHECK_HIP(hipGetDevice(&device_id));
CHECK_HIP(hipGetDeviceProperties(&device_props, device_id));
max_wg_size_ = device_props.maxThreadsPerBlock;
queue_ = Queue(maximum_num_contexts_, max_wg_size_, queue_size_);
transport_ = new MPITransport(comm, &queue_);
num_pes = transport_->getNumPes();
my_pe = transport_->getMyPe();
@@ -68,16 +80,18 @@ ROBackend::ROBackend(MPI_Comm comm)
bp->heap_ptr = &heap;
ro_window_proxy_ = new WindowProxyT(&heap, transport_->get_world_comm());
ro_window_proxy_ = new WindowProxyT(&heap, transport_->get_world_comm(),
num_windows_);
bp->heap_window_info = ro_window_proxy_->get();
initIPC();
init_g_ret(&heap, transport_->get_world_comm(), MAX_NUM_BLOCKS, &bp->g_ret);
init_g_ret(&heap, transport_->get_world_comm(), maximum_num_contexts_, &bp->g_ret);
allocate_atomic_region(&bp->atomic_ret, MAX_NUM_BLOCKS);
allocate_atomic_region(&bp->atomic_ret, maximum_num_contexts_);
transport_->initTransport(MAX_NUM_BLOCKS, &backend_proxy);
transport_->initTransport(maximum_num_contexts_, &backend_proxy);
host_interface = transport_->host_interface;
@@ -99,7 +113,8 @@ ROBackend::ROBackend(MPI_Comm comm)
default_context_proxy_ = DefaultContextProxyT(this, tinfo);
block_handle_proxy_ = BlockHandleProxyT(bp->g_ret, bp->atomic_ret, &queue_,
&ipcImpl, hdp_proxy_.get());
&ipcImpl, hdp_proxy_.get(),
maximum_num_contexts_);
setup_ctxs();
worker_thread = std::thread(&ROBackend::ro_net_poll, this);