- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a question on the omp parallelization in the nested loop. I want to parallelize the outer loop by omp while in the inner loop a loop-dependent array "temp" is used. Without the omp inplementation, this serial of codes work well. But when I set "temp" to be private, and run it, it complains "Segmentation fault!". I guess there must be a mismatch in the dimension of "temp" and "phinew" due to the parallelization. But I don't know how to fix it. Obviously, "temp" cannot be shared by all the threads. Can anyone tell me why and show me a solution?
FYI, the original code is listed here:
#pragma omp parallel shared(phinew, chunk) private(temp)
{
#pragma omp for schedule(static, chunk)
for(j = 0; j <= J; j++){
for(i = 0; i <= I; i++){
temp = phinew;
}
cosft1(temp - 1, I);
for(i = 0; i <= I; i++){
phinew = 2.0 / (I + 0.0) * temp; // don't forget this coefficient 2/I for the inverse transform
}
}
}
I have a question on the omp parallelization in the nested loop. I want to parallelize the outer loop by omp while in the inner loop a loop-dependent array "temp" is used. Without the omp inplementation, this serial of codes work well. But when I set "temp" to be private, and run it, it complains "Segmentation fault!". I guess there must be a mismatch in the dimension of "temp" and "phinew" due to the parallelization. But I don't know how to fix it. Obviously, "temp" cannot be shared by all the threads. Can anyone tell me why and show me a solution?
FYI, the original code is listed here:
#pragma omp parallel shared(phinew, chunk) private(temp)
{
#pragma omp for schedule(static, chunk)
for(j = 0; j <= J; j++){
for(i = 0; i <= I; i++){
temp = phinew
}
cosft1(temp - 1, I);
for(i = 0; i <= I; i++){
phinew
}
}
}
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is really a forum about a more powerful alternative for OpenMP (with which I am not so familiar), and you have probably left out some essential details in the code, but here is my best guess.
(2012-06-22 Added after #5) Of course... OpenMP is not my thing (and I therefore didn't dare assume it could be so elemental).
(2012-06-22 Added after #5) Of course... OpenMP is not my thing (and I therefore didn't dare assume it could be so elemental).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As Raf said, the TBB forum is not the best place to get advice about OpenMP, which even uses a separate threading library, with no mutual awareness between that and the TBB library.
When you make an array private, that implies the run-time calls to allocate a copy of the array for each thread, evidently increasing consumption of stack space. You would likely require an explicit boost in thread stack limit or general stack limit, or both.
In C or C++, if the array is private, it may be good simply to define it with local scope.
When you make an array private, that implies the run-time calls to allocate a copy of the array for each thread, evidently increasing consumption of stack space. You would likely require an explicit boost in thread stack limit or general stack limit, or both.
In C or C++, if the array is private, it may be good simply to define it with local scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to make the private variable "temp" locally allocated inside each omp parallel block. But it still does not work and the same complaint comes out as before. In openmp, when I make a variable to be private, does it mean that the different threads replicate it for their own use? If "temp" is a pointer, each thread just produce its own replication of pointer "temp" in the parallel block?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Add i to your private or use for(int i=...
j is implicitly private.
Jim Dempsey
j is implicitly private.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting jimdempseyatthecove
Add i to your private or use for(int i=...
It looks that some oftemp values contain a garbage due to this. printf() is the best method to debug this in this case:)
--Vladimir
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page