Commit 1487499d authored by Mulas, Giacomo's avatar Mulas, Giacomo
Browse files

clean up DEBUG_REFINE stuff

parent 266a968d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -841,7 +841,7 @@ int cluster_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryConf
#endif
  // we put the accuracygoal in, get the actual accuracy back out
  double actualaccuracy = cid->accuracygoal;
  invert_matrix(cid->am, ndit, jer, cid->maxrefiters, actualaccuracy, cid->refinemode, mxndm, cid->proc_device);
  invert_matrix(cid->am, ndit, jer, cid->maxrefiters, actualaccuracy, cid->refinemode, output_path, jxi488, mxndm, cid->proc_device);
  // in principle, we should check whether the returned actualaccuracy is indeed lower than the accuracygoal, and do something about it if not
#ifdef USE_REFINEMENT
  if (cid->refinemode==2) {
+3 −1
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@
#ifndef INCLUDE_ALGEBRAIC_H_
#define INCLUDE_ALGEBRAIC_H_

using namespace std;

/*! \brief Perform in-place matrix inversion.
 *
 * \param mat: `complex double **` The matrix to be inverted (must be a square matrix).
@@ -38,6 +40,6 @@
 * optional, defaults to 0).
 * \param target_device: `int` ID of target GPU, if available (defaults to 0).
 */
void invert_matrix(dcomplex **mat, np_int size, int &ier, int &maxrefiters, double &accuracygoal, int refinemode, np_int max_size=0, int target_device=0);
void invert_matrix(dcomplex **mat, np_int size, int &ier, int &maxrefiters, double &accuracygoal, int refinemode, const string& output_path, int jxi488, np_int max_size=0, int target_device=0);

#endif
+4 −2
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
 *
 */

#include <string>

#ifndef INCLUDE_MAGMA_CALLS_H_
#define INCLUDE_MAGMA_CALLS_H_

@@ -57,7 +59,7 @@ void magma_zinvert1(dcomplex * &inva, np_int n, int &jer, int device_id);
 * \param accuracygoal: `double` Accuracy to achieve in iterative refinement, defined as the module of the maximum difference between the identity matrix and the matrix product of the (approximate) inverse times the original matrix. On return, it contains the actually achieved accuracy
 * \param device_id: `int` ID of the device for matrix inversion offloading.
 */
void magma_zinvert_and_refine(dcomplex **mat, np_int n, int &jer, int &maxrefiters, double &accuracygoal, int refinemode, int device_id);
void magma_zinvert_and_refine(dcomplex **mat, np_int n, int &jer, int &maxrefiters, double &accuracygoal, int refinemode, int device_id, const string& output_path, int jxi488);

/*! \brief apply iterative refinement of the solution of a matrix inversion
 *
@@ -71,6 +73,6 @@ void magma_zinvert_and_refine(dcomplex **mat, np_int n, int &jer, int &maxrefite
 * \param accuracygoal: `double` Accuracy to achieve in iterative refinement, defined as the module of the maximum difference between the identity matrix and the matrix product of the (approximate) inverse times the original matrix. On return, it contains the actually achieved accuracy
 * \param device_id: `int` ID of the device for matrix inversion offloading.
 */
void magma_refine(dcomplex *aorig, dcomplex *inva, np_int n, int &jer, int &maxrefiters, double &accuracygoal, int refinemode, int device_id);
void magma_refine(dcomplex *aorig, dcomplex *inva, np_int n, int &jer, int &maxrefiters, double &accuracygoal, int refinemode, int device_id, const string& output_path, int jxi488);

#endif
+1 −1
Original line number Diff line number Diff line
@@ -1480,7 +1480,7 @@ int inclusion_jxi488_cycle(int jxi488, ScattererConfiguration *sconf, GeometryCo
#endif
  // we the accuracygoal in, get the actual accuracy back out
  double actualaccuracy = cid->accuracygoal;
  invert_matrix(cid->am, cid->c1->ndm, jer, cid->maxrefiters, actualaccuracy, cid->refinemode, mxndm, cid->proc_device);
  invert_matrix(cid->am, cid->c1->ndm, jer, cid->maxrefiters, actualaccuracy, cid->refinemode, output_path, jxi488, mxndm, cid->proc_device);
  // in principle, we should check whether the returned actualaccuracy is indeed lower than the accuracygoal, and do something about it if not
#ifdef USE_REFINEMENT
  if (cid->refinemode==2) {
+6 −2
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@
 *
 * \brief Implementation of algebraic functions with different call-backs.
 */

#include <string>
using namespace std;

#ifndef INCLUDE_TYPES_H_
#include "../include/types.h"
#endif
@@ -58,14 +62,14 @@ extern void lucin(dcomplex **mat, np_int max_size, np_int size, int &ier);

using namespace std;

void invert_matrix(dcomplex **mat, np_int size, int &ier, int &maxrefiters, double &accuracygoal, int refinemode, np_int max_size, int target_device) {
void invert_matrix(dcomplex **mat, np_int size, int &ier, int &maxrefiters, double &accuracygoal, int refinemode, const string& output_path, int jxi488, np_int max_size, int target_device) {
  ier = 0;
#ifdef USE_MAGMA
#ifdef USE_REFINEMENT
  // try using the iterative refinement to obtain a more accurate solution
  // we pass to magma_zinvert_and_refine() the accuracygoal in, get the actual
  // accuracy back out
  magma_zinvert_and_refine(mat, size, ier, maxrefiters, accuracygoal, refinemode, target_device);
  magma_zinvert_and_refine(mat, size, ier, maxrefiters, accuracygoal, refinemode, target_device, output_path, jxi488);
#else
  magma_zinvert(mat, size, ier, target_device);
#endif  
Loading