Autodetect if transposing is needed

This commit is contained in:
Tong Dong Qiu 2022-11-03 14:13:56 +01:00
parent 5dea01b9dc
commit f91154c165

View File

@ -28,6 +28,7 @@
#include <opm/simulators/linalg/bda/rocalutionSolverBackend.hpp>
#include <rocalution.hpp>
#include <base/matrix_formats_ind.hpp> // check if blocks are interpreted as row-major or column-major
namespace Opm
{
@ -88,6 +89,9 @@ void rocalutionSolverBackend<block_size>::convert_matrix(std::shared_ptr<Blocked
// convert values inside block from row major to col major
// this is the same as transposing a block
// when compiling rocm from scratch, it is possible to choose the direction, making this transposing unnecessary
// BCSR_IND_BASE == 0: rocalution expects column-major
// BCSR_IND_BASE == 1: rocalution expects row-major
if (BCSR_IND_BASE == 0) {
for(int i = 0; i < nnzb; ++i){
tmp_nnzvalues[i * block_size * block_size + 0] = matrix->nnzValues[i * block_size * block_size + 0];
tmp_nnzvalues[i * block_size * block_size + 1] = matrix->nnzValues[i * block_size * block_size + 3];
@ -99,6 +103,7 @@ void rocalutionSolverBackend<block_size>::convert_matrix(std::shared_ptr<Blocked
tmp_nnzvalues[i * block_size * block_size + 7] = matrix->nnzValues[i * block_size * block_size + 5];
tmp_nnzvalues[i * block_size * block_size + 8] = matrix->nnzValues[i * block_size * block_size + 8];
}
}
if (verbosity >= 3) {
std::ostringstream out;
out << "rocalutionSolver::convert_matrix(): " << t.stop() << " s";