1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2017, Intel Corporation, all rights reserved.
14 // Copyright (c) 2016-2017 Fabian David Tschopp, all rights reserved.
15 // Third party copyrights are property of their respective owners.
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
20 // * Redistribution's of source code must retain the above copyright notice,
21 // this list of conditions and the following disclaimer.
23 // * Redistribution's in binary form must reproduce the above copyright notice,
24 // this list of conditions and the following disclaimer in the documentation
25 // and/or other materials provided with the distribution.
27 // * The name of the copyright holders may not be used to endorse or promote products
28 // derived from this software without specific prior written permission.
30 // This software is provided by the copyright holders and contributors "as is" and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
47 __kernel void op_sum4(__global const Dtype * A,
48 __global const Dtype * B,
49 unsigned int A_col_size,
54 unsigned int row_gid = get_group_id(0);
55 unsigned int lid = get_local_id(0);
56 const __global Dtype *src0_read = A + row_gid * 4 * A_col_size;
57 const __global Dtype *src1_read = B + row_gid * 4 * A_col_size;
58 __global Dtype *dst0_read = C + row_gid * 4 * A_col_size;
60 Dtype4 a0, a1, a2, a3;
61 Dtype4 dot0, dot1, dot2, dot3;
63 while( i < A_col_size / 4)
65 const Dtype4 b0 = vload4(i, src1_read);
66 const Dtype4 b1 = vload4(i, src1_read + A_col_size);
67 const Dtype4 b2 = vload4(i, src1_read + 2 * A_col_size);
68 const Dtype4 b3 = vload4(i, src1_read + 3 * A_col_size);
71 a0 = vload4(i, src0_read);
72 a1 = vload4(i, src0_read + A_col_size);
73 a2 = vload4(i, src0_read + 2 * A_col_size);
74 a3 = vload4(i, src0_read + 3 * A_col_size);
76 dot0 = a0 * coeff1 + b0 * coeff2;
77 dot1 = a1 * coeff1 + b1 * coeff2;
78 dot2 = a2 * coeff1 + b2 * coeff2;
79 dot3 = a3 * coeff1 + b3 * coeff2;
81 a0 = vload4(i, dst0_read);
82 a1 = vload4(i, dst0_read + A_col_size);
83 a2 = vload4(i, dst0_read + 2 * A_col_size);
84 a3 = vload4(i, dst0_read + 3 * A_col_size);
86 dot0 = a0 + b0 * coeff2;
87 dot1 = a1 + b1 * coeff2;
88 dot2 = a2 + b2 * coeff2;
89 dot3 = a3 + b3 * coeff2;
91 vstore4(dot0, i, dst0_read);
92 vstore4(dot1, i, dst0_read + A_col_size);
93 vstore4(dot2, i, dst0_read + 2 * A_col_size);
94 vstore4(dot3, i, dst0_read + 3 * A_col_size);
96 i += get_local_size(0);