Commit 562e538e authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Implement a get_ram_overhead() utility function

parent 5669d21d
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -22,6 +22,19 @@
#ifndef INCLUDE_UTILS_H_
#define INCLUDE_UTILS_H_

/*! \brief Obtain an estimate of the RAM overhead factor for optimization.
 *
 * Code speed-up optimization usually comes at the cost of increased memory
 * requirements. While this should not generally be a serious issue, it can
 * become such in case of models that require large amounts of memory to be
 * handled. This function tests the code build configuration to provide an
 * zero-order estimate of the weight of these overheads to protect the host
 * system from saturating the RAM.
 *
 * \return factor: `double` The multiplicative factor to be applied to data size.
 */
double get_ram_overhead();

/*! \brief Write a double complex matrix to a text file.
 *
 * \param af: `VirtualAsciiFile *` Pointer to an existing VirtualAsciiFile.
+14 −2
Original line number Diff line number Diff line
@@ -42,6 +42,18 @@

using namespace std;

double get_ram_overhead() {
  double result = 1.0;
#ifdef USE_MAGMA
  if (result < 15.0) result = 15.0;
#endif //USE_MAGMA
#ifdef USE_LAPACK
  if (result < 2.0) result = 2.0;
#endif //USE_MAGMA
  return result;
}


int write_dcomplex_matrix(
  VirtualAsciiFile *af, dcomplex **mat, int rows, int columns,
  const std::string& format, int first_index