Re: [OMPI users] OMPI users] OMPI users] MPI_Type_Create_Struct + MPI_TYPE_CREATE_RESIZED
Diego, yes, it works for me (at least with the v1.8 head and gnu compilers) Cheers, Gilles On 2015/01/08 17:51, Diego Avesani wrote: > Dear Gilles, > thanks again, however it does not work. > > the program says: "SIGSEGV, segmentation fault occurred" > > Does the program run in your case? > > Thanks again > > > > Diego > > > On 8 January 2015 at 03:02, Gilles Gouaillardet < > gilles.gouaillar...@iferc.org> wrote: > >> Diego, >> >> my bad, i should have passed displacements(1) to MPI_Type_create_struct >> >> here is an updated version >> >> (note you have to use a REQUEST integer for MPI_Isend and MPI_Irecv, >> and you also have to call MPI_Wait to ensure the requests complete) >> >> Cheers, >> >> Gilles >> >> >> On 2015/01/08 8:23, Diego Avesani wrote: >> >> Dear Gilles, Dear all, >> >> I'm sorry to bother you again, but I have some problem with send and >> receive the struct_data. >> >> I tried to send a MPI_Type_Create_Struct but I get a segmentation fault >> occurred and I do not know why. The program is very simple, it is the old >> one with the isend and irecv subroutines >> >> (you can find it in the attachment) >> >> Thanks again >> >> >> Diego >> >> >> On 5 January 2015 at 15:54, Diego Avesani>> wrote: >> >> >> Dear Gilles, >> >> Thanks, Thanks a lot. >> Now is more clear. >> >> Again, thanks a lot >> >> Diego >> >> >> >> >> >> ___ >> users mailing listus...@open-mpi.org >> Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users >> Link to this post: >> http://www.open-mpi.org/community/lists/users/2015/01/26116.php >> >> >> >> ___ >> users mailing list >> us...@open-mpi.org >> Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users >> Link to this post: >> http://www.open-mpi.org/community/lists/users/2015/01/26118.php >> > > > ___ > users mailing list > us...@open-mpi.org > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users > Link to this post: > http://www.open-mpi.org/community/lists/users/2015/01/26124.php
Re: [OMPI users] OMPI users] OMPI users] MPI_Type_Create_Struct + MPI_TYPE_CREATE_RESIZED
Dear Gilles, thanks again, however it does not work. the program says: "SIGSEGV, segmentation fault occurred" Does the program run in your case? Thanks again Diego On 8 January 2015 at 03:02, Gilles Gouaillardet < gilles.gouaillar...@iferc.org> wrote: > Diego, > > my bad, i should have passed displacements(1) to MPI_Type_create_struct > > here is an updated version > > (note you have to use a REQUEST integer for MPI_Isend and MPI_Irecv, > and you also have to call MPI_Wait to ensure the requests complete) > > Cheers, > > Gilles > > > On 2015/01/08 8:23, Diego Avesani wrote: > > Dear Gilles, Dear all, > > I'm sorry to bother you again, but I have some problem with send and > receive the struct_data. > > I tried to send a MPI_Type_Create_Struct but I get a segmentation fault > occurred and I do not know why. The program is very simple, it is the old > one with the isend and irecv subroutines > > (you can find it in the attachment) > > Thanks again > > > Diego > > > On 5 January 2015 at 15:54, Diego Avesani> wrote: > > > Dear Gilles, > > Thanks, Thanks a lot. > Now is more clear. > > Again, thanks a lot > > Diego > > > > > > ___ > users mailing listus...@open-mpi.org > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users > Link to this post: > http://www.open-mpi.org/community/lists/users/2015/01/26116.php > > > > ___ > users mailing list > us...@open-mpi.org > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users > Link to this post: > http://www.open-mpi.org/community/lists/users/2015/01/26118.php >
Re: [OMPI users] OMPI users] OMPI users] MPI_Type_Create_Struct + MPI_TYPE_CREATE_RESIZED
Diego, my bad, i should have passed displacements(1) to MPI_Type_create_struct here is an updated version (note you have to use a REQUEST integer for MPI_Isend and MPI_Irecv, and you also have to call MPI_Wait to ensure the requests complete) Cheers, Gilles On 2015/01/08 8:23, Diego Avesani wrote: > Dear Gilles, Dear all, > > I'm sorry to bother you again, but I have some problem with send and > receive the struct_data. > > I tried to send a MPI_Type_Create_Struct but I get a segmentation fault > occurred and I do not know why. The program is very simple, it is the old > one with the isend and irecv subroutines > > (you can find it in the attachment) > > Thanks again > > > Diego > > > On 5 January 2015 at 15:54, Diego Avesaniwrote: > >> Dear Gilles, >> >> Thanks, Thanks a lot. >> Now is more clear. >> >> Again, thanks a lot >> >> Diego >> >> > > > ___ > users mailing list > us...@open-mpi.org > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users > Link to this post: > http://www.open-mpi.org/community/lists/users/2015/01/26116.php MODULE MOD_PRECISION integer, parameter :: dp = selected_real_kind(p=16) ENDMODULE PROGRAM PROVA_STRUCT USE MOD_PRECISION IMPLICIT NONE INCLUDE 'mpif.h' ! TYPE tMPI INTEGER :: myrank, nCPU, iErr, status END TYPE tMPI ! type particle sequence integer :: ip real(dp) :: rp(2) real(dp) :: QQ(4) end type particle ! TYPE(tMPI) :: MPI INTEGER:: COMM_CART INTEGER:: MPI_PARTICLE_TYPE_OLD INTEGER:: MPI_PARTICLE_TYPE INTEGER :: nstruct INTEGER,ALLOCATABLE :: TYPES(:) INTEGER,ALLOCATABLE :: LENGTHS(:) INTEGER :: REQUEST(2) INTEGER(MPI_ADDRESS_KIND),ALLOCATABLE,DIMENSION(:) ::DISPLACEMENTS type(particle) :: dummy(2) ! Used for calculation of displacement CALL MPI_INIT(MPI%iErr) CALL MPI_COMM_RANK(MPI_COMM_WORLD, MPI%myrank, MPI%iErr) CALL MPI_COMM_SIZE(MPI_COMM_WORLD, MPI%nCPU, MPI%iErr) ! ! nstruct=3 ALLOCATE(TYPES(nstruct)) ALLOCATE(LENGTHS(nstruct)) ALLOCATE(DISPLACEMENTS(0:nstruct+1)) ! TYPES(1)=MPI_INTEGER TYPES(2)=MPI_DOUBLE_PRECISION TYPES(3)=MPI_DOUBLE_PRECISION ! LENGTHS(1)=1 LENGTHS(2)=2 LENGTHS(3)=4 ! ! CALL MPI_GET_ADDRESS(dummy(1),DISPLACEMENTS(0),MPI%iErr) CALL MPI_GET_ADDRESS(dummy(1)%ip,DISPLACEMENTS(1),MPI%iErr) CALL MPI_GET_ADDRESS(dummy(1)%RP(1),DISPLACEMENTS(2),MPI%iErr) CALL MPI_GET_ADDRESS(dummy(1)%QQ(1),DISPLACEMENTS(3),MPI%iErr) CALL MPI_GET_ADDRESS(dummy(2),DISPLACEMENTS(4),MPI%iErr) ! DISPLACEMENTS(1:nstruct+1)= DISPLACEMENTS(1:nstruct+1)-DISPLACEMENTS(0) ! CALL MPI_TYPE_CREATE_STRUCT(nstruct,lengths,displacements(1),types,MPI_PARTICLE_TYPE_OLD,MPI%iErr) CALL MPI_TYPE_COMMIT(MPI_PARTICLE_TYPE_OLD,MPI%iErr) ! ! CALL MPI_TYPE_CREATE_RESIZED(MPI_PARTICLE_TYPE_OLD, DISPLACEMENTS(1), DISPLACEMENTS(4), MPI_PARTICLE_TYPE, MPI%iErr) CALL MPI_TYPE_COMMIT(MPI_PARTICLE_TYPE,MPI%iErr) ! IF(MPI%myrank==0)THEN WRITE(*,*) DISPLACEMENTS ENDIF ! IF(MPI%myrank==0)THEN CALL MPI_ISEND(DUMMY(1),1,MPI_PARTICLE_TYPE,1,0,MPI_COMM_WORLD,REQUEST,MPI%iErr) ENDIF ! IF(MPI%myrank==1)THEN CALL MPI_IRECV(DUMMY(1),1,MPI_PARTICLE_TYPE,0,0,MPI_COMM_WORLD,REQUEST,MPI%iErr) ENDIF CALL MPI_WAIT(REQUEST, MPI_STATUS_IGNORE) ! CALL MPI_Finalize(MPI%iErr) ! ENDPROGRAM
Re: [OMPI users] OMPI users] OMPI users] MPI_Type_Create_Struct + MPI_TYPE_CREATE_RESIZED
Dear Gilles, Dear all, I'm sorry to bother you again, but I have some problem with send and receive the struct_data. I tried to send a MPI_Type_Create_Struct but I get a segmentation fault occurred and I do not know why. The program is very simple, it is the old one with the isend and irecv subroutines (you can find it in the attachment) Thanks again Diego On 5 January 2015 at 15:54, Diego Avesaniwrote: > Dear Gilles, > > Thanks, Thanks a lot. > Now is more clear. > > Again, thanks a lot > > Diego > > MODULE MOD_PRECISION integer, parameter :: dp = selected_real_kind(p=16) ENDMODULE PROGRAM PROVA_STRUCT USE MOD_PRECISION IMPLICIT NONE INCLUDE 'mpif.h' ! TYPE tMPI INTEGER :: myrank, nCPU, iErr, status END TYPE tMPI ! type particle sequence integer :: ip real(dp) :: rp(2) real(dp) :: QQ(4) end type particle ! TYPE(tMPI) :: MPI INTEGER:: COMM_CART INTEGER:: MPI_PARTICLE_TYPE_OLD INTEGER:: MPI_PARTICLE_TYPE INTEGER :: nstruct INTEGER,ALLOCATABLE :: TYPES(:) INTEGER,ALLOCATABLE :: LENGTHS(:) INTEGER(MPI_ADDRESS_KIND),ALLOCATABLE,DIMENSION(:) ::DISPLACEMENTS type(particle) :: dummy(2) ! Used for calculation of displacement CALL MPI_INIT(MPI%iErr) CALL MPI_COMM_RANK(MPI_COMM_WORLD, MPI%myrank, MPI%iErr) CALL MPI_COMM_SIZE(MPI_COMM_WORLD, MPI%nCPU, MPI%iErr) ! ! nstruct=3 ALLOCATE(TYPES(nstruct)) ALLOCATE(LENGTHS(nstruct)) ALLOCATE(DISPLACEMENTS(0:nstruct+1)) ! TYPES(1)=MPI_INTEGER TYPES(2)=MPI_DOUBLE_PRECISION TYPES(3)=MPI_DOUBLE_PRECISION ! LENGTHS(1)=1 LENGTHS(2)=2 LENGTHS(3)=4 ! ! CALL MPI_GET_ADDRESS(dummy(1),DISPLACEMENTS(0),MPI%iErr) CALL MPI_GET_ADDRESS(dummy(1)%ip,DISPLACEMENTS(1),MPI%iErr) CALL MPI_GET_ADDRESS(dummy(1)%RP(1),DISPLACEMENTS(2),MPI%iErr) CALL MPI_GET_ADDRESS(dummy(1)%QQ(1),DISPLACEMENTS(3),MPI%iErr) CALL MPI_GET_ADDRESS(dummy(2),DISPLACEMENTS(4),MPI%iErr) ! DISPLACEMENTS(1:nstruct+1)= DISPLACEMENTS(1:nstruct+1)-DISPLACEMENTS(0) ! CALL MPI_TYPE_CREATE_STRUCT(nstruct,lengths,displacements,types,MPI_PARTICLE_TYPE_OLD,MPI%iErr) CALL MPI_TYPE_COMMIT(MPI_PARTICLE_TYPE_OLD,MPI%iErr) ! ! CALL MPI_TYPE_CREATE_RESIZED(MPI_PARTICLE_TYPE_OLD, DISPLACEMENTS(1), DISPLACEMENTS(4), MPI_PARTICLE_TYPE, MPI%iErr) CALL MPI_TYPE_COMMIT(MPI_PARTICLE_TYPE,MPI%iErr) ! IF(MPI%myrank==0)THEN WRITE(*,*) DISPLACEMENTS ENDIF ! IF(MPI%myrank==0)THEN CALL MPI_ISEND(DUMMY(1),1,MPI_PARTICLE_TYPE,1,0,MPI_COMM_WORLD,1,MPI%iErr) ENDIF ! IF(MPI%myrank==1)THEN CALL MPI_IRECV(DUMMY(1),1,MPI_PARTICLE_TYPE,0,0,MPI_COMM_WORLD,1,MPI%iErr) ENDIF ! CALL MPI_Finalize(MPI%iErr) ! ENDPROGRAM
Re: [OMPI users] OMPI users] OMPI users] MPI_Type_Create_Struct + MPI_TYPE_CREATE_RESIZED
Dear Gilles, Thanks, Thanks a lot. Now is more clear. Again, thanks a lot Diego
Re: [OMPI users] OMPI users] OMPI users] MPI_Type_Create_Struct + MPI_TYPE_CREATE_RESIZED
Diego, The compiler likely added some padding after %ip to have data aligned on 128 bits. You need two dummies in case the compiler adds some padding at the end of the type. Cheers, Gilles Diego Avesaniさんのメール: >Dear Gilles, Dear all, > >thanks, thanks a lot. > > >Could you explain it to me, please? > > >I mean, when I print displacements I get: > > >displacements(0)= 6922656 > >displacements(1)= 0 > >displacements(2)= 16 > >displacements(3)= 48 > >displacements(4)= 112 > > > >Why do I have 16 spaces in displacements(2), I have only an integer in >dummy%ip? > >Why do you use dummy(1) and dummy(2)? > > >Thanks a lot > > > >Diego > > >On 5 January 2015 at 02:44, Gilles Gouaillardet > wrote: > >Diego, > >MPI_Get_address was invoked with parameters in the wrong order > >here is attached a fixed version > >Cheers, > >Gilles > >On 2015/01/05 2:32, Diego Avesani wrote: > >Dear Gilles, Dear all, It works. The only thing that is missed is: *CALL >MPI_Finalize(MPI%iErr)* at the end of the program. Now, I have to test it >sending some data from a processor to another. I would like to ask you if you >could explain me what you have done. I wrote in the program: * >IF(MPI%myrank==1)THEN* * WRITE(*,*) DISPLACEMENTS* * ENDIF* and the results >is: *139835891001320 -139835852218120 -139835852213832* * -139835852195016 >8030673735967299609* I am not able to understand it. Thanks a lot. In the >attachment you can find the program Diego On 4 January 2015 at 12:10, Gilles >Gouaillardet < gilles.gouaillar...@gmail.com> wrote: > >Diego, here is an updated revision i will double check tomorrow /* i dit not >test it yet, so forgive me it it does not compile/work */ Cheers, Gilles On >Sun, Jan 4, 2015 at 6:48 PM, Diego Avesani wrote: > >Dear Gilles, Dear all, in the attachment you can find the program. What do you >meam "remove mpi_get_address(dummy) from all displacements". Thanks for all >your help Diego Diego On 3 January 2015 at 00:45, Gilles Gouaillardet < >gilles.gouaillar...@gmail.com> wrote: > >Diego, George gave you the solution, The snippet you posted has two mistakes >You did not remove mpi_get_address(dummy) from all displacements (See my >previous reply) You pass incorrect values to mpi_type_create_resized Can you >post a trimmed version of your program instead of a snippet ? Gus is right >about using double precision vs real and -r8 Cheers, Gilles Diego Avesani > さんのメー > >ル: Dear Gilles Dear all, I have done all that to avoid to pedding an integer, >as suggested by George. I define tParticle as a common object. I am using >Intel fortran compiler. George suggests: *"" The displacements are relative to >the benign of your particle type. Thus the first one is not 0 but the >displacement of “integer :: ip” due to the fact that the compiler is allowed >to introduce gaps in order to better align.* * >DISPLACEMENTS(1)=MPI_GET_ADDRESS(dummy%ip)* * >DISPLACEMENTS(2)=**MPI_GET_ADDRESS(dummy%RP[1])* * >DISPLACEMENTS(3)=**MPI_GET_ADDRESS(dummy%QQ[1])* *and then remove the >MPI_GET_ADDRESS(dummy) from all of them.* *3. After creating the structure >type you need to resize it in order to correctly determine the span of the >entire structure, and how an array of such structures lays in memory. >Something like:* *MPI_TYPE_CREATE_RESIZED(old type, DISPLACEMENT(1),* * >MPI_GET_ADDRESS(dummy[2]) - MPI_GET_ADDRESS(dummy[1]), newt) ""* What do you >think? George, Did i miss something? Thanks a lot Diego On 2 January 2015 at >12:51, Gilles Gouaillardet < gilles.gouaillar...@gmail.com> wrote: > >Diego, First, i recommend you redefine tParticle and add a padding integer so >everything is aligned. Before invoking MPI_Type_create_struct, you need to >call MPI_Get_address(dummy, base, MPI%err) displacements = displacements - >base MPI_Type_create_resized might be unnecessary if tParticle is aligned And >the lower bound should be zero. BTW, which compiler are you using ? Is >tParticle object a common ? iirc, intel compiler aligns types automatically, >but not commons, and that means MPI_Type_create_struct is not aligned as it >should most of the time. Cheers, Gilles Diego Avesani > さんのメー > >ル: dear all, I have a problem with MPI_Type_Create_Struct and >MPI_TYPE_CREATE_RESIZED. I have this variable type: * TYPE tParticle* * >INTEGER :: ip* * REAL :: RP(2)* * REAL :: QQ(2)* * ENDTYPE tParticle* Then I >define: Nstruct=3 *ALLOCATE(TYPES(Nstruct))* *ALLOCATE(LENGTHS(Nstruct))* >*ALLOCATE(DISPLACEMENTS(Nstruct))* *!set the types* *TYPES(1) = MPI_INTEGER* >*TYPES(2) = MPI_DOUBLE_PRECISION* *TYPES(3) = MPI_DOUBLE_PRECISION* *!set the >lengths* *LENGTHS(1) = 1* *LENGTHS(2) = 2* *LENGTHS(3) = 2* As gently >suggested by Nick Papior Andersen and George Bosilca some months ago, I >checked the variable adress to resize my struct variable to avoid