kernel_code
stringlengths
49
1.22M
kernel void kernel_csr_calc_row_nnz(const int nrow, global const int* row_offset, global int* row_nnz) { int ai = get_global_id(0); if (ai < nrow) row_nnz[ai] = row_offset[ai + 1] - row_offset[ai]; }
kernel void doubleGrayScaleDoubleFloat(global double* v, global float* v2) { unsigned int i = get_global_id(0); if (i % 3 == 0) { v[i] = v[i]; v[i + 1] = v[i]; v[i + 2] = v[i]; v2[i] = v2[i]; v2[i + 1] = v2[i]; v2[i + 2] = v2[i]; } }
kernel void reduceForces(global long* restrict longBuffer, global float4* restrict buffer, int bufferSize, int numBuffers) { int totalSize = bufferSize * numBuffers; float scale = 1 / (float)0x100000000; for (int index = get_global_id(0); index < bufferSize; index += get_global_size(0)) { float4 sum = (float4...
kernel void outerprod_three_kern(global float* a, global float* b, global float* c) { int i = get_global_id(0); c[i] = 3.0f * a[i] * b[i]; }
kernel void zeroMemory(global uchar* buffer) { const int globalX = get_global_id(0); buffer[globalX] = 0; }
inline float atomic_add(volatile global float* address, const float value) { float old = value; while ((old = atomic_xchg(address, atomic_xchg(address, 0.0f) + old)) != 0.0f) ; return old; } kernel void sigmoid_backward(global float* dinp, global float* doutp, global float* outp, global float* inp, int input...
kernel void timestep(global const float3* positions, global float3* predictedPositions, global const float3* velocities, const float dt) { float3 velocity = velocities[get_global_id(0)]; velocity.y = velocity.y - dt * 9.82f; predictedPositions[get_global_id(0)] = positions[get_global_id(0)] + dt * velocity; }
kernel void rhadd_char2char2(global char2* src_0, global char2* src_1, global char2* dst) { int gid = get_global_id(0); dst[gid] = rhadd(src_0[gid], src_1[gid]); }
kernel void CopyOver(global float* src, global float* dst) { dst[get_global_id(0)] = src[get_global_id(0)]; }
kernel void neq(global int* out, long a, long b) { out[0] = a != b; }
kernel void pre_decrement_int16(global int16* src_0, global int16* dst) { int gid = get_global_id(0); dst[gid] = --src_0[gid]; }
kernel void kernel_div_withDD4(float p1, global float* result_div, int N) { float t1 = p1; float4 t2 = t1 + (float4)(0, 0.1, 0.2, 0.3); int i = 0; for (i = 0; i < N; i++) { t2 /= 1.0f; t2 /= 1.0f; t2 /= 1.0f; t2 /= 1.0f; t2 /= 1.0f; t2 /= 1.0f; t2 /= 1.0f; t2 /= 1.0f; t2 /= 1...
kernel void minimalValue(global float* grid, const float value, int const num_elements) { int global_id = get_global_id(0); if (global_id >= num_elements) return; if (grid[global_id] < 0) grid[global_id] = value; }
kernel void half_sqrt_float16(global float16* src_0, global float16* dst) { int gid = get_global_id(0); dst[gid] = half_sqrt(src_0[gid]); }
kernel void minCl(global const int* a, global int* minData, const unsigned int numOfTotal) { for (size_t i = 0; i < numOfTotal; i++) { *minData = min(*minData, a[i]); } }
const sampler_t sampler = 0 | 0x10 | 2; int read_val(read_only image2d_t input, int x, int y) { int2 pos = (int2)(x, y); uint4 pixel = read_imageui(input, sampler, pos); return pixel.s0; } kernel void reset_buffer(global int* buffer, int value) { int pos = get_global_id(0); buffer[pos] = value; }
inline float sigmoid(float z) { return 1.0f / (1.0f + exp(-z)); } inline float sigmoid_gradient(float y) { return y * (1.0f - y); } inline float relu(float z) { return z > 0 ? z : 0; } inline float relu_gradient(float y) { return y > 0 ? 1 : 0; } inline float tanh_gradient(float y) { return 1.0f - y * y; } ...
kernel void C(global int* a, global int* b, const int c) { int d = get_global_id(0); if (d < c) a[d] = b[d]; }
kernel void compiler_insn_selection_max(global float* src, global float* dst) { int id = (int)get_global_id(0); dst[id] = max(src[id], src[0]); }
inline float sigmoid(float z) { return 1.0f / (1.0f + exp(-z)); } inline float sigmoid_gradient(float y) { return y * (1.0f - y); } inline float relu(float z) { return z > 0 ? z : 0; } inline float relu_gradient(float y) { return y > 0 ? 1 : 0; } inline float tanh_gradient(float y) { return 1.0f - y * y; } ...
kernel void inc(global float* input, global float* output, const unsigned int max_items) { int i = get_global_id(0); if (i < max_items) output[i] = input[i] + 1; }
kernel void vectoradd(global const float* vecA, global const float* vecB, global float* vecC) { int idx = get_global_id(0); vecC[idx] = vecA[idx] + vecB[idx]; }
kernel void s_vector_add(global const float* a, global const float* b, global float* c, int iNumElements) { int i = get_global_id(0); if (i < iNumElements) { c[i] = a[i] + b[i]; } }
kernel void display_sRGB(global float* imageIn1, global float* imageIn2) { private float a = 0.055; private float thr = 0.04045; int i = get_global_id(0); private float value1 = imageIn1[i]; private float value2 = imageIn2[i]; if (value1 > thr) imageIn1[i] = 99.0 * pow((value1 + a) / (1.0 + a), 2...
inline void ComparatorPrivate(float* keyA, unsigned int* valA, float* keyB, unsigned int* valB, unsigned int dir) { if ((*keyA > *keyB) == dir) { float t; t = *keyA; *keyA = *keyB; *keyB = t; t = *valA; *valA = *valB; *valB = t; } } inline void ComparatorLocal(local float* keyA, local u...
inline void md5_2words(unsigned int* words, unsigned int len, unsigned int* digest) { unsigned int h0 = 0x67452301; unsigned int h1 = 0xefcdab89; unsigned int h2 = 0x98badcfe; unsigned int h3 = 0x10325476; unsigned int a = h0; unsigned int b = h1; unsigned int c = h2; unsigned int d = h3; unsigned i...
float FxaaLuma(uchar3 rgb) { return (float)rgb.y * 1.96321f + (float)rgb.x; } kernel void AntiAliasingFXAA(global uchar4* screenInput, global uchar4* screenOutput, global int* width, global int* height) { int id = get_global_id(0); int x = id % *width; int y = id / *width; bool canUp = true; bool canDown ...
kernel void add_mul_const_kernel(global float* input, const float add_value, const float mul_value) { const unsigned int idx = get_global_id(0); const float out_val = (input[idx] + add_value) * mul_value; input[idx] = out_val; }
kernel void kernel_copy(global float4* target, global float4* source) { size_t gid = get_global_id(0); target[gid].x = source[gid].x; target[gid].y = source[gid].y; target[gid].z = source[gid].z; target[gid].w = source[gid].w; }
kernel void FillBufferFloat(global float* buffer, const float value) { const int index = get_global_id(0); if (index < get_global_size(0)) { buffer[index] = value; } }
constant float GAMMA = 42.57748f; constant float TWOPI = 6.283185307179586476925286766559005768394338798750211641949889185f; void rotmn(const float* n, float* m, float* r) { float phi, hp, cp, sp, ar, ai, br, bi, arar, aiai, arai2, brbr, bibi, brbi2, arbi2, aibr2, arbr2, aibi2, brmbi, brpbi, armai, arpai, tmp[3]; ...
inline void ComparatorPrivate(float* keyA, unsigned int* valA, float* keyB, unsigned int* valB, unsigned int dir) { if ((*keyA > *keyB) == dir) { float t; t = *keyA; *keyA = *keyB; *keyB = t; t = *valA; *valA = *valB; *valB = t; } } inline void ComparatorLocal(local float* keyA, local u...
kernel void test_signed_char(char c, char4 c2, global char* out) { *out = c; vstore4(c2, 4, out); }
kernel void mad_test(global unsigned int* result) { unsigned int a = 0x123456; unsigned int b = 0x112233; unsigned int c = 0x111111; result[0] = mad24(a, b, c); result[1] = mad_hi(a, b, c); }
kernel void sobel(global unsigned int* restrict frame_in, global unsigned int* restrict frame_out, const int iterations, const unsigned int threshold) { int Gx[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}}; int Gy[3][3] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}}; int rows[2 * 640 + 3]; int count = -(2 * 640 + 3); ...
kernel void test(int mult, global int* buf) { int idx = get_global_id(0); buf[idx] = idx * mult; }
kernel void uninitialized_local_variable(global int* output) { local int x; if (*output > 0) x = *output; *output = x; }
kernel void test_arg_5_4_kern(global int4* a0, global int4* a1, global int4* a2, global int4* a3, global int4* a4, global int4* b0, global int4* b1, global int4* b2, global int4* b3) { int4 za = (int4)(0, 1, 2, 3); unsigned int gtid = get_global_id(0); int4 tmp0 = a0[gtid] + 0 + za; int4 tmp1 = a1[gtid] + 1 + z...
kernel void exp2_float2(global float2* src_0, global float2* dst) { int gid = get_global_id(0); dst[gid] = exp2(src_0[gid]); }
kernel void kernelLong(long2 input, global long2* output) { output[0] = input; }
kernel void vector_mult_opencl(unsigned int nx, global float* val, float factor) { const int i = get_global_id(0); if (i < nx) { val[i] = i + 0.1; val[i] *= factor; } }
kernel void test_block_7_1_kern(global float* a0, global float* a1, global float* a2, global float* a3, global float* a4, global float* a5, global float* a6, global float* b0, local float* c0, local float* c1, local float* c2, local float* c3, local float* c4, local float* c5, local float* c6) { int i; unsigned int...
kernel void foo(global float* A, float f, float g) { *A = f + g; }
float4 mod289f4(float4 x) { float4 t = x; return t - floor(t * (1.0f / 289.0f)) * 289.0f; } float mod289(float x) { return x - floor(x * (1.0f / 289.0f)) * 289.0f; } float4 permutef4(float4 x) { return mod289f4(((x * 34.0f) + 1.0f) * x); } float permute(float x) { return mod289(((x * 34.0f) + 1.0f) * x); }...
kernel void six_hump_camel_function(global float* pos, global float* value) { if (get_global_id(0) == 0) { *value = -1 * (4 * pow(pos[0], 2) - 2.1 * pow(pos[0], 4) + pow(pos[0], 6) / 3 + pos[0] * pos[1] - 4 * pow(pos[1], 2) + 4 * pow(pos[1], 4)); } }
kernel void test_fn(global int4* src, global short8* dst) { int tid = get_global_id(0); short8 tmp = __builtin_astype((src[tid]), short8); dst[tid] = tmp; }
float linear_to_gamma_2_2(float value) { if (value > 0.003130804954f) return 1.055f * native_powr(value, (1.0f / 2.4f)) - 0.055f; return 12.92f * value; } float gamma_2_2_to_linear(float value) { if (value > 0.04045f) return native_powr((value + 0.055f) / 1.055f, 2.4f); return value / 12.92f; } kernel...
kernel void EM_alphabeta_update_gamma(global const float* alpha_beta, global float* gamma, global const float* ll_d, const int N, const unsigned int current) { unsigned int idx = get_global_id(0); if (idx < N) { gamma[current + idx] = alpha_beta[idx] / ll_d[0]; } }
kernel void test_cos(const global float* in, global float* out) { size_t gid = get_global_id(0); out[gid] = cos(in[gid]); }
kernel void post_decrement_int4(global int4* src_0, global int4* dst) { int gid = get_global_id(0); dst[gid] = src_0[gid]--; }
kernel void test_arg_2_6_kern(global int4* a0, global int4* a1, global int4* b0, global int4* b1, global int4* b2, global int4* b3, global int4* b4, global int4* b5) { int4 za = (int4)(0, 1, 2, 3); unsigned int gtid = get_global_id(0); int4 tmp0 = a0[gtid] + 0 + za; int4 tmp1 = a1[gtid] + 1 + za; b0[gtid] = (...
kernel void qssab_kernel(global float* RF, global float* RB, global float* A) { float DEN; (A[((((((8) * (11)) + 0)) - 1) * (4)) + (get_global_id(0))]) = (A[((((((8) * (11)) + 0)) - 1) * (4)) + (get_global_id(0))]) + (A[((((((8) * (11)) + 10)) - 1) * (4)) + (get_global_id(0))]) * (A[((((((10) * (11)) + 0)) - 1) * ...
kernel void scan_add_atomic(global int* A, global int* B) { int id = get_global_id(0); int N = get_global_size(0); for (int i = id + 1; i < N && id < N; i++) atomic_add(&B[i], A[id]); }
kernel void propagate_subblock_results(global float* output, global float* block_results) { unsigned int group_id = get_group_id(0); unsigned int gid = get_global_id(0); if (group_id > 0) output[gid] += block_results[group_id - 1]; }
kernel void foo(global unsigned int* A, unsigned int i) { A[i] = 0; }
kernel void vecMulAdd(global float* const restrict out, global const float* const restrict in1, global const float* const restrict in2, global const float* const restrict in3) { const size_t id = get_global_id(0); out[id] = in1[id] * in2[id] + in3[id]; }
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...
void F(private unsigned int* state, int src_idx, int dst_idx); void FL(private unsigned int* state); void InvFL(private unsigned int* state); kernel void shuffle_state1(global unsigned int* state, local unsigned int* cache) { size_t id = get_local_id(0); cache += (id & 0xFFFFFFE0) << 2; state += (get_global_id(0)...
kernel void ab_dot_x(double2 a, global double* b, global double2* x, global double2* z, unsigned int NxNr, unsigned int Nx) { unsigned int i_cell = (unsigned int)get_global_id(0); if (i_cell < NxNr) { unsigned int ir = i_cell / Nx; unsigned int ix = i_cell - ir * Nx; z[i_cell].s0 = b[ix] * (a.s0 * x[i_...
constant int DNH[9] = {1, 1, 1, 1, 0, 1, 1, 1, 1}; constant int GNH[9] = {1, 1, 1, 1, 0, 1, 1, 1, 1}; void CheckCellValue(global float* C, global float* Cgen, int condition, int current) { if (C[current] == condition) Cgen[current] = 1; else Cgen[current] = 0; } float Neighbourhood_filter(constant int* t...
kernel void MSE(unsigned int size, global const float* a1, global const float* a2, global float* out) { unsigned int id = get_global_id(0); if (id < size) { out[id] = pown((a1[id] - a2[id]), 2); } }
kernel void mul_hi_char8char8(global char8* src_0, global char8* src_1, global char8* dst) { int gid = get_global_id(0); dst[gid] = mul_hi(src_0[gid], src_1[gid]); }
kernel void test_arg_2_1_kern(global int4* a0, global int4* a1, global int4* b0) { int4 za = (int4)(0, 1, 2, 3); unsigned int gtid = get_global_id(0); int4 tmp0 = a0[gtid] + 0 + za; int4 tmp1 = a1[gtid] + 1 + za; b0[gtid] = (0 + 1) * (+tmp0 + tmp1); }
kernel void atomTest5(global int* out) { int t1 = atomic_inc(&out[0]); }
kernel void dup(global uchar4* B) { *B = (uchar4)(0, 0, 0, 0); }
kernel void test_arg_3_1_kern(global int4* a0, global int4* a1, global int4* a2, global int4* b0) { int4 za = (int4)(0, 1, 2, 3); unsigned int gtid = get_global_id(0); int4 tmp0 = a0[gtid] + 0 + za; int4 tmp1 = a1[gtid] + 1 + za; int4 tmp2 = a2[gtid] + 2 + za; b0[gtid] = (0 + 1) * (+tmp0 + tmp1 + tmp2); }
struct tree_global { volatile int nextNode; volatile int activeNodes; int depth; int pad; }; void insertPoint(global int* entries, const unsigned int pointIdx); int childIndex(float4 delta); float4 childDirection(int idx); float roundPow2(float val); void insertPoint(global int* entries, const unsigned int po...
kernel void mad_hi_intintint(global int* src_0, global int* src_1, global int* src_2, global int* dst) { int gid = get_global_id(0); dst[gid] = mad_hi(src_0[gid], src_1[gid], src_2[gid]); }
kernel void kraljice_brojac(global int* data, global int* brpolja, local float* partial_sums, global float* output) { int brP = 6; int k, ind; int x[6]; int lid = get_local_id(0); partial_sums[lid] = 0.0; x[1] = 0; k = 1; while (k > 0) { x[k]++; if (x[k] <= brP) { if (k == brP) { ...
kernel void DecodeBBoxesCORNER(const int nthreads, global const float* loc_data, global const float* prior_data, const int variance_encoded_in_target, const int num_priors, const int share_location, const int num_loc_classes, const int background_label_id, const int clip_bbox, const int locPredTransposed, global float*...
kernel void add_ushortushort(global ushort* src_0, global ushort* src_1, global ushort* dst) { int gid = get_global_id(0); dst[gid] = src_0[gid] + src_1[gid]; }
kernel void test_clamp(global int* out, global int* in) { *out = clamp(*in, (int)7, (int)42); }
kernel void hsv2rgb_pkd(global const double* input, global unsigned char* output, const unsigned int height, const unsigned int width) { int pixIdx = get_global_id(0); double hh, p, q, t, ff; int i; double h, s, v; pixIdx = 3 * pixIdx; if (pixIdx < height * width * 3) { h = input[pixIdx]; s = input...
kernel void kernel_tanpi_withoutDD1(global float* result_tanpi, int N) { float t1; float t2; float t3; float t4; float t5; float t6; float t7; float t8; float t9; float t10; float i = 0.0; float n = (float)(N); for (i = 0.0; i < n; i = i + 0.1) { t1 = tanpi(i); t2 = tanpi(i); t3 =...
kernel void test3(global float* v, global float* sum) { for (unsigned int i = 0; i < 1024; i++) *sum += v[i]; }
kernel void yuv422toRgb(const global unsigned char* yuv, global unsigned char* rgb, const unsigned int BGRtoRGB) { int gid = get_global_id(0); int i = gid * 4; int j = gid * 6; unsigned int channelSwitch = 0; if (BGRtoRGB == 1) channelSwitch = 2; int u = yuv[i]; int y1 = yuv[i + 1]; int v = yuv[i ...
kernel void predec(global unsigned int* out, unsigned int in) { out[0] = --in; }
kernel void mathTransform(global float* globalBuffer, int globalSize, local float* localValue, int type, int amount) { int i = get_global_id(0); if (i >= globalSize) { return; } *localValue = globalBuffer[i]; switch (type) { case 0: *localValue += amount; break; case 1: *localV...
kernel void minCl(global const int* a, global int* minData) { size_t i = get_global_id(0); *minData = min((int)minData, a[i]); }
kernel void vector_double(global float* A) { int i = get_global_id(0); A[i] *= 2; }
kernel void unary_plus_uchar8(global uchar8* src_0, global uchar8* dst) { int gid = get_global_id(0); dst[gid] = +src_0[gid]; }
kernel void sha1_prefix_search(global const uchar* preprocessed_message, const unsigned int message_size, global const unsigned int* target, const unsigned int precision_bits, const unsigned int offset, const ulong start, global ulong* result) { unsigned int t; unsigned int W[16], temp, A, B, C, D, E; unsigned in...
kernel void minres(global float* A, global float* r, global float* x0, global float* x, float Ar_r, float Ar_Ar, unsigned int n) { unsigned int i = get_global_id(0); if (i >= n) return; x[i] = x0[i] + Ar_r / Ar_Ar * r[i]; }
float addLogs(float A, float B) { float maxi = fmax(A, B); float corr = native_log(1.0 + native_exp(-fabs(A - B))); return maxi + corr; } kernel void createMatrices(global float* alpha, global float* beta, global float* gamma) { int _outputs[16] = {0, 0, 1, 1, 1, 1, 0, 0, 3, 3, 2, 2, 2, 2, 3, 3}; int _nextSt...
kernel void reduceViaScratch_multipleworkgroups(global float* inout, global float* out, local float* scratch) { int globalId = get_global_id(0); int localId = get_local_id(0); int workgroupSize = get_local_size(0); int workgroupid = get_group_id(0); scratch[localId] = inout[globalId]; barrier(0x01); for ...
kernel void vecAdd(global float* a) { int gid = get_global_id(0); a[gid] += a[gid]; }
kernel void cpu_csr(global const float* restrict val, global const float* restrict vec, global const int* restrict cols, global const int* restrict rowLengths, const int dim, global float* restrict out, global int* rowall, const int rowallsize, const int maxrl, const int rowsetzf, global int* rowinfo, int start) { in...
kernel void compiler_uint3_unaligned_copy(global unsigned int* src, global unsigned int* dst) { const int id = (int)get_global_id(0); const uint3 from = vload3(id, src); vstore3(from, id, dst); }
kernel void lowPass(global const float* in, global float* out, const unsigned int windowSize) { unsigned int x = get_global_id(0); float value = 0.0f; for (unsigned int i = x; i < x + windowSize; i++) value += in[i]; out[x + windowSize - 1] = value / windowSize; }
kernel void vecsmooth_v4(global int4* restrict s, global const int4* restrict v, int nquarts) { const int i = get_global_id(0); if (i >= nquarts) return; int4 v1 = (int4)(0), v2 = v[i], v3 = (int4)(0); int4 c = (int4)(2, 3, 3, 2); if (i > 0) { v1.s0 = v[i - 1].s3; c.s0++; } if (i < nquarts - ...
kernel void test_read(const int one, const int two, global int* out) { const int globalid = get_global_id(0); int sum = 0; int n = 0; while (n < 100000) { sum = (sum + one) % 1357 * two; n++; } out[globalid] = sum; }
kernel void block_scan(global unsigned int* restrict data, global unsigned int* restrict part, global unsigned int* restrict flag, unsigned int len) { local unsigned int d[1024]; local unsigned int p[1024]; local unsigned int f[1024]; const unsigned int thread = get_local_id(0); const unsigned int threads_per...
kernel void rhadd_intint(global int* src_0, global int* src_1, global int* dst) { int gid = get_global_id(0); dst[gid] = rhadd(src_0[gid], src_1[gid]); }
kernel void test_arg_8_1_kern(global int* a0, global int* a1, global int* a2, global int* a3, global int* a4, global int* a5, global int* a6, global int* a7, global int* b0) { unsigned int gtid = get_global_id(0); int tmp0 = a0[gtid] + 0; int tmp1 = a1[gtid] + 1; int tmp2 = a2[gtid] + 2; int tmp3 = a3[gtid] +...
kernel void zeroIntMemory(global int* buffer) { const int globalX = get_global_id(0); buffer[globalX] = 0.0f; }
kernel void bench_math_exp2(global float* src, global float* dst, float pwr, unsigned int loop) { float result = src[get_global_id(0)]; for (; loop > 0; loop--) result = exp2(result) * 0.1f; dst[get_global_id(0)] = result; }
kernel void sum(global float* sum, const global float* p) { const unsigned int GID = get_global_id(0); const unsigned int GSIZE = get_global_size(0); if (GID == 0) { sum[0] = 0; for (size_t i = 0; i < GSIZE - 1; i++) sum[0] += p[i]; } }
kernel void sub_sat_char2char2(global char2* src_0, global char2* src_1, global char2* dst) { int gid = get_global_id(0); dst[gid] = sub_sat(src_0[gid], src_1[gid]); }
kernel void test_fa1_6_2_kern(global float* a0, global float* a1, global float* a2, global float* a3, global float* a4, global float* a5, global float* b0, global float* b1) { unsigned int gtid = get_global_id(0); float tmp0 = a0[gtid] + 0.1f; float tmp1 = a1[gtid] + 1.1f; float tmp2 = a2[gtid] + 2.1f; float ...
kernel void subtract_int4int4(global int4* src_0, global int4* src_1, global int4* dst) { int gid = get_global_id(0); dst[gid] = src_0[gid] - src_1[gid]; }