History

Increase alignment of av_malloc() as needed by AVX ASM.

Vitor Sessak committed 15 years ago

Commit 13dfce31 parent 33cbfa61 file · +7 −9Browse files

Unified · Split

libavutil/mem.c+7−9
@@ -69,21 +69,21 @@ void *av_malloc(size_t size) · 68 unmodified lines
6969 #endif
7070
7171 /* let's disallow possible ambiguous cases */
72− if(size > (INT_MAX-16) )
72+ if(size > (INT_MAX-32) )
7373 return NULL;
7474
7575 #if CONFIG_MEMALIGN_HACK
76− ptr = malloc(size+16);
76+ ptr = malloc(size+32);
7777 if(!ptr)
7878 return ptr;
79− diff= ((-(long)ptr - 1)&15) + 1;
79+ diff= ((-(long)ptr - 1)&31) + 1;
8080 ptr = (char*)ptr + diff;
8181 ((char*)ptr)[-1]= diff;
8282 #elif HAVE_POSIX_MEMALIGN
83− if (posix_memalign(&ptr,16,size))
83+ if (posix_memalign(&ptr,32,size))
8484 ptr = NULL;
8585 #elif HAVE_MEMALIGN
86− ptr = memalign(16,size);
86+ ptr = memalign(32,size);
8787 /* Why 64?
8888 Indeed, we should align it:
8989 on 4 for 386
@@ -93,10 +93,8 @@ void *av_malloc(size_t size) · 3 unmodified lines
9393 Because L1 and L2 caches are aligned on those values.
9494 But I don't want to code such logic here!
9595 */
96− /* Why 16?
97− Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs
98− it will just trigger an exception and the unaligned load will be done in the
99− exception handler or it will just segfault (SSE2 on P4).
96+ /* Why 32?
97+ For AVX ASM. SSE / NEON needs only 16.
10098 Why not larger? Because I did not see a difference in benchmarks ...
10199 */
102100 /* benchmarks with P3

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t