Hello TI support,
can you provide a simple example for a matrix matrix multiplication utilizing the C7x-MMA? The provided user guide does not provide the answers I'm looking for. I'd like to know how to call the init function correctly and what parameters needs to be passed for 'handle' and 'pKerInitArgs' as well as how the data is correctly assigned to the function.
const size_t rows = 3;
const size_t cols = 3;
const size_t matSize = rows * cols;
int32_t matA[matSize] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
int32_t matB[matSize] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
int32_t matRes[matSize] = {0};
// For each element C(i,j)
for (size_t i = 0; i < rows; i++)
{
for (size_t j = 0; j < cols; j++)
{
// C(i,j) = dot(A(i,:), B(:, j)
int32_t sum = 0;
for (size_t k = 0; k < rows; k++)
{
sum += matA[i * rows + k] * matB[k * rows + j];
}
matRes[i * rows + j] = sum;
}
}
assert(matRes[0] == 15);
assert(matRes[1] == 18);
assert(matRes[2] == 21);
assert(matRes[3] == 42);
assert(matRes[4] == 64);
assert(matRes[5] == 66);
assert(matRes[6] == 69);
assert(matRes[7] == 90);
assert(matRes[8] == 111);
std::cout << "Matrix multiplication successful!" << std::endl;
It would be great to see this simple example realized on the MMA.
Thank you and kind regards,
Florian