32class AlephVectorCnc :
public IAlephVector
39 : IAlephVector(tm, kernel, index)
42 debug() <<
"\t\t[AlephVectorCnc::AlephVectorCnc] new AlephVectorCnc";
47 void AlephVectorCreate(
void)
49 debug() <<
"\t\t[AlephVectorCnc::AlephVectorCreate] CNC VectorCreate 0-" << m_kernel->topology()->nb_row_size() - 1;
50 m_cnc_vector.allocate(m_kernel->topology()->nb_row_size());
51 debug() <<
"\t\t[AlephVectorCnc::AlephVectorCreate] done";
56 void AlephVectorSet(
const double* bfr_val,
const int* bfr_idx,
Integer size)
58 debug() <<
"\t\t[AlephVectorCnc::AlephVectorSet]";
59 for (
Integer i = 0; i < size; ++i) {
60 m_cnc_vector[bfr_idx[i]] = bfr_val[i];
66 int AlephVectorAssemble(
void)
73 void AlephVectorGet(
double* bfr_val,
const int* bfr_idx,
Integer size)
75 debug() <<
"\t\t[AlephVectorCnc::AlephVectorGet]";
76 for (
Integer i = 0; i < size; ++i) {
77 bfr_val[i] = m_cnc_vector[bfr_idx[i]];
83 void writeToFile(
const String filename)
85 debug() <<
"\t\t[AlephVectorCnc::writeToFile]";
97class AlephMatrixCnc :
public IAlephMatrix
107 : IAlephMatrix(tm, kernel, index)
111 , has_been_allocated_on_gpu(
false)
113 debug() <<
"\t\t[AlephMatrixCnc::AlephMatrixCnc] new SolverMatrixCnc";
121 debug() <<
"\t\t[AlephMatrixCnc::~AlephMatrixCnc] DELETE SolverMatrixCnc";
122 m_smcrs.gpu_deallocate();
127 void AlephMatrixCreate(
void)
129 debug() <<
"\t\t[AlephMatrixCnc::AlephMatrixCreate] CNC MatrixCreate";
130 m_cnc_matrix.allocate(m_kernel->topology()->nb_row_size(),
131 m_kernel->topology()->nb_row_size(),
134 m_cuda.cnc_cuda_set_dim_vec_from_n(m_kernel->topology()->nb_row_size());
139 void AlephMatrixSetFilled(
bool) {}
143 int AlephMatrixAssemble(
void)
145 debug() <<
"\t\t[AlephMatrixCnc::AlephMatrixConfigure] AlephMatrixConfigure";
146 m_cuda.convert_matrix(m_cnc_matrix, m_smcrs,
false);
147 if (has_been_allocated_on_gpu ==
false) {
148 m_smcrs.gpu_allocate();
149 has_been_allocated_on_gpu =
true;
156 void AlephMatrixFill(
int nrows,
int* rows,
int* cols,
double* values)
158 debug() <<
"\t\t[AlephMatrixCnc::AlephMatrixFill]";
159 for (
int i = 0, iMax = m_kernel->topology()->gathered_nb_setValued(m_kernel->rank()); i < iMax; ++i) {
160 m_cnc_matrix.add(rows[i],
164 debug() <<
"\t\t[AlephMatrixCnc::AlephMatrixFill] done";
185 const String func_name(
"SolverMatrixCnc::solve");
187 debug() <<
"\t\t[AlephMatrixCnc::AlephMatrixSolve] Getting X & B";
191 debug() <<
"\t\t[AlephMatrixCnc::AlephMatrixSolve] Flushing X";
195 unsigned int cnc_nb_iter_max = solver_param->maxIter();
196 double cnc_epsilon = solver_param->epsilon();
198 debug() <<
"\t\t[AlephMatrixCnc::AlephMatrixSolve] Launching CNC_Solver";
199 m_cuda.solve(m_smcrs, *B, *X, cnc_nb_iter_max, cnc_epsilon, nb_iteration, residual_norm);
206 if (nb_iteration == solver_param->maxIter() && solver_param->stopErrorStrategy()) {
207 info() <<
"\n============================================================";
208 info() <<
"\nThis error is returned after " << nb_iteration <<
"\n";
209 info() <<
"\nThe maximum number of solver iterations has been reached.";
210 info() <<
"\nIt is possible to ask the code not to consider this error.";
211 info() <<
"\nSee the dataset documentation regarding the solver service.";
212 info() <<
"\n======================================================";
213 throw Exception(
"AlephMatrixCnc::Solve",
"The maximum number of solver iterations has been reached");
220 void writeToFile(
const String filename)
230 bool has_been_allocated_on_gpu;