ToDo:
http://tabesugi.net/memo/cur/cur.html#182342
¤Õ¡¼¤à¡£ ƿ̾¤¸¤ã¤Ê¤¯¤ÆÎɤ¤Íýͳ¡¢¤È¤·¤Æ¤Ï¤È¤Æ¤âƱ°Õ¤Ç¤¤ë¤±¤É¡¢ ¼Â̾¤Ç¤¤¤¯Íýͳ¤Ë¤Ï¼«Ê¬¤Î¾ì¹ç¤Ê¤Ã¤Æ¤Ê¤¤¤«¤Ê¤¡¡£
¡Ö¼Â̾¤Î¤Û¤¦¤¬µ¤³Ú¤À¤È»×¤¨¤ë¡×¤Ã¤Æ¤Î¤¬°ìÈֶᤤµ¤¤¬¤¹¤ë¡£ Ëͤξì¹ç¤¿¤Ö¤ó²²É¤µ¤¬µÕ¤Ë½Ð¤Æ¤ë¤ó¤À¤È»×¤¦¡£ ƿ̾¤Ë¤è¤ë̵ÀÕǤ¤µ¤ËÊ¢¤¬Î©¤¿¤Ê¤¤¡¢ ¤ÏƱ°Õ¤Ê¤ó¤À¤±¤É¡¢ ¼«Ê¬¤¬Æ¿Ì¾¤À¤È̵ÀÕǤ¤Ë¤Ê¤ë¤Î¤Ï¤³¤ì¤Ï¤â¤¦¡¢¤Û¤È¤ó¤É´Ö°ã¤¤¤Ê¤¯¤Æ¡¢ ¤½¤Î¾õÂÖ¤¬¶²¤¤¤Ã¤Æ¤¤¤¦¤Î¤È¡¢ ¤¢¤È¤½¤Î̵ÀÕǤƿ̾¤¬¤Õ¤È¤·¤¿Çï»Ò¤Ç¥Ð¥ì¤¿¤ê¤¹¤ë¤Î¤¬¶²¤¤¤ó¤À¤è¤Ê¡£
¤¢¤È¡¢¡Ö¥¢¥ì¡¢¼«ºî¼«±é¤Ç¤·¤ç¡©¡×·Ï¤Î¼ÁÌä¤ò¤µ¤ì¤ë¤³¤È¤ò¹Í¤¨¤ë¤Î¤¬¶²¤¤¡£ ²¾¤Ë¼«ºî¼«±é¤Ç¤Ê¤¤¤â¤Î¤ËÂФ·¤Æ¤³¤Î¼ÁÌä¤ò¤µ¤ì¤¿¤È¤·¤Æ¤â¡¢ ¤«¤Ä¤Æ¼«ºî¼«±é¤ò¤·¤¿¤³¤È¤¬¤¢¤Ã¤¿¤ê¤¹¤ë¤È ¼«¿®¤ò»ý¤Ã¤ÆÈÝÄꤷ¤Ë¤¯¤¤¤È»×¤¦¤ó¤À¤è¤Ê¡£ ¿Íϵ¤È¤«¤ä¤Ã¤Æ¤ë¤È¤è¤¯¤ï¤«¤ë¤±¤É¡¢ °ì¤Ä¥¦¥½¤ò¤Ä¤¤¤Æ¤¤¤ë»Ò¤¬¡¢ ¥¦¥½¤ò¤Ä¤¤¤Æ¤Ê¤¤¸Ä½ê¤Ë¤Ä¤¤¤ÆÈù̯¤Ë¼å¤¤ÏÀÄ´¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¡¢ ¤¢¤ÎÈù̯¤Ê¤»¤Ä¤Ê¤µ¤Ë¶á¤¤¤â¤Î¤¬¤¢¤ë¤ó¤Ç¤Ê¤¤¤«¤È»×¤¦¡£ ¤½¤ì¤ËÂФ·¤Æ ¡Ö¤Á¤ã¤¤¤Þ¤¹¤è¡£ 2¤Á¤ã¤ó¤ËµÌ¾¤Ê¤ê¼«Ê¬¤Î¥µ¥¤¥È¤Ø¤Î¥ê¥ó¥¯¤¬Ìµ¤¤¾õÂ֤ǽñ¤¹þ¤ó¤À¤³¤È¤Ê¤¤¤·¡× ¤È¸À¤¨¤ë°Â¿´´¶¡£
¤Ç¤Þ¤¡¾¡¼ê¤Ë¼«Ê¬¤¬¶±¤¨¤Æ¤¤¤ë¤À¤±¤Ê¤Î¤Ç¡¢ Ê̤˾¿Í¤¬¡Ö¥¢¥ì¡¢¼«ºî¼«±é¤Ç¤·¤ç¡©¡×¡Ö¤½¤¦¤Ç¤¹¤¬²¿¤«¡©¡× ¤È¤«¸À¤Ã¤Æ¤Æ¤â¤É¤¦¤Ç¤â¤¤¤¤¤·¡¢ Ä̤ꤹ¤¬¤ê¤Î¤â¤Î¤Ç¤¹¤è´¶¤È¤«¤â¾¿Í¤Î¾ì¹ç¤Þ¤¡³ä¤È¤É¤¦¤Ç¤â¤¤¤¤¤«¤Ê¤¡¤È»×¤¦¡£
¤Ê¤ó¤«½ñ¤¤¤¿¤³¤È¤¢¤Ã¤¿¤ß¤¿¤¤¤À¡£
http://shinh.skr.jp/m/?date=20080526#p01
¤¢¤È¤½¤¦¤À¡£¥Ï¥ó¥É¥ë¥Í¡¼¥à°ìËܤǹԤ¯¤Ã¤Æ¤Î¤Ï¤Þ¤¡¤¤¤¤ÊýË¡¤À¤È»×¤¦¡£ ¤¿¤À¤Þ¤¡¼ÂºÝ¤Ë²ñ¤Ã¤¿»þ¤È¤«Èù̯¤Ê´¶¤¸¤Ë¤Ê¤ë¤Î¤¬Èù̯
(00:08)
¤Õ¡¼¤à
http://homepage1.nifty.com/herumi/diary/0810.html#28
¤¿¤Àµá¤á¤¿¤¤¤Î¤Ï¼Â¤Ï median ¤¸¤ã¤Ê¤¯¤Æ¡¢
m = median(i1, i2, i3) o1 = i1 == m ? i1 : 0 o2 = i2 == m ? i2 : 0 o3 = i3 == m ? i3 : 0
¤Ê¤Î¤Ç¡¢6¸ÄƱ»þÈæ³Ó¤ò pcmgtw ¤Ç¤ä¤Ã¤È¤¤¤Æ ¥Æ¡¼¥Ö¥ë¤Ò¤¤¤Æ¤Û¤²¤Û¤²¡Ä¤È¤«¤Ï¤É¤¦¤«¤Ê¤¡¡Ä ¤È¤«»×¤Ã¤Æ¤ä¤Ã¤Æ¤ß¤¿¡£
static const char tbl[] = { 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, -1, 3, -1, 2, -1, -1, 6, -1, -1, 5, 4, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 3, 5, 1, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; void calcScore(int p1, int p2, int p3, int* s1, int* s2, int* s3) { int cmp_result; asm("pinsrw $1, %3, %%xmm1;\n" "pinsrw $2, %4, %%xmm1;\n" "pinsrw $3, %5, %%xmm1;\n" "pinsrw $4, %4, %%xmm1;\n" "pinsrw $5, %5, %%xmm1;\n" "pinsrw $6, %3, %%xmm1;\n" "pinsrw $1, %4, %%xmm0;\n" "pinsrw $2, %5, %%xmm0;\n" "pinsrw $3, %3, %%xmm0;\n" "pinsrw $4, %3, %%xmm0;\n" "pinsrw $5, %4, %%xmm0;\n" "pinsrw $6, %5, %%xmm0;\n" "pcmpgtw %%xmm0, %%xmm1;\n" "pextrw $6, %%xmm1, %%rax;\n" "and $1, %%rax;\n" "pextrw $5, %%xmm1, %%rdx;\n" "and $1, %%rdx;\n" "shl $1, %%rdx;\n" "or %%rdx, %%rax;\n" "pextrw $4, %%xmm1, %%rdx;\n" "and $1, %%rdx;\n" "shl $2, %%rdx;\n" "or %%rdx, %%rax;\n" "pextrw $3, %%xmm1, %%rdx;\n" "and $1, %%rdx;\n" "shl $3, %%rdx;\n" "or %%rdx, %%rax;\n" "pextrw $2, %%xmm1, %%rdx;\n" "and $1, %%rdx;\n" "shl $4, %%rdx;\n" "or %%rdx, %%rax;\n" "pextrw $1, %%xmm1, %%rdx;\n" "and $1, %%rdx;\n" "shl $5, %%rdx;\n" "or %%rdx, %%rax;\n" "movzb (%6, %%rax, 1), %%rax;\n" "xor %%rcx, %%rcx;\n" "mov %%rax, %%rdx;\n" "and $4, %%rdx;\n" "cmovz %%rcx, %3;\n" "mov %3, %0;\n" "mov %%rax, %%rdx;\n" "and $2, %%rdx;\n" "cmovz %%rcx, %4;\n" "mov %4, %1;\n" "mov %%rax, %%rdx;\n" "and $1, %%rdx;\n" "cmovz %%rcx, %5;\n" "mov %5, %2;\n" :"=m"(*s1), "=m"(*s2), "=m"(*s3) :"r"(p1), "r"(p2), "r"(p3), "r"(&tbl) :"%rdx", "%rcx", "%rax", "%xmm0", "%xmm1"); return; }
1.5Çܤۤɤª¤½¤¯¤Ê¤Ã¤¿¡Ä
(23:45)
Á° | 2008ǯ 10·î |
¼¡ | ||||
Æü | ·î | ²Ð | ¿å | ÌÚ | ¶â | ÅÚ |
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Á´¤Æ¥ê¥ó¥¯¥Õ¥ê¡¼¤Ç¤¹¡£ ¥³¡¼¥ÉÊҤϼ«Í³¤Ë»ÈÍѤ·¤Æ¤¤¤¿¤À¤¤¤Æ¹½¤¤¤Þ¤»¤ó¡£ ¤½¤Î¾¤Î¤â¤Î¤ÏGPL°·¤¤¤Ç¤¢¤ì¤Ð¤¢¤é¤æ¤ë»ÈÍѤ˴ؤ·¤Æʸ¶ç¤Ï¸À¤¤¤Þ¤»¤ó¡£ ¤Ê¤Ë¤«¤¢¤ì¤Ð²¼µ¥á¡¼¥ë¥¢¥É¥ì¥¹¤Ø¡£