2 #ifdef CONFIG_FASTMEMCPY
5 aclib - advanced C library ;)
6 This file contains functions which improve and expand standard C-library
7 see aclib_template.c ... this file only contains runtime cpu detection and config options stuff
8 runtime cpu detection by michael niedermayer (michaelni@gmx.at) is under GPL
12 #include "cpudetect.h"
13 #include "fastmemcpy.h"
16 #define BLOCK_SIZE 4096
17 #define CONFUSION_FACTOR 0
18 //Feel free to fine-tune the above 2, it might be possible to get some speedup with them :)
22 #define CAN_COMPILE_X86_ASM
25 //Note: we have MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one
27 //#if !HAVE_MMX || defined (RUNTIME_CPUDETECT)
31 #ifdef CAN_COMPILE_X86_ASM
33 #if (HAVE_MMX && !HAVE_3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
37 #if (HAVE_MMX2 && !HAVE_SSE2) || defined (RUNTIME_CPUDETECT)
41 #if (HAVE_3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
45 #if HAVE_SSE2 || defined (RUNTIME_CPUDETECT)
71 #define RENAME(a) a ## _C
72 #include "aclib_template.c"
88 #define RENAME(a) a ## _MMX
89 #include "aclib_template.c"
107 #define RENAME(a) a ## _MMX2
108 #include "aclib_template.c"
124 #define RENAME(a) a ## _3DNow
125 #include "aclib_template.c"
128 //SSE versions (only used on SSE2 cpus)
141 #define RENAME(a) a ## _SSE
142 #include "aclib_template.c"
145 #endif // CAN_COMPILE_X86_ASM
149 void * fast_memcpy(void * to
, const void * from
, size_t len
)
151 #ifdef RUNTIME_CPUDETECT
152 #ifdef CAN_COMPILE_X86_ASM
153 // ordered per speed fasterst first
155 fast_memcpy_SSE(to
, from
, len
);
156 else if(gCpuCaps
.hasMMX2
)
157 fast_memcpy_MMX2(to
, from
, len
);
158 else if(gCpuCaps
.has3DNow
)
159 fast_memcpy_3DNow(to
, from
, len
);
160 else if(gCpuCaps
.hasMMX
)
161 fast_memcpy_MMX(to
, from
, len
);
163 #endif //CAN_COMPILE_X86_ASM
164 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
167 fast_memcpy_SSE(to
, from
, len
);
169 fast_memcpy_MMX2(to
, from
, len
);
171 fast_memcpy_3DNow(to
, from
, len
);
173 fast_memcpy_MMX(to
, from
, len
);
175 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
178 #endif //!RUNTIME_CPUDETECT
183 void * mem2agpcpy(void * to
, const void * from
, size_t len
)
185 #ifdef RUNTIME_CPUDETECT
186 #ifdef CAN_COMPILE_X86_ASM
187 // ordered per speed fasterst first
189 mem2agpcpy_SSE(to
, from
, len
);
190 else if(gCpuCaps
.hasMMX2
)
191 mem2agpcpy_MMX2(to
, from
, len
);
192 else if(gCpuCaps
.has3DNow
)
193 mem2agpcpy_3DNow(to
, from
, len
);
194 else if(gCpuCaps
.hasMMX
)
195 mem2agpcpy_MMX(to
, from
, len
);
197 #endif //CAN_COMPILE_X86_ASM
198 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
201 mem2agpcpy_SSE(to
, from
, len
);
203 mem2agpcpy_MMX2(to
, from
, len
);
205 mem2agpcpy_3DNow(to
, from
, len
);
207 mem2agpcpy_MMX(to
, from
, len
);
209 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
212 #endif //!RUNTIME_CPUDETECT
216 #endif /* CONFIG_FASTMEMCPY */