openGPMP
Open Source Mathematics Package
Functions
_gpu_kernel_mtx_mul.c File Reference

Go to the source code of this file.

Functions

__kernel void matrixMul (__global float *C, __global float *A, __global float *B, int wA, int wB)
 

Function Documentation

◆ matrixMul()

__kernel void matrixMul ( __global float *  C,
__global float *  A,
__global float *  B,
int  wA,
int  wB 
)

OpenCL C GPU kernel

Definition at line 4 of file _gpu_kernel_mtx_mul.c.

8  {
9 
10  int tx = get_global_id(0);
11  int ty = get_global_id(1);
12 
13  // value stores the element that is
14  // computed by the thread
15  float value = 0;
16  for (int k = 0; k < wA; ++k) {
17  float elementA = A[ty * wA + k];
18  float elementB = B[k * wB + tx];
19  value += elementA * elementB;
20  }
21 
22  // Write the matrix to device memory each
23  // thread writes one element
24  C[ty * wA + tx] = value;
25 }
list C
Definition: linalg.py:24
list A
Definition: linalg.py:22
list B
Definition: linalg.py:23

References python.linalg::A, python.linalg::B, and python.linalg::C.