Skip to content
Snippets Groups Projects
Commit 5c6b42f6 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed 2D grid traverser for CUDA

parent 20b876ed
No related branches found
No related tags found
No related merge requests found
...@@ -151,11 +151,9 @@ processEntities( ...@@ -151,11 +151,9 @@ processEntities(
CoordinatesType* kernelEnd = Devices::Cuda::passToDevice( end ); CoordinatesType* kernelEnd = Devices::Cuda::passToDevice( end );
CoordinatesType* kernelEntityOrientation = Devices::Cuda::passToDevice( entityOrientation ); CoordinatesType* kernelEntityOrientation = Devices::Cuda::passToDevice( entityOrientation );
CoordinatesType* kernelEntityBasis = Devices::Cuda::passToDevice( entityBasis ); CoordinatesType* kernelEntityBasis = Devices::Cuda::passToDevice( entityBasis );
//typename GridEntity::MeshType* kernelGrid = tnlCuda::passToDevice( *gridPointer ); //typename GridEntity::MeshType* kernelGrid = Devices::Cuda::passToDevice( *gridPointer );
UserData* kernelUserData = Devices::Cuda::passToDevice( userData ); UserData* kernelUserData = Devices::Cuda::passToDevice( userData );
//GridEntity entity( gridPointer.template getData< tnlCuda >(), coordinates, *entityOrientation, *entityBasis );
Devices::Cuda::synchronizeDevice(); Devices::Cuda::synchronizeDevice();
if( processOnlyBoundaryEntities ) if( processOnlyBoundaryEntities )
{ {
...@@ -281,25 +279,24 @@ template< typename Real, ...@@ -281,25 +279,24 @@ template< typename Real,
typename EntitiesProcessor, typename EntitiesProcessor,
bool processOnlyBoundaryEntities > bool processOnlyBoundaryEntities >
__global__ void __global__ void
GridTraverser2D( GridEntity entity, GridTraverser2D(
/*const Meshes::Grid< 2, Real, tnlCuda, Index >* grid,*/ const Meshes::Grid< 2, Real, Devices::Cuda, Index >* grid,
UserData* userData, UserData* userData,
const typename GridEntity::CoordinatesType* begin, const typename GridEntity::CoordinatesType* begin,
const typename GridEntity::CoordinatesType* end, const typename GridEntity::CoordinatesType* end,
/*const typename GridEntity::CoordinatesType* entityOrientation, const typename GridEntity::CoordinatesType* entityOrientation,
const typename GridEntity::CoordinatesType* entityBasis,*/ const typename GridEntity::CoordinatesType* entityBasis,
const Index gridXIdx, const Index gridXIdx,
const Index gridYIdx ) const Index gridYIdx )
{ {
typedef Meshes::Grid< 2, Real, Devices::Cuda, Index > GridType; typedef Meshes::Grid< 2, Real, Devices::Cuda, Index > GridType;
typename GridType::CoordinatesType coordinates; typename GridType::CoordinatesType coordinates;
entity.getCoordinates().x() = begin->x() + ( gridXIdx * Devices::Cuda::getMaxGridSize() + blockIdx.x ) * blockDim.x + threadIdx.x; coordinates.x() = begin->x() + ( gridXIdx * Devices::Cuda::getMaxGridSize() + blockIdx.x ) * blockDim.x + threadIdx.x;
entity.getCoordinates().y() = begin->y() + ( gridYIdx * Devices::Cuda::getMaxGridSize() + blockIdx.y ) * blockDim.y + threadIdx.y; coordinates.y() = begin->y() + ( gridYIdx * Devices::Cuda::getMaxGridSize() + blockIdx.y ) * blockDim.y + threadIdx.y;
//GridEntity entity( *grid, coordinates, *entityOrientation, *entityBasis );
GridEntity entity( *grid, coordinates, *entityOrientation, *entityBasis );
if( entity.getCoordinates().x() <= end->x() && if( entity.getCoordinates().x() <= end->x() &&
entity.getCoordinates().y() <= end->y() ) entity.getCoordinates().y() <= end->y() )
{ {
...@@ -337,15 +334,12 @@ processEntities( ...@@ -337,15 +334,12 @@ processEntities(
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
CoordinatesType* kernelBegin = Devices::Cuda::passToDevice( begin ); CoordinatesType* kernelBegin = Devices::Cuda::passToDevice( begin );
CoordinatesType* kernelEnd = Devices::Cuda::passToDevice( end ); CoordinatesType* kernelEnd = Devices::Cuda::passToDevice( end );
//CoordinatesType* kernelEntityOrientation = tnlCuda::passToDevice( entityOrientation ); CoordinatesType* kernelEntityOrientation = Devices::Cuda::passToDevice( entityOrientation );
//CoordinatesType* kernelEntityBasis = tnlCuda::passToDevice( entityBasis ); CoordinatesType* kernelEntityBasis = Devices::Cuda::passToDevice( entityBasis );
//typename GridEntity::MeshType* kernelGrid = tnlCuda::passToDevice( *gridPointer ); //typename GridEntity::MeshType* kernelGrid = Devices::Cuda::passToDevice( *gridPointer );
UserData* kernelUserData = Devices::Cuda::passToDevice( userData ); UserData* kernelUserData = Devices::Cuda::passToDevice( userData );
checkCudaDevice; checkCudaDevice;
CoordinatesType coordinates( 0 );
GridEntity entity( gridPointer.template getData< Devices::Cuda >(), coordinates, entityOrientation, entityBasis );
dim3 cudaBlockSize( 16, 16 ); dim3 cudaBlockSize( 16, 16 );
dim3 cudaBlocks; dim3 cudaBlocks;
cudaBlocks.x = Devices::Cuda::getNumberOfBlocks( end.x() - begin.x() + 1, cudaBlockSize.x ); cudaBlocks.x = Devices::Cuda::getNumberOfBlocks( end.x() - begin.x() + 1, cudaBlockSize.x );
...@@ -353,26 +347,27 @@ processEntities( ...@@ -353,26 +347,27 @@ processEntities(
const IndexType cudaXGrids = Devices::Cuda::getNumberOfGrids( cudaBlocks.x ); const IndexType cudaXGrids = Devices::Cuda::getNumberOfGrids( cudaBlocks.x );
const IndexType cudaYGrids = Devices::Cuda::getNumberOfGrids( cudaBlocks.y ); const IndexType cudaYGrids = Devices::Cuda::getNumberOfGrids( cudaBlocks.y );
Devices::Cuda::synchronizeDevice(); Devices::Cuda::synchronizeDevice();
for( IndexType gridYIdx = 0; gridYIdx < cudaYGrids; gridYIdx ++ ) for( IndexType gridYIdx = 0; gridYIdx < cudaYGrids; gridYIdx ++ )
for( IndexType gridXIdx = 0; gridXIdx < cudaXGrids; gridXIdx ++ ) for( IndexType gridXIdx = 0; gridXIdx < cudaXGrids; gridXIdx ++ )
GridTraverser2D< Real, Index, GridEntity, UserData, EntitiesProcessor, processOnlyBoundaryEntities > GridTraverser2D< Real, Index, GridEntity, UserData, EntitiesProcessor, processOnlyBoundaryEntities >
<<< cudaBlocks, cudaBlockSize >>> <<< cudaBlocks, cudaBlockSize >>>
( entity, ( &gridPointer.template getData< Devices::Cuda >(),
kernelUserData, kernelUserData,
kernelBegin, kernelBegin,
kernelEnd, kernelEnd,
kernelEntityOrientation,
kernelEntityBasis,
gridXIdx, gridXIdx,
gridYIdx ); gridYIdx );
cudaThreadSynchronize(); cudaThreadSynchronize();
checkCudaDevice; checkCudaDevice;
//tnlCuda::freeFromDevice( kernelGrid ); //Devices::Cuda::freeFromDevice( kernelGrid );
Devices::Cuda::freeFromDevice( kernelBegin ); Devices::Cuda::freeFromDevice( kernelBegin );
Devices::Cuda::freeFromDevice( kernelEnd ); Devices::Cuda::freeFromDevice( kernelEnd );
//tnlCuda::freeFromDevice( kernelEntityOrientation ); Devices::Cuda::freeFromDevice( kernelEntityOrientation );
//tnlCuda::freeFromDevice( kernelEntityBasis ); Devices::Cuda::freeFromDevice( kernelEntityBasis );
Devices::Cuda::freeFromDevice( kernelUserData ); Devices::Cuda::freeFromDevice( kernelUserData );
checkCudaDevice; checkCudaDevice;
#endif #endif
...@@ -543,7 +538,7 @@ processEntities( ...@@ -543,7 +538,7 @@ processEntities(
CoordinatesType* kernelEnd = Devices::Cuda::passToDevice( end ); CoordinatesType* kernelEnd = Devices::Cuda::passToDevice( end );
CoordinatesType* kernelEntityOrientation = Devices::Cuda::passToDevice( entityOrientation ); CoordinatesType* kernelEntityOrientation = Devices::Cuda::passToDevice( entityOrientation );
CoordinatesType* kernelEntityBasis = Devices::Cuda::passToDevice( entityBasis ); CoordinatesType* kernelEntityBasis = Devices::Cuda::passToDevice( entityBasis );
//typename GridEntity::MeshType* kernelGrid = tnlCuda::passToDevice( grid ); //typename GridEntity::MeshType* kernelGrid = Devices::Cuda::passToDevice( grid );
UserData* kernelUserData = Devices::Cuda::passToDevice( userData ); UserData* kernelUserData = Devices::Cuda::passToDevice( userData );
dim3 cudaBlockSize( 8, 8, 8 ); dim3 cudaBlockSize( 8, 8, 8 );
......
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