2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG.
\r
6 * CasparCG is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * CasparCG is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
24 #include <tbb/parallel_for.h>
\r
28 namespace internal {
\r
30 static void* fast_memcpy(void* dest, const void* source, size_t count)
\r
32 assert(dest != nullptr);
\r
33 assert(source != nullptr);
\r
43 movdqa xmm0, [esi+00h];
\r
44 movdqa xmm1, [esi+10h];
\r
45 movdqa xmm2, [esi+20h];
\r
46 movdqa xmm3, [esi+30h];
\r
48 movntdq [edi+00h], xmm0;
\r
49 movntdq [edi+10h], xmm1;
\r
50 movntdq [edi+20h], xmm2;
\r
51 movntdq [edi+30h], xmm3;
\r
53 movdqa xmm4, [esi+40h];
\r
54 movdqa xmm5, [esi+50h];
\r
55 movdqa xmm6, [esi+60h];
\r
56 movdqa xmm7, [esi+70h];
\r
58 movntdq [edi+40h], xmm4;
\r
59 movntdq [edi+50h], xmm5;
\r
60 movntdq [edi+60h], xmm6;
\r
61 movntdq [edi+70h], xmm7;
\r
63 lea edi, [edi+80h];
\r
64 lea esi, [esi+80h];
\r
74 static void* fast_memcpy(void* dest, const void* source, size_t count)
\r
77 return memcpy(dest, source, count);
\r
79 size_t rest = count % 128;
\r
82 tbb::affinity_partitioner ap;
\r
83 tbb::parallel_for(tbb::blocked_range<size_t>(0, count/128), [&](const tbb::blocked_range<size_t>& r)
\r
85 internal::fast_memcpy(reinterpret_cast<char*>(dest) + r.begin()*128, reinterpret_cast<const char*>(source) + r.begin()*128, r.size()*128);
\r
88 return memcpy(reinterpret_cast<char*>(dest)+count, reinterpret_cast<const char*>(source)+count, rest);
\r