40 #if defined(__x86_64__) || defined(__amd64__) || defined(__amd64)
47 #elif defined(__SSE2__)
49 #include <emmintrin.h>
50 #include <smmintrin.h>
58 void gpmp::linalg::Mtx::mtx_add(
const int *
A,
65 for (
int i = 0; i <
rows; ++i) {
68 for (; j <
cols - 3; j += 4) {
70 __m128i a = _mm_loadu_si128(
71 reinterpret_cast<const __m128i *
>(&
A[i *
cols + j]));
72 __m128i b = _mm_loadu_si128(
73 reinterpret_cast<const __m128i *
>(&
B[i *
cols + j]));
74 __m128i c = _mm_loadu_si128(
75 reinterpret_cast<const __m128i *
>(&
C[i *
cols + j]));
78 c = _mm_add_epi32(c, _mm_add_epi32(a, b));
81 _mm_storeu_si128(
reinterpret_cast<__m128i *
>(&
C[i *
cols + j]),
86 for (; j <
cols; ++j) {
void std_mtx_add(const T *A, const T *B, T *C, int rows, int cols)
Perform matrix addition on two matrices as flat arrays.