kernel_code
stringlengths
49
1.22M
unsigned int randomi(unsigned int low, unsigned int high, global uint4* s) { const unsigned int gid = get_global_id(0); unsigned int t; uint4 seed = s[gid]; t = (seed.x ^ (seed.x << 11)); seed.x = seed.y; seed.y = seed.z; seed.z = seed.w; seed.w = (seed.w ^ (seed.w >> 19)) ^ (t ^ (t >> 8)); s[gid] = s...
kernel void simulationStep(global float* A, global float* B, global float* Result) { int idx = get_global_id(0); Result[idx] = A[idx] + B[idx]; }
kernel void FIR(global float* output, global float* coeff, global float* temp_input, unsigned int numTap) { unsigned int tid = get_global_id(0); unsigned int numData = get_global_size(0); unsigned int xid = tid + numTap - 1; float sum = 0; unsigned int i = 0; for (i = 0; i < numTap; i++) { sum = sum +...
kernel void euler(global float4* pos, global float4* float3, global float4* vel, float dt, float dim) { unsigned int i = get_global_id(0); float4 p = pos[i]; float4 v = vel[i]; p.xyz += v.xyz; if (p.x >= dim) { p.x = -2.0f * dim + p.x; } else if (p.x <= -dim) { p.x = 2.0f * dim - p.x; } if (p...
constant int m[3] = {71, 72, 73}; const constant int n = 1; constant int o[3] = {3, 2, 1}; constant int4 a = {1, 2, 3, 4}; constant int4 b = {0, -1, -2, -3}; struct Person { char name[7]; int3 idNumber; }; struct Test1 { int a0; char a1; }; struct Test2 { char a0; int a1; }; struct Test3 { int a0; i...
kernel void half_log10_float16(global float16* src_0, global float16* dst) { int gid = get_global_id(0); dst[gid] = half_log10(src_0[gid]); }
kernel void foo(global uchar* a, global uchar* b, global uchar* c) { *a = bitselect(*a, *b, *c); }
kernel void float_precision(global float* output_ptr, float mul_value) { float mul_x = mul_value; float mul_y = (float)get_local_id(0); mul_x = mad(mul_y, mul_x, mul_y); mul_y = mad(mul_x, mul_y, mul_x); mul_x = mad(mul_y, mul_x, mul_y); mul_y = mad(mul_x, mul_y, mul_x); ; mul_x = mad(mul_y, mul_x, mul...
kernel void indexReduceMax(global float* buffer, const int length, local float* scratch, local int* scratchIndex, global float* result, global int* resultIndex) { int global_index = get_global_id(0); float accumulator = -1; int accumulatorIndex = -1; while (global_index < length) { float element = buffer[g...
kernel void bufferedFilter2(global float* inputBuff, global int* posBuff, int filterOrder, global float* table, global float* workBuffer, global float* output, int outputLen) { int idx = get_global_id(0); int flt = idx / filterOrder; int pos = idx % filterOrder; int currentPos = posBuff[0]; int outputPos = po...
kernel void test_atomic_dec(global unsigned* ptr) { atomic_dec(ptr); }
kernel void asbs_s_gpu_cpu(global float* s1, global float* fac2, unsigned int options2, global const float* s2, float fac3, unsigned int options3, global const float* s3) { float alpha = fac2[0]; float beta = fac3; if (options2 & (1 << 0)) { if (options3 & (1 << 0)) { if (options2 & (1 << 1)) { ...
kernel void compiler_abs_short3(global short3* src, global ushort3* dst) { int i = get_global_id(0); dst[i] = abs(src[i]); }
kernel void testWorkGroupIAddUnsigned(unsigned int a, global unsigned int* res) { res[0] = work_group_reduce_add(a); }
kernel void min_uchar8uchar8(global uchar8* src_0, global uchar8* src_1, global uchar8* dst) { int gid = get_global_id(0); dst[gid] = min(src_0[gid], src_1[gid]); }
kernel void rootn_float16int16(global float16* src_0, global int16* src_1, global float16* dst) { int gid = get_global_id(0); dst[gid] = rootn(src_0[gid], src_1[gid]); }
kernel void gen_numbers(global uint4* seeds, global unsigned int* output) { const unsigned int iWorkItem = get_global_id(0); unsigned int nNumbersInThisWorkItem = (0 / get_global_size(0)); if (iWorkItem == get_global_size(0) - 1) nNumbersInThisWorkItem += (0 - (0 / get_global_size(0)) * get_global_size(0)); ...
kernel void unary_plus_long16(global long16* src_0, global long16* dst) { int gid = get_global_id(0); dst[gid] = +src_0[gid]; }
kernel void rhadd_int8int8(global int8* src_0, global int8* src_1, global int8* dst) { int gid = get_global_id(0); dst[gid] = rhadd(src_0[gid], src_1[gid]); }
kernel void random_WELL512(global long* state, global int* index) { unsigned long a, b, c, d; a = state[index[0]]; c = state[(index[0] + 13) & 15]; b = a ^ c ^ (a << 16) ^ (c << 15); c = state[(index[0] + 9) & 15]; c ^= (c >> 11); a = state[index[0]] = b ^ c; d = a ^ ((a << 5) & 0xDA442D24UL); index[0...
kernel void kern(global float* a, global float* b, global float* c, global float* result) { result[0] = fmin(a[0], b[0]); result[1] = fmod(a[1], b[1]); result[2] = hypot(a[2], b[2]); result[3] = lgamma(a[3]); result[4] = log(a[4]); result[5] = log2(a[5]); result[6] = log10(a[6]); result[7] = log1p(a[7])...
int z(private int a) { return (a + 1); } int f(global int* buf, private int y) { if ((y == 0)) { return z(9); } else { return buf[2]; }; } kernel void brahmaKernel(global int* buf) { buf[0] = f(buf, 0); }
kernel void STREAM_Triad(global double* a, global double* b, global double* c, global double* scale, global int* len) { int threadIdX = get_local_id(0); int workGroupSize = get_global_size(0); int idx = get_global_id(0); if (idx < *len) a[idx] = c[idx] * (*scale) + b[idx]; }
kernel void selectionSortFinal(global float* keys, global float* vals, const int count) { const int i = get_local_id(0); const int numOfGroups = get_num_groups(0); const int wg = get_local_size(0); int pos = 0, same = 0; const int offset = get_group_id(0) * wg; const int remainder = count - wg * (numOfGroup...
kernel void ker_scale_fwd(global float* out_data, const int count, const float scale, const float shift, global const float* in_data) { int global_idx = get_global_id(0); out_data[global_idx] = in_data[global_idx] * scale + shift; }
double4 bar(global double4* in, int n) { return in[n]; } kernel void foo(global double4* out, global double4* in, int n) { *out = bar(in, n); }
kernel void crossover(int pop_len, int num_cities, global const int* old_x_coord, global const int* old_y_coord, global int* new_x_coord, global int* new_y_coord, global int* selected_parents_inx, float prob_crossover, global float* rnd_prob_cross, global int* cross_loc) { int tid = get_global_id(0); if (tid < pop...
kernel void min_uint4uint4(global uint4* src_0, global uint4* src_1, global uint4* dst) { int gid = get_global_id(0); dst[gid] = min(src_0[gid], src_1[gid]); }
kernel void vload_bench_1short3(global short* src, global unsigned int* dst, unsigned int offset) { int id = (int)get_global_id(0); uint3 srcV = 0; for (int i = 0; i < 1; i++) { srcV += convert_uint3(vload3(id + (i & 0xFFFF), src + offset)); } vstore3(srcV, id, dst); }
kernel void foo(global char* a, global char* b, global char* c) { *a = add_sat(*b, *c); }
kernel void assignGlobal(global int* A, global int* B, global int* C) { int tid = get_global_id(0); C[tid] = A[tid]; }
kernel void matrixScalarMultiply(global const float* m, float k, global float* mr) { int iGID = get_global_id(0); mr[iGID] = m[iGID] * k; }
struct Test { char t0; int t1; }; constant int two = 2; kernel void compiler_local_slm1(global ulong* dst) { local int hop[16]; dst[1] = (ulong)&hop[1]; dst[0] = (ulong)&hop[0]; }
constant int x[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; kernel void compiler_private_const(global int* dst) { const int array0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; dst[get_global_id(0)] = array0[get_global_id(0)] + x[get_global_id(0)]; }
kernel void SetValue(global float* Buffer, float Value) { unsigned int id = get_global_id(0); Buffer[id] = Value; }
kernel void compiler_clz_short(global short* src, global short* dst) { int i = get_global_id(0); dst[i] = clz(src[i]); }
kernel void kernel_exp_withDD1(global float* result_exp, int N) { float t1 = -9999.99; int i = 0; for (i = 0; i < N; i++) { t1 = exp(t1 / (t1 + 0.01)); t1 = exp(t1 / (t1 + 0.01)); t1 = exp(t1 / (t1 + 0.01)); t1 = exp(t1 / (t1 + 0.01)); t1 = exp(t1 / (t1 + 0.01)); t1 = exp(t1 / (t1 + 0.01))...
kernel void apply_periodic_boundary(global double2* position, global double2* oldPosition, const double4 boundaries) { size_t index = get_global_id(0); double holder; double intervals = boundaries.y - boundaries.x; double2 privatePos = position[index]; double2 privateOldPos = oldPosition[index]; holder = (...
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 NothingTwo(global float* one, global float* two) { }
kernel void vecAdd(global int* a, global int* b, global int* c) { size_t pos = get_global_id(0); c[pos] = a[pos] + b[pos]; }
kernel void test(long A, long B, global long* dst) { *dst = A >= B; }
kernel void mataccKernel5(global float8* mA, global float* mC, const unsigned int mWidth) { unsigned int g_id = get_group_id(0); unsigned int nunits = get_num_groups(0); float8 elt = (float8)(0.0); for (unsigned int idx = 0; idx < mWidth * mWidth / 8 / nunits; idx++) { float8 mAtmp = mA[idx]; elt.s0 += ...
kernel void test(float global* a, const int n) { float sum = 0.0; for (int i = 0; i < n; i++) sum += a[i]; a[get_global_id(0)] = sum; }
kernel void compiler_write_only_bytes(global char* dst) { int id = (int)get_global_id(0); dst[id] = 2; }
kernel void vectorAdd(global int* bufferA, global int* bufferB, global int* result, const unsigned int size, local int* flags) { size_t id = get_global_id(0); if (id < size) { result[id] = bufferA[id] + bufferB[id]; } }
kernel void vecinit(global float* vectorA, global float* vectorB) { vectorA[get_global_id(0)] = (float)get_global_id(0); vectorB[get_global_id(0)] = (float)get_global_id(0) / 2; }
float CND(float d); void BlackScholesBody(global float* call, global float* put, float S, float X, float T, float R, float V); float CND(float d) { const float A1 = 0.31938153f; const float A2 = -0.356563782f; const float A3 = 1.781477937f; const float A4 = -1.821255978f; const float A5 = 1.330274429f; cons...
float4 computeForce(float4 ipos, float4 jpos, float softening) { float4 d = jpos - ipos; d.w = 0; float distSq = d.x * d.x + d.y * d.y + d.z * d.z + softening * softening; float invdist = native_rsqrt(distSq); float coeff = jpos.w * (invdist * invdist * invdist); return coeff * d; } kernel void nbody(globa...
kernel void logb_float(global float* src_0, global float* dst) { int gid = get_global_id(0); dst[gid] = logb(src_0[gid]); }
kernel void test_clamp(global short3* out, global short3* in) { *out = clamp(*in, (short3)7, (short3)42); }
kernel void real_to_complex(global float* in, global float2* out, unsigned int size) { for (unsigned int i = get_global_id(0); i < size; i += get_global_size(0)) { float2 val = 0; val.x = in[i]; out[i] = val; } }
unsigned int sumReduce128(local unsigned int* arr); unsigned int compactSIMDPrefixSum(local const unsigned int* dsData, local const unsigned int* dsValid, local unsigned int* dsCompact, local unsigned int* dsLocalIndex); unsigned int exclusivePrescan128(local const unsigned int* in, local unsigned int* outAndTemp); uns...
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 test_barrier(global int* status) { global int* base = status + get_global_id(0) * (8 + 4); base[0] = 0; barrier(0x01); base[1] = 1; barrier(0x02); base[2] = 2; for (int i = 1; i < 8; i += 1) { barrier(0x01); base[3 + i] = 3 + i; } }
kernel void atomTest1(global int* out) { int gid = get_global_id(0); int lid = get_local_id(0); local int test[6]; if (lid < 6) test[lid] = 0; int a = 1; int t1 = atomic_add(&out[0], a); int t2 = atomic_add(&test[0], a); out[1] = test[0]; int t3 = atomic_sub(&out[2], a); int t4 = atomic_sub(&t...
kernel void __cl_cpy_region_align4(global float* src, unsigned int src_offset, global float* dst, unsigned int dst_offset, unsigned int size) { int i = get_global_id(0); if (i < size) dst[i + dst_offset] = src[i + src_offset]; }
kernel void rhadd_overflow(global ulong* output) { output[0] = rhadd(0UL, 0xFFFFFFFFFFFFFFFFUL); }
int ave(int a, int b) { return (a + b) / 2; } kernel void simple(global int* data) { int tid = get_global_id(0) * get_global_size(0) + get_local_id(0); data[tid] = ave(tid, tid); }
kernel void array_negate_f32(global float* a, global float* b) { unsigned int i = get_global_id(0); b[i] = -a[i]; }
kernel void OCL_SSSP_KERNEL2(global int* vertexArray, global int* edgeArray, global float* weightArray, global int* maskArray, global float* costArray, global float* updatingCostArray, int vertexCount) { int tid = get_global_id(0); if (costArray[tid] > updatingCostArray[tid]) { costArray[tid] = updatingCostArr...
kernel void Encrypt(global const char* DecStrng, global char* EncStrng, int Key) { unsigned int xid = get_global_id(0); EncStrng[xid] = DecStrng[xid]; }
kernel void getBufferAddress2(global ulong* dataArray) { dataArray[get_global_id(0) + 2] = dataArray[get_global_id(0)]; dataArray[get_global_id(0) + 3] = dataArray[get_global_id(0) + 1]; }
kernel void sum(global float* c) { int gid = get_global_id(0); c[gid] = 1.f; }
struct A { float4 x; }; struct B { struct A a[2]; }; kernel void foo(global short* a) { }
kernel void atomic_cmpxchg_read_race(global int* data) { int i = get_global_id(0); if (i == 0) { *data = 0; } else { atomic_cmpxchg(data, 0, 0x01000001); } }
kernel void clean_mcd43b3_qa(global const float* albedowsa, global const float* albedobsa, global const float* albedoqa, global float* albedo_clean, global const int* N) { int i = get_global_id(0); if (i < N) albedo_clean[i] = (albedowsa[i] * 0.25 + (1 - 0.25) * albedobsa[i]) * 0.1; if (albedoqa[i] > 1) a...
__attribute__((intel_reqd_sub_group_size(16))) kernel void test_kernel(const global unsigned int* M, const global unsigned int* V, global unsigned int* dst) { const int x = get_global_id(0); const int wind = get_global_size(0); dst[x] = 0; for (int i = 0; i < wind; ++i) { dst[x] += M[x * wind + i] * V[i]; ...
kernel void brahmaKernel(global int* buf) { buf[0] = (2 - 3); buf[1] = (2 - 5); }
kernel void kernel_acos_withoutDD1(global float* result_acos, int N) { float t1 = 1.23; float t2 = t1; float t3 = t1; float t4 = t1; float t5 = t1; float t6 = t1; float t7 = t1; float t8 = t1; float t9 = t1; float t10 = t1; float t11 = 1.23; float t12 = t1; float t13 = t1; float t14 = t1; ...
kernel void kernel_add_withDD1(global float* result_add, int N) { float t1 = 1.0f; float t2 = 1.0f; int i = 0; for (i = 0; i < N; i++) { t1 += t2; t1 += t2; t1 += t2; t1 += t2; t1 += t2; t1 += t2; t1 += t2; t1 += t2; t1 += t2; t1 += t2; t1 += t2; t1 += t2; t1 ...
kernel void kernel1_write(global char* ptr, unsigned long memsize) { int i; global unsigned long* buf = (global unsigned long*)ptr; int idx = get_global_id(0); unsigned long n = memsize / sizeof(unsigned long); int total_num_threads = get_global_size(0); for (i = idx; i < n; i += total_num_threads) { b...
kernel void global_squarenorm_reduction(global float* dest, global float* result_tmp, const unsigned int elems) { unsigned int id = get_global_id(0); float tmp = 0; if (id == 0) { for (unsigned int i = 0; i < elems; i++) { tmp += result_tmp[i]; } *dest = tmp; } }
kernel void add_sat_ushort2ushort2(global ushort2* src_0, global ushort2* src_1, global ushort2* dst) { int gid = get_global_id(0); dst[gid] = add_sat(src_0[gid], src_1[gid]); }
float linear_to_gamma_2_2(float value); float gamma_2_2_to_linear(float value); 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 ...
kernel void copy_with_offset(const int N, global const float* in, const int inoffset, global float* out, const int outoffset) { const int globalId = get_global_id(0); if (globalId >= N) { return; } out[globalId + outoffset] = in[globalId + inoffset]; }
kernel void clkernel_sign(const int num, global const float* in, global float* out) { const int i = get_global_id(0); if (i >= num) return; out[i] = (in[i] > 0) - (in[i] < 0); }
kernel void source_lines_test(global int* Out) { int var0 = 0x777; int var1 = 0x888; int var2 = var0 + var1; *Out = var2; }
kernel void foo(global long2* a, global long2* b) { *a = popcount(*b); }
kernel void kernel_rsqrt_withDD2(global float* result_rsqrt, int N) { float t1 = 23456.234; float2 t2 = t1 + (float2)(0.1, 0.2); int i = 0; for (i = 0; i < N; i++) { t2 = rsqrt(t2); t2 = rsqrt(t2); t2 = rsqrt(t2); t2 = rsqrt(t2); t2 = rsqrt(t2); t2 = rsqrt(t2); t2 = rsqrt(t2); t2...
kernel void half_log2_float8(global float8* src_0, global float8* dst) { int gid = get_global_id(0); dst[gid] = half_log2(src_0[gid]); }
kernel void bitonicSort(global unsigned int* theArray, const unsigned int stage, const unsigned int passOfStage, const unsigned int width) { unsigned int sortIncreasing = 1; unsigned int threadId = get_global_id(0); unsigned int pairDistance = 1 << (stage - passOfStage); unsigned int blockWidth = 2 * pairDista...
kernel void Map_LOG(global float* x, float arg, global float* dest, long offsetX, long offsetDest, long stepX, long stepDest) { unsigned int id = get_global_id(0); float a = x[offsetX + stepX * id]; float b = arg; float c = (float)(log((float)a) / log((float)b)); dest[offsetDest + stepDest * id] = c; }
kernel void buildin_work_dim(global int* ret) { *ret = get_work_dim(); }
kernel void FillBufferBytes(global uchar* pDst, unsigned int dstOffsetInBytes, const global uchar* pPattern) { unsigned int dstIndex = get_global_id(0) + dstOffsetInBytes; unsigned int srcIndex = get_local_id(0); pDst[dstIndex] = pPattern[srcIndex]; }
kernel void gemm(const global float* A, const global float* B, global float* C) { barrier(0x01); barrier(0x01); barrier(0x01); barrier(0x01); barrier(0x01); barrier(0x01); barrier(0x01); barrier(0x01); barrier(0x01); barrier(0x01); C[0] += A[0] * B[0]; C[1] += A[1] * B[1]; }
kernel void Reduction_SequentialAddressing(global unsigned int* array, unsigned int stride) { unsigned int id = get_global_id(0); array[id] = array[id] + array[id + stride]; }
kernel void abs_diff_short2short2(global short2* src_0, global short2* src_1, global ushort2* dst) { int gid = get_global_id(0); dst[gid] = (ushort2)(abs_diff(src_0[gid], src_1[gid])); }
kernel void init(global unsigned int* out, const ulong out_count, const unsigned int empty) { for (unsigned int i = 0; i < out_count; ++i) { out[i] = empty; } }
kernel void diag_precond(global const float* diag_A_inv, global float* x, unsigned int size) { for (unsigned int i = get_global_id(0); i < size; i += get_global_size(0)) x[i] *= diag_A_inv[i]; }
kernel void test_abs_short3(global short* srcA, global ushort* dst) { int tid = get_global_id(0); ushort3 tmp = abs(vload3(tid, srcA)); vstore3(tmp, tid, dst); }
kernel void even_squares_kernel_gpu(global const int* in, global int* out) { int i = get_global_id(0) * 2; out[i] = in[i] * in[i]; }
kernel void test_stream_write_float(global float* src, global float* dst) { int tid = get_global_id(0); dst[tid] = src[tid]; }
kernel void compiler_float_convert_double(global float* src, global double* dst) { int i = get_global_id(0); double d = src[i]; dst[i] = d; }
kernel void test_nextafter(const global float* in0, const global float* in1, global float* out) { size_t gid = get_global_id(0); out[gid] = nextafter(in0[gid], in1[gid]); }
kernel void compiler_double_div(global double* src1, global double* src2, global double* dst) { int i = get_global_id(0); if (i % 3 != 0) dst[i] = src1[i] / src2[i]; else dst[i] = 0.0; }
kernel void test_arg_4_2_kern(global int4* a0, global int4* a1, global int4* a2, global int4* a3, global int4* b0, global int4* b1) { 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; int4 tmp3 = a...
kernel void test_clamp(global int4* out, global int4* in) { *out = clamp(*in, (int4)7, (int4)42); }
kernel void test_uchar(global uchar* src, global uchar* dst) { int i = get_global_id(0); dst[i] = popcount(src[i]); }
kernel void clkernel_eltmult(const int num, global const float* in1, global const float* in2, global float* out) { const int i = get_global_id(0); if (i >= num) return; out[i] = in1[i] * in2[i]; }
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]...