Skip to content
Snippets Groups Projects
Commit a56b6e30 authored by Tomas Sobotik's avatar Tomas Sobotik
Browse files

Improved CUDA support, still some problems remaining.

parent b71adb55
No related branches found
No related tags found
No related merge requests found
...@@ -112,6 +112,7 @@ public: ...@@ -112,6 +112,7 @@ public:
int*boundaryConditions_cuda; int*boundaryConditions_cuda;
int* unusedCell_cuda; int* unusedCell_cuda;
int* calculationsCount_cuda; int* calculationsCount_cuda;
double* tmpw;
//MeshTypeCUDA mesh_cuda, subMesh_cuda; //MeshTypeCUDA mesh_cuda, subMesh_cuda;
//SchemeDevice scheme_cuda; //SchemeDevice scheme_cuda;
//double delta_cuda, tau0_cuda, stopTime_cuda,cflCondition_cuda; //double delta_cuda, tau0_cuda, stopTime_cuda,cflCondition_cuda;
...@@ -156,7 +157,7 @@ template <typename SchemeHost, typename SchemeDevice, typename Device> ...@@ -156,7 +157,7 @@ template <typename SchemeHost, typename SchemeDevice, typename Device>
__global__ void initRunCUDA(tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int >* caller); __global__ void initRunCUDA(tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int >* caller);
template <typename SchemeHost, typename SchemeDevice, typename Device> template <typename SchemeHost, typename SchemeDevice, typename Device>
__global__ void initCUDA( tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int >* cudaSolver, double* ptr); __global__ void initCUDA( tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int >* cudaSolver, double* ptr, bool * ptr2);
template <typename SchemeHost, typename SchemeDevice, typename Device> template <typename SchemeHost, typename SchemeDevice, typename Device>
__global__ void synchronizeCUDA(tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int >* cudaSolver); __global__ void synchronizeCUDA(tnlParallelEikonalSolver<SchemeHost, SchemeDevice, Device, double, int >* cudaSolver);
......
...@@ -149,16 +149,16 @@ public: ...@@ -149,16 +149,16 @@ public:
const RealType& time, const RealType& time,
const IndexType boundaryCondition ) const; const IndexType boundaryCondition ) const;
template< typename Vector >
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
__device__ __host__ __device__
#endif #endif
Real getValue( const MeshType& mesh, Real getValueDev( const MeshType& mesh,
const IndexType cellIndex, const IndexType cellIndex,
const CoordinatesType& coordinates, const CoordinatesType& coordinates,
const RealType* u, const RealType* u,
const RealType& time, const RealType& time,
const IndexType boundaryCondition ) const; const IndexType boundaryCondition) const;
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
__device__ __host__ __device__ __host__
#endif #endif
......
...@@ -145,6 +145,7 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re ...@@ -145,6 +145,7 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re
const IndexType boundaryCondition ) const const IndexType boundaryCondition ) const
{ {
if ( ((coordinates.x() == 0 && (boundaryCondition & 4)) or if ( ((coordinates.x() == 0 && (boundaryCondition & 4)) or
(coordinates.x() == mesh.getDimensions().x() - 1 && (boundaryCondition & 2)) or (coordinates.x() == mesh.getDimensions().x() - 1 && (boundaryCondition & 2)) or
(coordinates.y() == 0 && (boundaryCondition & 8)) or (coordinates.y() == 0 && (boundaryCondition & 8)) or
...@@ -165,6 +166,7 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re ...@@ -165,6 +166,7 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re
signui = sign(u[cellIndex],epsilon); signui = sign(u[cellIndex],epsilon);
if(fabs(u[cellIndex]) < acc) return 0.0; if(fabs(u[cellIndex]) < acc) return 0.0;
if(signui > 0.0) if(signui > 0.0)
...@@ -296,18 +298,19 @@ template< typename MeshReal, ...@@ -296,18 +298,19 @@ template< typename MeshReal,
typename MeshIndex, typename MeshIndex,
typename Real, typename Real,
typename Index > typename Index >
template< typename Vector >
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
__device__ __host__ __device__
#endif #endif
Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: getValue( const MeshType& mesh, Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: getValueDev( const MeshType& mesh,
const IndexType cellIndex, const IndexType cellIndex,
const CoordinatesType& coordinates, const CoordinatesType& coordinates,
const Real* u, const Real* u,
const Real& time, const Real& time,
const IndexType boundaryCondition ) const const IndexType boundaryCondition) const
{ {
if ( ((coordinates.x() == 0 && (boundaryCondition & 4)) or if ( ((coordinates.x() == 0 && (boundaryCondition & 4)) or
(coordinates.x() == mesh.getDimensions().x() - 1 && (boundaryCondition & 2)) or (coordinates.x() == mesh.getDimensions().x() - 1 && (boundaryCondition & 2)) or
(coordinates.y() == 0 && (boundaryCondition & 8)) or (coordinates.y() == 0 && (boundaryCondition & 8)) or
...@@ -327,8 +330,10 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re ...@@ -327,8 +330,10 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re
RealType nabla, xb, xf, yb, yf, signui; RealType nabla, xb, xf, yb, yf, signui;
signui = sign(u[cellIndex],epsilon); signui = sign(u[cellIndex],epsilon);
#ifdef HAVE_CUDA
if(fabs(u[cellIndex]) < acc) return 0.0; //printf("%d : %d ;;;; %d : %d\n",threadIdx.x, coordinates.x(), threadIdx.y,coordinates.y());
#endif
//if(fabs(u[cellIndex]) < acc) return 0.0;
if(signui > 0.0) if(signui > 0.0)
{ {
...@@ -379,8 +384,8 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re ...@@ -379,8 +384,8 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re
yb = 0.0; yb = 0.0;
nabla = sqrt (xf*xf + xb*xb + yf*yf + yb*yb ); nabla = sqrt (xf*xf + xb*xb + yf*yf + yb*yb );
if(fabs(1.0-nabla) < acc) // if(fabs(1.0-nabla) < acc)
return 0.0; // return 0.0;
return signui*(1.0 - nabla); return signui*(1.0 - nabla);
} }
else if (signui < 0.0) else if (signui < 0.0)
...@@ -435,8 +440,8 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re ...@@ -435,8 +440,8 @@ Real parallelGodunovEikonalScheme< tnlGrid< 2, MeshReal, Device, MeshIndex >, Re
nabla = sqrt (xf*xf + xb*xb + yf*yf + yb*yb ); nabla = sqrt (xf*xf + xb*xb + yf*yf + yb*yb );
if(fabs(1.0-nabla) < acc) // if(fabs(1.0-nabla) < acc)
return 0.0; // return 0.0;
return signui*(1.0 - nabla); return signui*(1.0 - nabla);
} }
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment