Skip to content

Commit

Permalink
Revert "More replacement"
Browse files Browse the repository at this point in the history
This reverts commit 4ea0d8c.
  • Loading branch information
loumalouomega committed Mar 12, 2024
1 parent 9f55bcf commit 6524a34
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions kratos/utilities/sparse_matrix_multiplication_utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ class SparseMatrixMultiplicationUtility
const double* values_b = B.value_data().begin();

// Definition of TLS
struct TLS_max {
struct TLS {
IndexType my_max = 0;
};

const IndexType max_row_width = IndexPartition<IndexType>(nrows).for_each<MaxReduction<IndexType>>(TLS_max(), [&](IndexType i, TLS_max& rTLS) {
const IndexType max_row_width = IndexPartition<IndexType>(nrows).for_each<MaxReduction<IndexType>>(TLS(), [&](IndexType i, TLS& rTLS) {
const IndexType row_beg = index1_a[i];
const IndexType row_end = index1_a[i+1];

Expand Down Expand Up @@ -307,27 +307,25 @@ class SparseMatrixMultiplicationUtility
IndexType* c_ptr = new IndexType[nrows + 1];
c_ptr[0] = 0;

// Definition of TLS
struct TLS_col {
TLS_col(std::vector<std::vector<IndexType>>& rTmpCol)
{
#ifdef _OPENMP
const int tid = omp_get_thread_num();
#else
const int tid = 0;
#endif
t_col = &rTmpCol[tid][0];
}
IndexType* t_col;
};
// TODO: Replace with block_for_each
#pragma omp parallel
{
#ifdef _OPENMP
const int tid = omp_get_thread_num();
#else
const int tid = 0;
#endif

IndexPartition<IndexType>(nrows).for_each(TLS_col(tmp_col), [&](IndexType i, TLS_col& rTLS) {
IndexType* t_col = &tmp_col[tid][0];

const IndexType row_beg = index1_a[i];
const IndexType row_end = index1_a[i+1];
#pragma omp for
for(int i = 0; i < static_cast<int>(nrows); ++i) {
const IndexType row_beg = index1_a[i];
const IndexType row_end = index1_a[i+1];

c_ptr[i+1] = ProdRowWidth( index2_a + row_beg, index2_a + row_end, index1_b, index2_b, rTLS.t_col, rTLS.t_col + max_row_width, rTLS.t_col + 2 * max_row_width );
});
c_ptr[i+1] = ProdRowWidth( index2_a + row_beg, index2_a + row_end, index1_b, index2_b, t_col, t_col + max_row_width, t_col + 2 * max_row_width );
}
}

// We initialize the sparse matrix
std::partial_sum(c_ptr, c_ptr + nrows + 1, c_ptr);
Expand Down

0 comments on commit 6524a34

Please sign in to comment.