fortran pointer assignment as omp atomic

fortran pointer assignment as omp atomic

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?

Jens Henrik

5 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

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 ?
Jens Henrik

Bild des Benutzers jimdempseyatthecove

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

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

Bild des Benutzers Steve Lionel (Intel)

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


Melden Sie sich an, um einen Kommentar zu hinterlassen.