Update backend to use provided MPI communicator during library initialization (#79)
* Update backend to use provided MPI communicator during library initialization, default to `MPI_COMM_WORLD`
* Update `rocshmem_my_pe` and `rocshmem_n_pes` host APIs
- Return values from backend if initialized; otherwise, fallback to MPI_Singleton.
[ROCm/rocshmem commit: 05755847f5]
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a3a211a677
Коммит
be35f3ef93
@@ -50,7 +50,9 @@ class CommunicatorMPI {
|
||||
/**
|
||||
* @brief Primary constructor
|
||||
*/
|
||||
CommunicatorMPI(char* heap_base, size_t heap_size) {
|
||||
CommunicatorMPI(char* heap_base, size_t heap_size,
|
||||
MPI_Comm comm = MPI_COMM_WORLD)
|
||||
: comm_{comm} {
|
||||
int initialized;
|
||||
MPI_Initialized(&initialized);
|
||||
if (!initialized) {
|
||||
@@ -87,8 +89,8 @@ class CommunicatorMPI {
|
||||
* @brief Performs MPI_Allgather on recvbuf
|
||||
*/
|
||||
void allgather(void* recvbuf) {
|
||||
MPI_Allgather(MPI_IN_PLACE, sizeof(void*), MPI_CHAR, recvbuf, sizeof(void*),
|
||||
MPI_CHAR, comm_);
|
||||
MPI_Allgather(MPI_IN_PLACE, sizeof(void*), MPI_CHAR, recvbuf,
|
||||
sizeof(void*), MPI_CHAR, comm_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +102,7 @@ class CommunicatorMPI {
|
||||
/**
|
||||
* @brief Identifier for this processing element
|
||||
*/
|
||||
MPI_Comm comm_{MPI_COMM_WORLD};
|
||||
MPI_Comm comm_{};
|
||||
|
||||
/**
|
||||
* @brief Identifier for this processing element
|
||||
@@ -139,8 +141,9 @@ class RemoteHeapInfo {
|
||||
* @param[in] The identifier for this processing element
|
||||
* @param[in] The total number of processing elements
|
||||
*/
|
||||
RemoteHeapInfo(char* heap_ptr, size_t heap_size)
|
||||
: communicator_{heap_ptr, heap_size} {
|
||||
RemoteHeapInfo(char* heap_ptr, size_t heap_size,
|
||||
MPI_Comm comm = MPI_COMM_WORLD)
|
||||
: communicator_{heap_ptr, heap_size, comm} {
|
||||
heap_bases_.resize(communicator_.num_pes());
|
||||
for (auto& base : heap_bases_) {
|
||||
base = nullptr;
|
||||
|
||||
@@ -54,6 +54,10 @@ class SymmetricHeap {
|
||||
using RemoteHeapInfoType = RemoteHeapInfo<CommunicatorMPI>;
|
||||
|
||||
public:
|
||||
SymmetricHeap(MPI_Comm comm = MPI_COMM_WORLD)
|
||||
: remote_heap_info_{single_heap_.get_base_ptr(),
|
||||
single_heap_.get_size(),
|
||||
comm} {}
|
||||
/**
|
||||
* @brief Allocates heap memory and returns ptr to caller
|
||||
*
|
||||
@@ -120,8 +124,7 @@ class SymmetricHeap {
|
||||
/**
|
||||
* @brief Implementation of remote heaps
|
||||
*/
|
||||
RemoteHeapInfoType remote_heap_info_{single_heap_.get_base_ptr(),
|
||||
single_heap_.get_size()};
|
||||
RemoteHeapInfoType remote_heap_info_{};
|
||||
};
|
||||
|
||||
} // namespace rocshmem
|
||||
|
||||
@@ -165,7 +165,7 @@ class WindowInfo {
|
||||
/**
|
||||
* @brief MPI Communicator
|
||||
*/
|
||||
MPI_Comm comm_{MPI_COMM_WORLD};
|
||||
MPI_Comm comm_{};
|
||||
|
||||
/**
|
||||
* @brief Owning pointer to MPI_Win
|
||||
|
||||
Ссылка в новой задаче
Block a user