• Shared-memory implementation for coarray Fortran in gfortrn

    From Steven G. Kargl@[email protected] to comp.lang.fortran on Thu Mar 5 20:56:35 2026
    From Newsgroup: comp.lang.fortran

    All,

    The gfortran developers have added a shared-memory
    implementation for coarray Fortran. The forthcoming
    GCC 16.1 will be the first release with this support.
    This implementation sits on top an operating system's
    pthread library (at least on Linux and BSD).

    To use it, one compile with

    % gfortran -fcoarray=lib -lcaf_shmem file.f90
    --
    steve

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Gary Scott@[email protected] to comp.lang.fortran on Thu Mar 5 16:03:13 2026
    From Newsgroup: comp.lang.fortran

    On 3/5/2026 2:56 PM, Steven G. Kargl wrote:
    All,

    The gfortran developers have added a shared-memory
    implementation for coarray Fortran. The forthcoming
    GCC 16.1 will be the first release with this support.
    This implementation sits on top an operating system's
    pthread library (at least on Linux and BSD).

    To use it, one compile with

    % gfortran -fcoarray=lib -lcaf_shmem file.f90

    Speaking of coarrays, I never did get a clear explanation of how to have
    a single instance of a GUI but with a coarray subsection (4 cores on
    Windows with the particular IVF and hardware I had) in the same process.
    Within the same application i always got 4 copies of the GUI. I could
    find no way to designate only certain threads were to be duplicated on
    the 4 cores, rather than the entire executable/program. I ended up
    trying a coarray calculation engine and a separate GUI process that communicated with it via shared memory. Is it possible within a single coarray application to have such fine control over what is delegated to
    each core?

    It worked with the separate GUI control, but for my application it only
    got about 10% performance improvement and was too difficult to support
    long term.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Steven G. Kargl@[email protected] to comp.lang.fortran on Thu Mar 5 22:16:45 2026
    From Newsgroup: comp.lang.fortran

    On Thu, 5 Mar 2026 16:03:13 -0600, Gary Scott wrote:

    On 3/5/2026 2:56 PM, Steven G. Kargl wrote:
    All,

    The gfortran developers have added a shared-memory
    implementation for coarray Fortran. The forthcoming
    GCC 16.1 will be the first release with this support.
    This implementation sits on top an operating system's
    pthread library (at least on Linux and BSD).

    To use it, one compile with

    % gfortran -fcoarray=lib -lcaf_shmem file.f90

    Speaking of coarrays, I never did get a clear explanation of how to have
    a single instance of a GUI but with a coarray subsection (4 cores on
    Windows with the particular IVF and hardware I had) in the same process.
    Within the same application i always got 4 copies of the GUI. I could find no way to designate only certain threads were to be duplicated on
    the 4 cores, rather than the entire executable/program. I ended up
    trying a coarray calculation engine and a separate GUI process that communicated with it via shared memory. Is it possible within a single coarray application to have such fine control over what is delegated to
    each core?

    It worked with the separate GUI control, but for my application it only
    got about 10% performance improvement and was too difficult to support
    long term.

    I don't know if one can get fine-grain control for a gui.
    I don't use gui's. All of programs are CLI only. I would
    guess that one could write the code to do

    if (this_image == 1) then
    ! Do GUI stuff here
    end if

    You need a 'sync all' on entry into the if block and exit.

    PS: I forgot to mention, one may need to also add -lpthread
    so the loader finds the pthread library.
    --
    steve
    --- Synchronet 3.21d-Linux NewsLink 1.2