Chris
Member
|
Optimizing Iterating on Images
Hi,
I have an algorithm which is split up into two parts:
Code:
REP(n) {
if (image.lock()) { FREPA(someHugeArray) {
someHugeArray[i] = read a set of pixels from image.color3D(...);
} image.unlock(); }
if (image.lock()) { FREPA(someHugeArray) {
write a set of pixels to image.color3D(...);
} image.unlock(); }
}
In the first part, the same pixel may get read. In the second part, the same pixel may get written. Is there any way to accelerate either/both of these parts with multi-threading (e.g. for a processor with 6 CPUs and 12 hardware-threads)? If so, what would be the best way?
Thanks
(This post was last modified: 03-14-2011 12:57 AM by Chris.)
|
|
03-13-2011 12:16 PM |
|
Chris
Member
|
RE: Optimizing Iterating on Images
1. Can I use MultiThreadedCall() to do this? and what's "ThreadMayUseGPUData();"?
I'm really not sure how to set this up properly to max out the processors - please advise - it's very important to get the best result possible for this. Thanks.
|
|
03-14-2011 12:56 AM |
|
Esenthel
Administrator
|
RE: Optimizing Iterating on Images
Use image.data after lock to get direct memory access. Faster.
Yes you can use multi thread call
For the second function there are comments explaining it.
|
|
03-14-2011 08:06 AM |
|
Chris
Member
|
RE: Optimizing Iterating on Images
Thanks! I found i'm getting about 3x speedup 80% load now on a quad core - this is great (this loss is caused because I have to push the writing of images to a single thread as the same pixel may get written by different threads, but the slowest part can be spread across multiple cores! - very happy), can't wait to get results from university lab hardware.
Q. Please can you expand on how to access direct memory for images of a custom resolution, in the practical example:
VecI res3d; Image voxels; voxels.createTry(res3d.x, res3d.y, res3d.z, IMAGE_B8G8R8A8, IMAGE_3D); // 32-bit image
Idealistically, for any given voxel, i'd like to read/write the first 24-bits as an unsigned int, and the last 8-bits as a Byte, but just having access to VecB4 would be lovely - or whatevers available.
Thank you so much,
Chris
|
|
03-15-2011 02:04 AM |
|
Esenthel
Administrator
|
RE: Optimizing Iterating on Images
for b8r8g8a8 you can use vecb4:
image.lock
VecB4 *row=(VecB4*)(image.data()+y*image.pitch()+z*image.pitch2());
image.unlock;
|
|
03-15-2011 10:03 AM |
|