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
24899efe
There was an error fetching the commit references. Please try again later.
Commit
24899efe
authored
3 years ago
by
Xuan Thang Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
sort without shared memory
parent
5b7045ed
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/bitonicSort/bitonicSort.h
+32
-0
32 additions, 0 deletions
src/bitonicSort/bitonicSort.h
with
32 additions
and
0 deletions
src/bitonicSort/bitonicSort.h
+
32
−
0
View file @
24899efe
...
...
@@ -178,6 +178,38 @@ void bitonicSort_Block(TNL::Containers::ArrayView<Value, TNL::Devices::Cuda> src
dst
[
copy2
]
=
sharedMem
[
copy2
];
}
}
template
<
typename
Value
,
typename
Function
>
__device__
void
bitonicSort_Block
(
TNL
::
Containers
::
ArrayView
<
Value
,
TNL
::
Devices
::
Cuda
>
src
,
TNL
::
Containers
::
ArrayView
<
Value
,
TNL
::
Devices
::
Cuda
>
dst
,
const
Function
&
Cmp
)
{
int
i
=
threadIdx
.
x
;
int
paddedSize
=
closestPow2
(
src
.
getSize
());
for
(
int
monotonicSeqLen
=
2
;
monotonicSeqLen
<=
paddedSize
;
monotonicSeqLen
*=
2
)
{
//calculate the direction of swapping
int
monotonicSeqIdx
=
i
/
(
monotonicSeqLen
/
2
);
bool
ascending
=
(
monotonicSeqIdx
&
1
)
!=
0
;
if
((
monotonicSeqIdx
+
1
)
*
monotonicSeqLen
>=
src
.
getSize
())
//special case for parts with no "partner"
ascending
=
true
;
for
(
int
len
=
monotonicSeqLen
;
len
>
1
;
len
/=
2
)
{
//calculates which 2 indexes will be compared and swap
int
part
=
i
/
(
len
/
2
);
int
s
=
part
*
len
+
(
i
&
((
len
/
2
)
-
1
));
int
e
=
s
+
len
/
2
;
if
(
e
<
src
.
getSize
())
//not touching virtual padding
cmpSwap
(
src
[
s
],
src
[
e
],
ascending
,
Cmp
);
__syncthreads
();
}
}
}
/**
* very similar to bitonicMergeSharedMemory
* does bitonicMergeSharedMemory but afterwards increases monotoncSeqLen
...
...
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