TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Solv_cuDSS.h
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Solv_cuDSS_included
17#define Solv_cuDSS_included
18
19#include <Solv_Externe.h>
20#include <Motcle.h>
21#include <Device.h>
22#include <Matrice_Morse.h>
23class EChaine;
24
25#ifdef TRUST_USE_CUDA
26#include <cudss.h>
27#include <cuda.h>
28#define cuDSS_
29#endif
30
32{
33 Declare_instanciable_sans_constructeur_ni_destructeur(Solv_cuDSS);
34
35public :
37 Solv_cuDSS(const Solv_cuDSS&);
38 ~Solv_cuDSS() override;
39
40 inline int solveur_direct() const override { return 1; };
41 inline int resoudre_systeme(const Matrice_Base& a, const DoubleVect& b, DoubleVect& x, int niter_max) override { return resoudre_systeme(a,b,x); };
42
43 int resoudre_systeme(const Matrice_Base& a, const DoubleVect& b, DoubleVect& x) override;
44
45private :
46 void Create_objects(const Matrice_Morse&);
47 void set_pointers_A(const Matrice_Morse&);
48 void set_pointers_xb(const DoubleVect& bvect, DoubleVect& xvect);
49
50 Matrice_Morse csr_;
51
52#ifdef cuDSS_
53 int nrhs=1; //For batched solve
54 int n=-1;
55 int nnz=-1;
56
57 double * b_values_d=nullptr;
58 double * x_values_d=nullptr;
59 int * csr_offsets_d=nullptr;
60 int * csr_columns_d =nullptr;
61 double * csr_values_d =nullptr;
62
63 bool Axb_are_built = false;
64 bool solver_is_built = false;
65 bool first_solve=true;
66
67 cudssAlgType_t reorder_alg = CUDSS_ALG_DEFAULT; //Can be 0->5. Default / recommended is 0
68 cudssConfig_t solverConfig;
69 cudssHandle_t handle;
70 cudssData_t solverData;
71 cudssMatrixType_t mtype;
72 cudssMatrixViewType_t mview;
73 cudssMatrix_t x, b, A;
74 cudssIndexBase_t base = CUDSS_BASE_ONE; //Fortran indexing
75 cudssStatus_t status;
76#endif
77};
78
79#endif
80
81
Une entree dont la source est une chaine de caracteres.
Definition EChaine.h:31
Classe Matrice_Base Classe de base de la hierarchie des matrices.
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
~Solv_cuDSS() override
int resoudre_systeme(const Matrice_Base &a, const DoubleVect &b, DoubleVect &x, int niter_max) override
Definition Solv_cuDSS.h:41
int solveur_direct() const override
Definition Solv_cuDSS.h:40