- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let's assume that I have initialized a pointer P and its associated target T outside a parallel region. Then, from within a parallel region, I call a subroutine SUB(P), having declared P as shared in the parallel region directives.
Is it correct to assume thatthe threads calling SUB will all have proper access to the values of T?
Thanks in advance,
Olivier
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Olivier,
The threads inside SUB will have access to values of T. However, as to having "proper access" it is up to you.
Example of improper access
T%value = T%value + incriment
Example of proper access
!$OMP ATOMIC
T%value = T%value + incriment
Reading is generally safe (except for sequencing issues)
Writing is generally safe (except for sequencing issues)
Updating is generally unsafe without atomic or critical section.
When coding SUB you have to be aware that values within the shared object can change at unpredictable times and take proper precautions.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Jim - I was concerned that since each thread makes a duplicate of the code, the address this pointer refers to would be *local* to each thread.
Olivier

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page