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
5be8dc1e
There was an error fetching the commit references. Please try again later.
Commit
5be8dc1e
authored
4 years ago
by
Xuan Thang Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
removing namespace pollution
parent
4d4439f9
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
bitonicGPU/bitonicSort.h
+9
-15
9 additions, 15 deletions
bitonicGPU/bitonicSort.h
with
9 additions
and
15 deletions
bitonicGPU/bitonicSort.h
+
9
−
15
View file @
5be8dc1e
#include
<TNL/Containers/Array.h>
#include
<iostream>
using
namespace
TNL
;
using
namespace
TNL
::
Containers
;
typedef
Devices
::
Cuda
Device
;
#define deb(x) std::cout << #x << " = " << x << std::endl;
//---------------------------------------------
__host__
__device__
int
closestPow2
(
int
x
)
...
...
@@ -33,7 +26,7 @@ __host__ __device__ void cmpSwap(Value & a, Value &b, bool ascending, const Func
* this kernel simulates 1 exchange
*/
template
<
typename
Value
,
typename
Function
>
__global__
void
bitonicMergeGlobal
(
ArrayView
<
Value
,
Device
>
arr
,
__global__
void
bitonicMergeGlobal
(
TNL
::
Containers
::
ArrayView
<
Value
,
TNL
::
Device
s
::
Cuda
>
arr
,
int
begin
,
int
end
,
const
Function
&
Cmp
,
int
monotonicSeqLen
,
int
len
,
int
partsInSeq
)
{
...
...
@@ -62,7 +55,7 @@ __global__ void bitonicMergeGlobal(ArrayView<Value, Device> arr,
* will merge all the way down til stride == 2
* */
template
<
typename
Value
,
typename
Function
>
__global__
void
bitonicMergeSharedMemory
(
ArrayView
<
Value
,
Device
>
arr
,
__global__
void
bitonicMergeSharedMemory
(
TNL
::
Containers
::
ArrayView
<
Value
,
TNL
::
Device
s
::
Cuda
>
arr
,
int
begin
,
int
end
,
const
Function
&
Cmp
,
int
monotonicSeqLen
,
int
len
,
int
partsInSeq
)
{
...
...
@@ -139,7 +132,8 @@ __global__ void bitonicMergeSharedMemory(ArrayView<Value, Device> arr,
* this continues until whole sharedMem is sorted
* */
template
<
typename
Value
,
typename
Function
>
__global__
void
bitoniSort1stStepSharedMemory
(
ArrayView
<
Value
,
Device
>
arr
,
int
begin
,
int
end
,
const
Function
&
Cmp
)
__global__
void
bitoniSort1stStepSharedMemory
(
TNL
::
Containers
::
ArrayView
<
Value
,
TNL
::
Devices
::
Cuda
>
arr
,
int
begin
,
int
end
,
const
Function
&
Cmp
)
{
extern
__shared__
int
externMem
[];
...
...
@@ -209,7 +203,7 @@ __global__ void bitoniSort1stStepSharedMemory(ArrayView<Value, Device> arr, int
//---------------------------------------------
template
<
typename
Value
,
typename
Function
>
void
bitonicSort
(
ArrayView
<
Value
,
Device
>
arr
,
int
begin
,
int
end
,
const
Function
&
Cmp
)
void
bitonicSort
(
TNL
::
Containers
::
ArrayView
<
Value
,
TNL
::
Device
s
::
Cuda
>
arr
,
int
begin
,
int
end
,
const
Function
&
Cmp
)
{
int
arrSize
=
end
-
begin
;
int
paddedSize
=
closestPow2
(
arrSize
);
...
...
@@ -252,13 +246,13 @@ void bitonicSort(ArrayView<Value, Device> arr, int begin, int end, const Functio
//---------------------------------------------
template
<
typename
Value
,
typename
Function
>
void
bitonicSort
(
ArrayView
<
Value
,
Device
>
arr
,
const
Function
&
cmp
)
void
bitonicSort
(
TNL
::
Containers
::
ArrayView
<
Value
,
TNL
::
Device
s
::
Cuda
>
arr
,
const
Function
&
cmp
)
{
bitonicSort
(
arr
,
0
,
arr
.
getSize
(),
cmp
);
}
template
<
typename
Value
>
void
bitonicSort
(
ArrayView
<
Value
,
Device
>
arr
)
void
bitonicSort
(
TNL
::
Containers
::
ArrayView
<
Value
,
TNL
::
Device
s
::
Cuda
>
arr
)
{
bitonicSort
(
arr
,
[]
__cuda_callable__
(
const
Value
&
a
,
const
Value
&
b
)
{
return
a
<
b
;});
}
...
...
@@ -268,14 +262,14 @@ void bitonicSort(ArrayView<Value, Device> arr)
template
<
typename
Value
>
void
bitonicSort
(
std
::
vector
<
Value
>
vec
)
{
TNL
::
Containers
::
Array
<
Value
,
Devices
::
Cuda
>
Arr
(
vec
);
TNL
::
Containers
::
Array
<
Value
,
TNL
::
Devices
::
Cuda
>
Arr
(
vec
);
bitonicSort
(
Arr
.
getView
());
}
template
<
typename
Value
,
typename
Function
>
void
bitonicSort
(
std
::
vector
<
Value
>
vec
,
const
Function
&
cmp
)
{
TNL
::
Containers
::
Array
<
Value
,
Devices
::
Cuda
>
Arr
(
vec
);
TNL
::
Containers
::
Array
<
Value
,
TNL
::
Devices
::
Cuda
>
Arr
(
vec
);
bitonicSort
(
Arr
.
getView
(),
cmp
);
}
...
...
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