ã¢ããªã±ãŒã·ã§ã³ã®æé©åã«ã€ããŠã®è°è«ãç¶ããŸããããã¯ã ãã¢ããªã±ãŒã·ã§ã³ã®æé©åã®å質ã«é¢ããç°¡åãªè©äŸ¡ã¯ãããŸããïŒãã®æçš¿ã§å§ãŸããŸããã
ããã»ããµãŒã«ã€ããŠè©³ãã話ãããšãã§ããŸãã確ãã«ãHabréã®èªè ã®äžã«ã¯ãã®ãããªäŒè©±ãã§ãã人ãããããããŸãã ããããããã»ããµã«é¢ããç§ã®èŠè§£ã¯çŽç²ã«å®çšçã§ãã ã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ã«èå³ãããã®ã§ãããã»ããµã®ããã©ãŒãã³ã¹ã®ããªãºã ãéããŠãã³ã³ãã¥ãŒãã£ã³ã°ã³ã¢ã®åºæ¬ååãç解ããã ãã§ãã ãããã®åºæ¬ååã«åœ±é¿ãäžããããã«ååšããæ¹æ³ãšåæ§ã«ã Intel64ã¢ãŒããã¯ãã£ã«çŠç¹ãåœãŠãŸãã ããã¯ãããã©ãŒãã³ã¹åæããŒã ã§ãäž»ã«ãã®ã¢ãŒããã¯ãã£ã«ã€ããŠã€ã³ãã«ã®æé©åã³ã³ãã€ã©ã®äœæ¥ãåæããŠããããã§ãã é«æ§èœã³ã³ãã¥ãŒãã£ã³ã°çšã®ã³ã³ãã¥ãŒãã£ã³ã°ã·ã¹ãã ã®åžå Žã§ã¯ããã®ã¢ãŒããã¯ãã£ãšäºææ§ã®ããã¢ãŒããã¯ãã£ãæ倧ã®ã·ã§ã¢ãå ããŠãããããããã©ãŒãã³ã¹ã®åé¡ã®ã»ãšãã©ã¯ããªãäžè¬çãªæ§è³ªã®ãã®ã§ãã ã«ãŒãã«ãšã³ã³ãã¥ãŒãã£ã³ã°ã·ã¹ãã ã®ããã©ãŒãã³ã¹ã決å®ããäž»ãªåé¡ãšæ©äŒãç°¡åã«ãªã¹ããããããã®åé¡ã«åœ±é¿ãäžããããã«èšèšãããããŸããŸãªæé©åã®çããªã¹ããæäŸããŸãã
åœä»€åæå®è¡ã¬ãã«
ææ°ã®ã³ã³ãã¥ãŒãã£ã³ã°ã³ã¢ã®ç¹åŸŽã¯ããã€ãã©ã€ã³ïŒãã€ãã©ã€ã³åïŒã®ååšãã¹ãŒããŒã¹ã«ã©ãŒæ§ã§ãã ã³ã³ãã¥ãŒãã£ã³ã°ã³ã¢ã«ã¯ãç¬ç«ããããŒã ãå®çŸ©ããæ瀺ãã¹ã±ãžã¥ãŒã«ããããã®ã¡ã«ããºã ããããŸãã ã€ãŸã ãããã®ã¡ã«ããºã ã¯ãåŠçã®ããã«å°çããåœä»€ã®ãããã¡ãèŠãŠãé©åãªèšç®èœåããããåœä»€ããŸã å®è¡ãããŠããªãä»ã®åœä»€ã«äŸåããªãå Žåãå®è¡ã®ããã«ããããéžæããŸãã ãã®ãããIntel64ã¢ãŒããã¯ãã£ã®ç¹åŸŽã¯ãé äžåã®å®è¡ã§ãã ã€ãŸã ãã®ãããªã¢ãŒããã¯ãã£ã®å Žåãã³ã³ãã€ã©ã¯åœä»€ã®é åºã®è©³çŽ°ãªæ±ºå®ãåŠçããå¿ èŠããããŸããã ãã€ãã©ã€ã³ã®è² è·ã¬ãã«ã¯ãåŠçãããç¬ç«ããåœä»€ã®æ°ãããããåœä»€äžŠååŠçã®ã¬ãã«ã«ãã£ãŠæ±ºãŸããŸãã
æ¡ä»¶ä»ãé·ç§»ã®æ°ãšé·ç§»äºæž¬åã®å質
ããŸããŸãªã³ãã³ãã®å®è¡é åºã¯ãã³ãŒãã®çŽç·éšåãã€ãªãå¶åŸ¡ãããŒã°ã©ãã«ãã£ãŠæ±ºå®ãããŸãã å¶åŸ¡ãããŒã®åå²ãçºçããå Žæã§ã¯ãååãšããŠãããŸããŸãªæ¡ä»¶ä»ãé·ç§»ã䜿çšãããŸãã ã€ãŸããæ¡ä»¶ãèšç®ããããŸã§ã次ã«ã©ã®åœä»€ãå®è¡ããå¿ èŠããããã¯æ確ã§ã¯ãããŸããã ãã€ãã©ã€ã³ãäžæããªãããã«ããããã«ãå¯èœãªå¶åŸ¡è»¢éãã¹ã®1ã€ãéžæãããã®æ¹åããã³ã³ãã¥ãŒãã£ã³ã°ãã€ãã©ã€ã³ã«åœä»€ãéãç¶ããåå²äºæž¬ã¡ã«ããºã ãã³ã³ãã¥ãŒãã£ã³ã°ã³ã¢ã«ãããŸãã æ¡ä»¶ãèšç®ãããåŸã«è¡ãããæ€èšŒã¯ããã§ã«å®äºããæ瀺ãåŸ ã£ãŠããŸãã äºæž¬åãééããå Žåãèšç®ã³ã¢ã®ãããã¡ãŒãã¯ãªã¢ããŠæ°ããåœä»€ãããŒãããå¿ èŠããããããèšç®ã³ã¢ã®äœæ¥ã«é 延ãçããŸãã ãã®ç¶æ³ã¯ãåå²äºæž¬ãã¹ãšåŒã°ããŸãã åå²äºæž¬ã¡ã«ããºã ã¯éåžžã«è€éã§ãæ¡ä»¶ä»ãé·ç§»ã«æåã«ééãããšãã«æ¹åãæšæž¬ããããšããéçéšåãšãçµ±èšãèç©ããŠäœ¿çšããåçéšåã®äž¡æ¹ãå«ã¿ãŸãã
ã¡ã¢ãªãµãã·ã¹ãã ã®å質
ãã¹ãŠã®ã¡ã€ã³ããŒã¿ãšåœä»€ã¯RAMã«ããããããã®ããŒã¿ãã³ã³ãã¥ãŒãã£ã³ã°ããã€ã¹ã«é ä¿¡ã§ããæéã¯ããã©ãŒãã³ã¹ã«ãšã£ãŠéèŠã§ãã ãã®å Žåãã¡ã€ã³ã¡ã¢ãªããããŒã¿ãåä¿¡ããéã®é 延ã¯ãæ°çŸããã»ããµãµã€ã¯ã«ã§ãã ããã»ããµãé«éåããããã«ããã£ãã·ã¥ãŸãã¯ãã£ãã·ã¥ã®ãµãã·ã¹ãã ããããŸãã ãã£ãã·ã¥ã«ã¯ãã¡ã€ã³ã¡ã¢ãªããé »ç¹ã«äœ¿çšãããããŒã¿ã®ã³ããŒãæ ŒçŽãããŸãã çŸä»£ã®ãã«ãã³ã¢ããã»ããµã®å Žåãã«ãŒãã«ã第1ã¬ãã«ãšç¬¬2ã¬ãã«ã®ãã£ãã·ã¥ãææããããã»ããµãã³ã¢ãå ±æãã第3ã¬ãã«ã®ãã£ãã·ã¥ãæã£ãŠããå Žåãäžè¬çã§ãã æåã®ã¬ãã«ã®ãã£ãã·ã¥ã¯ãµã€ãºãæå°ã§æéã§ãããäžäœéå±€ã®ãã£ãã·ã¥ã¯äœéã§ããã倧ãããªããŸãã Intel64ããã»ããµã«ã¯å æ¬çãªãã£ãã·ã¥ããããŸãã ããã¯ãäœããã®ã¬ãã«ã®ãã£ãã·ã¥ã§ã¢ãã¬ã¹ãè¡šãããå Žåãäžäœéå±€ã®ãã£ãã·ã¥ã«ãå«ãŸããããšãæå³ããŸãã ãããã£ãŠãã¡ã¢ãªããããŒã¿ãååŸããå¿ èŠãããå Žåãã¡ã¢ãªãµãã·ã¹ãã ã¯ã第1ã第2ãããã³ç¬¬3ã¬ãã«ã®ãã£ãã·ã¥å ã®ã¢ãã¬ã¹ãé 次ãã§ãã¯ããŸãã ãã£ãã·ã¥ãã¹ïŒã€ãŸãããã£ãã·ã¥ã«å¿ èŠãªæ å ±ããªãïŒã®å ŽåãåŸç¶ã®åã±ãŒã¹ã§ã¯ãé 延ã¯å€§ãããªããŸãã ããšãã°ãNehalemã®å Žåãç°ãªãã¬ãã«ã®ãã£ãã·ã¥ãžã®ããããã®ã¢ã¯ã»ã¹æéã¯æ¬¡ã®ããã«ãªããŸãã第1ã¬ãã«ã®ãã£ãã·ã¥ã§ã¯4ã第2ã¬ãã«ããã³ç¬¬3ã¬ãã«ã®ãã£ãã·ã¥ã§ã¯ãããã11ããã³38ã§ãã RAMãžã®ã¢ã¯ã»ã¹ã®é 延ã¯çŽ100ã200ãµã€ã¯ã«ã§ãã ã¡ã¢ãªãµãã·ã¹ãã ã®åäœãç解ããã«ã¯ããã£ãã·ã¥å ã®å¿ èŠãªæ å ±ã®éä¿¡ãšä¿åãããã£ãã·ã¥ã©ã€ã³ãšåŒã°ããïŒçŸæç¹ã§ã¯ïŒ64ãã€ãã®åºå®é·ã®ãã±ããã§è¡ãããããšãéèŠã§ãã ç¹å®ã®ã¡ã¢ãªã¢ãã¬ã¹ãèŠæ±ããããšãäžéšã®ãé£æ¥ãããŒã¿ããéäžã§ããã£ãã·ã¥ã«ããŒããããŸãã ã·ã¹ãã ãã¹ã¯ããã£ãã·ã¥ãµãã·ã¹ãã ãšCPUã®éã§ããŒã¿ã転éããŸãã ã¡ã¢ãªãµãã·ã¹ãã ã®éèŠãªç¹æ§ã¯ããã¹åž¯åå¹ ã§ãã åäœæéãããã«ãã£ãã·ã¥ã«è»¢éã§ãããã£ãã·ã¥ã©ã€ã³ã®æ°ã ãããã£ãŠãã·ã¹ãã ãã¹ã®åäœã¯ãã¢ããªã±ãŒã·ã§ã³ã®å®è¡ã«ãããããã«ããã¯ã«ãªãããšããããããŸãã
ãã®ãããªãã£ãã·ã¥ç·šæã«é¢é£ããŠãããã°ã©ã ã䜿çšããããŒã¿ã®åç §åçã®å±ææ§ãªã©ã®èŠå ã倧ããªåœ¹å²ãæãããŸãã ã¢ããªã±ãŒã·ã§ã³ããã»ã¹äžã®åºæ¬ãªããžã§ã¯ããšããŒã¿ã®åå©çšãç¹åŸŽä»ããæéçå±ææ§ãšã空éçå±ææ§ïŒæ¯èŒçè¿ãã¹ãã¬ãŒãžé åãæã€ããŒã¿ã®äœ¿çšïŒã¯åºå¥ãããŸãã ãŸããã³ã³ãã¥ãŒãã£ã³ã°ã³ã¢ã§ã¯ãããŒã«ãªãã£ã®ååããµããŒãããã¡ã«ããºã ãå®è£ ãããŠããŸãã äžæçãªããŒã«ãªãã£ã¯ãæãé »ç¹ã«äœ¿çšãããããŒã¿ããã£ãã·ã¥ã«ãã£ãã·ã¥ããããšãããã£ãã·ã¥ã¡ã«ããºã ã«ãã£ãŠãµããŒããããŸãã ãã£ãã·ã¥ã©ã€ã³ã解æŸããŠæ°ãããã£ãã·ã¥ã©ã€ã³ãããŒãããå¿ èŠããããšããåé¡ãçºçããå Žåãæã䜿çšãããŠããªãã©ã€ã³ã¯åé€ãããŸãã 空éçå±ææ§ã«ã€ããŠã¯ãäºåååŸã¡ã«ããºã ãæ©èœããŸããããã¯ãåŸç¶ã®äœæ¥ã«å¿ èŠãªã¡ã¢ãªã¢ãã¬ã¹ãäºåã«æ±ºå®ããããšããŸãã åæã«ã空éçãªå±ææ§ãé«ãã»ã©ïŒé£æ¥ããèŠçŽ ãžã®ã¢ã¯ã»ã¹ãé²ãïŒããã£ãã·ã¥ã«ããŠã³ããŒãããå¿ èŠãããããŒã¿ãå°ãªããªããã·ã¹ãã ãã¹ã®è² è·ãå°ãªããªããŸãã
ããã§ã¯ãã³ã³ãã¥ãŒãã£ã³ã°ã³ã¢ã®ã¬ãžã¹ã¿ãæéã®ã¡ã¢ãªãšããŠèšåããããšãã§ããŸãã åå©çšãããããŒã¿ãã¬ãžã¹ã¿ã«ä¿åãããšäŸ¿å©ã§ãã èšç®äžã«ããŒã¿ãã¬ãžã¹ã¿ããã¹ã¿ãã¯ã«ã³ããŒãããããã¹ã¿ãã¯ããã³ããŒãããããããšãã¬ãžã¹ã¿ã®ã¹ãã«ãªã©ã®ããã©ãŒãã³ã¹ã®åé¡ãçºçããŸãã
ãã¯ãã«åã®äœ¿çš
Intel64ããã»ããµã¯ãã¯ãã«åœä»€ããµããŒãããŠããŸãã ã€ãŸã ããŸããŸãªã¿ã€ãã®ãã¯ãã«ãäœæãããã¯ãã«ãåŠçããåºåã§çµæã®ãã¯ãã«ãåãåãåœä»€ããããã«é©çšããå¯èœæ§ããããŸãã ãããã¯SSEãã¡ããªãŒã®æ瀺ã§ãã äžé£ã®åœä»€ãéçºãããŠãããæ°ããã³ãã³ããšæ©èœãè¿œå ãããŠããŸãã SSE2ãSSE3ãSSE4ãAVX-å ã®ã¢ã€ãã¢ã®æ¡åŒµã åé¡ã¯ãç§ãã¡ã®ããã°ã©ãã³ã°èšèªã¯æåã¯ã¹ã«ã©ãŒã§ãããã³ã³ãã¥ãŒãã£ã³ã°ã³ã¢ã®ãã®æ©èœã䜿çšããããã«ããããåªåããå¿ èŠããããšããããšã§ãã ãã¯ãã«åã¯ãã¹ã«ã©ãŒã³ãŒãããã¯ãã«ã³ãŒãã«çœ®ãæããã³ãŒãå€æŽã§ãã ã€ãŸã ã¹ã«ã©ãŒããŒã¿ã¯ãã¯ãã«ã«ããã¯ãããã¹ã«ã©ãŒæŒç®ã¯ãã¯ãã«ïŒãã±ããïŒã®æŒç®ã«çœ®ãæããããŸãã xmmintrin.hã䜿çšããŠããã¯ãã«åãæåã§ããã°ã©ãã³ã°ããããèªåãã¯ãã«åã§äœããã®æé©åã³ã³ãã€ã©ã䜿çšãããããã¯ãã«åœä»€ã䜿çšãããŠãŒãã£ãªãã£ã§æé©åãããã©ã€ãã©ãªã䜿çšãããã§ããŸãã ãã®å€æŽã䜿çšããå¯èœæ§ã«ã¯å€ãã®å¶éããããŸãã ããã«ãåçæ§ã決å®ããå€ãã®èŠå ããããŸãã æé©åã¯ããã©ãŒãã³ã¹ãåäžããããã®ã§ããããããããå€æŽãèšè¿°ããçç±ã§ãã ãã¯ãã«åãæ¹åããã«ã¯ãç¹å®ã®æ¡ä»¶ãæºããå¿ èŠããããŸãã ã€ãŸã ãã¯ãã«åã¯åãªããæ©äŒãã§ãã ãã®æ©äŒãçã®ææã«ã€ãªããããã«äžçæžåœåªåããå¿ èŠããããŸãã
ãã«ãã¹ã¬ããã³ã³ãã¥ãŒãã£ã³ã°ã®äœ¿çš
ææ°ã®ããã»ããµäžã«è€æ°ã®ã³ã³ãã¥ãŒãã£ã³ã°ã³ã¢ãååšããããããããã®ã³ã¢éã§ã³ã³ãã¥ãŒãã£ã³ã°ãåæ£ããããšã«ãããé«ãã¢ããªã±ãŒã·ã§ã³ããã©ãŒãã³ã¹ãå®çŸã§ããŸãã ããããããã¯åãªããæ©äŒãã§ãã 100äžäººã®é«åºŠã«å°éçãªããã°ã©ããŒãããããšã¯ã圌ãã1æéã§æé©åã³ã³ãã€ã©ãå®è£ ã§ãããšããåžæãäžããŸããã ã·ã³ã°ã«ã¹ã¬ããã®ã³ãŒãããã«ãã¹ã¬ããã®ã³ãŒãã«å€æããã«ã¯ãçå£ãªåªåãå¿ èŠã§ãã äžéšã®æé©åã³ã³ãã€ã©ã«ã¯ããã«ãã¹ã¬ããã¢ããªã±ãŒã·ã§ã³ãäœæããããã»ã¹ããã³ã³ãã€ã«äžã«åäžã®ãªãã·ã§ã³ãè¿œå ããããã»ã¹ã«æžããèªå䞊ååæ©èœããããŸãã ããããèªåãã©ã¬ã©ã€ã¶ãŒã®ãã¹ã«ã¯éåžžã«å€ãã®èœãšãç©Žããããããå€ãã®å Žåãæé©åã³ã³ãã€ã©ãŒãæ¯æŽãå¿ èŠãšããå€ãã®å Žåãããã¯åã«ç¡åã§ãã OpenMPãã£ã¬ã¯ãã£ãã䜿çšãããšã倧ããªæåãåããããšãã§ããŸãã ãã ããã»ãšãã©ã®å Žåãæåã®ã·ã³ã°ã«ã¹ã¬ããã¢ã«ãŽãªãºã ã䞊ååããã«ã¯åªåãå¿ èŠã§ãã ç§ã®æèŠã§ã¯ããããã¯èšç®ã¢ã«ãŽãªãºã ã®é倧ãªå€æŽã«é¢é£ããŠãããéã¢ã«ãŽãªãºã ã³ãŒãæé©åãšåŒã°ãããã®ãè¶ ããŠãããããããã§ã¯ä»ã®äžŠååæ¹æ³ã«ã€ããŠã¯èšåããŸããã
ãããã®åé¡ã«åºã¥ããŠãå®è¡äžã®ã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ã決å®ãã3ã€ã®äž»ãªç¹åŸŽãšãå®è£ å¯èœãª2ã€ã®åªããæ©èœãåºå¥ã§ããŸãã
1.ïŒã¡ã¢ãªãµãã·ã¹ãã ã®å質ã
2.ïŒæ¡ä»¶ä»ãé·ç§»ã®æ°ãšé·ç§»äºæž¬åã®å質ã
3.ïŒæå°ã®äžŠè¡æ§ã®ã¬ãã«ã
4.ïŒãã¯ãã«åã®äœ¿çšã
5.ïŒãã«ãã¹ã¬ããã³ã³ãã¥ãŒãã£ã³ã°ã®äœ¿çšã
æé©å
ã³ã³ãã€ã©ãŒãšããã°ã©ããŒã¯ããªã¹ããããèšç®ã®ç¹æ§ã«åºã¥ããŠã©ã®ããŒã«ã䜿çšããå¿ èŠããããŸããïŒ
ã¡ã¢ãªãµãã·ã¹ãã ãæ¹åããããã«ãã«ãŒãã®äº€æãã«ãŒãã®ãããã¯ãžã®åå²ïŒã«ãŒãããããã³ã°ïŒãã«ãŒãã®çµåãšåå²ïŒã«ãŒãã®èå/åé ïŒãªã©ãå€ãã®ã«ãŒãæé©åãåŒã³åºãããŸãã ãããã®æé©åã«ã¯æ¬ ç¹ããããŸãã ãã¹ãŠã®ãµã€ã¯ã«ããã®ãããªæé©åã«é©ããŠããããã§ã¯ãªããäž»ã«Cããã³Fortranã®ã³ã³ãã¥ãŒãã£ã³ã°ããã°ã©ã ã§äœ¿çšãããŠããŸãã ã³ã³ãã€ã©ãŒã¯ãããªãšã³ããã£ãããŠã³ã¹ã¡ã«ããºã ãæ¯æŽããããªãã§ããããã°ã©ã åœä»€ãèªåçã«æ¿å ¥ããããšããå ŽåããããŸããããããéåžžã«ç¹æ®ãªæäœã§ãããæã®å¥œãŸããé 眮ãå¿ èŠãšããŸãã å®è¡å¯èœã¢ãžã¥ãŒã«ãæ§ç¯ãããŠããå Žåãåçãããã¡ã€ã©ãŒã䜿çšããŠãã³ã³ãã€ã©ã¯æ§é äœã®ãã£ãŒã«ããåé 眮ããã³ãŒã«ãé åãåå¥ã®æ§é äœã«ç§»åããããšã«ãããã¢ããªã±ãŒã·ã§ã³ããŒã¿ã®ç©ºéçå±ææ§ãæ¹åã§ããŸãã ããæ§é ããå¥ã®æ§é ã«ãã£ãŒã«ãã転éãããããªæé©åããããŸãã ã³ã³ãã€ã©ãŒããã®ãããªæé©åã®æ£ç¢ºããšåçæ§ã蚌æããããšã¯éåžžã«å°é£ã§ãããããã°ã©ããŒããã®ãããªããšãè¡ãã®ã¯ã¯ããã«ç°¡åã§ããäž»ãªããšã¯ã1ã€ãŸãã¯å¥ã®ã³ãŒãå€æŽã®ã¢ã€ãã¢ãç解ããããšã§ã
ããŒã¿ã®å±ææ§ãæ¹åããäžã§éèŠãªåœ¹å²ã¯ãã¹ã«ã©ãŒæé©åãã€ãŸã ããŒã¿ãããŒã®åæãå®æ°ã®ååŸãå¶åŸ¡ã°ã©ãã®æé©åãäžè¬çãªéšååŒã®åé€ããããã³ãŒãã®åé€ã«é¢é£ããæé©åã ãããã®æé©åã«ãããã¢ããªã±ãŒã·ã§ã³ãå®è¡ããå¿ èŠã®ããèšç®éãåæžãããŸãã ãã®çµæãåœä»€ããã£ãã·ã¥ã«ä¿åããå¿ èŠããããããåœä»€ã®æ°ãæžããããŒã¿ã®å±ææ§ãåäžããŸãã ãããã®æé©åææ³ã®å®è¡å質ã¯ãèšç®å¹çãšåŒã°ããŸãã ããã·ãŒãžã£ãŒéã®åæã¯ããããã®æé©åã®ãã¹ãŠã«åœ¹ç«ã¡ãŸãã 䜿çšããå ŽåãããŒã¿ãããŒã®åæã¯ã°ããŒãã«ã«ãªããŸãã ã³ã³ãã€ã©ã«ãã£ãŠåŠçãããŠããç¹å®ã®ããã·ãŒãžã£ã®ã¬ãã«ã ãã§ãªããããã°ã©ã å šäœã§ãªããžã§ã¯ãã®ããããã£ã®è»¢éãåæããŸãã ãã®ããã·ãŒãžã£ãã¢ããªã±ãŒã·ã§ã³ã®ããŸããŸãªå ŽæããåŒã³åºãããç¹å®ã®åŒæ°ã®ããããã£ã調ã¹ãããããã·ãŒãžã£å ã§äœ¿çšãããã°ããŒãã«ãªããžã§ã¯ãã®ããããã£ã調ã¹ãããŸããåé¢æ°ã«ã€ããŠããã®é¢æ°å ã§äœ¿çšãŸãã¯å€æŽã§ãããªããžã§ã¯ãã®ãªã¹ããäœæãããŸããã€ã³ã©ã€ã³åïŒããã³éšåçãªçœ®æããããŒã¿ã®å±ææ§ã«ãã©ã¹ã®åœ±é¿ãäžããå¯èœæ§ããããŸãã äžèšã®æé©åã®å€ãã¯æäœæ¥ã§è¡ãããšã¯ã§ããŸãããããããã®æ¡åŒµãããå®æ°ã®å¹æã¯ãããã§ããå¯èœæ§ããããŸããããã®çµæãå®æ°ãåŒã£åŒµããšå šäœçãªå¹æãåŸãããããè€éãªæé©åã®å¹æãé©çšããŠããæ£ç¢ºã«è©äŸ¡ããããšãã§ããŸãã
ããã«ãæé©åã³ã³ãã€ã©ã¯ãã¬ãžã¹ã¿ã®å²ãåœãŠã«å€ãã®æ³šæãæã£ãŠããŸãã
æé©åã³ã³ãã€ã©ãŒã¯ãç¹å®ã®ã¢ã¯ã·ã§ã³ãå®è¡ããŠãæ¡ä»¶åå²ã®æ°ãšé·ç§»äºæž¬ã®å質ãåæžã§ããŸãã æãç°¡åãªã®ã¯ãé·ç§»ãçºçããæ¡ä»¶ãå€æŽããããšã«ãããéçåå²äºæž¬ã®ããã©ãŒãã³ã¹ãæ¹åããããšã§ãã éçäºæž¬åã¯ãå¶åŸ¡ã°ã©ãã®åå²äžã«äžæ¹é·ç§»ãå¯èœãªå Žåãå®è¡ãããªãããšãæ³å®ããŠããŸãã ã³ã³ãã€ã©ãifåå²ã®ç¢ºçãelseã®ç¢ºçãããäœããšä¿¡ããŠããå Žåãã³ã³ãã€ã©ã¯ãããã亀æã§ããŸãã éåžžã«åŒ·åãªæé©åã¯ããµã€ã¯ã«ããäžå€ãã§ãã¯ãåé€ããããšã§ãã ãã1ã€ã®ããç¥ãããæé©åã¯ãã«ãŒãã®å±éã§ãã å¶åŸ¡ã°ã©ãã«æ²¿ã£ãŠæ¡ä»¶ãåŒã䌞ã°ã䟿å©ãªã¹ã«ã©ãŒæé©åããããŸããããã«ãããåé·ãªãã§ãã¯ãåé€ããããããçµã¿åãããŠãå¶åŸ¡ã°ã©ããç°¡çŽ åã§ããŸãã ãŸããã³ã³ãã€ã©ã¯ç¹å®ã®ãã¿ãŒã³ãèªèããcmovãªã©ã®åœä»€ã䜿çšããŠãã©ã³ãã眮ãæããããšãã§ããŸãã ããããããå€ãã®äŸãæããããšãã§ããŸãããããã¯ãæé©åã³ã³ãã€ã©ãŒã«ã誀ã£ãäºæž¬ã«ããé 延ã«å¯ŸåŠããæ¹æ³ãããããšã瀺ããŠããŸãã
åœä»€ã®äžŠååŠçãæ¹åããããã«ãã¹ã±ãžã¥ãŒãªã³ã°ã䜿çšãããŸããã¹ã±ãžã¥ãŒãªã³ã°ã¯ãã³ãŒãçæäžã®ã³ã³ãã€ã©ãŒã®äœæ¥ã®æåŸã®æ®µéã§å®è¡ãããŸãã
ãã¯ãã«åã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãåäžãããããã«ãã³ã³ãã€ã©ã«ã¯ã«ãŒãã®ãã¯ãã«åãå®è¡ããã¹ã«ã©ãŒã³ãŒãããã¯ãã«1ã«çœ®ãæããèªåãã¯ãã©ã€ã¶ãŒããããŸãã ãã®ã³ã³ãã€ã©ã³ã³ããŒãã³ãã¯çµ¶ããé²åããŠããããã¯ãã«æ¡åŒµã®æ°ããæ©èœãå®è£ ããèªèãããã€ãã£ãªã ã®æ°ãå¢ãããæ··åããŒã¿ã«ãŒãããã¯ãã«åããŸããããã«ããã¯ãã«åã¯å¹ççãªã³ãŒãåã®ãããããŸããŸãªã©ã³ã¿ã€ã ãã§ãã¯ãã³ãŒãã«æ¿å ¥ãããã«ãããŒãžã§ã³ã³ãŒããäœæããŸãã«ãŒãå ã®å埩åæ°ãã¡ã¢ãªå ã®ããŸããŸãªãªããžã§ã¯ãã®å Žæã䜿çšãããŠãããã«ãã¡ãã£ã¢æ¡åŒµæ©èœããã æäœãããå¹ççã«ããã«ã¯ããã¯ãã©ã€ã¶ãŒãšä»ã®ã«ãŒãæé©åã®çžäºäœçšãå¿ èŠã§ãã ã³ã³ãã€ã©ã¯åžžã«ãã¯ãã«åã®æå¹æ§ã蚌æã§ãããšã¯éããªããããããã°ã©ããŒãããã°ã©ã ã«é¢ããç¥èã掻çšããŠçç£çãªã³ãŒãã®äœæãæ¯æŽã§ããããã«ãããŸããŸãªãã£ã¬ã¯ãã£ãããµããŒããããŠããŸãã
ã€ã³ãã«Â®ã³ã³ãã€ã©ãŒã¯ãéçºè ã«èªå䞊ååïŒã«ãŒãã®èªå䞊ååã®ã¡ã«ããºã ïŒã®äœ¿çšãæäŸããŸãã å®éã人件費ã®èŠ³ç¹ãããã«ãã¹ã¬ããã¢ããªã±ãŒã·ã§ã³ãäœæããæãå®äŸ¡ãªæ¹æ³ã¯ãç¹å¥ãªãªãã·ã§ã³ã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ã®æ§ç¯ãéå§ããããšã§ãã ããããæé©åã³ã³ãã€ã©ã®èŠ³ç¹ããèŠããšãããã¯ç°¡åãªäœæ¥ã§ã¯ãããŸããã æé©åã®å®è¡å¯èœæ§ã蚌æããå¿ èŠããããŸããã«ãŒãå ã§å®è¡ãããäœæ¥éãæ£ããè©äŸ¡ããå¿ èŠããããŸãããã®ããã䞊ååã®æ±ºå®ã«ããçç£æ§ãåäžããŸãã èªå䞊ååããã³èªåãã¯ãã«åã¯ãä»ã®ã«ãŒãæé©åãšçžäºäœçšããå¿ èŠããããŸãã ããããããã®åéã§ã¯æé«ã®æé©åã¢ã«ãŽãªãºã ã¯ãŸã äœæãããŠããããå®éšãšé©æ°çãªã¢ã€ãã¢ã®ç¯å²ã¯ãŸã çŽ æŽãããã§ãã ããã°ã©ããŒã«ãšã£ãŠããæçœãªäžŠååã¡ãœãããéçºããããã«ãCILK +ãThreading Building Blocksãªã©ã®æ°ããèšèªæ¡åŒµæ©èœãšããŸããŸãªãµããŒãã©ã€ãã©ãªãäœæãããŸãã ãŸããåªããä¿¡é Œã§ããOPENMPãå²åŒããã«ã¯æ©ãããŸãã
çµè«ïŒ
以åã®æçš¿ã§ãã¢ããªã±ãŒã·ã§ã³ãã©ãã ãæé©åãããŠããããç解ããããã®ç°¡åãªåºæºã¯ãªãããšãææ¡ããŸããã ããã¯ãç¹å®ã®æ¡ä»¶ãæºããããå Žåã«ã®ã¿äœ¿çšã§ããããŸããŸãªããã©ãŒãã³ã¹æé©åãååšãããšããäºå®ã«ç±æ¥ããŠããŸãã ãããã®æ¡ä»¶ãæºããããŠãããã©ããã«ãããããããããŸãã¯ãã®æé©åãè¡ãæ©äŒããããŸã-ãã®åé¡ãç解ããã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãåæããããã»ã¹ã§å¿ èŠã§ãã ãããã£ãŠãç§ã®æèŠã§ã¯ãã¢ããªã±ãŒã·ã§ã³ããã©ãŒãã³ã¹ã®åæã¯ãããã©ãŒãã³ã¹ã«éèŠãªã¢ããªã±ãŒã·ã§ã³é åã®ç¹å®ããããã®é åã®ããã»ããµã®é 延ã®åå ã®ç¹å®ãç¹å®ãããçç±ã«åœ±é¿ããæé©åã®äœ¿çšãå¯èœãã©ããã®å€æãããã³ãã¯ãã«åã«ããã¢ããªã±ãŒã·ã§ã³ããã©ãŒãã³ã¹ã®åäžã®å¯èœæ§ã®å€æã«éå®ãããŸã䞊ååã
ãã¯ãã«åã¯ãã¯ãã«åãããŠããŸãïŒåæã®å°ããªäŸïŒ
åãã¢ããªã±ãŒã·ã§ã³ã§ãã£ãŠããããã©ãŒãã³ã¹ãåæãããšãã«ããŸã£ããé©ãã¹ãçµæã瀺ãããšããããŸãã ããã§ãããšãã°ããã¯ãã«ããã¯ãã«åãããŠãããã©ãããèªåããŸããïŒ ãã®ãã¹ããæ€èšããŠãã ããã
#include <vector> using namespace std; int main () { vector<float> myvector; vector<float>::iterator it; for(int j=0; j<1000; j++) { it = myvector.end(); it = myvector.insert ( it , j ); } for (int i=1; i < myvector.size(); ++i) myvector[i]++; printf("%f\n",myvector[0]); return 0; }
ãã®ããã¹ããã³ã³ãã€ã«ããã«ã¯ãVS2008ã«çµ±åãããIntelã³ã³ãã€ã©ã䜿çšããŸãã ãã®å Žåããµã€ã¯ã«ãã³ãŒãã®14è¡ç®ã§å ¬éãããŠãããã©ããã®è³ªåã«èå³ããããŸãã âQvec_report3ãªãã·ã§ã³ã䜿çšããŠããªãŒããã¯ãã©ã€ã¶ãŒã¬ããŒãã衚瀺ããŸãã
icl -Qvec_report3 -Qipo -Qansi_alias vector.cpp
Intel C ++ Intel 64ãããŒãžã§ã³Mainline Beta Build xã§å®è¡ãããã¢ããªã±ãŒã·ã§ã³çšã®Intel 64ã³ã³ãã€ã©XE
...
... \ vector.cppïŒ14ïŒïŒïŒå30ïŒãªããŒã¯ïŒã«ãŒãããã¯ãã«åãããŠããŸããïŒã«ãŒãæ§é ããµããŒããããŠããŸããã
...
çŸåšãåãã³ã³ãã€ã©ã䜿çšããŠããŸãããVS2010ã«æ¢ã«çµ±åãããŠããŸãã
icl -Qvec_report3 -Qipo -Qansi_alias vector.cpp
...
... \ vector.cppïŒ14ïŒïŒïŒå30ïŒåèïŒLOOP WAS VECTORIZEDã
...
ããã§ã¯ãåãããã°ã©ã ãã³ã³ãã€ã«ããéã«ã³ã³ãã€ã©ã®åäœãç°ãªãçç±ã®äžçªäžã«å°éããæ¹æ³ã«ã€ããŠã¯èª¬æããŸããã ïŒã¢ã»ã³ãã©ãŒã衚瀺ãããã³ãŒããååŠçã§ããŸãïŒã Intelã³ã³ãã€ã©ã¯ç°ãªãããŒãžã§ã³ã®VSã«çµ±åãããŠããããããã®å Žåãç°ãªãããŒãžã§ã³ã®STLã©ã€ãã©ãªã䜿çšãããŸãã STL VS2008ããŒãžã§ã³ã§ã¯ã[]æŒç®åã«é åã®ç¯å²å€ã®ãã§ãã¯ãå«ãŸããŠããŸãã ãã®çµæã__ invalid_parameter_noinfoããã·ãŒãžã£ã®åŒã³åºããã«ãŒãå ã«çŸããŠããã°ã©ã ãçµäºããã³ã³ãã€ã©ã¯ãã®ãããªã«ãŒãããã¯ãã«åã§ããŸããã ããããVS2010ã§ã¯ããã®ãããªæ€èšŒã¯ãããããŸããã ãªãã ãããïŒ
âQansi_aliasãªãã·ã§ã³ãåé€ãããšããã¯ãã«åãæ¶ããŠããŸãã®ã¯é¢çœãã§ãã å®éã®æŽæ°ã§ã¯ãªãæŽæ°ãæ ŒçŽãããã¯ãã«ãäœæããå Žåãåãããšãèµ·ãããŸãã ãããããããã®ãå¥è·¡ãã®çç±ã¯ãå¥ã®èšäºã®æ©äŒã§ãã
äžæ¬¡è³æ
ããŸããŸãªããã©ãŒãã³ã¹ã®åé¡ã調æ»ããããã®æç®ïŒ Software Optimization CookbookãSecond EditionããŸãã¯The Software Vectorization Handbookã
ããŸããŸãªæé©åææ³ã®åºæ¬çãªãœãŒã¹ïŒRandy AllenãKen Kennedyã ææ°ã®ã¢ãŒããã¯ãã£åãã®ã³ã³ãã€ã©ã®æé©åãããã³David F. BaconãSusan L. GrahamãOliver J. Sharpã ãã€ããã©ãŒãã³ã¹ã³ã³ãã¥ãŒãã£ã³ã°çšã®ã³ã³ãã€ã©å€æã
ããã°ã©ã ã«ããã³ãŒãã®æ¹åã«é¢å¿ã®ããããã°ã©ããŒã®ããã«ãAgner Fogã Optimizing software in C ++ïŒWindowsãLinux and Macãã©ãããã©ãŒã çšã®æé©åã¬ã€ãããå§ãããŸãã
éèªãOpen Systemsãã®èšäºãOptimizing Compilersãããããã€ãã®èããã³ããŒããããšãæ¥ããããããŸããã§ããã