- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In a parallel region, there are several ALLOCATE statements, the questions is do we need to enclosethese statementswith OMP Critical directives explicitly,without the Critical directives, arethe statementsexecuted in a critical session?
I have seen some strange errors with the ALLOCATE function, sometimes the functions return the error of #41, insufficient virtual memory, though the allocated space is not big.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If allocating a private data region, I would think you could let each thread do its own allocation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your reply. I am allocating a private data region, in particular, the data region for allocatable arrays is allocated in the routines that are called by the statements within the parallel region, they are temporary arrays in the routines. I agree with you that each thread does its own allocation, and each thread should have its own copies of these allocatalbe variables, while thread data sharing detection monitor detects the variables being accessed by multiple threads. I understand that these messages do not indicate errors, but sometimes the program has trouble allocating data space for these allocatable arrays due to insufficient virtual memory problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if(.not. allocated(YourArray)) then
!$omp critical(critical_allocate_YourArray)
if(.not. allocated(YourArray)) then
allocate(YourArray(YourSize(s)))
endif
!$omp end critical(critical_allocate_YourArray)
do while((.not. allocated(YourArray))
call sleepqq(0)
end do
endif
The above avoids a barrier when it is not needed.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have a valid concern.
For shared arrays, consider making the large shared array SAVE'd (and allocate it once). The code I provided earlier would perform the allocation once, enter critical section once by the allocating threadand potentially enter the critical section once by the other threads. Subsequent to the first call the critical section is bypassed.
As (?) TimP pointed out, you could "lift" the allocation outside the parallel region then pass in the array by reference on the CALL's issued within the parallel region.
How do you multi-thread and not allocate large private arrays N times when calling a subroutine N times?
A way to do this is to use(static) thread private allocatable arrays
IOW each thread has its own thread private array descriptor that they allocate from the heap once.
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page