Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
AlephCuda.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7#ifndef _IALEPH_CUDA_H_
8#define _IALEPH_CUDA_H_
9
10#include <set>
11#include <vector>
12#include <algorithm>
13#include <stdio.h>
14
15#include <cuda.h>
16#include <cublas.h>
17#include <cuda_runtime.h>
18
19#define CNC_ASSERT(isOK, message) \
20 if (!(isOK)) { \
21 (void)printf("ERROR!! Assert '%s' failed\n%s\n", \
22 #isOK, message); \
23 return false ; \
24 }
25
26//---------------------------------------------------------------------------//
27
28template<class T, class S> inline S * CNCallocate_and_copy ( const T * in, int size ) {
29
30 S * out = new S[size] ;
31 for ( int i=0; i<size; i++ ) {
32 out[i] = (S)in[i] ;
33 }
34 return out ;
35}
36
37//---------------------------------------------------------------------------//
38
39template <class T> T* CNCallocate ( long number ) {
40 return new T[number] ;
41}
42
43//---------------------------------------------------------------------------//
44
45template <class T> void CNCdeallocate ( T*& addr ) {
46 delete[] addr ;
47 addr = NULL ; // makes it possible to track
48 // access to deallocated memory.
49}
50
51//---------------------------------------------------------------------------//
52
53template <class T> void CNCreallocate (T*& addr, long old_number, long new_number) {
54 T* new_addr = new T[new_number] ;
55 for(int i=0; i<old_number; i++) {
56 new_addr[i] = addr[i] ;
57 }
58 delete[] addr ;
59 addr = new_addr ;
60}
61
62#include "arcane/aleph/cuda/AlephCudaVector.h"
63#include "arcane/aleph/cuda/AlephCudaMatrix.h"
64#include "arcane/aleph/cuda/AlephCudaMatrixCrs.h"
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69ARCANE_BEGIN_NAMESPACE
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
74class Cuda{
75public:
76 Cuda();
77 ~Cuda();
78 void cnc_cuda_set_dim_vec_from_n(long);
79 void convert_matrix(const CNC_Matrix& rhs, CNC_MatrixCRS<double>& A, bool separate_diag );
80 bool solve(CNC_MatrixCRS<double> &A,
81 const CNC_Vector<double> &b,
83 const unsigned int nb_iter_max,
84 const double epsilon,
85 Integer& nb_iteration,
86 Real* residual_norm) ;
87 void cublas_get_error(cublasStatus_t);
88 public:
89 void *gpu_r ;
90 void *gpu_d ;
91 void *gpu_h ;
92 void *gpu_Ad ;
93 void *gpu_diag_inv;
94 void *gpu_b;
95 void *gpu_x;
96 void *gpu_temp;
97 void *gpu_temp0;
98 void *gpu_temp1;
99 void *gpu_res0;
100};
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
105ARCANE_END_NAMESPACE
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
109
110#endif //_IALEPH_CUDA_H_
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120