kernel_code
stringlengths
49
1.22M
kernel void foo(global float* in, global float* out) { *out = -(*in); }
; ; ; ; ; ; kernel void compiler_half_math_log(global float* src, global float* dst) { int i = get_global_id(0); dst[i] = log(src[i]); }
kernel void relational_greater_than_ucharuchar(global uchar* src_0, global uchar* src_1, global int* dst) { int gid = get_global_id(0); dst[gid] = (int)(src_0[gid] > src_1[gid]); }
kernel void nextafter_float16float16(global float16* src_0, global float16* src_1, global float16* dst) { int gid = get_global_id(0); dst[gid] = nextafter(src_0[gid], src_1[gid]); }
kernel void compiler_long_convert_double(global long* src0, global ulong* src1, global double* dst0, global double* dst1) { int i = get_global_id(0); double d = src0[i]; dst0[i] = d; d = src1[i]; dst1[i] = d; }
kernel void NCC(global const uchar* patch, global const uchar* positiveSamples, global const uchar* negativeSamples, global float* ncc, int posNum, int negNum) { int id = get_global_id(0); if (id >= 1000) return; bool posFlg; if (id < 500) posFlg = true; if (id >= 500) { id = id - 500; posFlg...
kernel void Kernel_C(global int* input, global int* output) { printf("\nExecuting NODE C.."); }
kernel void updateWeights(const int N, const float learningRate, const float momentum, global float* lastUpdate, global const float* gradWeights, global float* weights) { const int globalId = get_global_id(0); if (globalId >= N) { return; } lastUpdate[globalId] = momentum * lastUpdate[globalId] - learningR...
inline unsigned int GlobalIndex(unsigned int x, unsigned int y, unsigned int z, unsigned int w, unsigned int h, unsigned int d) { return (z * (w * h)) + (y * w) + x; } kernel void MinGPU(global uint4* src, global unsigned int* gmin, unsigned int nitems) { unsigned int count = (nitems / 4) / get_global_size(0); u...
kernel void serial_unique_copy(const unsigned int size, global unsigned int* unique_count, global int* _buf0, global int* _buf1) { unsigned int index = 0; int current = _buf0[0]; _buf1[0] = current; for (unsigned int i = 1; i < size; i++) { int next = _buf0[i]; if (!((current) == (next))) { _b...
kernel void builtin_shuffle2(global float* src1, global float* src2, global float* dst1, global float* dst2) { int i = get_global_id(0); float2 x = (float2)(src1[i], src2[i]); float2 y = (float2)(1234, 5678); uint4 mask = (uint4)(1, 0, 0, 0); float4 v1 = shuffle2(x, y, mask); float16 x2 = 0; float16 y2 = ...
kernel void atanh_float8(global float8* src_0, global float8* dst) { int gid = get_global_id(0); dst[gid] = atanh(src_0[gid]); }
kernel void harris_corner_response(global float* xx, global float* xy, global float* yy, global float* output, float sigmaD, float corner_response_alpha) { int i = get_global_id(0); float A = xx[i] * pow(sigmaD, 2); float B = yy[i] * pow(sigmaD, 2); float C = xy[i] * pow(sigmaD, 2); output[i] = A * B - C * C...
kernel void atomic_race_after(global int* data, global int* output) { atomic_inc(data); if (get_global_id(0) == get_global_size(0) - 1) { *output = *data; } }
kernel void transform_array_index(global int* array) { const int i = get_global_id(0); int pair[2] = {0, 0}; pair[i + 0] = 0; (i + 1)[pair] = 1; array[i] = pair[i + 0] + (i + 1)[pair] ; }
kernel void cpu_inplace_sub(global float* val1, float val2) { if (get_global_id(0) == 0) *val1 -= val2; }
kernel void calc_beta_dev(global float* beta_d, global float* b_d, float scale_t, int nstates, int obs_t, int t) { unsigned int idx = get_group_id(0) * get_local_size(0) + get_local_id(0); if (idx < nstates) { beta_d[(t * nstates) + idx] = beta_d[((t + 1) * nstates) + idx] * b_d[(obs_t * nstates) + idx] / scal...
inline unsigned int GlobalIndex(unsigned int x, unsigned int y, unsigned int z, unsigned int w, unsigned int h, unsigned int d) { return (z * (w * h)) + (y * w) + x; } kernel void MaxGPU(global uint4* src, global unsigned int* gmax, unsigned int nitems) { unsigned int count = (nitems / 4) / get_global_size(0); u...
kernel void exp2_float(global float* src_0, global float* dst) { int gid = get_global_id(0); dst[gid] = exp2(src_0[gid]); }
kernel void dotProduct(global const float* gridA, global const float* gridB, global float* result, int const num_elements, local float* cache) { const unsigned int local_id = get_local_id(0); const unsigned int global_id = get_global_id(0); const unsigned int group_id = get_group_id(0); const unsigned int local...
kernel void vector_copy(global int* in, global int* out, int offset) { int id = get_global_id(0); out[id + offset] = in[id + offset]; }
kernel void or (global int* out, int a, int b) { out[0] = a || b; }
kernel void compiler_abs_diff_long2(global long2* x, global long2* y, global ulong2* diff) { int i = get_global_id(0); diff[i] = abs_diff(x[i], y[i]); }
kernel void builtin_modf(global float* src, global float* dst, global float* it) { int i = get_global_id(0); float x; dst[i] = modf(src[i], &x); it[i] = x; }
kernel void reduce_mean(int total_size, int inner_size, global const float* src, global float* mean) { int blockSize = get_local_size(0); int blockIdx_x = get_group_id(0); local float sdata[256]; int tid = get_local_id(0); sdata[tid] = 0.0f; for (int j = tid; j < inner_size; j += blockSize) { sdata[tid...
uint2 ROTL64_1(const uint2 x, const unsigned int y) { return (uint2)((x.x << y) ^ (x.y >> (32 - y)), (x.y << y) ^ (x.x >> (32 - y))); } uint2 ROTL64_2(const uint2 x, const unsigned int y) { return (uint2)((x.y << y) ^ (x.x >> (32 - y)), (x.x << y) ^ (x.y >> (32 - y))); } ulong ROTL641(const ulong x) { return (x <...
inline float scanLocalMem(float val, local float* lmem, int exclusive) { int idx = get_local_id(0); lmem[idx] = 0.0f; idx += get_local_size(0); lmem[idx] = val; barrier(0x01); float t; for (int i = 1; i < get_local_size(0); i *= 2) { t = lmem[idx - i]; barrier(0x01); lmem[idx] += t; barr...
kernel void push_frontier(int nitems, global int* in_queue, global int* queue, int len) { int tid = get_global_id(0); int vertex; int flag = 0; if (tid < nitems) { vertex = in_queue[tid]; flag = 1; } if (flag == 1) queue[len + tid] = vertex; }
kernel void write(global int* data) { data[get_global_id(0)] *= 2; }
kernel void sample_test(global short3* sourceA, global int* destValues) { int tid = get_global_id(0); destValues[tid] = all(vload3(tid, (global short*)sourceA)); }
float LaplacianXY(global float* C, int row, int column) { float retval; float dx = 1; float dy = 1; int current = row * (32 * 16) + column; int left = row * (32 * 16) + column - 1; int right = row * (32 * 16) + column + 1; int top = (row - 1) * (32 * 16) + column; int bottom = (row + 1) * (32 * 16) + c...
kernel void reduce(global unsigned char* g_answer, global unsigned char* g_reducedSet, const unsigned int num_size) { unsigned int gid = get_group_id(0); unsigned int lid = get_local_id(0); unsigned int tid = get_global_id(0); if (tid < num_size) { int mod = 2; int remainder = 1; for (mod = 2, remai...
kernel void kernel_ldexp_withoutDD1(global float* result_ldexp, 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; int j = 1.0; float n = 10 * (float)(N); for (i = 0.0; i < n; i = i + 1.0) { t1 = ldexp(i, j); ...
kernel void max_pool_backward(const int nthreads, global const float* top_diff, global const float* mask, const int channels, const int height, const int width, const int pooled_h, const int pooled_w, const int kernel_h, const int kernel_w, const int stride_h, const int stride_w, const int pad_h, const int pad_w, globa...
kernel void indexing_sum_tester3(global unsigned int* inOutBuffer, global unsigned int* blockSumsBuffer) { inOutBuffer[get_global_id(0)] += blockSumsBuffer[get_group_id(0)]; }
kernel void abs_uchar8(global uchar8* src_0, global uchar8* dst) { int gid = get_global_id(0); dst[gid] = abs(src_0[gid]); }
kernel void double_precision_check(global float* src, global float* dst) { int id = (int)get_global_id(0); double d0 = 0.12345678912345678 + src[1]; double d1 = 0.12355678922345678 + src[0]; float rem = d1 - d0; dst[id] = rem; }
kernel void nonlinearpart_a(global double2* u, global double2* v, const double A, const double dt, const double a) { const int ind = get_global_id(0); u[ind].x = u[ind].x * exp(dt * a * (-1.0) * v[ind].x * v[ind].x); u[ind].y = 0.0; }
kernel void test_arg_1_7_kern(global float* a0, 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; b0[gtid] = (0.0f + 1.1f) * (+tmp0); b1[gtid] = (1.0f + 1.1f) * (+tmp...
kernel void array_copy_to_i32(global const int* f, global int* t) { unsigned int i = get_global_id(0); t[i] = f[i]; }
kernel void solver(global float* restrict L, global float* restrict x, global float* restrict y) { int i, j; for (i = 0; i < 20; i++) { y[i] = 1.0; for (j = 0; j < i; j++) { y[i] -= L[i * 20 + j] * y[j]; } y[i] /= L[i * 20 + i]; } for (i = 20 - 1; i >= 0; i--) { x[i] = y[i]; for ...
kernel void compiler_workgroup_reduce_add_uint(global unsigned int* src, global unsigned int* dst) { unsigned int val = src[get_global_id(0)]; unsigned int sum = work_group_reduce_add(val); dst[get_global_id(0)] = sum; }
kernel void VectorAddKernel(global float* c, global float* a, global float* b, const unsigned int n) { size_t wid = get_global_id(0); if (wid < n) c[wid] = a[wid] + b[wid]; }
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...
inline int changeTranspositionIndex(int i, int n) { int ip; ip = i; return ip; } kernel void kernel_PasteHistograms(global int* histo, global int* globsum) { size_t ig = get_global_id(0); size_t gr = get_group_id(0); int s; s = globsum[gr]; histo[2 * ig] += s; histo[2 * ig + 1] += s; barrier(...
kernel void test_arg_2_7_kern(global float4* a0, global float4* a1, global float4* b0, global float4* b1, global float4* b2, global float4* b3, global float4* b4, global float4* b5, global float4* b6) { float4 za = (float4)(0.75f, 0.5f, 0.25f, 0.33f); unsigned int gtid = get_global_id(0); float4 tmp0 = a0[gtid] +...
kernel void set_float2_kernel(global float2* d_out, const float first, const float second) { const unsigned int gidx = get_global_id(0); d_out[gidx] = (float2)(first, second); }
kernel void sum(global const double* a_g, global const double* b_g, global double* res_g) { int gid = get_global_id(0); res_g[gid] = a_g[gid] + b_g[gid]; }
kernel void test_arg_1_5_kern(global int4* a0, global int4* b0, global int4* b1, global int4* b2, global int4* b3, global int4* b4) { int4 za = (int4)(0, 1, 2, 3); unsigned int gtid = get_global_id(0); int4 tmp0 = a0[gtid] + 0 + za; b0[gtid] = (0 + 1) * (+tmp0); b1[gtid] = (1 + 1) * (+tmp0); b2[gtid] = (2 +...
kernel void compiler_unstructured_branch2(global int* src, global int* dst) { int id = (int)get_global_id(0); dst[id] = src[id]; if (dst[id] < 0) goto label1; dst[id] = 1; if (dst[id] > src[id]) goto label3; dst[id]++; if (src[id] <= 2) goto label2; label1: dst[id] -= 2; label2: dst[id] +=...
float4 matmul(float4 m[], float4 v) { return m[0] * v.s0 + m[1] * v.s1 + m[2] * v.s2 + m[3] * v.s3; } void transpose(float4 m[], float4 t[]) { t[0].s0 = m[0].s0; t[0].s1 = m[1].s0; t[0].s2 = m[2].s0; t[0].s3 = m[3].s0; t[1].s0 = m[0].s1; t[1].s1 = m[1].s1; t[1].s2 = m[2].s1; t[1].s3 = m[3].s1; t[2]...
kernel void clz_uint8(global uint8* src_0, global uint8* dst) { int gid = get_global_id(0); dst[gid] = clz(src_0[gid]); }
kernel void equal_float4float4(global float4* src_0, global float4* src_1, global int4* dst) { int gid = get_global_id(0); dst[gid] = (int4)(src_0[gid] == src_1[gid]); }
kernel void compute_next_record_start(global int* recordStart, global const int* lastRelevantIndex, unsigned int buffer_size) { if (get_global_id(0) == 0) { *recordStart = (*lastRelevantIndex + 1) % buffer_size; } }
kernel void Scan(global unsigned int* histogram) { unsigned int sum = 0; for (size_t i = 0; i < 8; ++i) { unsigned int val = atomic_xchg(&histogram[i], sum); sum += val; } }
inline void lotus_transform_password(private unsigned int* i1, private unsigned int* o1, local unsigned int* lotus_magic_table) { unsigned int p1; int i; p1 = 0x00; for (i = 0; i < 4; i++) { p1 = o1[i] = lotus_magic_table[((i1[i] & 0xff) ^ p1) & 0xff]; p1 = lotus_magic_table[(((i1[i] & 0x0000ff00) >> 8...
typedef int2 int2; ; ; ; ; ; ; ; ; kernel void Exp(unsigned int size, global const float* input, global float* output) { unsigned int base = get_local_id(0) + (get_global_id(0) - get_local_id(0)) * 10; for (unsigned int i = 0; i < 10; i++) { unsigned int index = base + i * get_local_size(0); if (index < siz...
kernel void kernel_cbrt_withoutDD1(global float* result_cbrt, int n) { float p1 = 1.0; float p2 = 1.0; float p3 = 1.0; float p4 = 1.0; float p5 = 1.0; float p6 = 1.0; float p7 = 1.0; float p8 = 1.0; float p9 = 1.0; float p10 = 1.0; float i = 0.0; float N = 3 * (float)(n); for (i = 0.0; i < N...
kernel void square_f32(unsigned int length, global float* a, global float* out) { const unsigned int id = get_global_id(0); if (id < length) { const float aVal = a[id]; out[id] = aVal * aVal; } }
void FHTIteration_gcs(local float* data, const global float* ang, int n, int n2, int k) { float a; float b; float c; float d; float e; float f; int i, j, ang_off; i = (int)((float)k / (float)(n / 2 + 1)); j = k - mul24(i, (n / 2 + 1)); int diff = (j == 0) ? n : j; float flip_sign = (float)((j ==...
kernel void statelessKernel(global uchar* src) { unsigned int tid = get_global_id(0); src[tid] = 0xCD; }
double dev_round_double(double value) { int newValue = (int)(value); if (value - newValue < .5f) return newValue; else return newValue++; } double calcLikelihoodSum(global unsigned char* I, global int* ind, int numOnes, int index) { double likelihoodSum = 0.0; int x; for (x = 0; x < numOnes; x++) ...
kernel void inplace_div_sub(global float* vec1, global const float* float2, global const float* fac, unsigned int size) { float factor = *fac; for (unsigned int i = get_global_id(0); i < size; i += get_global_size(0)) vec1[i] -= float2[i] / factor; }
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; } ...
float MathCalculations(float a, float b) { float res = 0; res += a * a * 0.315f + b * 0.512f + 0.789f; res += a * a * 0.15f + b * 0.12f + 0.789f; res += a * a * 0.35f + b * 0.51f + 0.89f; res += a * a * 0.31f + b * 0.52f + 0.7f; res += a * a * 0.4315f + b * 0.512f + 0.4789f; res += a * a * 0.515f + b * 0....
kernel void Accum1D(const global float* input, global float* output) { const int x_in = get_global_id(0); output[x_in] += input[x_in]; }
struct stable_info { double k1; double theta0; double alfa; double alfainvalfa1; double mu_0; double sigma; double xi; double xxi_th; double c2_part; double c1; double THETA_TH; double beta; double xi_coef; short is_xxi_negative; unsigned int integrand; double final_pdf_factor; double ...
kernel void Fill(global double* values, int n, const double value) { for (int i = get_global_id(0); i < n; i += get_global_size(0)) { values[i] = value; } }
struct S { int a; char b[2]; }; kernel void static_array_padded_struct(global char* output) { struct S s = {-1, {42, 7}}; int i = get_global_id(0); output[i] = s.b[i]; }
kernel void multiplication_assignment(global double* a, global double* b, const int n) { int i = get_global_id(0); if (i > n) return; a[i] *= b[i]; }
kernel void round_float2(global float2* src_0, global float2* dst) { int gid = get_global_id(0); dst[gid] = round(src_0[gid]); }
kernel void weight_CIC(global double* grid, int nx, double dx, global const double* xp, global const double* q, int N) { int gid = get_global_id(0); const int stride = get_global_size(0); int left, right; double xis; while (gid < N) { xis = xp[gid] / dx; left = (int)(floor(xis)); right = (left + ...
kernel void test2(global float* A, global float* B, float K, int start, int end) { for (int i = start; i < end; ++i) A[i] *= B[i] + K; }
kernel void ParallelBitonic_B_test(global const unsigned int* restrict in, global unsigned int* restrict out, int inc, int dir) { int t = get_global_id(0); int low = t & (inc - 1); int i = (t << 1) - low; int j = i | inc; unsigned int iData = in[i]; unsigned int iKey = iData; unsigned int jData = in[j]; ...
kernel void normalize_float(global float* buffer, private unsigned int buffer_size, private float one_over_sum) { size_t i = get_global_id(0); if (i < buffer_size) { buffer[i] = buffer[i] * one_over_sum; if (buffer[i] < 0 || !isfinite(buffer[i]) || isnan(buffer[i])) buffer[i] = 0; } }
; kernel void compiler_half_math_cos(global float* src, global float* dst) { int i = get_global_id(0); dst[i] = cos(src[i]); }
kernel void isunordered_float16float16(global float16* src_0, global float16* src_1, global int16* dst) { int gid = get_global_id(0); dst[gid] = (int16)(isunordered(src_0[gid], src_1[gid])); }
kernel void pown_(global float4* in, global float4* out, int n) { int gX = get_global_id(0); out[gX] = pown(in[gX], n); }
kernel void bsort_stage_n_manning(global uint4* g_data, local uint4* l_data, unsigned int stage, unsigned int high_stage) { int dir; uint4 input1, input2; int4 comp, add; unsigned int global_start, global_offset; add = (int4)(4, 5, 6, 7); dir = (get_group_id(0) / high_stage & 1) * -1; global_start = (ge...
kernel void variable_opencl(global int* val, global int* err, int factor) { const int i = get_global_id(0); if (i > 0) return; if (*val != 42 * factor) *err = 1; else *val *= -1; }
kernel void s_dot_kernel_naive(int n, global float* paramA, int offsetA, global float* paramB, int offsetB, global float* partialSum_d) { unsigned int i; unsigned int tid = get_local_id(0); unsigned int totalThreads = get_num_groups(0) * (128); unsigned int offset = (128) * get_group_id(0); for (i = offset +...
kernel void test_write_only(global int* dst) { int id = (int)get_global_id(0); dst[id] = id; }
float sstep(float a, float x) { if (x >= a) { return 1; } return 0; } float pulse(float a, float b, float x) { return sstep(a, x) - sstep(b, x); } float window(float x, float y) { return pulse(0.05, 0.95, x) - pulse(0.48, 0.52, x) - pulse(0, 0.05, y) - pulse(0.95, 1, y) - pulse(0.48, 0.52, y); } kernel...
kernel void relational_greater_than_or_equal_to_uint2uint2(global uint2* src_0, global uint2* src_1, global int2* dst) { int gid = get_global_id(0); dst[gid] = (int2)(src_0[gid] >= src_1[gid]); }
kernel void helloworld(global char* pIn, global char* pOut) { int iNum = get_global_id(0); pOut[iNum] = pIn[iNum] + 1; }
kernel void test_uint(global unsigned int* src, global unsigned int* dst) { int i = get_global_id(0); dst[i] = popcount(src[i]); }
kernel void vectAddInt(global int* A, global int* B, global int* C) { int i = get_global_id(0); C[i] = A[i] + B[i]; }
kernel void ker_elt_sum_f4(global float* out_data, const int with_relu, global const float* in_data1, global const float* in_data2, float coeff1, float coeff2, int count) { float4 tmp1, tmp2, tmp3; global float4* vdst; int idx = get_global_id(0); if (idx < count) { tmp1 = *((global const float4*)(&in_data...
kernel void initVects(global float* x, global float* r, global float* p, global float* b) { int id = get_global_id(0); x[id] = 0.0f; r[id] = b[id]; p[id] = b[id]; }
kernel void copy_half(global short* in, global short* out) { int index = get_global_id(0); out[index] = in[index]; }
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 acos_float16(global float16* src_0, global float16* dst) { int gid = get_global_id(0); dst[gid] = acos(src_0[gid]); }
kernel void max_pool_forward(const int nthreads, global const float* bottom, const int channels, const int height, const int width, const int pooled_h, const int pooled_w, const int kernel_h, const int kernel_w, const int stride_h, const int stride_w, const int pad_h, const int pad_w, global float* top, global float* m...
kernel void DeletionSphere(global float4* positions, global int* deletionBuffer, float4 centerAndRadius) { const int idx = get_global_id(0); float3 position = positions[idx].xyz; float3 center = centerAndRadius.xyz; float radiusSqr = centerAndRadius.w * centerAndRadius.w; float3 p = position - center; if (d...
kernel void grayScale(global char* v) { 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]; } }
kernel void cl_red_eye_removal(global const float4* in, global float4* out, float threshold) { int gid = get_global_id(0); float4 in_v = in[gid]; float adjusted_red = in_v.x * 0.5133333f; float adjusted_green = in_v.y * 1; float adjusted_blue = in_v.z * 0.1933333f; float adjusted_threshold = (threshold - 0....
kernel void max_fit_phase_1(int length, global float* result_val, global int* result_inx) { int tid = get_global_id(0); if (tid == 0) { float maxval = result_val[0]; int maxinx = result_inx[0]; for (int i = 1; i < length; i++) { float x = result_val[i]; if (x > maxval) { maxval = x;...
kernel void local_scan(global unsigned int* block_sums, local unsigned int* scratch, const unsigned int block_size, const unsigned int count, const unsigned int init, global unsigned int* _buf0, global unsigned int* _buf1) { const unsigned int gid = get_global_id(0); const unsigned int lid = get_local_id(0); if (...
kernel void kernelUChar(uchar16 input, global uchar16* output) { output[0] = input; }
kernel void kernel_rootn_withDD4(global float* result_rootn, int N) { float4 t1 = 4 + (float4)(0); int4 t2 = (int4)(1); int i = 0; for (i = 0; i < N; i++) { t1 = rootn(t1, t2); t1 = rootn(t1, t2); t1 = rootn(t1, t2); t1 = rootn(t1, t2); t1 = rootn(t1, t2); t1 = rootn(t1, t2); t1 = ro...