Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Common/src/linear_algebra/CSysMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ void CSysMatrix<ScalarType>::Initialize(unsigned long npoint, unsigned long npoi

/*--- This is akin to the row_ptr. ---*/
omp_partitions = new unsigned long [omp_num_parts+1];
for (unsigned long i = 0; i <= omp_num_parts; ++i) omp_partitions[i] = nPointDomain;

/*--- Work estimate based on non-zeros to produce balanced partitions. ---*/

Expand All @@ -202,7 +203,15 @@ void CSysMatrix<ScalarType>::Initialize(unsigned long npoint, unsigned long npoi
if (row_ptr_prec[iPoint] >= part*nnz_per_part)
omp_partitions[part++] = iPoint;
}
omp_partitions[omp_num_parts] = nPointDomain;

for (unsigned long thread = 0; thread < omp_num_parts; ++thread) {
const auto begin = omp_partitions[thread];
const auto end = omp_partitions[thread + 1];
if (begin == end) {
cout << "WARNING: Redundant thread has been detected. Performance could be impacted due to low number of nodes per thread." << endl;
break;
}
}

/*--- Generate MKL Kernels ---*/

Expand Down Expand Up @@ -707,6 +716,7 @@ void CSysMatrix<ScalarType>::BuildILUPreconditioner() {
{
const auto begin = omp_partitions[thread];
const auto end = omp_partitions[thread+1];
if (begin == end) continue;

/*--- Each thread will work on the submatrix defined from row/col "begin"
* to row/col "end-1" (i.e. the range [begin,end[). Which is exactly
Expand Down Expand Up @@ -784,6 +794,7 @@ void CSysMatrix<ScalarType>::ComputeILUPreconditioner(const CSysVector<ScalarTyp
{
const auto begin = omp_partitions[thread];
const auto end = omp_partitions[thread+1];
if (begin == end) continue;

ScalarType aux_vec[MAXNVAR];

Expand Down Expand Up @@ -846,6 +857,7 @@ void CSysMatrix<ScalarType>::ComputeLU_SGSPreconditioner(const CSysVector<Scalar
{
const auto begin = omp_partitions[thread];
const auto end = omp_partitions[thread+1];
if (begin == end) continue;

/*--- Each thread will work on the submatrix defined from row/col "begin"
* to row/col "end-1", except the last thread that also considers halos.
Expand Down Expand Up @@ -876,6 +888,8 @@ void CSysMatrix<ScalarType>::ComputeLU_SGSPreconditioner(const CSysVector<Scalar
{
const auto begin = omp_partitions[thread];
const auto row_end = omp_partitions[thread+1];
if (begin == row_end) continue;

/*--- On the last thread partition the upper
* product should consider halo columns. ---*/
const auto col_end = (row_end==nPointDomain)? nPoint : row_end;
Expand Down