Created
October 22, 2022 00:46
-
-
Save Eren121/518594534c78abb612a12f533812a96c to your computer and use it in GitHub Desktop.
SIMD float subtraction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <array> | |
#include <xmmintrin.h> | |
int main() | |
{ | |
alignas(32) std::array<float, 8> A = {1, 2, 3, 4, 5, 6, 7, 8}; | |
alignas(32) std::array<float, 8> B = {10, 11, 12, 13, 14, 15, 16, 0.0f}; | |
alignas(32) std::array<float, 8> C; | |
const __m256 A_vec = _mm256_load_ps(A.data()); | |
const __m256 B_vec = _mm256_load_ps(B.data()); | |
const __m256 Sub = _mm256_sub_ps(A_vec, B_vec); | |
_mm256_store_ps(C.data(), Sub); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment