ããã«ã¡ã¯ã芪æãªãhabrasocietyã
OpenCLã«é¢ãã以åã®èšäºã§ããã®ãã¯ãããžãŒã®æŠèŠãäœæããããŠãŒã¶ãŒã«æäŸã§ããå¯èœæ§ãšçŸæç¹ã§ã®ã¹ããŒã¿ã¹ã«ã€ããŠèª¬æããŸããã
ããã§ããã¯ãããžãŒããã詳现ã«æ€èšããŠãã ããã OpenCLãç°çš®ã·ã¹ãã ãè¡šããããã€ã¹ãšã®å¯Ÿè©±ã®æ©äŒãæäŸããããã°ã©ã ãäœæããã¢ãããŒããæäŸããç°çš®ã·ã¹ãã ãç解ããããšããŸãã
OpenCLã¯ãç°æ©çš®æ··åç°å¢ã§å®è¡ã§ããã¢ããªã±ãŒã·ã§ã³ãäœæããããã®ãã¯ãããžãŒãšããŠèæ¡ãããŸããã ããã«ãçŸåšèšç»ã«å«ãŸããŠããããã€ã¹ãããŸã 誰ãçºæããŠããªãããã€ã¹ã§ãå¿«é©ãªæäœãæäŸããããã«èšèšãããŠããŸãã ããããã¹ãŠã®ããã€ã¹ã®äœæ¥ã調æŽããããã«ãç°çš®ã·ã¹ãã ã«ã¯åžžã«OpenCL APIã®ä»ã®ãã¹ãŠã®æ段ãšçžäºäœçšãã1ã€ã®ãã¡ã€ã³ãããã€ã¹ããããŸãã ãã®ãããªããã€ã¹ã¯ããã¹ãããšåŒã°ããOpenCLã®å€éšã§å®çŸ©ãããŸãã
ãããã£ãŠãOpenCLã¯ãOpenCLããµããŒãããããã€ã¹ã®ã¢ã€ãã¢ãæäŸããæãäžè¬çãªåæããå§ãŸããŸãããã®ããã€ã¹ã¯èšç®ã«äœ¿çšãããããšã«ãªã£ãŠãããããäžè¬çãªæå³ã§ç¹å®ã®ãããã»ããµããåããŠããŸãã ã³ãã³ããå®è¡ã§ãããã®ã OpenCLã¯äžŠåã³ã³ãã¥ãŒãã£ã³ã°çšã«èšèšãããŠããããããã®ãããªããã»ããµã¯ ã䞊ååŠçã®æ段ãåããŠããå ŽåããããŸãïŒããšãã°ã1ã€ã®CPUã®è€æ°ã®ã³ã¢ãCellã®è€æ°ã®SPEããã»ããµïŒã 䞊åã³ã³ãã¥ãŒãã£ã³ã°ã®ããã©ãŒãã³ã¹ãåäžããããã1ã€ã®åºæ¬çãªæ¹æ³ã¯ããããã®ããã»ããµã®ããã€ããããã€ã¹ã«ã€ã³ã¹ããŒã«ããããšã§ãïŒããšãã°ããã«ãããã»ããµPCãã¶ãŒããŒããªã©ïŒã ãããŠåœç¶ãç°æ©çš®æ··åã·ã¹ãã ã§ã¯ããã®ãããªOpenCLããã€ã¹ãããã€ãååšããå¯èœæ§ããããŸãïŒäžè¬çã«ã¯ãã¢ãŒããã¯ãã£ãç°ãªããŸãïŒã
ã³ã³ãã¥ãŒãã£ã³ã°ãªãœãŒã¹ã«å ããŠãããã€ã¹ã«ã¯äžå®éã®ã¡ã¢ãªããããŸãã ããã«ããã®ã¡ã¢ãªã®èŠä»¶ã¯ãããŸãããããã€ã¹äžã«ãããããã¹ãRAMã«å²ãåœãŠãããšãã§ããŸãïŒããšãã°ãçµ±åãããªã«ãŒãã§è¡ãããŸãïŒã
å®éã«ã¯ãã¹ãŠã ããã€ã¹ã«ã€ããŠãã以äžã®ä»®å®ã¯è¡ãããŸããã
ããã€ã¹ã®ãã®ãããªåºãæŠå¿µã«ãããOpenCLçšã«éçºãããããã°ã©ã ã«å¶éã課ãããšã¯ã§ããŸããã ãã®ãã¯ãããžãŒã«ãããOpenCLããµããŒãããç¹å®ã®ããã€ã¹ã®ç¹å®ã®ã¢ãŒããã¯ãã£åãã«é«åºŠã«æé©åãããã¢ããªã±ãŒã·ã§ã³ãããã³ãã¹ãŠã®ã¿ã€ãã®ããã€ã¹ã§å®å®ããããã©ãŒãã³ã¹ãçºæ®ããã¢ããªã±ãŒã·ã§ã³ãéçºã§ããŸãïŒãããã®ããã€ã¹ã®åçã®ããã©ãŒãã³ã¹ãæ³å®ïŒã
OpenCLã¯ãããã°ã©ããããã€ã¹ãªãœãŒã¹ãšããåãããããã®äœã¬ãã«APIãããã°ã©ãã«æäŸããŸãã OpenCL APIã¯ãããã€ã¹ã§çŽæ¥ãµããŒããããããäžéAPIãä»ããŠåäœããŸãïŒNVidiaã®å ŽåïŒOpenCLã¯ããã€ã¹ã§ãµããŒããããCUDAãã©ã€ããŒAPIã®äžã§å®è¡ãããŸãïŒãç¹å®ã®å®è£ ã«äŸåããæšæºã§ã¯èšè¿°ãããŠããŸããã
äœã¬ãã«ã®æ§è³ªãç¶æããªãããOpenCLããã®ãããªæ±çšæ§ãæäŸããæ¹æ³ãèŠãŠã¿ãŸãããã
次ã«ãOpenCL 1.0ä»æ§ã®äžéšãç¡æã§ç¿»èš³ããã³ã¡ã³ããšè¿œå ãè¡ããŸãã
OpenCLã®äž»ãªã¢ã€ãã¢ã説æããããã«ã4ã€ã®ã¢ãã«ã®éå±€ã䜿çšããŸãã
- ãã©ãããã©ãŒã ã¢ãã«
- ã¡ã¢ãªã¢ãã«
- å®è¡ã¢ãã«
- ããã°ã©ãã³ã°ã¢ãã«
ãã©ãããã©ãŒã ã¢ãã«
OpenCLãã©ãããã©ãŒã ã¯ãOpenCLããµããŒãããããã€ã¹ã«æ¥ç¶ããããã¹ãã§æ§æãããŠããŸãã åOpenCLããã€ã¹ã¯ã1ã€ä»¥äžã®åŠçèŠçŽ ïŒåŠçèŠçŽ ã以éPEãšåŒã³ãŸãïŒã«ããã«åå²ãããèšç®ãŠãããã§æ§æãããŸãã
OpenCLã¢ããªã±ãŒã·ã§ã³ã¯ããã©ãããã©ãŒã ã®ãã€ãã£ãã¢ãã«ã«åŸã£ãŠãã¹ãäžã§å®è¡ãããŸãã OpenCLã¢ããªã±ãŒã·ã§ã³ã¯ããã¹ãããããã€ã¹ã«ã³ãã³ããéä¿¡ããŠãPEã§èšç®ãå®è¡ããŸãã èšç®ãŠãããå ã®PEã¯ãSIMDãããã¯ïŒãã¹ãŠã®PEãçŸåšã®åœä»€ã®å®è¡ãå®äºãããŸã§ã1ã€ã®åœä»€ãåæã«å®è¡ããã次ã®åœä»€ã®åŠçã¯éå§ãããŸããïŒãŸãã¯SPMDãããã¯ïŒåPEã«ç¬èªã®åœä»€ã«ãŠã³ã¿ãŒïŒããã°ã©ã ã«ãŠã³ã¿ãŒïŒ ïŒ
ã€ãŸããOpenCLã¯ãã¹ãããã®ç¹å®ã®ã³ãã³ããåŠçããŸãã ãããã£ãŠãã¢ããªã±ãŒã·ã§ã³ã¯OpenCLãšå³å¯ã«æ¥ç¶ãããŠããŸãããã€ãŸããããã°ã©ã ã®ããã©ãŒãã³ã¹ãæãªãããšãªããOpenCLã®å®è£ ããã€ã§ã眮ãæããããšãã§ããŸãã OpenCLããã€ã¹ã¢ãã«ã«é©åããªãããã€ã¹ãäœæãããå Žåã§ãããã¹ãã³ãã³ããããã€ã¹ã«ãšã£ãŠãã䟿å©ãªåœ¢åŒã«å€æããOpenCLå®è£ ãäœæã§ããŸãã
å®è¡ã¢ãã«
OpenCLããã°ã©ã ã®å®è¡ã¯ãããã°ã©ã ã®ãã¹ãéšåãšOpenCLããã€ã¹ã§å®è¡ãããŠããã«ãŒãã«ïŒã«ãŒãã«ãèš±å¯ãåŸãŠãç§ãã¡ã®ã»ãšãã©ãç¥ã£ãŠããè±èªã®çšèªãåŒãç¶ã䜿çšããŸãïŒã®2ã€ã®éšåã§æ§æãããŸãã ããã°ã©ã ã®ãã¹ãéšåã¯ãã«ãŒãã«ãå®è¡ãããã³ã³ããã¹ãã決å®ãããã®å®è¡ãå¶åŸ¡ããŸãã
OpenCLå®è¡ã¢ãã«ã®äž»èŠéšåã§ã¯ãã«ãŒãã«ã®å®è¡ã«ã€ããŠèª¬æããŠããŸãã ã«ãŒãã«ãå®è¡ã®ããã«ãã¥ãŒã«å ¥ãããããšãã€ã³ããã¯ã¹ã¹ããŒã¹ãå®çŸ©ãããŸãïŒNDRangeãå®çŸ©ã¯ä»¥äžã«ç€ºãããŸãïŒã ã«ãŒãã«ã®ã³ããŒïŒã€ã³ã¹ã¿ã³ã¹ïŒã¯ããã®ã¹ããŒã¹ã®åã€ã³ããã¯ã¹ã«å¯ŸããŠå®è¡ãããŸãã ç¹å®ã®ã€ã³ããã¯ã¹ã«å¯ŸããŠå®è¡ãããã«ãŒãã«ã®ã³ããŒã¯ãã¯ãŒã¯ã¢ã€ãã ãïŒã¯ãŒã¯ãŠãããïŒãšåŒã°ããã€ã³ããã¯ã¹ã¹ããŒã¹å ã®ãã€ã³ãã«ãã£ãŠå®çŸ©ãããŸããã€ãŸããåããŠããããã«ã¯ã°ããŒãã«IDãæäŸãããŸãã åWork-Itemã¯åãã³ãŒããå®è¡ããŸãããç¹å®ã®å®è¡ãã¹ïŒãã©ã³ããªã©ïŒãšãããæ©èœããããŒã¿ã¯ç°ãªãå ŽåããããŸãã
äœæ¥é ç®ã¯ã°ã«ãŒãïŒäœæ¥ã°ã«ãŒãïŒã«ç·šæãããŸãã ã°ã«ãŒãã¯ãã€ã³ããã¯ã¹ã¹ããŒã¹ã«ãã倧ããªããŒãã£ã·ã§ã³ãæäŸããŸãã åã°ã«ãŒãã«ã¯ãåã ã®èŠçŽ ã®ã¢ãã¬ã¹æå®ã«äœ¿çšãããã®ãšåã次å ã®ã°ã«ãŒãIDãå²ãåœãŠãããŸãã åèŠçŽ ã«ã¯ãã°ã«ãŒãå ã§äžæã®ããŒã«ã«IDãå²ãåœãŠãããŸãã ãããã£ãŠãã¯ãŒã¯ã¢ã€ãã ã¯ãã°ããŒãã«IDãšã°ã«ãŒãIDãšããŒã«ã«IDã®çµã¿åããã®äž¡æ¹ã§å¯ŸåŠã§ããŸãã
ã°ã«ãŒãå ã®äœæ¥é ç®ã¯ã1ã€ã®ã³ã³ãã¥ãŒãã£ã³ã°ãŠãããã®PEã§ç«¶åçã«ïŒäžŠè¡ããŠïŒå®è¡ãããŸãã
ããã«ã¯ãçµ±åãããããã€ã¹ã¢ãã«ãæ確ã«è¡šç€ºãããŠããŸããè€æ°ã®PE-> CUãè€æ°ã®CU->ããã€ã¹ãè€æ°ã®ããã€ã¹->ç°çš®ã·ã¹ãã ã
OpenCL 1.0ã®ã€ã³ããã¯ã¹ã¹ããŒã¹ã¯NDRangeãšåŒã°ãã1次å ã2次å ã3次å ã«ããããšãã§ããŸãã NDRangeã¯ãåæ¹åã®æ¬¡å ã瀺ãé·ãNã®æŽæ°ã®é åã§ãã
NDRangeãã£ã¡ã³ã·ã§ã³ã®éžæã¯ãç¹å®ã®ã¢ã«ãŽãªãºã ã®å©äŸ¿æ§ã«ãã£ãŠæ±ºå®ãããŸãã3次å ã¢ãã«ã§äœæ¥ããå Žåã¯ã3次å 座æšã§ã€ã³ããã¯ã¹ãäœæããã®ã䟿å©ã§ããç»åãŸãã¯2次å ã°ãªããã§äœæ¥ããå Žåã¯ãã€ã³ããã¯ã¹ã®æ¬¡å ã2ã®ãšãã«äŸ¿å©ã§ãããã«ãOpenCLã®äž»ãªç®æšã¯GPUã§ãã Nvidia GPUã¯ãããããæ倧3ã€ã®ã€ã³ããã¯ã¹ãµã€ãºããã€ãã£ãã§ãµããŒãããããã«ãªããŸããããã倧ããªæ¬¡å ãå®è£ ããã«ã¯ãCUDAãã©ã€ããŒAPIãŸãã¯OpenCLå®è£ ã®ããªãã¯ãšè€éãã«é Œããªããã°ãªããŸããã
OpenCLå®è¡ã¢ãã«ã®å®è¡ã³ã³ããã¹ããšã³ãã³ããã¥ãŒã
ãã¹ãã¯ã«ãŒãã«ã®å®è¡ã³ã³ããã¹ãã決å®ããŸãã ã³ã³ããã¹ãã«ã¯æ¬¡ã®ãªãœãŒã¹ãå«ãŸããŸãã
- ããã€ã¹ïŒãã¹ãã䜿çšããOpenCLããã€ã¹ã®ã»ããã
- ã«ãŒãã«ïŒããã€ã¹ã§å®è¡ãããOpenCLé¢æ°ã
- ããã°ã©ã ãªããžã§ã¯ãïŒãœãŒã¹ã³ãŒããšã«ãŒãã«å®è¡å¯èœãã¡ã€ã«ã
- ã¡ã¢ãªãªããžã§ã¯ãïŒãã¹ããšOpenCLããã€ã¹ã®äž¡æ¹ã«è¡šç€ºãããã¡ã¢ãªå ã®ãªããžã§ã¯ãã®ã³ã¬ã¯ã·ã§ã³ã ã¡ã¢ãªãªããžã§ã¯ãã«ã¯ãã«ãŒãã«ã䜿çšã§ããå€ãå«ãŸããŠããŸãã
ã³ã³ããã¹ãã¯ãOpenCL APIã®é¢æ°ã䜿çšããŠäœæããã³ç®¡çãããŸãã ãã¹ãã¯ãããã€ã¹äžã®ã«ãŒãã«ã®å®è¡ãå¶åŸ¡ããã³ãã³ããã¥ãŒãšåŒã°ããããŒã¿æ§é ãäœæããŸãã ãã¹ãã¯ã³ãã³ãããã¥ãŒã«éä¿¡ããŸãããã®åŸãã³ãã³ãã¯ã¹ã±ãžã¥ãŒã©ã«ãã£ãŠèšå®ãããç®çã®ã³ã³ããã¹ãã®ããã€ã¹ã§å®è¡ãããŸãã
ã³ãã³ãã«ã¯æ¬¡ã®ã¿ã€ãããããŸãã
- ã«ãŒãã«å®è¡ã³ãã³ãïŒ PEããã€ã¹ã§ã«ãŒãã«ãå®è¡ããŸãã
- ã¡ã¢ãªã³ãã³ãïŒã¡ã¢ãªãªããžã§ã¯ãéããŸãã¯ã¡ã¢ãªãªããžã§ã¯ãéã§ããŒã¿ã移åããŸãã
- åæã³ãã³ãïŒã³ãã³ããå®è¡ãããé åºãå¶åŸ¡ããŸãã
ã³ãã³ããã¥ãŒã¯ãããã€ã¹ã§å®è¡ããã³ãã³ããã¹ã±ãžã¥ãŒã«ããŸãã ãã¹ããšããã€ã¹éã§éåæã«å®è¡ãããŸãã ã³ãã³ãã¯ã次ã®2ã€ã®æ¹æ³ã§çžäºã«å®è¡ã§ããŸãã
- é çªã«å®è¡ïŒã³ãã³ãã¯ããã¥ãŒã«é 眮ãããŠããé åºã§å®è¡ãããåãé åºã§å®äºããŸãã ã€ãŸããã³ãã³ãã¯é çªã«å®è¡ãããŸãã
- äžè²«æ§ã®ãªãå®è¡ïŒã³ãã³ãã¯å®è¡ã®ããã«é çªã«éä¿¡ãããŸãããåã®ã³ãã³ããå®äºããã®ãåŸ
ã£ãŠããå®è¡ãéå§ããŸãã ãã®å Žåãããã°ã©ãã¯åæã³ãã³ããæ瀺çã«äœ¿çšããå¿
èŠããããŸãã
è€æ°ã®ã³ãã³ããã¥ãŒãåäžã®ã³ã³ããã¹ãã«é¢é£ä»ããããšãã§ããŸãã ãããã®ãã¥ãŒã¯ããããã®éã§ç«¶åãããããã®éã®æ瀺çãªåææ段ãªãã§ç¬ç«ããŠå®è¡ãããŸãã
ã³ãã³ããã¥ãŒã䜿çšãããšãOpenCLã䜿çšããéã®æ±çšæ§ãšæè»æ§ãå€§å¹ ã«åäžããŸãã ææ°ã®GPUã«ã¯ç¬èªã®ã¹ã±ãžã¥ãŒã©ããããå®è¡ãããã®ãšããã€ãã©ã®ã³ã³ãã¥ãŒãã£ã³ã°ãŠãããã§å®è¡ãããã決å®ããŸãã ãã¥ãŒã䜿çšããŠããç¬èªã®ã³ãã³ããã¥ãŒãæã€ã¹ã±ãžã¥ãŒã©ã®äœæ¥ã劚ããããšã¯ãããŸããã
å®è¡ã¢ãã«ïŒã«ãŒãã«ã«ããŽãªã
OpenCLã«ãŒãã«ã«ã¯2ã€ã®ã«ããŽãªããããŸãã
- OpenCLã«ãŒãã«ïŒ OpenCL Cã§èšè¿°ãããOpenCLã³ã³ãã€ã©ãŒã«ãã£ãŠã³ã³ãã€ã«ãããŸãã ãã¹ãŠã®OpenCLå®è£ ã¯ãOpenCl-kernelããµããŒãããå¿ èŠããããŸãã å®è£ ã¯ãOpenCLã«ãŒãã«ãäœæããããã®ä»ã®ã¡ã«ããºã ãæäŸããå ŽåããããŸãã
- ãã€ãã£ãã«ãŒãã«ïŒããããžã®ã¢ã¯ã»ã¹ã¯ãé¢æ°ãžã®ãã¹ããã€ã³ã¿ãŒãä»ããŠè¡ãããŸãã ãã€ãã£ãã«ãŒãã«ã¯ãOpenCL-kernelãšåæ§ã«å®è¡ã®ããã«ãã¥ãŒã«å ¥ããããOpenCL-kernelãšåãã¡ã¢ãªãªããžã§ã¯ãã䜿çšããŸãã ããšãã°ããã®ãããªã«ãŒãã«ã¯ãã¢ããªã±ãŒã·ã§ã³ã³ãŒãã§å®çŸ©ãããé¢æ°ã§ããã©ã€ãã©ãªãããšã¯ã¹ããŒããããé¢æ°ã§ãããŸããŸããã ãã€ãã£ãã«ãŒãã«ãå®è¡ããæ©èœã¯ãªãã·ã§ã³ã§ããããã®ã»ãã³ãã£ã¯ã¹ã¯æšæºã§å®çŸ©ãããŠããªãããšã«æ³šæããŠãã ããã OpenCL APIã«ã¯ããã®ãããªã«ãŒãã«ããµããŒãããããã®ããã€ã¹æ©èœãããŒãªã³ã°ããæ©èœãå«ãŸããŠããŸãã
ã¡ã¢ãªã¢ãã«
ã«ãŒãã«ãå®è¡ããã¯ãŒã¯ã¢ã€ãã ã¯ã4çš®é¡ã®ã¡ã¢ãªã䜿çšã§ããŸãã
- ã°ããŒãã«ã¡ã¢ãªã ãã®ã¡ã¢ãªã¯ããã¹ãŠã®ã°ã«ãŒãã®èŠçŽ ãžã®èªã¿åãããã³æžã蟌ã¿ã¢ã¯ã»ã¹ãæäŸããŸãã åWork-Itemã¯ãã¡ã¢ãªãªããžã§ã¯ãã®ä»»æã®éšåã§èªã¿æžãã§ããŸãã ããã€ã¹ã®æ©èœã«ãã£ãŠã¯ãã°ããŒãã«ã¡ã¢ãªã®æžã蟌ã¿ãšèªã¿åãããã£ãã·ã¥ãããå ŽåããããŸãã
- äžå®ã®ã¡ã¢ãªã ã«ãŒãã«å®è¡äžã«äžå®ã®ãŸãŸã§ããã°ããŒãã«ã¡ã¢ãªã®é åã ãã¹ãã¯ãå®æ°ã¡ã¢ãªã«ããã¡ã¢ãªãªããžã§ã¯ããå²ãåœãŠãŠåæåããŸãã
- ããŒã«ã«ã¡ã¢ãª ã°ã«ãŒãã«ããŒã«ã«ãªã¡ã¢ãªã®é åã ãã®ã¡ã¢ãªé åã䜿çšããŠãã°ã«ãŒãå šäœã§å ±æãããå€æ°ãäœæã§ããŸãã OpenCLããã€ã¹ã®ç¬ç«ããã¡ã¢ãªãšããŠå®è£ ã§ããŸãã ãŸãã¯ããã®ã¡ã¢ãªãã°ããŒãã«ã¡ã¢ãªã®é åãšããŠããŒã¯ããããšãã§ããŸãã
- ãã©ã€ããŒãïŒãã©ã€ããŒãïŒã¡ã¢ãªã Work-Itemãææããã¡ã¢ãªé åã 1ã€ã®ã¯ãŒã¯ã¢ã€ãã ã®ãã©ã€ããŒãã¡ã¢ãªã§å®çŸ©ãããå€æ°ã¯ãä»ã®ã¯ãŒã¯ã¢ã€ãã ããã¯èŠããŸããã
ä»æ§ã§ã¯4çš®é¡ã®ã¡ã¢ãªãå®çŸ©ãããŠããŸãããããŒããŠã§ã¢ã§ã®ã¡ã¢ãªã®å®è£ ã«é¢ããèŠä»¶ã¯ãããŸããã 4ã€ã®ã¿ã€ãã®ã¡ã¢ãªã¯ãã¹ãŠã°ããŒãã«ã¡ã¢ãªã«é 眮ã§ããã¿ã€ãã¬ãã«ã®åé¢ã¯ãã©ã€ããŒã¬ãã«ã§å®è¡ã§ããŸããéã®å Žåã¯ãããã€ã¹ã¢ãŒããã¯ãã£ã«ãã£ãŠæ±ºå®ãããã¡ã¢ãªã¿ã€ãã®å³å¯ãªåé¢ããããŸãã
ãŸãã«ãããã®ã¿ã€ãã®ã¡ã¢ãªã®ååšã¯éåžžã«è«ççã§ããããã»ããµã³ã¢ã«ã¯ç¬èªã®ãã£ãã·ã¥ããããããã»ããµã«ã¯å ±éã®ãã£ãã·ã¥ããããããã€ã¹å šäœã«ã¯äžå®éã®ã¡ã¢ãªããããŸãã
ãœãããŠã§ã¢ã¢ãã«ã ïŒããã°ã©ãã³ã°ã¢ãã«ïŒ
OpenCLå®è¡ã¢ãã«ã¯ãããŒã¿äžŠååŠçãšã¿ã¹ã¯äžŠååŠçã®2ã€ã®ãœãããŠã§ã¢ã¢ãã«ããµããŒãããŠããŸã;ãã€ããªããã¢ãã«ããµããŒããããŠããŸãã OpenCLã®èšèšãå®çŸ©ããäž»ãªã¢ãã«ã¯ãããŒã¿ã®äžŠååŠçã§ãã
ããŒã¿äžŠåæ§ãåãããœãããŠã§ã¢ã¢ãã«ã
ãã®ã¢ãã«ã¯ãã¡ã¢ãªãªããžã§ã¯ãã®å€ãã®èŠçŽ ã«é©çšãããäžé£ã®åœä»€ãšããŠèšç®ãå®çŸ©ããŸãã OpenCLã©ã³ã¿ã€ã ã¢ãã«ã«é¢é£ä»ããããã€ã³ããã¯ã¹ã¹ããŒã¹ã¯ãã¯ãŒã¯ã¢ã€ãã ãšã¯ãŒã¯ã¢ã€ãã éã®ããŒã¿ã®åæ£æ¹æ³ãå®çŸ©ããŸãã ããŒã¿äžŠååŠçã®å³å¯ãªã¢ãã«ã§ã¯ãWork-Itemãšã¡ã¢ãªãªããžã§ã¯ãå ã®èŠçŽ ãšã®éã«å³å¯ãª1察1ã®å¯Ÿå¿ããããã«ãŒãã«ã¯ããã䜿çšããŠäžŠåã«äœæ¥ã§ããŸãã OpenCLã¯ãå³å¯ãª1察1ã®ãããã³ã°ãäžèŠãªãããæè»ãªããŒã¿åæå®è¡ã¢ãã«ãå®è£ ããŠããŸãã
OpenCLã¯ãããŒã¿ã®äžŠè¡æ§ã®éå±€ã¢ãã«ãæäŸããŸãã éå±€åå²ãå®çŸ©ããã«ã¯2ã€ã®æ¹æ³ããããŸãã æ瀺çãªã¢ãã«ã§ã¯ãããã°ã©ããŒã¯ã䞊åã«å®è¡ããå¿ èŠã®ããèŠçŽ ã®ç·æ°ãšããããã®èŠçŽ ãã°ã«ãŒãã«åé ããæ¹æ³ã決å®ããŸãã æé»çãªã¢ãã«ã§ã¯ãããã°ã©ããŒã¯äžŠåã«å®è¡ããå¿ èŠã®ããèŠçŽ ã®ç·æ°ã®ã¿ã決å®ããã¯ãŒã¯ã°ã«ãŒããžã®åå²ã¯èªåçã«å®è¡ãããŸãã
ãžã§ãã®äžŠåæ§ãåãããœãããŠã§ã¢ã¢ãã«ã
ãã®ã¢ãã«ã§ã¯ãã€ã³ããã¯ã¹ã¹ããŒã¹ã«é¢ä¿ãªããã«ãŒãã«ã®åã³ããŒãå®è¡ãããŸãã è«ççã«ã¯ãããã¯ã1ã€ã®èŠçŽ ã§æ§æãããã°ã«ãŒããæã€ã³ã³ãã¥ãŒãã£ã³ã°ãŠãããïŒCUïŒã§ã«ãŒãã«ãå®è¡ããããšãšåãã§ãã ãã®ã¢ãã«ã§ã¯ããŠãŒã¶ãŒã¯æ¬¡ã®æ¹æ³ã§äžŠè¡æ§ãè¡šçŸããŸãã
- ããã€ã¹ã«å®è£ ãããŠãããã¯ã¿ãŒããŒã¿ã¿ã€ãã䜿çšããŸãã
- å€ãã®ã¿ã¹ã¯ããã¥ãŒã«å ¥ããŸãã
- OpenCLã«çŽäº€ãããœãããŠã§ã¢ã¢ãã«ã䜿çšããŠãã€ãã£ãã«ãŒãã«ããã¥ãŒã«å ¥ããŸãã
2ã€ã®ããã°ã©ãã³ã°ã¢ãã«ã®ååšãæ®éæ§ãžã®ãªããŒãžã¥ã§ãã ææ°ã®GPUãšã»ã«ã«ã¯ãæåã®ã¢ãã«ãé©ããŠããŸãã ãã ãããã®ãããªã¢ãã«ã®ãã¬ãŒã ã¯ãŒã¯å ã§ãã¹ãŠã®ã¢ã«ãŽãªãºã ãå¹æçã«å®è£ ã§ããããã§ã¯ãªããæåã®ã¢ãã«ã䜿çšããã®ã«ã¢ãŒããã¯ãã£ãäžäŸ¿ãªããã€ã¹ãåºçŸããå¯èœæ§ããããŸãã ãã®å Žåã2çªç®ã®ã¢ãã«ã䜿çšãããšãå¥ã®ã¢ãŒããã¯ãã£ã«åºæã®ã¢ããªã±ãŒã·ã§ã³ãäœæã§ããŸãã
OpenCLãã©ãããã©ãŒã ã®æ§æ
OpenCLãã©ãããã©ãŒã ã䜿çšãããšãã¢ããªã±ãŒã·ã§ã³ã¯ãã¹ããš1ã€ä»¥äžã®OpenCLããã€ã¹ã1ã€ã®ç°çš®äžŠåã³ã³ãã¥ãŒã¿ãŒã·ã¹ãã ãšããŠäœ¿çšã§ããŸãã ãã©ãããã©ãŒã ã¯ã次ã®ã³ã³ããŒãã³ãã§æ§æãããŠããŸãã
- OpenCLãã©ãããã©ãŒã ã¬ã€ã€ãŒïŒãã¹ããOpenCLããã€ã¹ãæ€åºãããã®ããããã£ãã¯ãšãªããã³ã³ããã¹ããäœæã§ããããã«ããŸãã
- OpenCLã©ã³ã¿ã€ã ïŒã©ã³ã¿ã€ã ã䜿çšãããšããã¹ãããã°ã©ã ã§ã³ã³ããã¹ããäœæããåŸãã³ã³ããã¹ãã管çã§ããŸãã
- OpenCLã³ã³ãã€ã©ïŒOpenCLã³ã³ãã€ã©ã¯ãOpenCL âã«ãŒãã«ãå«ãå®è¡å¯èœãã¡ã€ã«ãäœæããŸãã OpenCL-Cããã°ã©ãã³ã°èšèªã¯ã䞊è¡æ§ãæ¡åŒµããISO C99èšèªæšæºã®ãµãã»ããããµããŒãããã³ã³ãã€ã©ãŒã«ãã£ãŠå®è£ ãããŸãã
ã©ã®ããã«æ©èœããŸããïŒ
次ã®èšäºã§ã¯ãäŸãšããŠNvidia Computing SDKã§é åžãããŠããã¢ããªã±ãŒã·ã§ã³ã®1ã€ã䜿çšããŠOpenCLã¢ããªã±ãŒã·ã§ã³ãäœæããããã»ã¹ã詳ããèŠãŠãããŸãã Nvidiaãæšå¥šäºé ãšããŠæäŸããŠããOpenCLã®ã¢ããªã±ãŒã·ã§ã³æé©åã®äŸã次ã«ç€ºããŸãã
ããã§ããã®ãããªã¢ããªã±ãŒã·ã§ã³ãäœæããããã»ã¹ã®æ§ææé ãæŠç¥çã«èª¬æããŸãã
- ããã€ã¹äžã§ããã°ã©ã ãå®è¡ããããã®ã³ã³ããã¹ããäœæããŸãã
- å¿ èŠãªããã€ã¹ãéžæããŸãïŒããããã®æ°ãæãå€ãããã€ã¹ãããã«éžæã§ããŸãïŒã
- éžæããããã€ã¹ããäœæããã³ã³ããã¹ãã§åæåããŸãã
- ããã€ã¹IDãšã³ã³ããã¹ãã«åºã¥ããŠã³ãã³ããã¥ãŒãäœæããŸãã
- ãœãŒã¹ã³ãŒããšã³ã³ããã¹ãã«åºã¥ããŠããã°ã©ã ãäœæãã
ãã€ããªãã¡ã€ã«ãšã³ã³ããã¹ãã«åºã¥ããŠããŸãã - ããã°ã©ã ïŒãã«ãïŒãåéããŸãã
- ã«ãŒãã«ãäœæããŸãã
- å ¥åããã³åºåããŒã¿çšã®ã¡ã¢ãªãªããžã§ã¯ããäœæããŸãã
- ãã¹ãäžã®ããŒã¿ãšãšãã«ã¡ã¢ãªé åããããã€ã¹ã®ã¡ã¢ãªã«ããŒã¿ãæžã蟌ãã³ãã³ãããã¥ãŒã«å ¥ããŸãã
- äœæããã«ãŒãã«ã®å®è¡ã³ãã³ãããã¥ãŒã«å ¥ããŸãã
- ã³ãã³ãããã¥ãŒã«å ¥ããŠãããã€ã¹ããããŒã¿ãèªã¿åããŸãã
- äœæ¥ã®å®äºãåŸ ã£ãŠããŸãã
ããã°ã©ã ã®ã¢ã»ã³ããªã¯å®è¡æã«å®è¡ãããã»ãšãã©JITã³ã³ãã€ã«ãããããšã«æ³šæããŠãã ããã æšæºã§ã¯ãéžæãããã³ã³ããã¹ããèæ ®ããŠããã°ã©ã ãã¢ã»ã³ãã«ã§ããããã«ããããè¡ãããŠãããšèª¬æãããŠããŸãã ãŸããOpenCLå®è£ ã®åãããã€ããŒã¯ãããã€ã¹ã®ã³ã³ãã€ã©ãŒãæé©åã§ããŸãã ãã ããããã°ã©ã ã¯ãã€ããªã³ãŒãããäœæããããšãã§ããŸãã ãŸãã¯ãæåã®èµ·åæã«äžåºŠäœæããŠããåå©çšãããšããã®æ©èœãæšæºã§èª¬æãããŸãã ããã«ãããããããã³ã³ãã€ã©ã¯OpenCLãã©ãããã©ãŒã ã«çµ±åãããŠããŸãããè¯ããæªããããã§ãã
ãããã«
ãã®çµæãOpenCLã¢ãã«ã¯éåžžã«æ®éçã§ããããšãå€æããŸããããäœã¬ãã«ã®ãŸãŸã§ãããããç¹å®ã®ã¢ãŒããã¯ãã£åãã«ã¢ããªã±ãŒã·ã§ã³ãæé©åã§ããŸãã ãŸããããã¿ã€ãã®OpenCLããã€ã¹ããå¥ã®ã¿ã€ãã«ç§»åãããšãã«ã¯ãã¹ãã©ãããã©ãŒã ãæäŸããŸãã OpenCLå®è£ ã®ãããã€ããŒã¯ãããããæ¹æ³ã§ããã€ã¹ãšOpenCL APIãšã®å¯Ÿè©±ãæé©åããæ©èœãåããŠãããããã€ã¹ã®ãªãœãŒã¹å²ãåœãŠã®å¹çãé«ããããšããŠããŸãã ããã«ãæ£ããèšè¿°ãããOpenCLã¢ããªã±ãŒã·ã§ã³ã¯ãããã€ã¹ã®äžä»£ãè¶ ããŠåŒãç¶ãæå¹ã§ãã
åç §ïŒ
- http://www.khronos.org/registry/cl/specs/opencl-1.0.48.pdf-è±èªã®OpenCLä»æ§ã®ææ°ããŒãžã§ã³ïŒ6.10.09ïŒ