accelerInt  v0.1
rational_approximant.cu
Go to the documentation of this file.
1 
11 //cf
12 #include <cuComplex.h>
13 #include "header.cuh"
14 extern "C" {
15 #include "cf.h"
16 }
17 #include "solver_options.cuh"
18 #include "gpu_macros.cuh"
19 
20 __device__ __constant__ cuDoubleComplex poles[N_RA];
21 __device__ __constant__ cuDoubleComplex res[N_RA];
22 
27 {
28  // get poles and residues for rational approximant to matrix exponential
29  double *poles_r = (double *) calloc (N_RA, sizeof(double));
30  double *poles_i = (double *) calloc (N_RA, sizeof(double));
31  double *res_r = (double *) calloc (N_RA, sizeof(double));
32  double *res_i = (double *) calloc (N_RA, sizeof(double));
33 
34  cf (N_RA, poles_r, poles_i, res_r, res_i);
35 
36  cuDoubleComplex polesHost[N_RA];
37  cuDoubleComplex resHost[N_RA];
38 
39  for (int i = 0; i < N_RA; ++i)
40  {
41  polesHost[i] = make_cuDoubleComplex(poles_r[i], poles_i[i]);
42  resHost[i] = make_cuDoubleComplex(res_r[i], res_i[i]);
43  }
44 
45  // free memory
46  free (poles_r);
47  free (poles_i);
48  free (res_r);
49  free (res_i);
50 
51  //copy to GPU memory
52  cudaErrorCheck( cudaMemcpyToSymbol (poles, polesHost, N_RA * sizeof(cuDoubleComplex), 0, cudaMemcpyHostToDevice) );
53  cudaErrorCheck( cudaMemcpyToSymbol (res, resHost, N_RA * sizeof(cuDoubleComplex), 0, cudaMemcpyHostToDevice) );
54 }
void cf(int n, double *poles_r, double *poles_i, double *res_r, double *res_i)
Function that calculates the poles and residuals of best rational (partial fraction) approximant to t...
Definition: cf.c:41
Defines some simple macros to simplify GPU indexing.
#define N_RA
void find_poles_and_residuals()
get poles and residues for rational approximant to matrix exponential
__device__ __constant__ cuDoubleComplex res[N_RA]
__device__ __constant__ cuDoubleComplex poles[N_RA]
An example header file that defines system size, memory functions and other required methods for inte...
#define cudaErrorCheck(ans)
Definition: gpu_macros.cuh:26
A file generated by Scons that specifies various options to the solvers.
Header definition for rational approximation to matrix exponential.