// // Copyright (c) 2017 The Khronos Group Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #include "harness/compat.h" #include #include #include #include #include "procs.h" #define NUM_PROGRAMS 6 static const int vector_sizes[] = {1, 2, 3, 4, 8, 16}; const char *int_mad24_kernel_code = "__kernel void test_int_mad24(__global int *srcA, __global int *srcB, __global int *srcC, __global int *dst)\n" "{\n" " int tid = get_global_id(0);\n" "\n" " dst[tid] = mad24(srcA[tid], srcB[tid], srcC[tid]);\n" "}\n"; const char *int2_mad24_kernel_code = "__kernel void test_int2_mad24(__global int2 *srcA, __global int2 *srcB, __global int2 *srcC, __global int2 *dst)\n" "{\n" " int tid = get_global_id(0);\n" "\n" " dst[tid] = mad24(srcA[tid], srcB[tid], srcC[tid]);\n" "}\n"; const char *int3_mad24_kernel_code = "__kernel void test_int3_mad24(__global int *srcA, __global int *srcB, __global int *srcC, __global int *dst)\n" "{\n" " int tid = get_global_id(0);\n" " int3 tmp = mad24(vload3(tid, srcA), vload3(tid, srcB), vload3(tid, srcC));\n" " vstore3(tmp, tid, dst);\n" "}\n"; const char *int4_mad24_kernel_code = "__kernel void test_int4_mad24(__global int4 *srcA, __global int4 *srcB, __global int4 *srcC, __global int4 *dst)\n" "{\n" " int tid = get_global_id(0);\n" "\n" " dst[tid] = mad24(srcA[tid], srcB[tid], srcC[tid]);\n" "}\n"; const char *int8_mad24_kernel_code = "__kernel void test_int8_mad24(__global int8 *srcA, __global int8 *srcB, __global int8 *srcC, __global int8 *dst)\n" "{\n" " int tid = get_global_id(0);\n" "\n" " dst[tid] = mad24(srcA[tid], srcB[tid], srcC[tid]);\n" "}\n"; const char *int16_mad24_kernel_code = "__kernel void test_int16_mad24(__global int16 *srcA, __global int16 *srcB, __global int16 *srcC, __global int16 *dst)\n" "{\n" " int tid = get_global_id(0);\n" "\n" " dst[tid] = mad24(srcA[tid], srcB[tid], srcC[tid]);\n" "}\n"; const char *uint_mad24_kernel_code = "__kernel void test_uint_mad24(__global uint *srcA, __global uint *srcB, __global uint *srcC, __global uint *dst)\n" "{\n" " uint tid = get_global_id(0);\n" "\n" " dst[tid] = mad24(srcA[tid], srcB[tid], srcC[tid]);\n" "}\n"; const char *uint2_mad24_kernel_code = "__kernel void test_uint2_mad24(__global uint2 *srcA, __global uint2 *srcB, __global uint2 *srcC, __global uint2 *dst)\n" "{\n" " uint tid = get_global_id(0);\n" "\n" " dst[tid] = mad24(srcA[tid], srcB[tid], srcC[tid]);\n" "}\n"; const char *uint3_mad24_kernel_code = "__kernel void test_uint3_mad24(__global uint *srcA, __global uint *srcB, __global uint *srcC, __global uint *dst)\n" "{\n" " int tid = get_global_id(0);\n" " uint3 tmp = mad24(vload3(tid, srcA), vload3(tid, srcB), vload3(tid, srcC));\n" " vstore3(tmp, tid, dst);\n" "}\n"; const char *uint4_mad24_kernel_code = "__kernel void test_uint4_mad24(__global uint4 *srcA, __global uint4 *srcB, __global uint4 *srcC, __global uint4 *dst)\n" "{\n" " uint tid = get_global_id(0);\n" "\n" " dst[tid] = mad24(srcA[tid], srcB[tid], srcC[tid]);\n" "}\n"; const char *uint8_mad24_kernel_code = "__kernel void test_uint8_mad24(__global uint8 *srcA, __global uint8 *srcB, __global uint8 *srcC, __global uint8 *dst)\n" "{\n" " uint tid = get_global_id(0);\n" "\n" " dst[tid] = mad24(srcA[tid], srcB[tid], srcC[tid]);\n" "}\n"; const char *uint16_mad24_kernel_code = "__kernel void test_uint16_mad24(__global uint16 *srcA, __global uint16 *srcB, __global uint16 *srcC, __global uint16 *dst)\n" "{\n" " uint tid = get_global_id(0);\n" "\n" " dst[tid] = mad24(srcA[tid], srcB[tid], srcC[tid]);\n" "}\n"; int verify_int_mad24(int *inptrA, int *inptrB, int *inptrC, int *outptr, size_t n, size_t vecSize) { int r; size_t i; for (i=0; i> 8; } static inline int random_int32( MTdata d ) { return genrand_int32(d); } int test_integer_mad24(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems) { cl_mem streams[4]; cl_int *input_ptr[3], *output_ptr, *p; cl_program program[2*NUM_PROGRAMS]; cl_kernel kernel[2*NUM_PROGRAMS]; size_t threads[1]; int num_elements; int err; int i; MTdata d; size_t length = sizeof(cl_int) * 16 * n_elems; num_elements = n_elems * 16; input_ptr[0] = (cl_int*)malloc(length); input_ptr[1] = (cl_int*)malloc(length); input_ptr[2] = (cl_int*)malloc(length); output_ptr = (cl_int*)malloc(length); streams[0] = clCreateBuffer(context, 0, length, NULL, &err); test_error(err, "clCreateBuffer failed"); streams[1] = clCreateBuffer(context, 0, length, NULL, &err); test_error(err, "clCreateBuffer failed"); streams[2] = clCreateBuffer(context, 0, length, NULL, &err); test_error(err, "clCreateBuffer failed"); streams[3] = clCreateBuffer(context, 0, length, NULL, &err); test_error(err, "clCreateBuffer failed"); d = init_genrand( gRandomSeed ); p = input_ptr[0]; for (i=0; i