# OpenCL matrix multiplication on Mathematica

I took a matrix multiplication written using OpenCL from here:

src = "__kernel void
floatMatrixMult(__global float * MResp,
__global float * M1,
__global float * M2,
__global int * q)
{
// Vector element index
int i = get_global_id(0);
int j = get_global_id(1);
int p = get_global_size(0);
int r = get_global_size(1);
MResp[i + p * j] = 0;
int QQ = q[0];
for (int k = 0; k < QQ; k++)
{
MResp[i + p * j] += M1[i + p * k] * M2[k + QQ * j];
}
}";


then I used:

test = OpenCLFunctionLoad[{src}, "floatMatrixMult", {"Float", "Float", "Float", _Integer}, {8, 8}];


but I get this error:

OpenCLFunctionLoad::nofile: -- Message text not found -- (contents of src) >>

There isn't any documents to explain this. How can I resolve the issue? If the code itself has problem are there some other codes to do matrix multiplication using OpenCL?

• The documentation you're looking for is the OpenCLFunctionLoad help page. Your call to it is completely wrong. Jan 14 '15 at 23:23
• Also, there is a matrix-matrix multiplication example in the documentation. Jan 15 '15 at 0:03

Needs["OpenCLLink"]

{"Float", 2, "Output"},
{"Float", 2, "Input"}, {"Float", 2, "Input"}, {_Integer, 1, "Input"}
},
{16, 16}
];

SIZE = 1024;

a = RandomReal[1, {SIZE, SIZE}];
`