Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
9abaa587
Commit
9abaa587
authored
Jun 18, 2018
by
Peter Eastman
Browse files
Fixed race condition in sorting
parent
73cac8e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
0 deletions
+4
-0
platforms/cuda/src/kernels/sort.cu
platforms/cuda/src/kernels/sort.cu
+2
-0
platforms/opencl/src/kernels/sort.cl
platforms/opencl/src/kernels/sort.cl
+2
-0
No files found.
platforms/cuda/src/kernels/sort.cu
View file @
9abaa587
...
@@ -144,6 +144,7 @@ __global__ void computeBucketPositions(unsigned int numBuckets, unsigned int* __
...
@@ -144,6 +144,7 @@ __global__ void computeBucketPositions(unsigned int numBuckets, unsigned int* __
// Load the bucket sizes into local memory.
// Load the bucket sizes into local memory.
unsigned
int
globalIndex
=
startBucket
+
threadIdx
.
x
;
unsigned
int
globalIndex
=
startBucket
+
threadIdx
.
x
;
__syncthreads
();
posBuffer
[
threadIdx
.
x
]
=
(
globalIndex
<
numBuckets
?
bucketOffset
[
globalIndex
]
:
0
);
posBuffer
[
threadIdx
.
x
]
=
(
globalIndex
<
numBuckets
?
bucketOffset
[
globalIndex
]
:
0
);
__syncthreads
();
__syncthreads
();
...
@@ -218,6 +219,7 @@ __global__ void sortBuckets(DATA_TYPE* __restrict__ data, const DATA_TYPE* __res
...
@@ -218,6 +219,7 @@ __global__ void sortBuckets(DATA_TYPE* __restrict__ data, const DATA_TYPE* __res
if
(
threadIdx
.
x
<
length
)
if
(
threadIdx
.
x
<
length
)
data
[
startIndex
+
threadIdx
.
x
]
=
dataBuffer
[
threadIdx
.
x
];
data
[
startIndex
+
threadIdx
.
x
]
=
dataBuffer
[
threadIdx
.
x
];
__syncthreads
();
}
}
else
{
else
{
// Copy the bucket data over to the output array.
// Copy the bucket data over to the output array.
...
...
platforms/opencl/src/kernels/sort.cl
View file @
9abaa587
...
@@ -147,6 +147,7 @@ __kernel void computeBucketPositions(uint numBuckets, __global uint* restrict bu
...
@@ -147,6 +147,7 @@ __kernel void computeBucketPositions(uint numBuckets, __global uint* restrict bu
//
Load
the
bucket
sizes
into
local
memory.
//
Load
the
bucket
sizes
into
local
memory.
uint
globalIndex
=
startBucket+get_local_id
(
0
)
;
uint
globalIndex
=
startBucket+get_local_id
(
0
)
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
buffer[get_local_id
(
0
)
]
=
(
globalIndex
<
numBuckets
?
bucketOffset[globalIndex]
:
0
)
;
buffer[get_local_id
(
0
)
]
=
(
globalIndex
<
numBuckets
?
bucketOffset[globalIndex]
:
0
)
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
...
@@ -220,6 +221,7 @@ __kernel void sortBuckets(__global DATA_TYPE* restrict data, __global const DATA
...
@@ -220,6 +221,7 @@ __kernel void sortBuckets(__global DATA_TYPE* restrict data, __global const DATA
if
(
get_local_id
(
0
)
<
length
)
if
(
get_local_id
(
0
)
<
length
)
data[startIndex+get_local_id
(
0
)
]
=
buffer[get_local_id
(
0
)
]
;
data[startIndex+get_local_id
(
0
)
]
=
buffer[get_local_id
(
0
)
]
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
}
}
else
{
else
{
//
Copy
the
bucket
data
over
to
the
output
array.
//
Copy
the
bucket
data
over
to
the
output
array.
...
...
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