kernel_code
stringlengths
49
1.22M
kernel void rectangles_reduction(global float* rect_buf, global float* rect, const unsigned int bufElems) { int id = get_global_id(0); if (id == 0) { for (unsigned int i = 1; i < bufElems; i++) { rect_buf[0] += rect_buf[i]; } (*rect) = rect_buf[0]; } return; }
kernel void mul(global int* a, int value, int iNumElements) { int iGID = get_global_id(0); if (iGID >= iNumElements) { return; } a[iGID] *= value; }
kernel void addem(global float* a, global float* b, global float* c) { int i = get_global_id(0); c[i] = a[i] + b[i]; }
kernel void multiply_ulong2ulong2(global ulong2* src_0, global ulong2* src_1, global ulong2* dst) { int gid = get_global_id(0); dst[gid] = src_0[gid] * src_1[gid]; }
kernel void relu_layer(global float* pData) { const int x = get_global_id(0); float zero = 0.0; pData[x] = fmax(zero, pData[x]); }
kernel void add(global const float* a, global const float* b, global float* c) { int gid = get_global_id(0); c[gid] = a[gid] + b[gid]; }
kernel void do_init_distances(int num_elts, global float* dist_mins_global, global int* idx_mins_global) { int tid = get_global_id(0); if (tid >= num_elts) { return; } dist_mins_global[tid] = 3.402823466e+38; idx_mins_global[tid] = 0; }
kernel void column_prepare(global const unsigned int* restrict chids, global const unsigned int* restrict input, global unsigned int* restrict tmp, global unsigned int* restrict heads, unsigned int len) { const unsigned int n_half = get_global_size(0); const unsigned int ai = get_global_id(0); const unsigned int ...
kernel void isgreaterequal_float16float16(global float16* src_0, global float16* src_1, global int16* dst) { int gid = get_global_id(0); dst[gid] = (int16)(isgreaterequal(src_0[gid], src_1[gid])); }
inline float dotproduct(global float* a, global float* b, const int size) { float out = 0.0f; for (int i = 0; i < size; i++) { out += a[i] * b[i]; } return out; } inline float sigmoid(global float* X, global float* theta, int row_id, int nrows, int ncols) { float linear_sum = 0.0f; for (int j = 0; j < ...
kernel void point_edge_expand_back(int group_length, global int* group, int group_temp_length, global int* group_temp, int neighbours_length, global int* neighbours_index, global int* neighbours) { int idx = get_global_id(0); if (idx >= group_length || group[idx]) return; group[idx] = group_temp[idx]; }
kernel void sigmoid_vec(global double* input, global double* output) { unsigned int idx = get_global_id(0); double x = input[idx]; output[idx] = 1.0 / (1.0 + exp(-x)); }
kernel void straightPrice(global float* buffer, float ignored) { 1; }
kernel void gegl_invert_linear(global const float4* in, global float4* out) { int gid = get_global_id(0); float4 in_v = in[gid]; float4 out_v; out_v.xyz = (1.0f - in_v.xyz); out_v.w = in_v.w; out[gid] = out_v; }
kernel void compObjWave(global float* pc, unsigned int pc_size, global float2* of, unsigned int of_row_offset, unsigned int of_col_offset, float hologram_z, float k, float pitch, float corner_x, float corner_y) { float2 sample = (float2)(0.0f, 0.0f); float4 dist = (float4)(((of_col_offset - 1) * pitch) + corner_x,...
kernel void Sspmv_naive(int uplo, int n, float alpha, global float* AP, global float* x, int incx, float beta, global float* y, int incy) { bool isUp = (uplo == 0); if (isUp) { int kk1 = 0; int kk2 = 0; for (int i = 0; i < n; i++) { int k1 = kk1; int k2 = kk2; float value = 0.f; ...
float GL_to_CL(unsigned int val); float3 RGBtoXYZ(float3 rgb); const sampler_t sampler = 0 | 0 | 0x10; kernel void finalReduc(global float* logAvgLum_acc, const unsigned int num_reduc_bins) { if (get_global_id(0) == 0) { float logAvgLum = 0.f; for (int i = 0; i < num_reduc_bins; i++) { logAvgLum += logA...
kernel void shuffle_test(global float8* s1, global char16* s2) { uint8 mask1 = (uint8)(1, 2, 0, 1, 3, 1, 2, 3); float4 input = (float4)(0.25f, 0.5f, 0.75f, 1.0f); *s1 = shuffle(input, mask1); uchar16 mask2 = (uchar16)(6, 10, 5, 2, 8, 0, 9, 14, 7, 5, 12, 3, 11, 15, 1, 13); char8 input1 = (char8)('l', 'o', 'f'...
kernel void commands_aggregation(global unsigned int* buffer, const unsigned int kernel_offset) { const unsigned int id = get_global_id(0); const unsigned int size = get_global_size(0); const ulong number_of_iterations = 1000000; for (unsigned int i = 0; i < number_of_iterations; ++i) { buffer[kernel_offset...
kernel void mc_kernel_gridval(float m, float cellSize, float kNorm, float kNearNorm, float kEpsilon, global float4* pos, global float4* mcgrid, int numVolIdx) { size_t gid = get_global_id(0); float3 myPos = pos[gid].xyz; int i; float3 posJ; float a; for (i = 0; i < numVolIdx; i++) { posJ = mcgrid[i]...
kernel void square(global unsigned int* input, global unsigned int* output, unsigned int count) { unsigned int i = get_global_id(0); if (i < count) output[i] = input[i] * input[i]; }
kernel void clear_memory(global unsigned int* dst) { dst[get_global_id(0)] = 0; }
kernel void kernel_cos_withoutDD1(global float* result_cos, int N) { float t1 = 1.23; float t2 = 1.23; float t3 = t1; float t4 = t3; float t5 = t4; float t6 = t5; float t7 = t6; float j = 0.0; for (j = 0.0; j < 10 * N; j = j + 1.0) { t1 = cos(j); t2 = cos(j); t3 = cos(j); t4 = cos(j); ...
kernel void preinc(global ushort* out, ushort in) { out[0] = ++in; }
kernel void mul(global int* out, int a, int b) { out[0] = a * b; }
kernel void kernel_copysign_withoutDD1(global float* result_copysign, int n) { float p1 = 1.2; float p2 = 1.2; float p3 = 1.2; float p4 = 1.2; float p5 = 1.2; float p6 = 1.2; float p7 = 1.2; float p8 = 1.2; float p9 = 1.2; float p10 = 1.2; float p11 = 1.2; float p12 = 1.2; float p13 = 1.2; f...
kernel void test_switch_more_default(global int* out, global const int* in, global const int* cond) { unsigned int gid = get_global_id(0); int val = in[gid]; switch (cond[gid]) { case 0: out[gid] = -val; break; case -1: out[gid] = val ^ 45; break; case 1: out[gid] = val -...
kernel void calculateHistogram(global const unsigned char* restrict data, global unsigned int* restrict histogram, int numData) { const int tid = 0; const int startIdx = tid * numData; unsigned int hist1[256]; unsigned int hist2[256]; for (int i = 0; i < 256; i++) { hist1[i] = 0; hist2[i] = 0; }...
kernel void asbs_s_gpu_cpu(global float* s1, global const float* fac2, unsigned int options2, global const float* s2, float fac3, unsigned int options3, global const float* s3) { float alpha = fac2[0]; if ((options2 >> 2) > 1) { for (unsigned int i = 1; i < (options2 >> 2); ++i) alpha += fac2[i]; } if...
kernel void brahmaKernel(global int* buf) { if ((0 == 2)) { buf[0] = 1; }; }
inline int get_index(int nelems, int index) { if (index == -1) { index = get_global_id(0); } else { index += get_global_size(0); } if (index >= nelems) index = -1; return index; } kernel void add(global const float* x, global const float* y, global float* z, int N) { int id = get_index(N, -1)...
double norm(double3); double squared_euclidian_distance(global double*, unsigned int, unsigned int); int3 get_box_coordinates(double3, constant int*, unsigned int); int3 get_box_coordinates_2(unsigned int, constant unsigned int*); unsigned int get_box_id_2(int3, constant unsigned int*); unsigned int get_box_id(double3,...
kernel void compiler_write_only_shorts(global short* dst) { int id = (int)get_global_id(0); dst[id] = 2; }
kernel void test(int global* in, int global* in2) { if (!in) return; if (in == 1) return; if (in > in2) return; if (in < in2) return; }
__inline unsigned int read_sumTex_(global unsigned int* sumTex, int sum_step, int img_rows, int img_cols, int2 coord) { int x = clamp(coord.x, 0, img_cols); int y = clamp(coord.y, 0, img_rows); return sumTex[sum_step * y + x]; } __inline uchar read_imgTex_(global uchar* imgTex, int img_step, int img_rows, int im...
kernel void gpu_csr_ve_slm_pm_fs(global int* rowptr, global int* colid, global int* randlist, global int* vplist, int float3, global char* over, int rownum, global unsigned long* bitmap) { int tid = get_global_id(0); int getnumsum = get_global_size(0); for (; tid < rownum; tid += getnumsum) { if (vplist[tid]...
__attribute__((reqd_work_group_size(512, 1, 1))) __attribute__((reqd_work_group_size(512, 1, 1))) __attribute__((reqd_work_group_size(512, 1, 1))) __attribute__((reqd_work_group_size(512, 1, 1))) __attribute__((reqd_work_group_size(512, 1, 1))) __attribute__((reqd_work_group_size(512, 1, 1))) __attribute__((reqd_work_g...
kernel void mul_redundancy(global float* a) { float b = *a * 0.0; *a = b; }
constant float QUAR = 0.25; constant float HALF = 0.5; constant float TWO = 2.; constant float SIX = 6.; constant bool isHiPrecision = sizeof(TWO) == 8; constant float2 zero2 = (float2)(0, 0); constant float PI2 = (float)6.283185307179586476925286766559; constant float E2W = 1.51926751475e15; constant float C = 2.99792...
kernel void get_sight(global float* sight, global float* fields, unsigned int fields_internal_size2, int current_player) { unsigned int row_gid = get_global_id(0) / get_local_size(0); unsigned int col_gid = get_global_id(0) % get_local_size(0); for (unsigned int row = row_gid; row < 3; row += get_num_groups(0)) {...
kernel void ga_cl12(global char* device_target, global char* device_query, global char* device_batch_result, unsigned int length, int query_sequence_length, int coarse_match_length, int coarse_match_threshold, int current_position) { size_t tid = get_global_id(0); if (tid > length) return; bool match = false...
kernel void testConvertPtrToU(global int* a, global unsigned long* res) { res[0] = (unsigned long)&a[0]; }
kernel void TestLoopBarrier(global float* input, global float* output, const unsigned int count) { int i = get_global_id(0); output[i] = input[i] * input[i]; for (unsigned j = 0; j < 10; ++j) { barrier(0x01); output[i] -= count; barrier(0x01); } }
kernel void turnpoints(global float* src, unsigned int span, float threshold, global float* out) { unsigned int i = get_global_id(0); unsigned int s = i + span; out[i] = 0; unsigned int count = 0; for (unsigned int j = 1; j <= span; j++) { if (src[s] > src[s + j] && src[s] > src[s - j]) count++; ...
void apple(global int* B, global int* A, int n) { A[n] = B[n + 2]; } kernel void foo(global int* A, global int* B, int n) { apple(B, A, n); }
kernel void compiler_sub_char(global char* src0, global char* src1, global char* dst) { int id = (int)get_global_id(0); dst[id] = src0[id] - src1[id]; }
kernel void add_vector(global char* in, global char* out) { int iNum = get_global_id(0); out[iNum] = in[iNum] + 1; }
kernel void vectSquareUChar(global uchar* input, global uchar* output) { size_t id = get_global_id(0); output[id] = input[id] * input[id]; }
kernel void test_hadd(const global int* in0, const global int* in1, global int* out) { unsigned int gid = get_global_id(0); out[gid] = (int)hadd((short)in0[gid], (short)in1[gid]); }
kernel void brahmaKernel(global int* buf) { int y = 3; int x = y; int f = x; buf[0] = f; }
kernel void topk_radix_sort(global float* restrict out_data, int n, int inner_dim, int top_k, int out_max_val, global const float* restrict key_data, global const int* restrict value_data) { const int tid = get_global_id(0); if (tid < inner_dim) { if (out_max_val) { const int offset = n * 2 * top_k; ...
kernel void foo(global int* in1, global int* in2, global int* out, int a) { if (a == 0) { barrier(0x02); *out = *in1; } else { *out = *in2; } }
kernel void foo(global float* out, float x, float y) { int first_result; if (y >= 1.25f) { if (x > 0) { first_result = 0; } else { first_result = 1; } } else if (y >= 1.5f) { if (x > 0) { first_result = 2; } else { first_result = 3; } } else { if (y + 1.0f > ...
kernel void dfun(global float* state, global float* coupling, global float* param, global float* deriv) { int i = get_global_id(0), n = get_global_size(0); float y0 = state[0 * n + i], y1 = param[1 * n + i], y2 = state[2 * n + i], y3 = param[4 * n + i], y4 = state[4 * n + i], y5 = param[5 * n + i]; float c_pop1...
kernel void test_arg_2_7_kern(global float* a0, global float* a1, global float* b0, global float* b1, global float* b2, global float* b3, global float* b4, global float* b5, global float* b6) { unsigned int gtid = get_global_id(0); float tmp0 = a0[gtid] + 0.1f; float tmp1 = a1[gtid] + 1.1f; b0[gtid] = (0.0f + 1...
kernel void kernel_rint_withoutDD1(global float* result_rint, int N) { float t1; float t2; float t3; float t4; float t5; float t6; float t7; float t8; float t9; float t10; float i = 1.0; float n = 0.3 * (float)(N); for (i = 1.0; i < n; i = i + 0.01) { t1 = rint(i); t2 = rint(i + 0.01)...
kernel void test_upsample(global short* out, char a) { *out = upsample(a, (uchar)42); }
constant unsigned short crc16_table[256] = {0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, 0xD801, 0x18C0, 0x19...
kernel void ArrayMult(global const float* dA, global const float* dB, local float* prods, global float* dD) { int gid = get_global_id(0); int numItems = get_local_size(0); int tnum = get_local_id(0); int wgNum = get_group_id(0); prods[gid] = dA[gid] * dB[gid]; for (int offset = 1; offset < numItems; offs...
kernel void relational_less_than_ulongulong(global ulong* src_0, global ulong* src_1, global int* dst) { int gid = get_global_id(0); dst[gid] = (int)(src_0[gid] < src_1[gid]); }
constant float chn_6RB_filter_coef[47] = {8.193313185354206e-04, 3.535548569572820e-04, -1.453429245341695e-03, 1.042805860697287e-03, 1.264224526451337e-03, -3.219586065044259e-03, 1.423981657254563e-03, 3.859884310477692e-03, -6.552708013395765e-03, 8.590509694961493e-04, 9.363722386299336e-03, -1.120357391780316e-02...
kernel void subtract_ranges(global int* _buf0, global int* _buf1, global int* _buf2, const unsigned int count) { unsigned int index = get_local_id(0) + (32 * get_group_id(0)); for (unsigned int i = 0; i < 4; i++) { if (index < count) { _buf0[index] = ((_buf1[index]) - (_buf2[index])); index += 8; ...
kernel void divide_kernel3D_loginv_Ushort(global ushort* input, global ushort* divImg, global float* output) { const unsigned int idx = get_global_id(0); const float short_lim = log((float)65535); const float mu_in = short_lim - log((float)input[idx]); const float mu_div = short_lim - log((float)divImg[idx]); ...
kernel void zero_buffer(global float* buffer, private int n) { size_t i = get_global_id(0); if (i < n) buffer[i] = 0; }
kernel void first(global int* num1, global int* num2, global int* out) { int i = get_global_id(0); out[i] = num1[i] * num1[i] + num2[i] * num2[i]; }
kernel void bufferedFilter2(global float* lastInput, global float* input, int filterOrder, global float* table, global float* output, int N) { int idx = get_global_id(0); int flt = idx / N; int ind = idx % N; float val = 0; for (int i = 0; i < filterOrder; i++) { int index = ind - i; float b = table[f...
kernel void output_42(global int* output) { *output = 42; }
kernel void hypot_float2float2(global float2* src_0, global float2* src_1, global float2* dst) { int gid = get_global_id(0); dst[gid] = hypot(src_0[gid], src_1[gid]); }
int pow_two(int exp) { return 1 << exp; } kernel void baseAlgo(global int* arr, global int* prefixArr) { int locId = get_local_id(0); prefixArr[locId * 2] = arr[locId * 2]; prefixArr[locId * 2 + 1] = arr[locId * 2 + 1]; barrier(0x01); for (int d = 0; d < 7; d++) { int lowIndex = pow_two(d) - 1 + loc...
kernel void test7(global int* A) { for (int i = 1024; i > 0; --i) A[i] += 1; }
kernel void memoryCheckChar(global char* input, global int* output, unsigned int count) { unsigned int i; for (i = 0; i < count; i++) { if (input[i] != 0) output[0]++; } }
kernel void kernel_remquo_withDD1(global float* result_remquo, int N) { float t1 = 4.3; float t2 = 1.0; int j = 0; int* quo = &j; int i = 0; for (i = 0; i < N; i++) { t1 = remquo(t1, t2, quo); t1 = remquo(t1, t2, quo); t1 = remquo(t1, t2, quo); t1 = remquo(t1, t2, quo); t1 = remquo(t1, t...
kernel void concat(const int nthreads, global const float* in_data, const int num_concats, const int concat_size, const int top_concat_axis, const int bottom_concat_axis, const int offset_concat_axis, global float* out_data) { for (int index = get_global_id(0); index < nthreads; index += get_global_size(0)) { con...
float3 Acceleration(float3 in_pos) { float dSquared = (in_pos.x * in_pos.x) + (in_pos.y * in_pos.y) + (in_pos.z * in_pos.z); if (dSquared < 1.0f) return (float3)(0, 0, 0); float a = 1750.0f / dSquared; float3 accelVector = -normalize(in_pos); accelVector *= a; return accelVector; } float3 Velocity(fl...
kernel void neq(global int* out, ushort a, ushort b) { out[0] = a != b; }
unsigned char clamp_uc(int v, int l, int h) { if (v > h) v = h; if (v < l) v = l; return (unsigned char)v; } char clamp_c(int v, int l, int h) { if (v > h) v = h; if (v < l) v = l; return (char)v; } kernel void kernel_rgb2yuv_bt601(global float* r, global float* g, global float* b, global ...
kernel void test_f2i(const float val_exact, const float val_down, const float val_mid, const float val_up, global int* out) { size_t offset = 32 * get_global_id(0); out[offset] = (int)val_exact; out[offset + 1] = (int)val_down; out[offset + 2] = (int)val_mid; out[offset + 3] = (int)val_up; out[offset + 4] =...
kernel void DistanceTransformUnsignedByte(global const unsigned char* vIn, global unsigned char* vOut, int iDx, int iDy) { int iGID = get_global_id(0); if (iGID >= (iDx * iDy)) { return; } float minVal = (float)max(iDx, iDy); for (int y = 0; y < iDy; y++) { for (int x = 0; x < iDx; x++) { if (...
inline float distance_(global const float* center, global const float* src, int feature_length) { float res = 0; float4 v0, v1, v2; int i = 0; for (; i <= feature_length - 4; i += 4) { v0 = vload4(0, center + i); v1 = vload4(0, src + i); v2 = v1 - v0; res += dot(v2, v2); } for (; i < feat...
kernel void not(global int* out, int in) { out[0] = !in; }
kernel void scan_hillis_steele(global float* input, global float* output, local float* a, local float* b, int need_inplace) { unsigned int gid = get_global_id(0); unsigned int lid = get_local_id(0); unsigned int block_size = get_local_size(0); a[lid] = b[lid] = input[gid]; barrier(0x01); for (unsigned int...
kernel void global_write_write_race(global int* data) { data[0] = get_global_id(0); }
kernel void test(global float* out) { int globalId = get_global_id(0); int localId = get_local_id(0); atomic_work_item_fence(0x02, memory_order_seq_cst, memory_scope_device); out[globalId] = out[globalId] + globalId; }
kernel void test_block_5_4_kern(global int* a0, global int* a1, global int* a2, global int* a3, global int* a4, global int* b0, global int* b1, global int* b2, global int* b3, local int* c0, local int* c1, local int* c2, local int* c3, local int* c4) { int i; unsigned int gtid = get_global_id(0); unsigned int lti...
kernel void scalar_div(global const float* a, float factor, global float* out, int n) { int i = get_global_id(0); if (i >= n) return; out[i] = a[i] / factor; }
kernel void doubleInput(global float* input, global float* output) { int tid = get_global_id(0); output[tid] = 2 * 3.14575454 * 0.2312232 * 1.3232 * 0.99943 * input[tid]; }
kernel void test4(global int* A, global int* B) { unsigned sum = 0; for (int i = 0; i < 1024; ++i) sum += A[i] + 5; *B = sum; }
kernel void test_ushort2(global ushort* pin, global ushort* pout) { int x = get_global_id(0); ushort2 value; value = vload2(x, pin); value += (ushort2){(ushort)1, (ushort)2}; vstore2(value, x, pout); }
kernel void foo(global char4* A, float f) { *A = (char4)(1, 2, (char)f, 4); }
kernel void __cl_fill_region_align4(global float* dst, float pattern, unsigned int offset, unsigned int size) { int i = get_global_id(0); if (i < size) { dst[i + offset] = pattern; } }
void atomicAddGlobal(volatile global float* ptr, float value) { unsigned int oldIntVal, newIntVal; float newFltVal; do { oldIntVal = *((volatile global unsigned int*)ptr); newFltVal = ((*(float*)(&oldIntVal)) + value); newIntVal = *((unsigned int*)(&newFltVal)); } while (atomic_cmpxchg((volatile gl...
kernel void exampleKernelFunction(global int* inputdata, global int* outputdata) { int loopindex = get_global_id(0); int offset = 1; outputdata[loopindex] = inputdata[loopindex] - offset; }
kernel void md5(global const unsigned int* keys, global const uchar* lengths, global const unsigned int* target, global unsigned int* match) { int id = get_global_id(0); unsigned int W[16] = {0}; unsigned int i; unsigned int num_keys = get_global_size(0); int base = id * (16 / 4); unsigned int a, b, c, d; ...
kernel void compute_weights(global float* sims, global float* kls, global float* weights, const int size, const float h, const float T) { const int tx = get_global_id(0); if (tx < size) { float weight = exp(sims[tx] / h + kls[tx] / T); if (isnan(weight) || isinf(weight)) { weight = 0.0f; } we...
kernel void hadd_uint16uint16(global uint16* src_0, global uint16* src_1, global uint16* dst) { int gid = get_global_id(0); dst[gid] = hadd(src_0[gid], src_1[gid]); }
kernel void pass_along(global const float4* source, global float4* destination, int numInstances, int offset, global unsigned int* indirectCommandData, int indirectCommandOffset, float16 MVP) { int iGID = get_global_id(0); if (iGID >= numInstances) { return; } float4 translation = source[offset + iGID]; ...
kernel void wgf_reduce_atomic(const int numElems, global const int* src, global int* dst) { unsigned int global_id = get_global_id(0); int sum = 0; for (int i = global_id; i < numElems; i += get_global_size(0)) sum += src[i]; sum = work_group_reduce_add(sum); if (get_local_id(0) == 0) atomic_add(ds...
kernel void foo(global uchar4* A, int n) { *A = (uchar4)(1, 2, (uchar)n, 4); }
kernel void spinFact(global float2* w, int n) { unsigned int i = get_global_id(0); float2 angle = (float2)(2 * i * 3.14159265358979323846 / (float)n, (2 * i * 3.14159265358979323846 / (float)n) + 1.57079632679489661923); w[i] = cos(angle); }
kernel void uniform_write_race(global int* data) { *data = 0; }