Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

fortran pointer assignment as omp atomic

jhgoebbert
Beginner
1,263 Views

Hi out there,

I would like lock-free join two linked list in Fortran+OpenMP.
Therefore I need to change a pointer atomically. This should not be any problem in C/C++, but in Fortran I do not manage to :(

The following code is rejected by the Intel Compiler with the error:
error #7646: A store statement is expected in an OpenMP* ATOMIC construct.

        !$omp atomic
        last_job%next => tmp_first_job
        !$omp end atomic

Is there any work-around?
Will there be support of the "=>" operation in future?

regards,
Jens Henrik

0 Kudos
4 Replies
jhgoebbert
Beginner
1,263 Views

just an additional remark:

I cannot use the following as an alternative, because ifort gives the error:
error #7656: Subobjects are not allowed in this OpenMP* clause; a named variable must be specified.   [NEXT]

        last_job%next => tmp_first_job
        !$omp flush (last_job%next)

but just using !$omp flush(last_job) will probably only flush the pointer to the structure of "last_job" and not of the "next" pointer inside the structure.

Any idea ?
regards,
Jens Henrik

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,263 Views

Please provide a small copy of your linked list code. What you have in your first example is not indicative of a functionally correct, thread-safe, linked list management piece of code. This would typically require an !$OMP CRITICAL section or use of a CAS or DCAS type of implimentation.

Jim Dempsey

0 Kudos
TimP
Honored Contributor III
1,263 Views

Assuming that atomic applies only to simple data items, it might work with a c_ptr, but I wouldn't recommend it.

0 Kudos
Steven_L_Intel1
Employee
1,263 Views

The documented requirements for OMP$ ATOMIC say that "all assignments must be intrinsic assignments". Pointer assignment doesn't comply.

0 Kudos
Reply