Рассмотрим следующий код, который представляет собой очень простое воссоздание более сложной программы:
Код: Выделить всё
#include
#include
#include
#include
#include
using namespace std::literals::chrono_literals;
void copy_sse(__m128i* src, __m128i* dst, const size_t size)
{
const size_t loopcount = size / 16;
for (int i = 0; i < loopcount; i++)
{
_mm_stream_si128(dst, _mm_load_si128(src));
dst++; src++;
}
}
int main()
{
const size_t size = 1'000'000 * 16;
unsigned char* src = reinterpret_cast(std::aligned_alloc(16, size));
unsigned char* dst = reinterpret_cast(std::aligned_alloc(16, size));
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/79843410/why-is-a-simple-sse-loop-faster-than-stdcopy[/url]
Мобильная версия