- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
How can I return back the 2D Array after parallel_for to main code?
I have tried to do that, but unluckly I couldnt manage to return the array and accessing a wrong memory location. The source per below:
const size_t M = 1000;
const size_t N = 1000;
class pSubstitutionClass {
public:
int (*my_a)
int (*my_xor1);
void operator()(const blocked_range2d
int (*a)
int (*xor1) = my_xor1;
for (size_t i = r.rows().begin(); i!=r.rows().end(); i++)
for (size_t j = r.cols().begin(); j!=r.cols().end(); j++) {
a
}
}
pSubstitutionClass( int (*a)
my_a(a), my_xor1(xor1)
{}
};
int(*(ParallelSubstitution)( int (*a)
pSubstitutionClass pSub(a,xor1);
parallel_for(blocked_range2d
return pSub.my_a;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You don't need to return the array because it is enough just to callParallelSubstitution(A, XOR1) (where A is your 2D array). After that you can use changed array A.For that ParallelSubstitution() function should be changed andshould be like the function below:
voidParallelSubstitution( int (*a)
parallel_for(blocked_range2d
}
Then call ParallelSubstitution(A, XOR1) and usearray A. For example,
for (int i = 0; i < M; i++) for (int j = 0; j < N; j++)printf (
"A[%d][%d] = %d ", i, j, A- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page