MichaelSiehl / Coarray-with-Allocatable-Component-Example

THIS REPOSITORY CONTAINS A FORTRAN (2008) COARRAY EXAMPLE PROGRAM THAT ILLUSTRATES THE USE OF A DERIVED TYPE COARRAY WITH AN ALLOCATABLE COMPONENT
5 stars 0 forks source link

Missing a procedure, a module incomplete... #1

Open szaghi opened 7 years ago

szaghi commented 7 years ago

Dear @MichaelSiehl

I am now studying your examples. Hasty is now ready to accept some coarray stuff (and I have now some time...).

I tried to compile this example, but:

I can complete this module with some guessing, but I am looking for your complete example because your are my master, I am afraid to get the wrong way if I am alone :smile:

Cheers.

szaghi commented 7 years ago

I complete the module with this


subroutine GetBoundsFromCoarrayMember(Coarray_Object, intImageNumber, intLowerBound, intUpperBound)
  type(NonSymmetricCoarray), intent(in)  :: Coarray_Object[*]
  integer,                   intent(in)  :: intImageNumber
  integer,                   intent(out) :: intLowerBound
  integer,                   intent(out) :: intUpperBound

  intLowerBound = 0
  intUpperBound = 0
  if (allocated(Coarray_Object[intImageNumber]%reaDataArray)) then
    intLowerBound = lbound(Coarray_Object[intImageNumber]%reaDataArray, dim=1)
    intUpperBound = ubound(Coarray_Object[intImageNumber]%reaDataArray, dim=1)
  endif
endsubroutine GetBoundsFromCoarrayMember
endmodule NonSymmetricDemo  

The results are as expetected:

stefano@zaghi(04:30 PM Fri Nov 11) on master [!?]
~/fortran/Coarray-with-Allocatable-Component-Example 5 files, 32Kb
→ ifort -coarray -coarray-num-images=2 src/NonSymmetricDemo.f90 src/main.f90 -o a.out

stefano@zaghi(04:47 PM Fri Nov 11) on master [!?]
~/fortran/Coarray-with-Allocatable-Component-Example 6 files, 824Kb
→ a.out
 This example shows how to access the array bounds on Image 2 from Image 1.
 The following output comes from image            1
 Lower and upper bounds on image           2 :           1          15
MichaelSiehl commented 7 years ago

Dear Stefano, thanks for pointing to that, the example code was inclompete indeed. I did overlook that and just added the following missing code to the module:

! SUBROUTINE GetBoundsFromCoarrayMember (CoarrayObject, intImageNumber, intLowerBound, intUpperBound) ! TYPE (NonSymmetricCoarray), CODIMENSION[], INTENT (INOUT) :: Coarray_Object INTEGER, INTENT (IN) :: intImageNumber INTEGER, INTENT (OUT) :: intLowerBound INTEGER, INTENT (OUT) :: intUpperBound ! IF (Coarray_Object[intImageNumber] % logAllocationStatus) THEN intLowerBound = LBOUND (Coarray_Object[intImageNumber] % reaDataArray, 1) intUpperBound = UBOUND (CoarrayObject[intImageNumber] % reaDataArray, 1) ELSE intLowerBound = 1 intUpperBound = 0 END IF ! END SUBROUTINE GetBoundsFromCoarrayMember ! !** END MODULE NonSymmetricDemo

I see your code using the ALLOCATED function to access a remote image. This did not work when I did code the original version (using ifort 14, some two years ago). Great, I will try this shortly myself.

cheers

2016-11-11 16:54 GMT+01:00 Stefano Zaghi notifications@github.com:

I complete the module with this

subroutine GetBoundsFromCoarrayMember(Coarray_Object, intImageNumber, intLowerBound, intUpperBound) type(NonSymmetricCoarray), intent(in) :: Coarray_Object[*] integer, intent(in) :: intImageNumber integer, intent(out) :: intLowerBound integer, intent(out) :: intUpperBound

