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
b8f60127
There was an error fetching the commit references. Please try again later.
Commit
b8f60127
authored
5 years ago
by
Jakub Klinkovský
Browse files
Options
Downloads
Patches
Plain Diff
Optimized CudaReductionKernel to improve compilation times
parent
322b5b58
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/Containers/Algorithms/CudaReductionKernel.h
+32
-3
32 additions, 3 deletions
src/TNL/Containers/Algorithms/CudaReductionKernel.h
with
32 additions
and
3 deletions
src/TNL/Containers/Algorithms/CudaReductionKernel.h
+
32
−
3
View file @
b8f60127
...
...
@@ -456,6 +456,9 @@ struct CudaReductionKernelLauncher
?
2
*
blockSize
.
x
*
sizeof
(
ResultType
)
:
blockSize
.
x
*
sizeof
(
ResultType
);
// This is "general", but this method always sets blockSize.x to a specific value,
// so runtime switch is not necessary - it only prolongs the compilation time.
/*
/////
// Depending on the blockSize we generate appropriate template instance.
switch( blockSize.x )
...
...
@@ -518,6 +521,18 @@ struct CudaReductionKernelLauncher
TNL_ASSERT( false, std::cerr << "Block size is " << blockSize. x << " which is none of 1, 2, 4, 8, 16, 32, 64, 128, 256 or 512." );
}
TNL_CHECK_CUDA_DEVICE;
*/
// Check just to future-proof the code setting blockSize.x
if
(
blockSize
.
x
==
Reduction_maxThreadsPerBlock
)
{
cudaFuncSetCacheConfig
(
CudaReductionKernel
<
Reduction_maxThreadsPerBlock
,
Result
,
DataFetcher
,
Reduction
,
VolatileReduction
,
Index
>
,
cudaFuncCachePreferShared
);
CudaReductionKernel
<
Reduction_maxThreadsPerBlock
>
<<<
gridSize
,
blockSize
,
shmem
>>>
(
zero
,
dataFetcher
,
reduction
,
volatileReduction
,
size
,
output
);
}
else
{
TNL_ASSERT
(
false
,
std
::
cerr
<<
"Block size was expected to be "
<<
Reduction_maxThreadsPerBlock
<<
", but "
<<
blockSize
.
x
<<
" was specified."
<<
std
::
endl
;
);
}
////
// Return the size of the output array on the CUDA device
...
...
@@ -547,9 +562,11 @@ struct CudaReductionKernelLauncher
?
2
*
blockSize
.
x
*
(
sizeof
(
ResultType
)
+
sizeof
(
Index
)
)
:
blockSize
.
x
*
(
sizeof
(
ResultType
)
+
sizeof
(
Index
)
);
/***
* Depending on the blockSize we generate appropriate template instance.
*/
// This is "general", but this method always sets blockSize.x to a specific value,
// so runtime switch is not necessary - it only prolongs the compilation time.
/*
/////
// Depending on the blockSize we generate appropriate template instance.
switch( blockSize.x )
{
case 512:
...
...
@@ -610,6 +627,18 @@ struct CudaReductionKernelLauncher
TNL_ASSERT( false, std::cerr << "Block size is " << blockSize. x << " which is none of 1, 2, 4, 8, 16, 32, 64, 128, 256 or 512." );
}
TNL_CHECK_CUDA_DEVICE;
*/
// Check just to future-proof the code setting blockSize.x
if
(
blockSize
.
x
==
Reduction_maxThreadsPerBlock
)
{
cudaFuncSetCacheConfig
(
CudaReductionWithArgumentKernel
<
Reduction_maxThreadsPerBlock
,
Result
,
DataFetcher
,
Reduction
,
VolatileReduction
,
Index
>
,
cudaFuncCachePreferShared
);
CudaReductionWithArgumentKernel
<
Reduction_maxThreadsPerBlock
>
<<<
gridSize
,
blockSize
,
shmem
>>>
(
zero
,
dataFetcher
,
reduction
,
volatileReduction
,
size
,
output
,
idxOutput
,
idxInput
);
}
else
{
TNL_ASSERT
(
false
,
std
::
cerr
<<
"Block size was expected to be "
<<
Reduction_maxThreadsPerBlock
<<
", but "
<<
blockSize
.
x
<<
" was specified."
<<
std
::
endl
;
);
}
////
// return the size of the output array on the CUDA device
...
...
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