• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2017 The Khronos Group Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //    http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #include "harness/compat.h"
17 
18 #include <stdio.h>
19 #include <string.h>
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 
23 #include "procs.h"
24 
min_verify_float(float * x,float * y,float * out,int numElements,int vecSize)25 static int min_verify_float( float *x, float *y, float *out, int numElements, int vecSize )
26 {
27     for( int i = 0; i < numElements * vecSize; i++ )
28     {
29         float v = ( y[ i ] < x[ i ] ) ? y[ i ] : x[ i ];
30         if( v != out[ i ] ) {
31       log_error("x[%d]=%g y[%d]=%g out[%d]=%g, expected %g. (index %d is vector %d, element %d, for vector size %d)\n", i, x[i], i, y[i], i, out[i], v, i, i/vecSize, i%vecSize, vecSize);
32             return -1;
33     }
34     }
35     return 0;
36 }
37 
min_verify_double(double * x,double * y,double * out,int numElements,int vecSize)38 static int min_verify_double( double *x, double *y, double *out, int numElements, int vecSize )
39 {
40     for( int i = 0; i < numElements * vecSize; i++ )
41     {
42         double v = ( y[ i ] < x[ i ] ) ? y[ i ] : x[ i ];
43         if( v != out[ i ] ) {
44       log_error("x[%d]=%g y[%d]=%g out[%d]=%g, expected %g. (index %d is vector %d, element %d, for vector size %d)\n", i, x[i], i, y[i], i, out[i], v, i, i/vecSize, i%vecSize, vecSize);
45             return -1;
46     }
47     }
48     return 0;
49 }
50 
test_min(cl_device_id device,cl_context context,cl_command_queue queue,int n_elems)51 int test_min(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems)
52 {
53     return test_binary_fn( device, context, queue, n_elems, "min", true, min_verify_float, min_verify_double );
54 }
55 
56 
57