Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GPUSort
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
TNL
GPUSort
Commits
9328c524
There was an error fetching the commit references. Please try again later.
Commit
9328c524
authored
4 years ago
by
Xuan Thang Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
parallel block wide prefix sum
parent
7d6e4313
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
quicksort/reduction.cuh
+34
-0
34 additions, 0 deletions
quicksort/reduction.cuh
with
34 additions
and
0 deletions
quicksort/reduction.cuh
+
34
−
0
View file @
9328c524
...
...
@@ -34,4 +34,38 @@ __device__ int blockReduceSum(int val)
__syncthreads
();
return
shared
[
0
];
}
__device__
int
warpPrefixSum
(
int
value
)
{
int
laneId
=
threadIdx
.
x
&
0x1f
;
for
(
int
i
=
1
;
i
*
2
<=
warpSize
;
i
*=
2
)
{
int
n
=
__shfl_up_sync
(
0xffffffff
,
value
,
i
);
if
((
laneId
&
(
warpSize
-
1
))
>=
i
)
value
+=
n
;
}
return
value
;
}
__device__
int
blockPrefixSum
(
int
value
)
{
static
__shared__
int
shared
[
32
];
int
lane
=
threadIdx
.
x
&
(
warpSize
-
1
);
int
wid
=
threadIdx
.
x
/
warpSize
;
int
tmp
=
warpPrefixSum
(
value
);
if
(
lane
==
warpSize
-
1
)
shared
[
wid
]
=
tmp
;
__syncthreads
();
int
tmp2
=
(
threadIdx
.
x
<
blockDim
.
x
/
warpSize
)
?
shared
[
lane
]
:
0
;
if
(
wid
==
0
)
shared
[
lane
]
=
warpPrefixSum
(
tmp2
)
-
shared
[
lane
];
__syncthreads
();
tmp
+=
shared
[
wid
];
return
tmp
;
}
\ No newline at end of file
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