-
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
d336d3c
commit 370a0c9
Showing
2 changed files
with
54 additions
and
12 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 |
---|---|---|
@@ -1,21 +1,60 @@ | ||
#ifdef __CLION_IDE__ | ||
#include "clion_defines.cl" | ||
#include "clion_defines.cl" | ||
#endif | ||
|
||
#line 5 | ||
|
||
|
||
__kernel void merge_global(__global const int *as, __global int *bs, unsigned int block_size) | ||
{ | ||
|
||
int lower_bound(__global const int* as, int size, int value) { | ||
int l = -1; | ||
int r = size; | ||
while (r - l > 1) { | ||
int m = (l + r) / 2; | ||
if (as[m] >= value) { | ||
r = m; | ||
} else { | ||
l = m; | ||
} | ||
} | ||
return r; | ||
} | ||
|
||
__kernel void calculate_indices(__global const int *as, __global unsigned int *inds, unsigned int block_size) | ||
{ | ||
int upper_bound(__global const int* as, int size, int value) { | ||
int l = -1; | ||
int r = size; | ||
while (r - l > 1) { | ||
int m = (l + r) / 2; | ||
if (as[m] > value) { | ||
r = m; | ||
} else { | ||
l = m; | ||
} | ||
} | ||
return r; | ||
} | ||
|
||
__kernel void merge_global(__global const int *as, __global int *bs, unsigned int block_size) { | ||
|
||
const unsigned int full_block = 2 * block_size; | ||
const unsigned int block = get_global_id(0) / full_block; | ||
unsigned int idx = get_global_id(0) % full_block; | ||
__global const int *begin = as + block * full_block; | ||
__global const int *mid = begin + block_size; | ||
__global int *out = bs + block * full_block; | ||
int tmp; | ||
|
||
if (idx >= block_size) { | ||
tmp = begin[idx]; | ||
__global int *pos = out + upper_bound(begin, block_size, tmp) + idx - block_size; | ||
*pos = tmp; | ||
} else { | ||
tmp = begin[idx]; | ||
__global int *pos = out + lower_bound(mid, block_size, tmp) + idx; | ||
*pos = tmp; | ||
} | ||
} | ||
|
||
__kernel void merge_local(__global const int *as, __global const unsigned int *inds, __global int *bs, unsigned int block_size) | ||
{ | ||
__kernel void calculate_indices(__global const int *as, __global unsigned int *inds, unsigned int block_size) { | ||
} | ||
|
||
__kernel void merge_local(__global const int *as, __global const unsigned int *inds, __global int *bs, | ||
unsigned int block_size) { | ||
} |
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