Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

What should the default access be for an associate name defined in an OpenMP loop?

Mark_Lewy
Valued Contributor I
428 Views

I've tried to find out what this is in both the Fortran and OpenMP standards, but haven't found anything relevant.

Consider this code fragment:

        ! 1 - find duplicates
        !$omp parallel do default(none) &
        !$omp & shared(lnodes, duplicate_of, nlinks, nnods) &
        !$omp & private(j, us_node, ds_node) schedule(dynamic)
        do i = 1, nlinks
            ! Why not ASSOCIATE? Looks like the associate names get shared in debug builds!
            us_node = lnodes(link_end_us, i)
            ds_node = lnodes(link_end_ds, i)

            if (us_node > nnods .or. ds_node > nnods) cycle ! ignore links to outfalls

            do j = 1, i - 1
                if (lnodes(link_end_us, j) == us_node .and. lnodes(link_end_ds, j) == ds_node) then
                    duplicate_of(i) = j
                    exit
                else if (lnodes(link_end_ds, j) == us_node .and. lnodes(link_end_us, j) == ds_node) then
                    duplicate_of(i) = -j ! < 0 means reversed orientation
                    exit
                end if
            end do
        end do

The original code had us_node and ds_node defined as associate names in an associate-block, but you can see that I found that these were being shared between loop iterations in recent Intel Fortran versions.  My expectation would be that associate-names should be private to an iteration.  Also, unsurprisingly, you cannot specify the associate-names in the private clause of the OpenMP do loop, as they aren't declared.  Obviously, you can code around this by either having temporary private variables or pointers, but that seems to defeat the object of associate.

0 Kudos
3 Replies
Andrew_Smith
New Contributor III
428 Views

I dont believe openMP supports associate names.

Try using a pointer instead.

0 Kudos
Mark_Lewy
Valued Contributor I
428 Views

Andrew Smith wrote:

I dont believe openMP supports associate names.

Try using a pointer instead.

This was true for older versions of OpenMP, but OpenMP 4.5 and later support most Fortran 2003 features, including associate AFAIK.

0 Kudos
Johannes_Rieke
New Contributor III
428 Views

Hi, I had the same question:

https://software.intel.com/en-us/forums/intel-fortran-compiler/topic/844210

and there was no clear answer.

The only thing I found is (scroll down):

https://www.openmp.org/spec-html/5.0/openmpse7.html#x28-270001.7

Further, especially OpenMP + O3 seems to be buggy in current 19.1 (there are some recent threads). My issues with OpenMP in more complex code are partially affected and gone with O2.

I avoid associate in OMP clauses curently. Maybe someone finds a clear statement, whether associate+OMP is allowed AND correctly implement in major compilers.

0 Kudos
Reply