fortran pointer assignment as omp atomic

fortran pointer assignment as omp atomic

jhgoebbert's picture

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

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
jhgoebbert's picture

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

jimdempseyatthecove's picture

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

www.quickthreadprogramming.com
Tim Prince's picture

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

Steve Lionel (Intel)'s picture

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

Steve

Login to leave a comment.