Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
SWE
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
SWE
Commits
f6789853
Commit
f6789853
authored
Oct 05, 2012
by
Sebastian Rettenberger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize memory access in max reduction
parent
04f8ea3b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
SWE_WavePropagationBlockCuda_kernels.cu
src/SWE_WavePropagationBlockCuda_kernels.cu
+9
-10
No files found.
src/SWE_WavePropagationBlockCuda_kernels.cu
View file @
f6789853
...
@@ -176,22 +176,21 @@ void computeNetUpdatesKernel(
...
@@ -176,22 +176,21 @@ void computeNetUpdatesKernel(
__syncthreads();
__syncthreads();
// initialize reduction block size with the original block size
// initialize reduction block size with the original block size
int reductionBlockDim
X
= blockDim.y;
int reductionBlockDim
Y
= blockDim.y;
int reductionBlockDim
Y
= blockDim.x;
int reductionBlockDim
X
= blockDim.x;
// do the reduction
// do the reduction
while(reductionBlockDim
X != 1 || reductionBlockDimY
!= 1) { // if the reduction block size == 1*1 (1 cell) -> done.
while(reductionBlockDim
Y != 1 || reductionBlockDimX
!= 1) { // if the reduction block size == 1*1 (1 cell) -> done.
//! reduction partner for a thread
//! reduction partner for a thread
int reductionPartner = 0;
int reductionPartner = 0;
// split the block in the x-direction (size in x-dir. > 1) or y-direction (size in x-dir. == 1, size in y-dir. > 1)
// split the block in the x-direction (size in x-dir. > 1) or y-direction (size in x-dir. == 1, size in y-dir. > 1)
if(reductionBlockDimX != 1) {
if(reductionBlockDimX != 1) {
reductionBlockDimX /= 2; //reduce column wise
reductionBlockDimX >>= 1; //reduce row wise (divide by 2)
reductionPartner = computeOneDPositionKernel(threadIdx.y + reductionBlockDimX, threadIdx.x, blockDim.x);
reductionPartner = computeOneDPositionKernel(threadIdx.y, threadIdx.x + reductionBlockDimX, blockDim.x);
}
} else if(reductionBlockDimY != 1) {
else if(reductionBlockDimY != 1) {
reductionBlockDimY >>= 1; //reduce column wise (divide by 2)
reductionBlockDimY /= 2; //reduce row wise
reductionPartner = computeOneDPositionKernel(threadIdx.y + reductionBlockDimY, threadIdx.x, blockDim.x);
reductionPartner = computeOneDPositionKernel(threadIdx.y, threadIdx.x+reductionBlockDimY, blockDim.x);
}
}
#ifndef NDEBUG
#ifndef NDEBUG
#if defined(__CUDA_ARCH__) & (__CUDA_ARCH__ < 200)
#if defined(__CUDA_ARCH__) & (__CUDA_ARCH__ < 200)
...
@@ -202,7 +201,7 @@ void computeNetUpdatesKernel(
...
@@ -202,7 +201,7 @@ void computeNetUpdatesKernel(
}
}
#endif
#endif
#endif
#endif
if(threadIdx.y < reductionBlockDim
X && threadIdx.x < reductionBlockDimY
) { // use only half the threads in each reduction
if(threadIdx.y < reductionBlockDim
Y && threadIdx.x < reductionBlockDimX
) { // use only half the threads in each reduction
//execute the reduction routine (maximum)
//execute the reduction routine (maximum)
l_maxWaveSpeedShared[l_maxWaveSpeedPosition] = fmax( l_maxWaveSpeedShared[l_maxWaveSpeedPosition],
l_maxWaveSpeedShared[l_maxWaveSpeedPosition] = fmax( l_maxWaveSpeedShared[l_maxWaveSpeedPosition],
l_maxWaveSpeedShared[reductionPartner]
l_maxWaveSpeedShared[reductionPartner]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment