2009ǯ09��10��
gcc��NEON��SIMD̿���������������ˡ
���ε����Ǥ�gcc 4.4.0����Ѥ��Ƥ��ޤ�����äȿ�����gcc�ξ��Ϥ����顣
Android��SDK��goldfish��CPU��cortex-A8���֤�������NEON��SIMD̿���(����2) �ΤȤ��ˤ�arm_neon.h���������Ƥ���intrinsics��Ȥä�NEON��SIMD̿������������ޤ�����������ˡ����NEON��̿��ˤĤ��ƾܺ٤��ΤäƤ��ʤ���Фʤ�ޤ��󤷡��ʤˤ��⤽�Υץ�����बNEON�˰�¸������ΤˤʤäƤ��ޤ��ޤ���
����ϥ���ѥ���κ�Ŭ���ε�ǽ��Ȥä�NEON��SIMD̿������������륳�Ĥ�Ҳ𤷤ޤ���
������SIMD�黻�Υ���ץ�Ȥ��Ƥ���ʥץ�������ñ¤¤Þ¤ï¿½ï¿½ï¿½ï¿½ï¿½
void vmla(float* a, float* x, float* y, float* z) { a[0] = x[0] * y[0] + z[0]; a[1] = x[1] * y[1] + z[1]; a[2] = x[2] * y[2] + z[2]; a[3] = x[3] * y[3] + z[3]; }
������ȼºݤˤ�NEON��SIMD̿�����������ޤ��󤬡���������äȽ�ľ����NEON��SIMD̿�᤬���������褦�ˤʤ�ޤ���
�ݥ���Ȥ�
- �����롼�פǻȤ����ȡ�
- ��������Υݥ��󥿤� __restrict����°�����Ĥ��Ƥ��뤳�ȡ�
�Τ褦�Ǥ���
__restrict �Ϥ��Υݥ��󥿤�¾���ѿ��ȽŤʤäƤ��ʤ����Ȥ򥳥�ѥ�����Τ餻�뤿��Τ�ΤǤ���
�������������Τ��ʲ��Υץ������Ǥ���
void vmla2(float* __restrict a, float* __restrict x, float* __restrict y, float* __restrict z) { int i; for (i=0; i< 4; i++) { a[i] = x[i] * y[i] + z[i]; } }
�����neon0.c �Ȥ����ե�����˳�Ǽ���ޤ���
���󥳥�ѥ����gcc 4.4.0��ȤäƤ��ޤ���
����ѥ��륪�ץ����ϰʲ��Τ�Τ�Ĥ��ޤ���
arm-eabi-gcc -O2 -march=armv7-a -ftree-vectorize -mhard-float -mfloat-abi=softfp -mfpu=neon -mvectorize-with-neon-quad -S neon0.c
�������줿�����ɤϰʲ��ΤȤ��ꡣ
.align 2 .global vmla2 .type vmla2, %function vmla2: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. orr ip, r1, r0 orr ip, r2, ip orr ip, r3, ip tst ip, #15 str r4, [sp, #-4]! bne .L4 vldmia r1, {d18-d19} vldmia r2, {d16-d17} vmul.f32 q8, q9, q8 vldmia r3, {d18-d19} vadd.f32 q8, q8, q9 vstmia r0, {d16-d17} .L7: ldmfd sp!, {r4} bx lr .L4: mov ip, #0 .L6: add r4, r1, ip flds s13, [r4, #0] add r4, r2, ip flds s14, [r4, #0] add r4, r3, ip flds s15, [r4, #0] fmacs s15, s13, s14 fmrs r4, s15 str r4, [r0, ip] @ float add ip, ip, #4 cmp ip, #16 bne .L6 b .L7 .size vmla2, .-vmla2
NEON��SIMD̿�᤬��������ޤ�����������̿��Ǥʤ����軻�Ȳû���ʬ����ޤ��������Υץ������Ǥ�ľ���˥��꤫������ɤ��Ƥ���Τǡ����Υ����ɤ��ٱ���θ����Ȥ�������®���Τ��⤷��ޤ��󡣤ޤ���3�ĤΥ��ڥ��ɤΥ��饤���Ȥ�����å����Ƥ���3�ĤȤ�16�Х��ȶ����ˤ���Ȥ��Τ�NEON̿���Ȥ��褦�ˤʤäƤ��ޤ�����̣�����Ǥ���
���Υ������򻲹ͤˤ����Ƥ��������ޤ�����
�ȥ�å��Хå�URL
�ȥ�å��Хå�����
�����Ȱ���
���Ĥⶽ̣�����Ҹ������Ƥ��������Ƥ��ޤ���
�ᥤ�������Ȥ���Ƥ��ƶ��̤Ǥ���
> -mhard-float -mfloat-abi=softfp
�� "-mhard-float" �λ�������פǤϤʤ��Ǥ��礦����
gcc-4.3��man�򻲾Ȥ���ȡ�
> -mfloat-abi=name
> Specifies which ABI to use for floating point values. Permissible values are: soft, softfp and hard.
>
> soft and hard are equivalent to -msoft-float and -mhard-float respectively.
�Ƚ񤤤Ƥ���Τǡ�"-mhard-float" �� "-mfloat-abi=hard" ��Ʊ�����Ȥ����褦�����򤷤Ƥ��ޤ���
-mhard-float�ϡ�(Android�ǤΥǥե���ȤǤ���)��-msoft-float�Ȥ�����ΰ�̣������Ū�˻��ꤷ�Ƥ��ޤ���
�Ĥ��Ǥ��ä򤹤�ȡ�
-mhard-float��Ĥ���Ȱ��ۤΤ����� -mfloat-abi=hard �ˤʤ�ޤ���������ARM�Υ���ѥ���Ǥ�float��ABI��hard�ϥ��ݡ��Ȥ���Ƥ��ޤ��󡣤ʤΤǡ�ɬ�� -mhard-float ����ꤷ���顡-mfloat-abi=softfp ����ꤹ��ɬ�פ�����ޤ���
���ˤǤƤ���gcc 4.5 �Ǥ�ARM�Ǥ�-mfloat-api=hard�����ݡ��Ȥ����褦�Ǥ���
�Ȥ����Τϡ��ʲ��Τ褦�� "-mhard-float" ��Ĥ��ƥ���ѥ��뤹��ȥ��顼�ˤʤ뤳�Ȥ���⡢ʬ����ޤ���
$ arm-linux-gnueabi-gcc -mhard-float sample.c
sample.c:1: sorry, unimplemented: -mfloat-abi=hard and VFP
> �ʤΤǡ�ɬ�� -mhard-float ����ꤷ���顡-mfloat-abi=softfp ����ꤹ��ɬ�פ�����ޤ���
�Ȥ����Τ���ʬ����ʤ��Ǥ���
�ʲ��Τ褦�ˡ�"-mfloat-abi=softfp" �� "-mhard-float" �ν��֤������ؤ��ơ�"-mhard-float" �����˻��äƤ���ȡ�"-mhard-float"��������ꤷ���Ȥ���Ʊ�����顼�ˤʤ�ޤ���
$ arm-linux-gnueabi-gcc -mhard-float -mfloat-abi=softfp sample.c
(���顼�ʤ�)
$ arm-linux-gnueabi-gcc -mfloat-abi=softfp -mhard-float sample.c
sample.c:1: sorry, unimplemented: -mfloat-abi=hard and VFP
ñ�ˡ�����˽ñ¤¤¤ï¿½ï¿½ï¿½ï¿½×¥ï¿½ï¿½ï¿½ï¿½Ë¾ï¿½ñ¤¤ï¿½ï¿½ï¿½Æ¤ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½È»×¤Ã¤Æ¤ï¿½ï¿½ï¿½ï¿½Î¤Ç¤ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½
-mhard-float��-msoft-float�Τ��줾��ˡ�(float��ABI�Ȥ���)-mfloat-abi=softfp���ݤ���¸�ߤ���
�ΤǤϤʤ���
-float-abi=hard or soft or softfp ������
�������򤷤Ƥ���ΤǤ�������������˴��㤤���Ƥ���Ǥ��礦����
���������ɤäƸ���ФϤä��ꤹ�뤳�ȤǤ�����gcc�Υ������ƥ����㶦�̤���ʬ�ν����Ȥ��� -mhard-float�Υ��ץ������ᤷ���Ȥ�������Ū��float-abi�Υե饰��hard�˥��åȤ��Ƥ��ơ�ARM�������ƥ������Í����ʬ�ν�����-mhard-float��float-abi=hard���Ȥ߹�碌�ò¥¨¥é¡¼ï¿½Ë¤ï¿½ï¿½Æ¤ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½È¡ï¿½ï¿½ï¿½ï¿½Î¥ï¿½ï¿½é¡¼ï¿½ï¿½ï¿½ï¿½ï¿½Ã¥ï¿½ï¿½Î¤È¤ï¿½ï¿½ï¿½ï¿½Ç¤ï¿½ï¿½ï¿½ï¿½ï¿½Åªï¿½ï¿½-mfloat-abi=�Υ��ץ����ǻ��ꤵ�줿�Τ�����Ū�����ꤵ�줿�Τ��ϸ��Ƥ��ʤ��ʤޤ��Ϥ��λ����ǤϾ��󤬻ĤäƤ��ʤ��ˤΤǤ��礦��
PowerPC��MIPS�Ǥ�-mhard-float�λ����Ϣư����float-abi=hard�ˤʤ�ۤ����Թ礬�褤������������꤬�ʤ��ΤǤ�����ARM�������ü�Ǥ�䤳�������ȤˤʤäƤ��ޤ���