intLowerBound = 0 intUpperBound = 0 if (allocated(Coarray_Object[intImageNumber]%reaDataArray)) then intLowerBound = lbound(Coarray_Object[intImageNumber]%reaDataArray, dim=1) intUpperBound = ubound(Coarray_Object[intImageNumber]%reaDataArray, dim=1) endifendsubroutine GetBoundsFromCoarrayMemberendmodule NonSymmetricDemo

The results are as expetected:

stefano@zaghi(04:30 PM Fri Nov 11) on master [!?]~/fortran/Coarray-with-Allocatable-Component-Example 5 files, 32Kb → ifort -coarray -coarray-num-images=2 src/NonSymmetricDemo.f90 src/main.f90 -o a.out

stefano@zaghi(04:47 PM Fri Nov 11) on master [!?]~/fortran/Coarray-with-Allocatable-Component-Example 6 files, 824Kb → a.out This example shows how to access the array bounds on Image 2 from Image 1. The following output comes from image 1 Lower and upper bounds on image 2 : 1 15

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MichaelSiehl/Coarray-with-Allocatable-Component-Example/issues/1#issuecomment-259987722, or mute the thread https://github.com/notifications/unsubscribe-auth/AQUQ_JaFxGhhOaMNPJrgfTSBo3l2Hlekks5q9I-0gaJpZM4Kv3MT .

MichaelSiehl commented 7 years ago

More importantly, if you are currently studying the MPMD-style and load balancing examples, I would suggest to wait for the shortly upcoming version, with some major improvements are:

-

SYNC MEMORY is now completely encapsulated into the coarray wrapper(s) for safer use. Thus, it is possible to hide the coarray related language elements from the program logic codes even when using atomic subroutines and SYNC MEMORY.

I reduced the functionality of the coarray wrappers to a required minimum only. This should make the coarray wrappers much easier to maintain and understand. More importantly, I believe that the current redundant version would be a major source for coding, logical, and runtime errors.

All derived type coarrays, and thus their components, are VOLATILE by now. I hope this might be helpful (for the compilers) with remote data transfer of data types that can't be used with atomic_define or atomic_ref. (Considering that the SYNC MEMORY statements do form user-defined execution segments).

I am currently streamlining the code as much as possible, removing everything which is not really required, turning Fortran keywords into lowercase etc.

I am also sitting on a new rationale for that, the plan is to open a new topic on comp.lang.fortran about atomic subroutines shortly.

The objective is to hide the inner implementation of the coarray wrappers (and thus atomic subroutines, SYNC MEMORY, VOLATILE, etc.) from the parallel software development process.

cheers

2016-11-11 23:28 GMT+01:00 michael siehl miesiehl@gmail.com:

Dear Stefano, thanks for pointing to that, the example code was inclompete indeed. I did overlook that and just added the following missing code to the module:

! SUBROUTINE GetBoundsFromCoarrayMember (CoarrayObject, intImageNumber, intLowerBound, intUpperBound) ! TYPE (NonSymmetricCoarray), CODIMENSION[], INTENT (INOUT) :: Coarray_Object INTEGER, INTENT (IN) :: intImageNumber INTEGER, INTENT (OUT) :: intLowerBound INTEGER, INTENT (OUT) :: intUpperBound ! IF (Coarray_Object[intImageNumber] % logAllocationStatus) THEN intLowerBound = LBOUND (Coarray_Object[intImageNumber] % reaDataArray, 1) intUpperBound = UBOUND (CoarrayObject[intImageNumber] % reaDataArray, 1) ELSE intLowerBound = 1 intUpperBound = 0 END IF ! END SUBROUTINE GetBoundsFromCoarrayMember ! !** END MODULE NonSymmetricDemo

I see your code using the ALLOCATED function to access a remote image. This did not work when I did code the original version (using ifort 14, some two years ago). Great, I will try this shortly myself.

cheers

2016-11-11 16:54 GMT+01:00 Stefano Zaghi notifications@github.com:

I complete the module with this

