Commit 4685ffa0 authored by MIJIEUX Thomas's avatar MIJIEUX Thomas

remove support for alpha and beta in mvp callback prototype

parent 3e13d023
# - Try to find fabulous (C-api)
#
# If this script have difficulties to find fabulous, you can try to help
# it by setting the variable FABULOUS_DIR to the prefix path where fabulous
# it by setting the variable FABULOUS_PREFIX to the prefix path where fabulous
# was installed
#
# Once done this will define
......@@ -44,11 +44,11 @@ endmacro()
find_package(PkgConfig QUIET)
set(ENV_FABULOUS_DIR "$ENV{FABULOUS_DIR}")
set(ENV_FABULOUS_PREFIX "$ENV{FABULOUS_PREFIX}")
set(ENV_FABULOUS_INCDIR "$ENV{FABULOUS_INCDIR}")
set(ENV_FABULOUS_LIBDIR "$ENV{FABULOUS_LIBDIR}")
set(FABULOUS_GIVEN_BY_USER "FALSE")
if ( FABULOUS_DIR OR ENV_FABULOUS_DIR
if ( FABULOUS_PREFIX OR ENV_FABULOUS_PREFIX
OR ( FABULOUS_INCDIR AND FABULOUS_LIBDIR )
OR ( ENV_FABULOUS_INCDIR AND ENV_FABULOUS_LIBDIR ) )
set(FABULOUS_GIVEN_BY_USER "TRUE")
......@@ -118,20 +118,20 @@ if ((NOT FABULOUS_FOUND) AND (FABULOUS_GIVEN_BY_USER OR (NOT PKG_CONFIG_FOUND)))
find_library(FABULOUS_STATIC_LIBRARY NAMES libfabulous.a HINTS ${FABULOUS_LIBDIR})
find_library(FABULOUS_SHARED_LIBRARY NAMES libfabulous.so HINTS ${FABULOUS_LIBDIR})
else()
if (ENV_FABULOUS_DIR AND NOT FABULOUS_DIR)
set(FABULOUS_DIR "${ENV_FABULOUS_DIR}" CACHE PATH "Installation prefix where fabulous is installed")
if (ENV_FABULOUS_PREFIX AND NOT FABULOUS_PREFIX)
set(FABULOUS_PREFIX "${ENV_FABULOUS_PREFIX}" CACHE PATH "Installation prefix where fabulous is installed")
else()
set(FABULOUS_DIR "${FABULOUS_DIR}" CACHE PATH "Installation prefix where fabulous is installed")
set(FABULOUS_PREFIX "${FABULOUS_PREFIX}" CACHE PATH "Installation prefix where fabulous is installed")
endif()
find_path(FABULOUS_INCLUDE_DIRS NAMES fabulous.h
HINTS ${FABULOUS_DIR}
HINTS ${FABULOUS_PREFIX}
PATH_SUFFIXES include include/fabulous)
find_library(FABULOUS_STATIC_LIBRARY NAMES libfabulous.a
HINTS ${FABULOUS_DIR}
HINTS ${FABULOUS_PREFIX}
PATH_SUFFIXES lib lib32 lib64 lib/fabulous lib32/fabulous lib64/fabulous)
find_library(FABULOUS_SHARED_LIBRARY NAMES libfabulous.so
HINTS ${FABULOUS_DIR}
HINTS ${FABULOUS_PREFIX}
PATH_SUFFIXES lib lib32 lib64 lib/fabulous lib32/fabulous lib64/fabulous)
endif()
......
......@@ -82,7 +82,7 @@ private:
o << "#######################################################\n";
std::stringstream ss;
ss << algo << "BGCR" ;
ss << algo;
int l = (55-(ss.str().length()+2))/2;
o << std::string(l, '#') << " " << ss.str() << " " << std::string(l, '#') << "\n";
o << "#######################################################\n";
......
......@@ -83,7 +83,7 @@ private:
o << "#######################################################\n";
std::stringstream ss;
ss << algo << "BGMRES" << get_type(restart_param);
ss << algo << get_type(restart_param);
int l = (55-(ss.str().length()+2))/2;
o << std::string(l, '#') << " " << ss.str() << " " << std::string(l, '#') << "\n";
o << "#######################################################\n";
......
......@@ -205,7 +205,13 @@ private:
_logger.notify_iteration_begin(_iteration_count, _size_krylov_space);
RJ.copy(B);
XJ.copy(X);
A.MatBlockVect(X, RJ, S{-1.0}, S{1.0}); // R <- B - A*X
A.MatBlockVect(X, RJ); // R <- B - A*X
for (int j = 0; j < RJ.get_nb_col(); ++j) {
for (int i = 0; i < RJ.get_nb_row(); ++i) {
RJ.at(i, j) = B.at(i, j) - RJ.at(i, j); // R -> B - A*X
}
}
_nb_mvp += X.get_nb_col();
auto MinMaxConv = get_not_converged(A, RJ, XJ, X, J, J_work, epsilon);
......
......@@ -98,7 +98,13 @@ private:
{
R.copy(B); // R <- B
_logger.notify_mvp_begin();
A.MatBlockVect(X, R, S{-1.0}, S{1.0}); // R <- B-A*X
A.MatBlockVect(X, R); // R <- A*X
for (int j = 0; j < R.get_nb_col(); ++j) {
for (int i = 0; i < R.get_nb_row(); ++i) {
R.at(i, j) = B.at(i, j) - R.at(i, j); // R -> B - A*X
}
}
_logger.notify_mvp_end();
_nb_mvp += X.get_nb_col();
}
......
......@@ -110,7 +110,12 @@ private:
{
R.copy(B); // R <- B
_logger.notify_mvp_begin();
A.MatBlockVect(X, R, S{-1.0}, S{1.0}); // R <- B-A*X
A.MatBlockVect(X, R); // R <- A*X
for (int j = 0; j < R.get_nb_col(); ++j) {
for (int i = 0; i < R.get_nb_row(); ++i) {
R.at(i, j) = B.at(i, j) - R.at(i, j); // R -> B - A*X
}
}
_logger.notify_mvp_end();
_nb_mvp += X.get_nb_col();
}
......
......@@ -128,7 +128,12 @@ private:
{
R.copy(B); // R <- B
_logger.notify_mvp_begin();
A.MatBlockVect(X, R, S{-1.0}, S{1.0}); // R <- B-A*X
A.MatBlockVect(X, R); // R <- A*X
for (int j = 0; j < R.get_nb_col(); ++j) {
for (int i = 0; i < R.get_nb_row(); ++i) {
R.at(i, j) = B.at(i, j) - R.at(i, j); // R -> B - A*X
}
}
_logger.notify_mvp_end();
_nb_mvp += X.get_nb_col();
}
......
......@@ -58,7 +58,6 @@ int64_t InPlaceQRFactoMGS_User(Block<S> &Q, Block<S> &R, const Matrix &A)
R.at(j, j) = norm;
if (norm == 0.0) {
#ifndef FABULOUS_IB_EXACT_BREAKDOWN_CONTINUE
// Q.display();
FABULOUS_NOTE("column [j="<<j<<"]");
FABULOUS_FATAL_ERROR("Rank loss in block candidate for extending the Krylov Space");
#else
......
......@@ -56,11 +56,12 @@ public:
FABULOUS_NOTE("Have you called fabulous_set_mvp() ?!");
FABULOUS_FATAL_ERROR("missing user matrix product; cannot recover");
}
FABULOUS_ASSERT( alpha == S{1.0} && beta == S{0.0} );
return _user_mvp(
_user_env, input.get_nb_col(),
input.get_ptr(), input.get_leading_dim(),
output.get_ptr(), output.get_leading_dim(),
&alpha, &beta
output.get_ptr(), output.get_leading_dim()
);
}
......
......@@ -94,7 +94,7 @@ typedef enum fabulous_orthoproc fabulous_orthoproc;
* \brief User defined function to compute
* product between user's %Matrix (A) and %Matrix given in argument (X)
*
* Operation to be performed: B := alpha * A * X + beta * B
* Operation to be performed: B := A * X
*
* \param user_data same pointer that was passed to fabulous_create()
* \param N number of vector in the matrices X and B.
......@@ -107,8 +107,6 @@ typedef enum fabulous_orthoproc fabulous_orthoproc;
* Values are stored in Column Major layout.
* \param ldb leading dimension of B
*
* \param[in] alpha scalar coefficient multipler for A*X
* \param[in] beta scalar coefficient multipler for B
* \return numbers of flops performed by the operation
* for (optionnal) perfomance analysis
*
......@@ -116,8 +114,7 @@ typedef enum fabulous_orthoproc fabulous_orthoproc;
*/
typedef int64_t (*fabulous_mvp_t)(void *user_data, int N,
const void *X, int ldx,
void *B, int ldb,
void *alpha, void *beta);
void *B, int ldb);
/**
* \brief User defined function to compute product between
......
......@@ -42,7 +42,7 @@ public:
// B := A * X
int64_t MatBlockVect(const Block &X, Block &B,
S alpha = S{1.0}, S beta = S{0.0}) const
S alpha = S{1.0}, S beta = S{0.0}) const
{
int M = B.get_nb_row();
int N = B.get_nb_col();
......@@ -69,9 +69,9 @@ public:
// C := A^{H} * B
int64_t DotProduct(int M, int N,
const S *A, int lda,
const S *B, int ldb,
S *C, int ldc) const
const S *A, int lda,
const S *B, int ldb,
S *C, int ldc) const
{
int dim = _data.get_nb_row();
::fabulous::lapacke::Tgemm(M, N, dim, A, lda, B, ldb, C, ldc);
......
......@@ -29,15 +29,14 @@ typedef struct {
/** \brief Matrix x BlockOfVector product CALLBACK */
static int64_t mvp( void *user_env, int N,
const void *XX, int ldx,
void *BB, int ldb,
void *alpha_, void *beta_)
void *BB, int ldb)
{
Matrix *mat = user_env;
int dim = mat->dim;
double *B = BB;
const double *X = XX;
double alpha = *(double*) alpha_;
double beta = *(double*) beta_;
const double alpha = 1.0;
const double beta = 0.0;
for (int j = 0; j < N; ++j)
for (int i = 0; i < dim; ++i)
......
......@@ -49,21 +49,22 @@ typedef struct user_env {
/** \brief Matrix x BlockOfVector product CALLBACK */
static int64_t mvp( void *user_env, int N,
const void *XX, int ldx,
void *BB, int ldb,
void *alpha, void *beta)
void *BB, int ldb)
{
Env *env = user_env;
Matrix *mat = env->mat;
int dim = mat->dim1;
const double complex *X = XX;
double complex *B = BB;
const double complex one = 1.0;
const double complex zero = 0.0;
cblas_zgemm(
CblasColMajor, CblasNoTrans, CblasNoTrans,
dim, N, dim,
alpha, mat->datas, dim,
&one, mat->datas, dim,
X, ldx,
beta, B, ldb
&zero, B, ldb
);
return (8L*dim + 12L)* N * dim;
}
......@@ -160,7 +161,7 @@ static Matrix* load_matrix_from_file(const char *filename)
exit(EXIT_FAILURE);
}
Matrix *m = calloc(sizeof*m, 1);
Matrix *m = calloc(1, sizeof*m);
read_IW_file(m, file, filename);
fclose(file);
return m;
......@@ -169,7 +170,7 @@ static Matrix* load_matrix_from_file(const char *filename)
/** \brief allocate and initialize the user environement structure */
static Env* create_user_env(Matrix *A, RightPrecond *rpc)
{
Env *env = calloc(sizeof*env, 1);
Env *env = calloc(1, sizeof*env);
env->mat = A;
env->right_precond = rpc;
return env;
......@@ -178,7 +179,7 @@ static Env* create_user_env(Matrix *A, RightPrecond *rpc)
/** \brief allocate and initialize the right preconditioner structure */
static RightPrecond* create_right_precond(Matrix *mat)
{
RightPrecond *rpc = calloc(sizeof*rpc, 1);
RightPrecond *rpc = calloc(1, sizeof*rpc);
rpc->datas = malloc(mat->dim1 * sizeof rpc->datas[0]);
rpc->dim = mat->dim1;
......@@ -264,7 +265,7 @@ int main(int argc, char *argv[])
const double *historic = fabulous_get_logs(&nb_iter, handle);
write_down_convergence("./ConvergenceHisto.txt", nb_iter, historic);
//Free the handle
// Free the handle
fabulous_destroy(handle);
free(rpc->datas);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment