Hello,<br><br>I would like to know some information about this LibOil API: oil_diffsquaresum_f64()<br>i.e. <br>typedef void (*_oil_type_diffsquaresum_f64)(double * d_1, const double * src1, int sstr1, const double * src2, int sstr2, int n);<br>
<br>where: src1 is a pointer to 1st source array<br> sstr1 is a stride value corresponding to 1st source array<br> src2 is a pointer to 2nd source array<br> sstr2 is a stride value corresponding to 2nd source array<br>
n is the number of elements in both array ( correct me if I'm wrong)<br><br><br>and its library implementation is as follows:<br><br>static void<br>diffsquaresum_f64_ref(double *dest, double *src1, int sstr1, double *src2,<br>
int sstr2, int n)<br>{<br> double sum = 0;<br> double errsum = 0;<br> double tmp;<br> double x;<br> int i;<br><br><br> for(i=0;i<n;i++){<br> x = OIL_GET(src1, i*sstr1, double) -<br> OIL_GET(src2, i*sstr2, double);<br>
x = x*x;<br> tmp = sum;<br> sum += x;<br> errsum += (tmp - sum) + x;<br> }<br><br> *dest = sum + errsum;<br>}<br><br>-->> Test case using this above API is: <br> int i;<br> double dsrc1[MAX_SIZE1], dsrc2[MAX_SIZE1]; // MAXSIZE1 is = 10 and RES_SIZE is = 1<br>
double ddest[RES_SIZE]={0}, dcheck[RES_SIZE]= {539.25000000000000};<br> <br> for(i=0;i<MAX_SIZE1;i++)<br> {<br> dsrc1[i]= i*(i+1);<br> dsrc2[i]=i*(0.5);<br> std_log(LOG_FILENAME_LINE,"dsrc1[%d]=%15.14f, dsrc2[%d]=%15.14f", i,dsrc1[i],i,dsrc2[i]);<br>
}<br> <br> oil_diffsquaresum_f64(ddest,dsrc1,4,dsrc2,2,MAX_SIZE1); // CRASH due Alignment Fault<br><br> // This is crashing with Fault Status Register containing info about Alignment Fault!!!! Pls observe stride values 4 and 2 thats passed<br>
// ?? Doubt here is: what are these stride values ?? Is that something related to offset within an array or is that talks about 4th element in first array and 2nd element in second source array ??<br> <br> if(comparefloats(ddest[0],dcheck[0])==0)<br>
{<br> std_log(LOG_FILENAME_LINE,"oil_diffsquaresum_f64 successful, ddest= %15.14f", ddest[0]);<br> }<br> else<br> {<br> assert_failed=1;<br> std_log(LOG_FILENAME_LINE,"oil_diffsquaresum_f64 unsuccessful,Expected =%15.14f,Obtained =%15.14f",dcheck[0],ddest[0]);<br>
} <br><br>Issues:<br>1. If stride values are m=4 & n=2 passed from a test case then on 32 bit architecture:<br> src1 + i*sstr1 = 0,4,8,12,16....etc -> This will fall into 4 byte word boundary while accessing ( 0<i<n where n is 10 in our case here)<br>
src2 + i*sstr2 = 0,2,4,6,8,10...etc -> This will not fall into 4 byte word boundary while accessing this 2nd source array and hence resulting in alignment fault ( Correct me if I'm wrong w.r.t this stride concept ). <br>
Thus, Is stride refers to offset in an array or to mth and nth element ??<br>How to avoid this alignment fault ??<br><br>It would be a great help.. Thank you :)<br><br><br>Best Regards,<br>Manjunath Sataraddi<br><br><br><br>
<br>