Hi Dmitry, I don't understand why must I have 2 levels of ISPC functions instead of 1. Wouldn't 1 be more efficient?
I will create a C wrapper which works on chunks of 4-8 pixels. It gives the chunk to ISPC function which updated a buffer chunk which is given as well. Would that be more efficient or better have 2 levels of ISPC? On Tue, Aug 21, 2018 at 2:29 AM Dmitry Babokin <[email protected]> wrote: > No, box3x3() is ISPC function, the function which calls it also has to be > ISPC (just because box3x3 accepts varying parameters). > > it will look like this: > > export void computeImage(uniform float * uniform ml, uniform int numRows, > uniform int numCols) { > for(uniform int ii = 0; ii < numRows; ii++){ // note uniform counter > for(int jj = 0; jj < numCols; jj++){ // note varying counter > mO[ii, jj] = box3x3(mI, jj, ii); // on the first iteration it > will handle pixels (0,0), (1,0), (2,0), (3,0), i.e. jj is (0,1,2,3), ii is > uniform int 0, which is casted to varying int (0,0,0,0). > } > } > } > > On Sat, Aug 18, 2018 at 2:02 AM Royi <[email protected]> wrote: > >> Hi Dmitry, >> >> If I get you right you're suggesting an ISPC wrapper around the function >> from the example. >> The host program is something like: >> >> for(ii = 0; ii < numRows; ii++){ >> for(jj = 0; jj < numCols; jj += 4){ >> mO[ii, jj] = IspcBoxBlurWrppaer(mI, jj, ii); >> } >> } >> >> Where IspcBoxBlurWrapper is something like: >> >> for(ii = 0; ii < 4; ii++){ >> mO[ii, jj] = box3x3(mI, jj, ii); >> } >> >> And box3x3(mI, jj, ii); is like in the documentation. >> Is it efficient? >> >> Otherwise I didn't get your code: >> >> for(uniform int ii = 0; ii < numRows; ii++){ // note uniform counter >> for(int jj = 0; jj < numCols; jj++){ // note varying counter >> mO[ii, jj] = box3x3(mI, jj, ii); // on the first iteration it >> will handle pixels (0,0), (1,0), (2,0), (3,0), i.e. jj is (0,1,2,3), ii is >> uniform int 0, which is casted to varying int (0,0,0,0). >> } >> } >> >> >> Which seems to require the whole image as input. >> >> >> On Friday, August 17, 2018 at 10:01:26 PM UTC+3, Dmitry Babokin wrote: >>> >>> box3x3(uniform float image[32][32], int x, int y) takes varying x and y >>> parameters and exploits parallelism coming from these vectors. For SSE4 it >>> will handle 4 pixels at a time. So you need to organise outer loops to >>> supply these pixels in chunks of 4 (or 8, or 16, depending on your target). >>> >>> This loop will do the job: >>> for(uniform int ii = 0; ii < numRows; ii++){ // note uniform counter >>> for(int jj = 0; jj < numCols; jj++){ // note varying counter >>> mO[ii, jj] = box3x3(mI, jj, ii); // on the first iteration it >>> will handle pixels (0,0), (1,0), (2,0), (3,0), i.e. jj is (0,1,2,3), ii is >>> uniform int 0, which is casted to varying int (0,0,0,0). >>> } >>> } >>> >>> In case of both counter are varying, it will basically handle only 4 >>> diagonal points of out of 16 in 4x4 area: (0,0), (1,1), (2,2), (3,3). >>> >>> >>> On Fri, Aug 17, 2018 at 3:15 AM Royi <[email protected]> wrote: >>> >>>> Hello, >>>> >>>> I'm trying to do my first steps with ISPC. >>>> >>>> I understand the concept of ISPC that you write the programs from the >>>> point of view of a single element. >>>> It is easy to understand in the case there is an array as input and >>>> array as output and the ISPC program is the whole program. >>>> >>>> What I don't get is how it the Box Blur example >>>> <https://ispc.github.io/ispc.html#uniform-control-flow> should be used >>>> by the host program. >>>> >>>> let's say we have an image (Single Channel) as mI. >>>> Should we iterate it like: >>>> >>>> for(ii = 0; ii < numRows; ii++){ >>>> for(jj = 0; jj < numCols; jj++){ >>>> mO[ii, jj] = box3x3(mI, jj, ii); >>>> } >>>> } >>>> >>>> But then it doesn't make sense. >>>> As it seem a "Gang" will update single value. >>>> >>>> Could someone show a simple example how to utilize ISPC for Image >>>> Filtering? >>>> >>>> Thank You. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Intel SPMD Program Compiler Users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Intel SPMD Program Compiler Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Intel SPMD Program Compiler Users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/ispc-users/QvlGaQQYRhw/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Intel SPMD Program Compiler Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