subroutine GetBoundsFromCoarrayMember(Coarray_Object, intImageNumber, intLowerBound, intUpperBound) type(NonSymmetricCoarray), intent(in) :: Coarray_Object[*] integer, intent(in) :: intImageNumber integer, intent(out) :: intLowerBound integer, intent(out) :: intUpperBound

intLowerBound = 0 intUpperBound = 0 if (allocated(Coarray_Object[intImageNumber]%reaDataArray)) then intLowerBound = lbound(Coarray_Object[intImageNumber]%reaDataArray, dim=1) intUpperBound = ubound(Coarray_Object[intImageNumber]%reaDataArray, dim=1) endifendsubroutine GetBoundsFromCoarrayMemberendmodule NonSymmetricDemo

The results are as expetected:

stefano@zaghi(04:30 PM Fri Nov 11) on master [!?]~/fortran/Coarray-with-Allocatable-Component-Example 5 files, 32Kb → ifort -coarray -coarray-num-images=2 src/NonSymmetricDemo.f90 src/main.f90 -o a.out

stefano@zaghi(04:47 PM Fri Nov 11) on master [!?]~/fortran/Coarray-with-Allocatable-Component-Example 6 files, 824Kb → a.out This example shows how to access the array bounds on Image 2 from Image 1. The following output comes from image 1 Lower and upper bounds on image 2 : 1 15

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MichaelSiehl/Coarray-with-Allocatable-Component-Example/issues/1#issuecomment-259987722, or mute the thread https://github.com/notifications/unsubscribe-auth/AQUQ_JaFxGhhOaMNPJrgfTSBo3l2Hlekks5q9I-0gaJpZM4Kv3MT .

szaghi commented 7 years ago

@MichaelSiehl

Dear Michael,

thank you very much for your help it is very appreciated!

Yes, I started to study your work more closely.

All your upcoming new features are much more than welcome. Anyhow, I have to start immediately because I need time to learn and because I have few time "now" and probably no more in the future :-(

I have one question: it is possible to wrap a MPMD-coarray inside a derive type in your approach? i.e.

type :: baz
  integer, allocatable :: mic(:)
end type baz

type :: foo
  type(baz), allocatable :: bar[:]
end type foo

I used a plain coarray member here: this is an unlimited polymorphic thus I think it could be also one of your MPMD type... this could be fantastic for HASTY...

MichaelSiehl commented 7 years ago

| I have one question: it is possible to wrap a coarray inside a derive type in your approach? i.e.

That would be a coarray component, see Modern Fortran explained chapter 19.9 and, more importantly, Aleksandar Donev's paper chapter 3.1 and 3.1.1. Due to the required allocation it may not be possible to use these within my MPMD approach. (But I have not tried coarray components myself yet). I believe, the main advantage of coarray components should be that you can use them together with inheritance and polymorphism. To use them for MPMD-style programming you may need upcomming F2015 teams.

cheers

2016-11-12 7:28 GMT+01:00 Stefano Zaghi notifications@github.com:

@MichaelSiehl https://github.com/MichaelSiehl

Dear Michael,

thank you very much for your help it is very appreciated!

Yes, I started to study your work more closely.

All your upcoming new features are much more than welcome. Anyhow, I have to start immediately because I need time to learn and because I have few time "now" and probably no more in the future :-(

I have one question: it is possible to wrap a coarray inside a derive type in your approach? i.e.

type :: baz integer, allocatable :: mic(:) end type baz

type :: foo type(baz), allocatable :: bar[:] end type foo

I used a plain coarray member here https://github.com/Fortran-FOSS-Programmers/FOODIE/blob/master/src/lib/foodie_adt_integrand.f90#L21: this is an unlimited polymorphic thus I think it could be also one of your MPMD type... this could be fantastic for HASTY...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MichaelSiehl/Coarray-with-Allocatable-Component-Example/issues/1#issuecomment-260105194, or mute the thread https://github.com/notifications/unsubscribe-auth/AQUQ_Nfw9_FJnuKdsOo68i3ehjutz6fFks5q9VyNgaJpZM4Kv3MT .