1 /* Copyright (C) 2018 Federico Simmross Wattenberg,
2 * Manuel Rodríguez Cayetano,
3 * Javier Royuela del Val,
4 * Elena Martín González,
6 * Marcos Martín Fernández and
7 * Carlos Alberola López
9 * This file is part of OpenCLIPER.
11 * OpenCLIPER is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 3 of the License.
15 * OpenCLIPER is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with OpenCLIPER; If not, see <http://www.gnu.org/licenses/>.
26 * Federico Simmross Wattenberg
27 * E.T.S.I. Telecomunicación
28 * Universidad de Valladolid
30 * 47011 Valladolid, Spain.
33 #include <OpenCLIPER/kernels/hostKernelFunctions.h>
35 __kernel void arrayMult_kernel(__global realType* arrayA, __global realType* arrayB, __global realType* arrayC,
36 unsigned int RowsA, unsigned int ColsA, unsigned int ColsB) {
37 // int row = get_global_id(0);
38 int row = get_global_id(0) / ColsA;
39 // int col = get_global_id(1);
40 int col = get_global_id(0) - row * ColsA;
42 printf("global_size(0): %d\tglobal_size(1): %d\n", get_global_size(0), get_global_size(1));
43 printf("row : %d\tcol: %d\n", row, col);
45 if ((row < RowsA) && (col < ColsA)){
47 printf("Calc C[%d,%d]\n", row, col);
49 unsigned int ColsC = ColsB;
51 for (unsigned int k = 0; k < ColsA; k ++) {
52 res += arrayA[row*ColsA+k] * arrayB[k*ColsB+col];
54 arrayC[row*ColsC+col] = res;
57 printf("Exiting without work, row: %d\tcol: %d\n", row, col);