-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
024d0d3
commit fe22472
Showing
3 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
build | ||
cmake-build* | ||
.vs | ||
CMakeLists.txt.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
__kernel void bitonic() | ||
__kernel void bitonic(__global int *const as, | ||
uint const top_block_size, | ||
uint const cur_block_size) | ||
{ | ||
|
||
uint const gid = get_global_id(0); | ||
|
||
uint const top_block_id = gid / (top_block_size / 2); | ||
uint const cur_step = cur_block_size / 2; | ||
uint const cur_block_id = gid / cur_step; | ||
|
||
bool const is_order_increase = top_block_id % 2 == 0; | ||
uint const idx1 = gid + (cur_block_id * cur_step); | ||
uint const idx2 = idx1 + cur_step; | ||
|
||
int const left_value = as[idx1]; | ||
int const right_value = as[idx2]; | ||
bool const is_lesser = left_value < right_value; | ||
|
||
if ((is_order_increase && !is_lesser) || (!is_order_increase && is_lesser)) | ||
{ | ||
as[idx1] = right_value; | ||
as[idx2] = left_value; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters