TP-openmp/TP1/lu_par_loop.c

49 lines
1,013 B
C
Raw Normal View History

2023-06-22 18:19:48 +00:00
#include "trace.h"
#include "common.h"
#include <omp.h>
/* This routine performs the LU factorization of a square matrix by
block-columns */
void lu_par_loop(Matrix A, info_type info){
int i, j;
/* Initialize the tracing system */
trace_init();
/* openMP magic stuff */
#pragma omp parallel private(i)
for(i=0; i<info.NB; i++){
/* Panel must be executed by one thread only */
#pragma omp single
/* Do the Panel operation on column i */
panel(A[i], i, info);
/* Wait for panel to be done */
#pragma omp barrier
/* Parallelize this loop */
#pragma omp for
for(j=i+1; j<info.NB; j++){
/* Update column j with respect to the result of panel(A, i) */
update(A[i], A[j], i, j, info);
}
}
/* This routine applies permutations resulting from numerical pivoting.
It has to be executed sequentially. */
backperm(A, info);
/* Write the trace in file (ignore) */
trace_dump("trace_par_loop.svg");
return;
}