Skip to content
Snippets Groups Projects
Commit 722e87ec authored by Roland Greffe's avatar Roland Greffe
Browse files

added mem estimation

parent e17eee14
No related branches found
No related tags found
No related merge requests found
Pipeline #12867 failed
...@@ -575,11 +575,15 @@ namespace gmshddm ...@@ -575,11 +575,15 @@ namespace gmshddm
std::cout << " - lddMult : " << _lddMult << std::endl; std::cout << " - lddMult : " << _lddMult << std::endl;
std::cout << " - sizeMult : " << _sizeMult << std::endl; std::cout << " - sizeMult : " << _sizeMult << std::endl;
size_t requiredMemory = _sizeMult * sizeof(Magma_Scalar) + _rhsMat_n * _numMatrices * sizeof(Magma_Scalar);
std::cout << " - Required memory : " << requiredMemory / 1e9 << std::endl;
_h_Mult = (Magma_Scalar *)calloc(sizeof(Magma_Scalar), _sizeMult); _h_Mult = (Magma_Scalar *)calloc(sizeof(Magma_Scalar), _sizeMult);
//magma_malloc_cpu( (void**) &_h_Mult, _sizeMult*sizeof(Magma_Scalar) ); //magma_malloc_cpu( (void**) &_h_Mult, _sizeMult*sizeof(Magma_Scalar) );
std::cout << "Allocation done" << std::endl; std::cout << "Allocation done" << std::endl;
// Fill the arrays // Fill the arrays
size_t sparseCount = 0;
for (size_t i = 0; i < _numMatrices; ++i) { for (size_t i = 0; i < _numMatrices; ++i) {
auto matrix = rhsMatricesSparsified[_ids[i]]; // Make sure that the order is correct auto matrix = rhsMatricesSparsified[_ids[i]]; // Make sure that the order is correct
PetscInt m, n; // m = number of rows, n = number of columns PetscInt m, n; // m = number of rows, n = number of columns
...@@ -590,6 +594,9 @@ namespace gmshddm ...@@ -590,6 +594,9 @@ namespace gmshddm
for (PetscInt j = 0; j < m; ++j) { for (PetscInt j = 0; j < m; ++j) {
PetscScalar value; PetscScalar value;
MatGetValue(matrix, j, k, &value); MatGetValue(matrix, j, k, &value);
if (!(value.real() == 0.0 && value.imag() == 0.0)) {
sparseCount++;
}
if constexpr(std::is_same_v<T_Scalar, std::complex<double>>) { if constexpr(std::is_same_v<T_Scalar, std::complex<double>>) {
_h_Mult[i*_ldMult*_rhsMat_n + k*_ldMult + j] = MAGMA_Z_MAKE(value.real(), value.imag()); _h_Mult[i*_ldMult*_rhsMat_n + k*_ldMult + j] = MAGMA_Z_MAKE(value.real(), value.imag());
} else if constexpr(std::is_same_v<T_Scalar, std::complex<float>>) { } else if constexpr(std::is_same_v<T_Scalar, std::complex<float>>) {
...@@ -602,6 +609,9 @@ namespace gmshddm ...@@ -602,6 +609,9 @@ namespace gmshddm
} }
} }
} }
std::cout << "Required sparse memory : " << sparseCount * (sizeof(Magma_Scalar) + 2 * sizeof(size_t)) / 1e9 << std::endl;
// Matrices filled // Matrices filled
// Allocate device memory // Allocate device memory
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment