====================== Geblockte LU-Zerlegung ====================== Implementiert die in der Vorlesung besprochende geblockte LU-Variante. Vorlage ======= ---- CODE(type=c) -------------------------------------------------------------- #include #include #include #include #include #include #include #include //-- TRLSM with simple cache optimization -------------------------------------- #ifndef DTRLSM_MC #define DTRLSM_MC 64 #endif #ifndef DTRLSM_NC #define DTRLSM_NC 64 #endif void dtrlsm_simple_unblk(int m, int n, double alpha, int unitDiag, const double *A, int incRowA, int incColA, double *B, int incRowB, int incColB) { int i, j; if (alpha!=1) { for (j=0; j(Y) ? (X) : (Y)) double A_[MAX_N*MAX_N]; double A_0[MAX_N*MAX_N*MIN(INCROW_A,INCCOL_A)]; int main() { int m, n; randGeMatrix(MAX_N, MAX_N, A_, 1, MAX_M); printf("#%9s %9s %9s %9s", "m", "n", "INCROW_A", "INCCOL_A"); printf(" %12s %12s %12s", "t", "MFLOPS", "err"); printf(" %12s %12s %12s", "t", "MFLOPS", "err"); printf("\n"); for (m=MIN_M, n=MIN_N; n<=MAX_N && m<=MAX_M; m+=INC_M, n+=INC_N) { double t, dt, err; int runs = 1; int minMN = MIN(m,n); int maxMN = MAX(m,n); double ops = minMN*minMN*maxMN -(minMN*minMN*minMN/3.) -(minMN*minMN/2.); printf(" %9d %9d %9d %9d", m, n, INCROW_A, INCCOL_A); t = 0; runs = 0; do { dgecopy(m, n, A_, 1, MAX_M, A_0, INCROW_A, INCCOL_A); dt = walltime(); lu_unblk_var3(m, n, A_0, INCROW_A, INCCOL_A); dt = walltime() - dt; t += dt; ++runs; } while (t<0.3); t /= runs; err = err_lu(m, n, A_, 1, MAX_M, A_0, INCROW_A, INCCOL_A); printf(" %12.2e %12.2lf %12.2e", t, ops/(1000*1000*t), err); t = 0; runs = 0; do { dgecopy(m, n, A_, 1, MAX_M, A_0, INCROW_A, INCCOL_A); dt = walltime(); lu_blk(m, n, A_0, INCROW_A, INCCOL_A); dt = walltime() - dt; t += dt; ++runs; } while (t<0.3); t /= runs; err = err_lu(m, n, A_, 1, MAX_M, A_0, INCROW_A, INCCOL_A); printf(" %12.2e %12.2lf %12.2e", t, ops/(1000*1000*t), err); printf("\n"); } return 0; } -------------------------------------------------------------------------------- :navigate: up -> doc:index back -> doc:session09/page02