33class AlephVectorCnc:
public IAlephVector{
37 Integer index):IAlephVector(tm,kernel,index),
39 debug()<<
"\t\t[AlephVectorCnc::AlephVectorCnc] new AlephVectorCnc";
44void AlephVectorCreate(
void){
45 debug()<<
"\t\t[AlephVectorCnc::AlephVectorCreate] CNC VectorCreate 0-"<<m_kernel->topology()->nb_row_size()-1;
46 m_cnc_vector.allocate(m_kernel->topology()->nb_row_size());
47 debug()<<
"\t\t[AlephVectorCnc::AlephVectorCreate] done";
52void AlephVectorSet(
const double *bfr_val,
const int *bfr_idx,
Integer size){
53 debug()<<
"\t\t[AlephVectorCnc::AlephVectorSet]";
55 m_cnc_vector[bfr_idx[i]] = bfr_val[i];
61int AlephVectorAssemble(
void){
67void AlephVectorGet(
double *bfr_val,
const int *bfr_idx,
Integer size){
68 debug()<<
"\t\t[AlephVectorCnc::AlephVectorGet]";
70 bfr_val[i]=m_cnc_vector[bfr_idx[i]];
76void writeToFile(
const String filename){
77 debug()<<
"\t\t[AlephVectorCnc::writeToFile]";
89class AlephMatrixCnc:
public IAlephMatrix{
98 Integer index):IAlephMatrix(tm,kernel,index),
102 has_been_allocated_on_gpu(
false){
103 debug()<<
"\t\t[AlephMatrixCnc::AlephMatrixCnc] new SolverMatrixCnc";
111 debug()<<
"\t\t[AlephMatrixCnc::~AlephMatrixCnc] DELETE SolverMatrixCnc";
112 m_smcrs.gpu_deallocate();
118void AlephMatrixCreate(
void){
119 debug()<<
"\t\t[AlephMatrixCnc::AlephMatrixCreate] CNC MatrixCreate";
120 m_cnc_matrix.allocate(m_kernel->topology()->nb_row_size(),
121 m_kernel->topology()->nb_row_size(),
124 m_cuda.cnc_cuda_set_dim_vec_from_n(m_kernel->topology()->nb_row_size());
129void AlephMatrixSetFilled(
bool){}
133int AlephMatrixAssemble(
void){
134 debug()<<
"\t\t[AlephMatrixCnc::AlephMatrixConfigure] AlephMatrixConfigure";
135 m_cuda.convert_matrix(m_cnc_matrix, m_smcrs,
false);
136 if (has_been_allocated_on_gpu==
false){
137 m_smcrs.gpu_allocate();
138 has_been_allocated_on_gpu=
true;
145void AlephMatrixFill(
int nrows,
int *rows,
int *cols,
double *values){
146 debug()<<
"\t\t[AlephMatrixCnc::AlephMatrixFill]";
147 for(
int i=0,iMax=m_kernel->topology()->gathered_nb_setValued(m_kernel->rank());i<iMax;++i){
148 m_cnc_matrix.add(rows[i],
152 debug()<<
"\t\t[AlephMatrixCnc::AlephMatrixFill] done";
172 const String func_name(
"SolverMatrixCnc::solve");
174 debug()<<
"\t\t[AlephMatrixCnc::AlephMatrixSolve] Getting X & B";
178 debug()<<
"\t\t[AlephMatrixCnc::AlephMatrixSolve] Flushing X";
182 unsigned int cnc_nb_iter_max = solver_param->maxIter();
183 double cnc_epsilon = solver_param->epsilon();
185 debug()<<
"\t\t[AlephMatrixCnc::AlephMatrixSolve] Launching CNC_Solver";
186 m_cuda.solve(m_smcrs, *B, *X, cnc_nb_iter_max, cnc_epsilon, nb_iteration, residual_norm);
193 if ( nb_iteration == solver_param->maxIter() && solver_param->stopErrorStrategy()){
194 info() <<
"\n============================================================";
195 info() <<
"\nCette erreur est retournée après " << nb_iteration <<
"\n";
196 info() <<
"\nOn a atteind le nombre max d'itérations du solveur.";
197 info() <<
"\nIl est possible de demander au code de ne pas tenir compte de cette erreur.";
198 info() <<
"\nVoir la documentation du jeu de données concernant le service solveur.";
199 info() <<
"\n======================================================";
200 throw Exception(
"AlephMatrixCnc::Solve",
"On a atteind le nombre max d'itérations du solveur");
207void writeToFile(
const String filename){
215 bool has_been_allocated_on_gpu;