fortran pointer assignment as omp atomic

fortran pointer assignment as omp atomic

Ritratto di jhgoebbert

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 post / 0 new
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Ritratto di jhgoebbert

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

Ritratto di 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

Blog: The Parallel Void

www.quickthreadprogramming.com
Ritratto di TimP (Intel)

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

Ritratto di Steve Lionel (Intel)

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

Steve

Accedere per lasciare un commento.