Skip to content

Instantly share code, notes, and snippets.

@athas
Created July 23, 2020 14:55
Show Gist options
  • Select an option

  • Save athas/def24345a9fa433c396a1dd31e28f63a to your computer and use it in GitHub Desktop.

Select an option

Save athas/def24345a9fa433c396a1dd31e28f63a to your computer and use it in GitHub Desktop.
static inline int smin32(int x, int y)
{
return x < y ? x : y;
}
static inline int sdiv_up32(int x, int y)
{
return (x + y - 1) / y;
}
__kernel void mainzisegred_nonseg_169(int numD_115,
int numBBins_116,
__global double *datapoints_mem_171,
__global double *binb_mem_172,
__global int *mem_175)
{
volatile __local bool local_failure;
local_failure = false;
barrier(CLK_LOCAL_MEM_FENCE);
int x_acc_195;
int chunk_sizze_196;
chunk_sizze_196 = smin32(sdiv_up32(numD_115, get_local_size(0) *
get_num_groups(0)),
sdiv_up32(numD_115 -
get_global_id(0),
get_global_size(0)));
int x_124;
int x_125;
x_acc_195 = 0;
for (int i_200 = 0; i_200 < chunk_sizze_196; i_200++) {
int gtid_168 = get_global_id(0) + get_global_size(0) * i_200;
int i_128 = gtid_168 / numD_115;
int j_129 = gtid_168 % numD_115;
bool x_130 = 0 <= i_128;
bool y_131 = i_128 < numD_115;
bool bounds_check_132 = x_130 && y_131;
bool index_certs_133;
if (!bounds_check_132) {
local_failure = true;
goto error_0;
}
double xOuter_134 = ((__global double *) datapoints_mem_171)[i_128];
double xInner_139 = ((__global double *) datapoints_mem_171)[j_129];
double dot_140 = xOuter_134 * xInner_139;
bool res_141;
int res_142;
int res_143;
bool loop_while_144;
int min_145;
int max_146;
loop_while_144 = 1;
min_145 = 0;
max_146 = 20;
while (loop_while_144) {
int x_147 = min_145 + max_146;
int k_148 = x_147 / 2;
bool x_149 = 0 <= k_148;
bool y_150 = k_148 < numBBins_116;
bool bounds_check_151 = x_149 && y_150;
bool index_certs_152;
if (!bounds_check_151) {
local_failure = true;
goto error_0;
}
double y_153 = ((__global double *) binb_mem_172)[k_148];
bool cond_154 = y_153 <= dot_140;
int loopres_155;
if (cond_154) {
loopres_155 = min_145;
} else {
loopres_155 = k_148;
}
int loopres_156;
if (cond_154) {
loopres_156 = k_148;
} else {
loopres_156 = max_146;
}
int x_157 = 1 + loopres_155;
bool loop_cond_158 = x_157 < loopres_156;
bool loop_while_tmp_201 = loop_cond_158;
int min_tmp_202 = loopres_155;
int max_tmp_203 = loopres_156;
loop_while_144 = loop_while_tmp_201;
min_145 = min_tmp_202;
max_146 = max_tmp_203;
}
res_141 = loop_while_144;
res_142 = min_145;
res_143 = max_146;
x_124 = x_acc_195;
x_125 = res_142;
x_acc_195 = x_124 + x_125;
}
((__global int *) mem_175)[get_local_id(0)] = 10 + x_acc_195;
error_0:
barrier(CLK_LOCAL_MEM_FENCE);
if (local_failure)
return;
barrier(CLK_LOCAL_MEM_FENCE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment