blocking_alg.c

Go to the documentation of this file.
00001 
00034 #include <stdlib.h>
00035 #include <stdio.h>
00036 
00037 #include "blocking_alg.h"
00038 #include "mad.h"
00039 
00040 blocking_struct_t* compute_blocking_structure(unsigned long long L,
00041                                               unsigned int B, unsigned int E) {
00042   
00043   unsigned int T;
00044   blocking_struct_t *bs;
00045   lldiv_t div_T;
00046   div_t div_N;
00047   div_t div_A;
00048   
00049   if (!(bs = (blocking_struct_t*)calloc(1, sizeof(blocking_struct_t)))) {
00050     printf("Could not alloc memory for blocking_struct!\n");
00051     return NULL;
00052   }
00053   
00054   /* (a) */
00055   
00056   div_T = lldiv(L, E);
00057   
00058   if(div_T.rem == 0) {
00059     T = (unsigned int)div_T.quot;
00060   }
00061   else {
00062     T = (unsigned int)div_T.quot + 1;
00063   }
00064   
00065   /* (b) */
00066   
00067   div_N = div(T, B);
00068   
00069   if(div_N.rem == 0) {
00070     bs->N = div_N.quot;
00071   }
00072   else {
00073     bs->N = div_N.quot + 1;
00074   }
00075   
00076   /* (c) */
00077   
00078   div_A = div(T, bs->N);
00079   
00080   if(div_A.rem == 0) {
00081     bs->A_large = div_A.quot;
00082   }
00083   else {
00084     bs->A_large = div_A.quot + 1;
00085   }
00086   
00087   /* (d) */
00088   
00089   bs->A_small = div_A.quot;
00090   
00091   /* (e) */
00092   
00093   bs->I = div_A.rem;    
00094   
00095   return bs;
00096 } 
00097 

Generated on Fri Mar 9 20:08:51 2007 for MAD-FCL by  doxygen 1.5.0