Ejemplo n.º 1
0
static void getri(void *descr[], int type) {
  // Computes the Echelon form of A, stores the corresponding inverted multiples
  // in the lower part
  // ------------------------------
  // | A |   |   |   |   |   |    | 
  // |----------------------------|
  // |   |   |   |   |   |   |    |
  // |----------------------------|
  // |   |   |   |   |   |   |    |
  // |----------------------------|
  // |   |   |   |   |   |   |    |
  // ------------------------------
  unsigned int i, j, k;
  unsigned int *sub_a   = (unsigned int *)STARPU_MATRIX_GET_PTR(descr[0]);
  unsigned int x_dim    = STARPU_MATRIX_GET_NX(descr[0]);
  unsigned int y_dim    = STARPU_MATRIX_GET_NY(descr[0]);
  unsigned int offset_a = STARPU_MATRIX_GET_OFFSET(descr[0]);
  unsigned int ld_a     = STARPU_MATRIX_GET_LD(descr[0]);
  unsigned int mult     = 0;
 
#if DEBUG0
  printf("\n --- GETRI ---\n");
#endif
#if DEBUG
  printf("x_dim = %u\n", x_dim);
  printf("y_dim = %u\n", y_dim);
  printf("ld_a  = %u\n", ld_a);
#endif
  for (i = 0; i < y_dim; ++i) {  
    // compute inverse
    neg_inv_piv[i+offset_a] = negInverseModP(sub_a[i+i*ld_a], prime);
#if DEBUG
    printf("sub_a[%u] = %u\n", i+i*ld_a,sub_a[i+i*ld_a]);
    printf("inv  = %u\n", neg_inv_piv[i+offset_a]);
#endif
    for (j = i+1; j < x_dim; ++j) {
      // multiply by corresponding coeff
      mult  = (neg_inv_piv[i+offset_a] * sub_a[i+j*ld_a]); //% prime;
#if DEBUG
      printf("sub_a[%u] = %u\n", i+j*ld_a,sub_a[i+j*ld_a]);
      printf("mult      = %u\n", mult);
#endif
      sub_a[i+j*ld_a] = mult;
      for (k = i+1; k < y_dim; ++k) {
        sub_a[k+j*ld_a] +=  (sub_a[k+i*ld_a] * mult);
        //sub_a[k+j*ld_a] %=  prime;
      }
    }
  }  
#if DEBUG0
  printf("\n --- GETRI DONE ---\n");
  printf("TASKS READY     %d\n", starpu_task_nready());
  printf("TASKS SUBMITTED %d\n", starpu_task_nsubmitted());
#endif
}
Ejemplo n.º 2
0
{ 
  float *subB;
  uint32_t nxB, nyB;
  uint32_t ldB;
  float east,west,north,south;
  uint32_t offset,dimension,offset_row_shift;
  subB = (float *)STARPU_MATRIX_GET_PTR(descr[0]);
    
  nxB = STARPU_MATRIX_GET_NX(descr[0]);
  nyB = STARPU_MATRIX_GET_NY(descr[0]);
  
  ldB = STARPU_MATRIX_GET_LD(descr[0]);

  unsigned i,j;
  unsigned int x,y;
  offset=STARPU_MATRIX_GET_OFFSET(descr[0]);
  //Based on offset we need to calculate the location of north,south,east and west in matrix A. 
  offset_row_shift=offset;
  for(i=0;i<nxB;i++)
  {
    for(j=0;j<nyB;j++)
    {
        dimension=offset/4;
        x=floor(dimension/ydim);
        y=dimension%ydim;
        if(x==0 && y!=0)
        {
          north=0;
          west=A[x*ydim+(y-1)];
          south=A[(x+1)*ydim+y];
          if(y==ydim-1)