Comments (8)
Please format your code and do copy/paste the outputs instead of posting pictures.
ierr
should pretty much always be MPI_SUCCESS
, but newcomm
might be MPI_COMM_NULL
.
MPI_Comm_size(MPI_COMM_NULL, ...)
is illegal w.r.t. the MPI standard.
from ompi.
@Bellahra Thanks for reporting the issue. Could you please edit the post using this template?
from ompi.
Please format your code and do copy/paste the outputs instead of posting pictures.
ierr
should pretty much always beMPI_SUCCESS
, butnewcomm
might beMPI_COMM_NULL
.MPI_Comm_size(MPI_COMM_NULL, ...)
is illegal w.r.t. the MPI standard.
Ok, thank you. The question has been complemented and formatted.
from ompi.
There are multiple issues with this code.
- As @ggouaillardet indicated calling
MPI_Comm_create_group
withMPI_GROUP_EMPTY
returnsMPI_COMM_NULL
, and it is illegal to callMPI_Comm_size
onMPI_COMM_NULL
. - On rank 0 (which is the rank that does not call
MPI_Comm_create_group
) thenewcomm
variable is not initialized, and that leads to badness inMPI_Comm_size
. - Based on your question, I don't think this code does what you expect it to do. There is no group create by this code, ever. The reason is simple, you create the comm from
MPI_GROUP_EMPTY
so it will always result inMPI_COMM_NULL
. If I understand what you are trying to do, I don't think usingMPI_Comm_create_group
is the right way to go, but instead you should take a look atMPI_Comm_split
.
from ompi.
There are multiple issues with this code.
- As @ggouaillardet indicated calling
MPI_Comm_create_group
withMPI_GROUP_EMPTY
returnsMPI_COMM_NULL
, and it is illegal to callMPI_Comm_size
onMPI_COMM_NULL
.- On rank 0 (which is the rank that does not call
MPI_Comm_create_group
) thenewcomm
variable is not initialized, and that leads to badness inMPI_Comm_size
.- Based on your question, I don't think this code does what you expect it to do. There is no group create by this code, ever. The reason is simple, you create the comm from
MPI_GROUP_EMPTY
so it will always result inMPI_COMM_NULL
. If I understand what you are trying to do, I don't think usingMPI_Comm_create_group
is the right way to go, but instead you should take a look atMPI_Comm_split
.
Thank you for your reply. I have tried your solution, and below is my code
program test7
use mpi
implicit none
integer :: rank, n_ranks, ierr, n1_ranks, rank1
integer :: group, newcomm
call MPI_Init(ierr)
call MPI_Comm_size(MPI_COMM_WORLD, n_ranks, ierr)
call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
if (rank > 1) then
print*,'1'
call MPI_Comm_create(MPI_COMM_WORLD, MPI_GROUP_EMPTY, newcomm, ierr)
else
newcomm = MPI_COMM_NULL
end if
if (newcomm /= MPI_COMM_NULL) then
print*,'begin'
CALL MPI_Comm_group(newcomm, group, ierr)
call MPI_Group_rank(group, rank1, ierr)
call MPI_Group_size(group, n1_ranks, ierr)
print*, "Rank ", rank, " belongs to the new group with size ", n1_ranks
endif
call MPI_Finalize(ierr)
end program test7
where I replaced the MPI_Comm_Split with its equivalent one, MPI_Comm_Create. I run the code with 5 CPU cores, but it takes tens of minutes to run, and up to now only one '1' has been printed. So I am not sure whether it can function correctly. Why does creating a new group consume so much time?
from ompi.
I'm afraid you missed quite a bit of the underlying nature of the communicator creation. At the highest level the communicator creation functions are collective, aka. all processes involved must call them. Now, depending on the MPI functions you use, the definition of involved differs, but overall it falls into one of the following two categories:
- All participants in the original communicator: This applies to
MPI_Comm_create
and toMPI_Comm_split
; - All participants in the group involved: This applies to :
MPI_Comm_create_group
.
For each of the communicator creation function this is well defined in the standard.
Now, let's go back to your new example, the one using MPI_Comm_create
. This function is collective across all ranks in the original communicator, in your case MPI_COMM_WORLD
. As you only make ranks > 1 go into this function, it is not collective and thus will eventually block.
Here is a working example:
program test7
use mpi
implicit none
integer :: rank, n_ranks, ierr, n1_ranks, rank1
integer :: group, newcomm, color
call MPI_Init(ierr)
call MPI_Comm_size(MPI_COMM_WORLD, n_ranks, ierr)
call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
color = 1 ! for now all ranks participate
if (rank == 0) then ! let's exclude 1 from the resulting communicator
color = MPI_UNDEFINED
endif
call MPI_Comm_split(MPI_COMM_WORLD, color, rank, newcomm, ierr)
if (newcomm /= MPI_COMM_NULL) then
print*,'begin'
CALL MPI_Comm_group(newcomm, group, ierr)
call MPI_Group_rank(group, rank1, ierr)
call MPI_Group_size(group, n1_ranks, ierr)
print*, "Rank ", rank, "in MPI_COMM_WORLD belongs to the new group with size ", n1_ranks, " as rank ", rank1
else
print*, "Rank ", rank, "in MPI_COMM_WORLD does not belongs to the new group"
endif
call MPI_Finalize(ierr)
end program test7
from ompi.
@bosilca Thank you most sincerely. Your explanation is very clear and helped me with exactly what I have misunderstood.
from ompi.
@Bellahra Please let us know if you have followup questions. Or this issue will be closed automatically.
from ompi.
Related Issues (20)
- mpirun 5.0.2 hangs - ssh works HOT 11
- --with-cuda failes to find libcuda.so HOT 4
- Scaling issue run openmp on a cluster HOT 4
- openmpi osc_ucx_component error HOT 4
- Error using openmpi mpirun in Fedora 40 HOT 5
- Errors when running mpi programs HOT 5
- Trying to run MPI 3.0.6 on docker HOT 6
- Error `Could not find viable pmix build` while building in Docker HOT 2
- COLL/UCC doesn't compile against head of UCC at master HOT 2
- Support zero-copy non-contiguous send HOT 4
- OpenMPI/5.0.3 with PMIx/4.2.7 compilation error HOT 2
- Configure --with-tm=/opt/pbs/ with PBS Professional fails with openmpi-5.0.3, succeeds with openmpi-4.1.4 HOT 9
- Failed to build RPM from SRPM because of large UID and old tar command HOT 3
- dead coll tuned alltoall mca parameters HOT 6
- Discrepancy between 'oshcc' compiler wrapper and corresponding pkg-config files "oshmem-c.pc" and "oshmem.pc"
- Base Allreduce Algorithm Selection/Performance Issue HOT 3
- Issues running OpenMPI 5.0.3 HOT 1
- configure: error: Could not run a simple Fortran program. Aborting. HOT 1
- Use OMPI without LSF integration on LSF HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ompi.