[Liboil] CRASH due to ALIGNMENT FAULT observed in FSR and FAR Registers!!

Manju N Sataraddi manju.mns at gmail.com
Wed Mar 16 07:11:10 PDT 2011


I would like to know some information about this LibOil API:
typedef void (*_oil_type_diffsquaresum_f64)(double * d_1, const double *
src1, int sstr1, const double * src2, int sstr2, int n);

where: src1 is a pointer to 1st source array
           sstr1 is a stride value corresponding to 1st source array
           src2 is a pointer to 2nd source array
           sstr2 is a stride value corresponding to 2nd source array
           n is the number of elements in both array ( correct me if I'm

and its library implementation is as follows:

static void
diffsquaresum_f64_ref(double *dest, double *src1, int sstr1, double *src2,
    int sstr2, int n)
    double sum = 0;
    double errsum = 0;
    double tmp;
    double x;
    int i;

        x = OIL_GET(src1, i*sstr1, double) -
                  OIL_GET(src2, i*sstr2, double);
        x = x*x;
        tmp = sum;
        sum += x;
        errsum += (tmp - sum) + x;

    *dest = sum + errsum;

-->> Test case using this above API is:
    int i;
    double dsrc1[MAX_SIZE1], dsrc2[MAX_SIZE1];  // MAXSIZE1 is = 10 and
RES_SIZE is = 1
    double ddest[RES_SIZE]={0}, dcheck[RES_SIZE]= {539.25000000000000};

         dsrc1[i]= i*(i+1);
         std_log(LOG_FILENAME_LINE,"dsrc1[%d]=%15.14f, dsrc2[%d]=%15.14f",

    oil_diffsquaresum_f64(ddest,dsrc1,4,dsrc2,2,MAX_SIZE1);  // CRASH due
Alignment Fault

   // This is crashing with Fault Status Register containing info about
Alignment Fault!!!! Pls observe stride values 4 and 2 thats passed
   // ?? 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 ??

          std_log(LOG_FILENAME_LINE,"oil_diffsquaresum_f64 successful,
ddest= %15.14f", ddest[0]);
unsuccessful,Expected =%15.14f,Obtained =%15.14f",dcheck[0],ddest[0]);

1. If stride values are m=4 & n=2 passed from a test case then on 32 bit
     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)
     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 ).
Thus, Is stride refers to offset in an array or to mth and nth element ??
How to avoid this alignment fault ??

It would be a great help.. Thank you :)

Best Regards,
Manjunath Sataraddi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/liboil/attachments/20110316/494e11ef/attachment.html>

More information about the Liboil mailing list