Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
5c6b42f6
There was an error fetching the commit references. Please try again later.
Commit
5c6b42f6
authored
8 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Fixed 2D grid traverser for CUDA
parent
20b876ed
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/Meshes/GridDetails/GridTraverser_impl.h
+21
-26
21 additions, 26 deletions
src/TNL/Meshes/GridDetails/GridTraverser_impl.h
with
21 additions
and
26 deletions
src/TNL/Meshes/GridDetails/GridTraverser_impl.h
+
21
−
26
View file @
5c6b42f6
...
...
@@ -151,11 +151,9 @@ processEntities(
CoordinatesType
*
kernelEnd
=
Devices
::
Cuda
::
passToDevice
(
end
);
CoordinatesType
*
kernelEntityOrientation
=
Devices
::
Cuda
::
passToDevice
(
entityOrientation
);
CoordinatesType
*
kernelEntityBasis
=
Devices
::
Cuda
::
passToDevice
(
entityBasis
);
//typename GridEntity::MeshType* kernelGrid =
tnl
Cuda::passToDevice( *gridPointer );
//typename GridEntity::MeshType* kernelGrid =
Devices::
Cuda::passToDevice( *gridPointer );
UserData
*
kernelUserData
=
Devices
::
Cuda
::
passToDevice
(
userData
);
//GridEntity entity( gridPointer.template getData< tnlCuda >(), coordinates, *entityOrientation, *entityBasis );
Devices
::
Cuda
::
synchronizeDevice
();
if
(
processOnlyBoundaryEntities
)
{
...
...
@@ -281,25 +279,24 @@ template< typename Real,
typename
EntitiesProcessor
,
bool
processOnlyBoundaryEntities
>
__global__
void
GridTraverser2D
(
GridEntity
entity
,
/*
const Meshes::Grid< 2, Real,
tnl
Cuda, Index >* grid,
*/
GridTraverser2D
(
const
Meshes
::
Grid
<
2
,
Real
,
Devices
::
Cuda
,
Index
>*
grid
,
UserData
*
userData
,
const
typename
GridEntity
::
CoordinatesType
*
begin
,
const
typename
GridEntity
::
CoordinatesType
*
end
,
/*
const typename GridEntity::CoordinatesType* entityOrientation,
const typename GridEntity::CoordinatesType* entityBasis,
*/
const
typename
GridEntity
::
CoordinatesType
*
entityOrientation
,
const
typename
GridEntity
::
CoordinatesType
*
entityBasis
,
const
Index
gridXIdx
,
const
Index
gridYIdx
)
{
typedef
Meshes
::
Grid
<
2
,
Real
,
Devices
::
Cuda
,
Index
>
GridType
;
typename
GridType
::
CoordinatesType
coordinates
;
entity
.
getCoordinates
().
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
;
//GridEntity entity( *grid, coordinates, *entityOrientation, *entityBasis );
coordinates
.
x
()
=
begin
->
x
()
+
(
gridXIdx
*
Devices
::
Cuda
::
getMaxGridSize
()
+
blockIdx
.
x
)
*
blockDim
.
x
+
threadIdx
.
x
;
coordinates
.
y
()
=
begin
->
y
()
+
(
gridYIdx
*
Devices
::
Cuda
::
getMaxGridSize
()
+
blockIdx
.
y
)
*
blockDim
.
y
+
threadIdx
.
y
;
GridEntity
entity
(
*
grid
,
coordinates
,
*
entityOrientation
,
*
entityBasis
);
if
(
entity
.
getCoordinates
().
x
()
<=
end
->
x
()
&&
entity
.
getCoordinates
().
y
()
<=
end
->
y
()
)
{
...
...
@@ -337,15 +334,12 @@ processEntities(
#ifdef HAVE_CUDA
CoordinatesType
*
kernelBegin
=
Devices
::
Cuda
::
passToDevice
(
begin
);
CoordinatesType
*
kernelEnd
=
Devices
::
Cuda
::
passToDevice
(
end
);
//
CoordinatesType* kernelEntityOrientation =
tnl
Cuda::passToDevice( entityOrientation );
//
CoordinatesType* kernelEntityBasis =
tnl
Cuda::passToDevice( entityBasis );
//typename GridEntity::MeshType* kernelGrid =
tnl
Cuda::passToDevice( *gridPointer );
CoordinatesType
*
kernelEntityOrientation
=
Devices
::
Cuda
::
passToDevice
(
entityOrientation
);
CoordinatesType
*
kernelEntityBasis
=
Devices
::
Cuda
::
passToDevice
(
entityBasis
);
//typename GridEntity::MeshType* kernelGrid =
Devices::
Cuda::passToDevice( *gridPointer );
UserData
*
kernelUserData
=
Devices
::
Cuda
::
passToDevice
(
userData
);
checkCudaDevice
;
CoordinatesType
coordinates
(
0
);
GridEntity
entity
(
gridPointer
.
template
getData
<
Devices
::
Cuda
>(),
coordinates
,
entityOrientation
,
entityBasis
);
dim3
cudaBlockSize
(
16
,
16
);
dim3
cudaBlocks
;
cudaBlocks
.
x
=
Devices
::
Cuda
::
getNumberOfBlocks
(
end
.
x
()
-
begin
.
x
()
+
1
,
cudaBlockSize
.
x
);
...
...
@@ -353,26 +347,27 @@ processEntities(
const
IndexType
cudaXGrids
=
Devices
::
Cuda
::
getNumberOfGrids
(
cudaBlocks
.
x
);
const
IndexType
cudaYGrids
=
Devices
::
Cuda
::
getNumberOfGrids
(
cudaBlocks
.
y
);
Devices
::
Cuda
::
synchronizeDevice
();
for
(
IndexType
gridYIdx
=
0
;
gridYIdx
<
cudaYGrids
;
gridYIdx
++
)
for
(
IndexType
gridXIdx
=
0
;
gridXIdx
<
cudaXGrids
;
gridXIdx
++
)
GridTraverser2D
<
Real
,
Index
,
GridEntity
,
UserData
,
EntitiesProcessor
,
processOnlyBoundaryEntities
>
<<<
cudaBlocks
,
cudaBlockSize
>>>
(
entity
,
(
&
gridPointer
.
template
getData
<
Devices
::
Cuda
>(),
kernelUserData
,
kernelBegin
,
kernelEnd
,
kernelEntityOrientation
,
kernelEntityBasis
,
gridXIdx
,
gridYIdx
);
cudaThreadSynchronize
();
checkCudaDevice
;
//
tnl
Cuda::freeFromDevice( kernelGrid );
//
Devices::
Cuda::freeFromDevice( kernelGrid );
Devices
::
Cuda
::
freeFromDevice
(
kernelBegin
);
Devices
::
Cuda
::
freeFromDevice
(
kernelEnd
);
//tnl
Cuda::freeFromDevice( kernelEntityOrientation );
//tnl
Cuda::freeFromDevice( kernelEntityBasis );
Devices
::
Cuda
::
freeFromDevice
(
kernelEntityOrientation
);
Devices
::
Cuda
::
freeFromDevice
(
kernelEntityBasis
);
Devices
::
Cuda
::
freeFromDevice
(
kernelUserData
);
checkCudaDevice
;
#endif
...
...
@@ -543,7 +538,7 @@ processEntities(
CoordinatesType
*
kernelEnd
=
Devices
::
Cuda
::
passToDevice
(
end
);
CoordinatesType
*
kernelEntityOrientation
=
Devices
::
Cuda
::
passToDevice
(
entityOrientation
);
CoordinatesType
*
kernelEntityBasis
=
Devices
::
Cuda
::
passToDevice
(
entityBasis
);
//typename GridEntity::MeshType* kernelGrid =
tnl
Cuda::passToDevice( grid );
//typename GridEntity::MeshType* kernelGrid =
Devices::
Cuda::passToDevice( grid );
UserData
*
kernelUserData
=
Devices
::
Cuda
::
passToDevice
(
userData
);
dim3
cudaBlockSize
(
8
,
8
,
8
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment