diff --git a/src/problem/MagmaHelper.cpp b/src/problem/MagmaHelper.cpp index 72f4b10a1730f934815114ce5c70b582d6a5db33..12381013ca5f291ea5f51eb0fa50fddca3015920 100644 --- a/src/problem/MagmaHelper.cpp +++ b/src/problem/MagmaHelper.cpp @@ -575,11 +575,15 @@ namespace gmshddm std::cout << " - lddMult : " << _lddMult << 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); //magma_malloc_cpu( (void**) &_h_Mult, _sizeMult*sizeof(Magma_Scalar) ); std::cout << "Allocation done" << std::endl; // Fill the arrays + size_t sparseCount = 0; for (size_t i = 0; i < _numMatrices; ++i) { auto matrix = rhsMatricesSparsified[_ids[i]]; // Make sure that the order is correct PetscInt m, n; // m = number of rows, n = number of columns @@ -590,6 +594,9 @@ namespace gmshddm for (PetscInt j = 0; j < m; ++j) { PetscScalar 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>>) { _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>>) { @@ -602,6 +609,9 @@ namespace gmshddm } } } + + std::cout << "Required sparse memory : " << sparseCount * (sizeof(Magma_Scalar) + 2 * sizeof(size_t)) / 1e9 << std::endl; + // Matrices filled // Allocate device memory