kernel_code
stringlengths
49
1.22M
kernel void __cl_cpy_region_align16(global float* src, unsigned int src_offset, global float* dst, unsigned int dst_offset, unsigned int size) { int i = get_global_id(0) * 4; if (i < size * 4) { dst[i + dst_offset] = src[i + src_offset]; dst[i + dst_offset + 1] = src[i + src_offset + 1]; dst[i + dst_off...
kernel void test_fa1_4_5_kern(global float* a0, global float* a1, global float* a2, global float* a3, global float* b0, global float* b1, global float* b2, global float* b3, global float* b4) { unsigned int gtid = get_global_id(0); float tmp0 = a0[gtid] + 0.1f; float tmp1 = a1[gtid] + 1.1f; float tmp2 = a2[gtid...
kernel void reduce(global float* src, global float* dest, local float* tmp, int length) { int global_index = get_global_id(0); float accumulator = 0.f; while (global_index < length) { float element = src[global_index]; accumulator += element; global_index += get_global_size(0); } int local_index...
kernel void kernel_add_withoutDD4(global float* result_add, int N) { float4 t1 = (float4)(0.1, 0.2, 0.3, 0.4); float4 t2 = (float4)(0.1, 0.2, 0.3, 0.4); float4 t3 = (float4)(0.1, 0.2, 0.3, 0.4); float4 t4 = (float4)(0.1, 0.2, 0.3, 0.4); float4 t5 = (float4)(0.1, 0.2, 0.3, 0.4); float4 t6 = (float4)(0.1, 0.2...
kernel void max_fit_phase_0(int pop_len, global float* fitness, local float* scratch_val, local int* scratch_inx, global float* result_val, global int* result_inx) { int ginx = get_global_id(0); int max_index; float accumulator = -(__builtin_inff()); while (ginx < pop_len) { float element = fitness[ginx]; ...
kernel void test_block_1_7_kern(global int* a0, global int* b0, global int* b1, global int* b2, global int* b3, global int* b4, global int* b5, global int* b6, local int* c0) { int i; unsigned int gtid = get_global_id(0); unsigned int ltid = get_local_id(0); size_t lsz = get_local_size(0); c0[ltid] = a0[gtid]...
kernel void test_int(global int* src, global int* dst) { int i = get_global_id(0); dst[i] = popcount(src[i]); }
kernel void baseline(global unsigned int* data) { atom_inc(&data[get_global_id(0)]); }
kernel void test_arg_2_5_kern(global float4* a0, global float4* a1, global float4* b0, global float4* b1, global float4* b2, global float4* b3, global float4* b4) { float4 za = (float4)(0.75f, 0.5f, 0.25f, 0.33f); unsigned int gtid = get_global_id(0); float4 tmp0 = a0[gtid] + 0.1f + za; float4 tmp1 = a1[gtid] +...
kernel void vecAdd(global float* a, global float* b, global float* c) { size_t i = get_global_id(0); float4 r = vload4(i, a) + vload4(i, b); vstore4(r * r, i, c); }
kernel void tgamma_float(global float* src_0, global float* dst) { int gid = get_global_id(0); dst[gid] = tgamma(src_0[gid]); }
kernel void Stencil4_1(global float* in, global float* out, int width, int height, local float* one, local float* two, local float* three, local float* prefetchSpace) { int localWidth = get_local_size(0) + 2; int globalIDx = get_global_id(0); int localIDx = get_local_id(0) + 1; int group = get_group_id(0); i...
kernel void prepare_index(global unsigned int* restrict chids, global unsigned int* restrict lits, global uint2* restrict index, private unsigned int k) { unsigned int thread = get_global_id(0); uint2 res; if (thread < k) { res.x = chids[thread]; res.y = lits[thread]; index[thread] = res; } }
kernel void mad_sat_short2short2short2(global short2* src_0, global short2* src_1, global short2* src_2, global short2* dst) { int gid = get_global_id(0); dst[gid] = mad_sat(src_0[gid], src_1[gid], src_2[gid]); }
kernel void k(global int* dobarrier) { int i = get_local_id(0); if (dobarrier[i]) { barrier(0x02); } }
kernel void test_clamp(global long* out, global long* in) { *out = clamp(*in, (long)7, (long)42); }
kernel void test_upsample(global long4* out, int4 a) { *out = upsample(a, (uint4)42); }
kernel void test_arg_2_1_kern(global int* a0, global int* a1, global int* b0) { unsigned int gtid = get_global_id(0); int tmp0 = a0[gtid] + 0; int tmp1 = a1[gtid] + 1; b0[gtid] = (0 + 1) * (+tmp0 + tmp1); }
kernel void brahmaKernel(global int* buf) { for (int i = 0; (i <= 3); i++) { int x = (i * i); buf[0] = x; }; }
kernel void vaddSimple(global const float* A, global const float* B, global float* C) { C[get_global_id(0)] = A[get_global_id(0)] + B[get_global_id(0)]; }
kernel void lud_perimeter(global float* m, local float* dia, local float* peri_row, local float* peri_col, int matrix_dim, int offset) { int bx = get_group_id(0); int tx = get_local_id(0); if (tx < 64) { int idx = tx; int array_offset = offset * matrix_dim + offset; for (int i = 0; i < 64 / 2; ++i) {...
kernel void treat_axis_d(global double* arr, unsigned int Nx) { unsigned int i_cell = (unsigned int)get_global_id(0); if (i_cell < Nx) { arr[i_cell + Nx] -= arr[i_cell]; } }
float Iq(float q, float rg); float Iq(float q, float rg) { float exponent = rg * rg * q * q / 3.0f; float value = exp(-exponent); return value; } float Iqxy(float qx, float qy, float rg); float Iqxy(float qx, float qy, float rg) { return Iq(sqrt(qx * qx + qy * qy), rg); } kernel void guinier_Iqxy(global const ...
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 single_add(global float* out, global const float* x, global const float* y, int N) { int id = get_ind...
kernel void test10(global int* A, global char* B) { for (int i = 0; i < 1024; ++i) A[i] += 4 * B[i]; }
kernel void fma_test(global float* a, global float* b, global float* c, global float* result) { size_t id = get_global_id(0); result[get_global_id(0)] = fma(a[id], b[id], c[id]); }
kernel void clear(global float4* framebuffer, float4 float3) { int pos = get_global_id(0); framebuffer[pos] = float3; }
kernel void inc(global int* vector) { size_t i = get_global_id(0); vector[i] = vector[i] + 1; }
kernel void test_barrier_fence(global const int4* in, global int4* out) { int offset = 0; int4 val = 0; val += in[offset]; val += in[offset + 1]; val += in[offset + 2]; val += in[offset + 3]; read_mem_fence(0x01); val += in[offset + 4]; val += in[offset + 5]; val += in[offset + 6]; out[0] = val; ...
kernel void test_atomic_xchg(global unsigned* ptr, unsigned val) { atomic_xchg(ptr, val); }
kernel void moments(global float8* data, global float* group_result, int NUM_WORK_ITEMS, local float* local_result, global double* central_moments, global int* workgroups_left, float x_, float y_) { const int KERNEL_SIZE = 8; const int row = get_group_id(0); const int initial_col = get_local_id(0) * KERNEL_SIZE; ...
kernel void TestBarrier2(global float* input, global float* output, local float* shared) { int i = get_global_id(0); int l = get_local_id(0); shared[l] = input[i]; barrier(0x01); output[i] = (l >= get_local_size(0) - 4) ? 0.f : shared[l + 4]; }
kernel void cl_color_exchange(global const float4* in, global float4* out, float3 color_diff, float3 min, float3 max) { int gid = get_global_id(0); float4 in_v = in[gid]; float4 out_v; if (in_v.x > min.x && in_v.x < max.x && in_v.y > min.y && in_v.y < max.y && in_v.z > min.z && in_v.z < max.z) { out_v.x = ...
inline unsigned int swapBitOrder(unsigned int input) { unsigned int tmp0 = input & 0x0F0F0F0F; unsigned int tmp1 = input & 0xF0F0F0F0; tmp0 = tmp0 << 4; tmp1 = tmp1 >> 4; unsigned int tmpIn = tmp0 | tmp1; tmp0 = tmpIn & 0x33333333; tmp1 = tmpIn & 0xCCCCCCCC; tmp0 = tmp0 << 2; tmp1 = tmp1 >> 2; ...
kernel void test_upsample(global int4* out, short4 a) { *out = upsample(a, (ushort4)42); }
kernel void range_op(global float* A, const int size) { const unsigned range = size / get_global_size(0); const unsigned start = get_global_id(0) * range; const unsigned end = get_global_id(0) == get_global_size(0) ? size : start + range; for (int i = start; i < end; ++i) { A[i] = sqrt(A[i]); } }
kernel void compiler_arith_shift_right(global int* src, global int* dst) { int i = get_global_id(0); dst[i] = src[i] >> 24; }
constant unsigned long k[] = { 0x428a2f98d728ae22UL, 0x7137449123ef65cdUL, 0xb5c0fbcfec4d3b2fUL, 0xe9b5dba58189dbbcUL, 0x3956c25bf348b538UL, 0x59f111f1b605d019UL, 0x923f82a4af194f9bUL, 0xab1c5ed5da6d8118UL, 0xd807aa98a3030242UL, 0x12835b0145706fbeUL, 0x243185be4ee4b28cUL, 0x550c7dc3d5ffb4e2UL, 0x72be5d74f27b896fUL,...
kernel void test_block_2_2_kern(global float* a0, global float* a1, global float* b0, global float* b1, local float* c0, local float* c1) { int i; unsigned int gtid = get_global_id(0); unsigned int ltid = get_local_id(0); size_t lsz = get_local_size(0); c0[ltid] = a0[gtid] + 0.1f; c1[ltid] = a1[gtid] + 1.1f...
enum r123_enum_threefry32x2 { R_32x2_0_0 = 13, R_32x2_1_0 = 15, R_32x2_2_0 = 26, R_32x2_3_0 = 6, R_32x2_4_0 = 17, R_32x2_5_0 = 29, R_32x2_6_0 = 16, R_32x2_7_0 = 24 }; unsigned int RotL_32(unsigned int x, unsigned int N) { return (x << (N & 31)) | (x >> ((32 - N) & 31)); } struct r123array2x32 { unsigned int v[2];...
kernel void test_vector_3(global int3* in1, global int3* out1, global short3* in2, global int3* out2, global char3* in3, global int3* out3) { size_t id = get_global_id(0); out1[id] = in1[id] + (int)id; out2[id] = convert_int3(in2[id]) + (int)id; out3[id] = convert_int3(in3[id]) + (int)id; }
kernel void compiler_workgroup_reduce_add_int(global int* src, global int* dst) { int val = src[get_global_id(0)]; int sum = work_group_reduce_add(val); dst[get_global_id(0)] = sum; }
kernel void square(global float* a, global float* result) { int gid = get_global_id(0); result[gid] = a[gid] * a[gid]; }
kernel void array_sqrt(const int N, global float* data) { const int globalId = get_global_id(0); if (globalId >= N) { return; } data[globalId] = native_sqrt(data[globalId]); }
kernel void floor_float8(global float8* src_0, global float8* dst) { int gid = get_global_id(0); dst[gid] = floor(src_0[gid]); }
void helper_norm1_parallel_reduction(local float* tmp_buffer) { for (unsigned int stride = get_global_size(0) / 2; stride > 0; stride /= 2) { barrier(0x01); if (get_global_id(0) < stride) tmp_buffer[get_global_id(0)] += tmp_buffer[get_global_id(0) + stride]; } } float impl_norm_1(global const float* ...
kernel void render(global char* input, global char* output, int width, int height) { unsigned int i = get_global_id(0); unsigned int i_mul_4 = i * 4; unsigned char temp; temp = 0.1 * input[i_mul_4] + 0.6 * input[i_mul_4 + 1] + 0.3 * input[i_mul_4 + 2]; output[i_mul_4] = temp; output[i_mul_4 + 1] = temp; ...
kernel void logarithm10(global float* grid, int const num_elements) { int global_id = get_global_id(0); if (global_id >= num_elements) return; grid[global_id] = log10(grid[global_id]); }
kernel void native_log_float2(global float2* src_0, global float2* dst) { int gid = get_global_id(0); dst[gid] = native_log(src_0[gid]); }
kernel void FindMinDist(global int* dist, global bool* visited, global int* mvalue, const unsigned int graphSize) { const int id = get_global_id(0); const int width = get_global_size(0); int min_v = -1; int min_k = -1; for (int i = id; i < graphSize; i += width) { if ((min_v > dist[i] || min_v < 0) && !v...
kernel void multiply_by_scalar(private float coeff, global float* src, global float* res) { unsigned int const idx = get_global_id(0); res[idx] = src[idx] * coeff; }
float boundRange(float x, float lowerLimit, float upperLimit) { return (x < lowerLimit ? lowerLimit : (x > upperLimit ? upperLimit : x)); } float Logistic_fn(float x) { if (x < 88.722839f) { if (x > -88.722839f) return (float)1.0 / ((float)1.0 + exp(-x)); else return 0; } return 1; } floa...
kernel void remainder_short4short4(global short4* src_0, global short4* src_1, global short4* dst) { int gid = get_global_id(0); dst[gid] = src_0[gid] % src_1[gid]; }
kernel void exp_float2(global float2* src_0, global float2* dst) { int gid = get_global_id(0); dst[gid] = exp(src_0[gid]); }
kernel void kernel_sin_withoutDD1(global float* result_sin, int N) { float t1 = 1.23; float t2 = 1.23; float t3 = 1.2; float t4 = 1.2; float t5 = 1.2; float t6 = 1.2; float t7 = 1.2; float j = 0.0; for (j = 0.0; j < 10 * N; j = j + 1.0) { t1 = sin(j); t2 = sin(j); t3 = sin(j); t4 = si...
kernel void do_init_allstacks(int num_elts, global int* all_stacks) { int tid = get_global_id(0); if (tid >= num_elts) { return; } all_stacks[tid] = 0; }
kernel void vcopy(global int* a, global int* b) { int id = get_global_id(0); b[id] = a[id]; }
__kernel void array_add(global const double* src1, global const double* src2, global double* dst) { int gid = get_global_id(0); dst[gid] = src1[gid] + src2[gid]; }
kernel void FWD_calc_alpha(const int N, global const float* b_d, global float* alpha_d) { unsigned int idx = get_global_id(0); if (idx < N) { alpha_d[idx] *= b_d[idx]; } }
kernel void simple_kernel_0(const unsigned int arg0, const float arg1, global unsigned int* dst) { unsigned int idx = get_global_id(0); unsigned int data = arg0 + (unsigned int)arg1; dst[idx] = data; }
kernel void clkernel_scale(const int num, float x, global float* out) { const int i = get_global_id(0); if (i >= num) return; out[i] = x * out[i]; }
constant float4 gravity = (float4)(0, 0, -10, 0); kernel void integrate2Euler(float dt, global float4* position_in, global float4* velocity_in, global float4* position_out) { int id = get_global_id(0); position_out[id] = position_in[id] + dt * velocity_in[id]; if ((position_out[id].z < -position_out[id].x * 0.3...
__attribute__((work_group_size_hint(256, 1, 1))) __attribute__((work_group_size_hint(256, 1, 1))) __attribute__((work_group_size_hint(256, 1, 1))) __attribute__((work_group_size_hint(256, 1, 1))) __attribute__((work_group_size_hint(256, 1, 1))) __attribute__((work_group_size_hint(256, 1, 1))) __attribute__((work_group_...
kernel void FWD_scaling(const int N, global const float* scale_factor, const int scale_factor_index, global float* alpha_d) { unsigned int idx = get_global_id(0); if (idx < N) { alpha_d[idx] /= scale_factor[scale_factor_index]; } }
constant float beta = 0.66666f; kernel void adjust_weights_rprop(global const float* gradient, global const float* prev_gradient, global float* n, global float* weights) { int gid = get_global_id(0); if (fabs(gradient[gid]) < 1e-6f) return; float new_delta; float factor = prev_gradient[gid] * gradient[gid...
kernel void global_only_fence(local int* scratch, global int* output) { int l = get_local_id(0); int g = get_group_id(0); scratch[l] = l; barrier(0x02); if (get_local_id(0) == 0) { int x = 0; for (int i = 0; i < get_local_size(0); i++) { x += scratch[i]; } output[g] = x; } }
kernel void array_sub_f32(global const float* a, global const float* b, global float* c) { unsigned int i = get_global_id(0); c[i] = a[i] - b[i]; }
kernel void _redux_opencl(global double* dota, global double* dotb) { const int i = get_global_id(0); *dota += *dotb; }
struct state { float V; float h; float n; float z; float s_AMPA; float x_NMDA; float s_NMDA; float s_GABAA; float I_app; }; inline float _f_I_Na_m_inf(const float V) { const float theta_m = -30; const float sigma_m = 9.5f; return pow((1 + exp(-(V - theta_m) / sigma_m)), -1); } inline float _f...
kernel void test_arg_2_5_kern(global int* a0, global int* a1, global int* b0, global int* b1, global int* b2, global int* b3, global int* b4) { unsigned int gtid = get_global_id(0); int tmp0 = a0[gtid] + 0; int tmp1 = a1[gtid] + 1; b0[gtid] = (0 + 1) * (+tmp0 + tmp1); b1[gtid] = (1 + 1) * (+tmp0 + tmp1); b2...
kernel void sumSqFloatTest(int N, int M, global float* deviceFloat, local float* localFloat, global float* blockResults) { int i = get_global_id(0); int j = get_local_id(0); localFloat[j] = deviceFloat[i] * deviceFloat[i]; barrier(0x01); if (j == 0) { float temp = 0; for (int k = 0; k < M; k++) { ...
kernel void plus(global unsigned int* out, unsigned int in) { out[0] = +in; }
kernel void increment(global int* data) { int i = get_global_id(0); data[i] = data[i] + 1; }
kernel void subtract_short8short8(global short8* src_0, global short8* src_1, global short8* dst) { int gid = get_global_id(0); dst[gid] = src_0[gid] - src_1[gid]; }
kernel void broadcast_fw_kernel(const global float* px, const unsigned skip1, const unsigned skip2, const unsigned size, global float* py) { const unsigned i = get_global_id(0); if (i < size) py[i] = px[i % skip1 + (i / skip2) * skip1]; }
inline unsigned int scanLocalMem(unsigned int val, local unsigned int* lmem, int exclusive) { int idx = get_local_id(0); lmem[idx] = 0; idx += get_local_size(0); lmem[idx] = val; barrier(0x01); unsigned int t; for (int i = 1; i < get_local_size(0); i *= 2) { t = lmem[idx - i]; barrier(0x01); ...
kernel void builtin_sinpi(global float* src, global float* dst) { int i = get_global_id(0); dst[i] = sinpi(src[i]); }
kernel void complex_scalar_mult(global double2* a, double2 b) { unsigned int n = get_global_id(0); a[n].x = a[n].x * b.x - a[n].y * b.y; a[n].y = a[n].x * b.y + a[n].y * b.x; }
kernel void abs_ushort2(global ushort2* src_0, global ushort2* dst) { int gid = get_global_id(0); dst[gid] = abs(src_0[gid]); }
kernel void clz_long2(global long2* src_0, global long2* dst) { int gid = get_global_id(0); dst[gid] = clz(src_0[gid]); }
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 calc_E(global const double* phi, int nx, double dx, global double* E) { int gid = get_global_id(0); const int stride = get_global_size(0); int left, right; const double scale = -1.0 / (2 * dx); while (gid < nx) { if (gid == 0) E[0] = phi[1] - phi[nx - 1]; else if (gid == nx - 1) ...
inline float squash(float x) { return (1.0 / (1.0 + exp(-x))); } __attribute__((max_global_work_dim(0))) kernel void bpnn_layerforward(global float* restrict l1, global float* restrict l2, global float* restrict conn, int n1, int n2) { float sum; int j, k, l; float shift_reg[((1 + (1 % 2)) / 2) * 8 + 1]; l1...
kernel void compiler_async_copy_and_prefetch(global float* p) { prefetch(p, 10); local float l[10]; event_t e[2]; async_work_group_copy(l, p, 10, 0); async_work_group_copy(p, l, 10, 0); wait_group_events(2, e); }
kernel void test_arg_5_3_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) { 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] + 3; int tmp4 =...
kernel void renderMandelbrotKernel(global float* restrict pixels, const int xRes, const int yRes, const double xMin, const double xMax, const double yMin, const double yMax, const int maxIters, const double colourPeriod) { const int x = get_global_id(0) % xRes; const int y = get_global_id(0) / xRes; int iter = 0...
kernel void testdot(global float* a, global float* b, global float* c) { int gid = get_global_id(0); c[gid] = dot(a[gid], b[gid]); }
void GPUResample(global float* spectra, global const float* resamplingTable, global const float* interpolationMatrix, unsigned int inputSpectraLength, global float* resampledSpectra); void preProcess(global const short* spectrum, global const float* resamplingTable, global const float* interpolationMatrix, global const...
kernel void mad_float16float16float16(global float16* src_0, global float16* src_1, global float16* src_2, global float16* dst) { int gid = get_global_id(0); dst[gid] = mad(src_0[gid], src_1[gid], src_2[gid]); }
kernel void sum_partial(global float* partial, int n) { float sum = 0.f; for (int i = 0; i < n; ++i) { sum += partial[i]; } partial[0] = sum; }
kernel void compiler_upsample_int(global short* src1, global ushort* src2, global int* dst) { int i = get_global_id(0); dst[i] = upsample(src1[i], src2[i]); }
kernel void kernel_multi_withDD4(float p1, global float* result_multi, 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 *= 0.899f; t2 *= 0.899f; t2 *= 0.899f; t2 *= 0.899f; t2 *= 0.899f; t2 *= 0.899f; t2 *= 0.899f; t2 *=...
kernel void reduce_kernel(long d_Ne, global float* restrict d_sums, global float* restrict d_sums2) { float sum_1 = 0, sum_2 = 0; for (long i = 0; i < d_Ne; ++i) { sum_1 += d_sums[i]; sum_2 += d_sums2[i]; } d_sums[0] = sum_1; d_sums2[0] = sum_2; }
kernel void VectorAdd(global const short4* a, global const short4* b, global short4* c) { int id = get_global_id(0); c[id] = a[id] + b[id]; }
kernel void trunc_float8(global float8* src_0, global float8* dst) { int gid = get_global_id(0); dst[gid] = trunc(src_0[gid]); }
kernel void vmax(global float* vec1, global float* result, unsigned int size) { for (unsigned int stride = get_global_size(0) / 2; stride > 0; stride /= 2) { if (get_global_id(0) < stride) vec1[get_global_id(0)] = fmax(vec1[get_global_id(0) + stride], vec1[get_global_id(0)]); barrier(0x02); } if (g...
kernel void produce_fills(global const unsigned int* restrict input, global const unsigned int* restrict chids, global unsigned int* restrict output, private unsigned int k) { const unsigned int thread = get_global_id(0); const unsigned int idx_a = 2 * thread; const unsigned int idx_b = 2 * thread + 1; if (idx_...
kernel void foo(global int* data) { int x = data[0]; mem_fence(0x02); data[1] = x; }
kernel void bufferedFilter(float input, int currentPos, int filterOrder, global float* table, global float* workBuffer, global float* output, int outputPos, int outputLen) { int idx = get_global_id(0); int flt = idx / filterOrder; int pos = idx % filterOrder; int index = (pos + currentPos) % filterOrder; floa...
kernel void sign_float4(global float4* src_0, global float4* dst) { int gid = get_global_id(0); dst[gid] = sign(src_0[gid]); }