{"id":245503,"date":"2014-12-11T00:06:03","date_gmt":"2014-12-10T20:06:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=245503"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=245503","title":{"rendered":"<span class=\"post_title\">\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 CUDA. \u0427\u0430\u0441\u0442\u044c 1: \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4>\u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e CUDA \u2014 \u0437\u0430\u0447\u0435\u043c?<\/h4>\n<p>   \u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0431\u044b\u043b\u043e \u0443\u0436\u0435 \u043d\u0435\u043c\u0430\u043b\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e CUDA \u2014 <a href=\"http:\/\/habrahabr.ru\/post\/119435\/\">\u0440\u0430\u0437<\/a>, <a href=\"http:\/\/habrahabr.ru\/post\/54707\/\">\u0434\u0432\u0430<\/a> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0438\u0441\u043a \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u00abCUDA <a href=\"http:\/\/http.developer.nvidia.com\/GPUGems3\/gpugems3_ch39.html\">scan<\/a>\u00bb \u0432\u044b\u0434\u0430\u043b \u0432\u0441\u0435\u0433\u043e 2 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c scan \u043d\u0430 GPU \u2014 \u0430 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0432\u0448\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u043c \u043a\u0443\u0440\u0441\u043e\u043c \u043d\u0430 Udacity \u2014 <a href=\"https:\/\/www.udacity.com\/course\/cs344\">Intro to Parallel Programming<\/a>, \u044f \u0438 \u0440\u0435\u0448\u0438\u043b\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u0443\u044e \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439 \u043e CUDA. \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0441\u0435\u0440\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u043a\u0443\u0440\u0441\u0435, \u0438 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u2014 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0439\u0442\u0438 \u0435\u0433\u043e.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435<\/h4>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438:<br \/>  <b>\u0427\u0430\u0441\u0442\u044c 1: \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/b><br \/>  <a href=\"http:\/\/habrahabr.ru\/company\/epam_systems\/blog\/245523\/\">\u0427\u0430\u0441\u0442\u044c 2: \u0410\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435 GPU \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u0438.<\/a><br \/>  \u0427\u0430\u0441\u0442\u044c 3: \u0424\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b GPU: \u0441\u0432\u0435\u0440\u0442\u043a\u0430 (reduce), \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (scan) \u0438 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 (histogram).<br \/>  \u0427\u0430\u0441\u0442\u044c 4: \u0424\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b GPU: \u0443\u043f\u043b\u043e\u0442\u043d\u0435\u043d\u0438\u0435 (compact), \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (segmented scan), \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432.<br \/>  \u0427\u0430\u0441\u0442\u044c 5: \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f GPU \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c.<br \/>  \u0427\u0430\u0441\u0442\u044c 6: \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432.<br \/>  \u0427\u0430\u0441\u0442\u044c 7: \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u043c\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c.<br \/>  <habracut\/>  <\/p>\n<h4>\u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 vs \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c<\/h4>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/cb2\/94c\/38c\/cb294c38cf0b4597acc43f4e31e32dae.jpg\"\/><br \/>  \u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u0434\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c GPU \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u2014 \u0430 \u0434\u043b\u044f \u043a\u0430\u043a\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u0445\u043e\u0440\u043e\u0448 GPU, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u043e\u0438\u0442 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c? \u0414\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c 2 \u043f\u043e\u043d\u044f\u0442\u0438\u044f:<br \/>  <b>\u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430<\/b> (latency) \u2014 \u0432\u0440\u0435\u043c\u044f, \u0437\u0430\u0442\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438\/\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<br \/>  <b>\u041f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c<\/b> \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439\/\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0437\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<br \/>  \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440: \u0438\u043c\u0435\u0435\u043c \u043b\u0435\u0433\u043a\u043e\u0432\u043e\u0439 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e 90 \u043a\u043c\/\u0447 \u0438 \u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c\u044e 4 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u0438 \u0430\u0432\u0442\u043e\u0431\u0443\u0441 \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e 60 \u043a\u043c\/\u0447 \u0438 \u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c\u044e 20 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0415\u0441\u043b\u0438 \u0437\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 1 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043d\u0430 1 \u043a\u0438\u043b\u043e\u043c\u0435\u0442\u0440, \u0442\u043e \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043b\u0435\u0433\u043a\u043e\u0432\u043e\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f \u2014 3600\/90=40\u0441 \u2014 \u0437\u0430 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434 1 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0435\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 1 \u043a\u0438\u043b\u043e\u043c\u0435\u0442\u0440, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f \u2014 4\/40=0.1 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439\/\u0441\u0435\u043a\u0443\u043d\u0434\u0443; \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0430\u0432\u0442\u043e\u0431\u0443\u0441\u0430 \u2014 3600\/60=60\u0441, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0430\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0430\u0432\u0442\u043e\u0431\u0443\u0441\u0430 \u2014 20\/60=0.3(3) \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439\/\u0441\u0435\u043a\u0443\u043d\u0434\u0443. <br \/>  \u0422\u0430\u043a \u0432\u043e\u0442, CPU \u2014 \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c, GPU \u2014 \u0430\u0432\u0442\u043e\u0431\u0443\u0441: \u043e\u043d \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0438 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0443\u044e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0436\u043d\u0430 \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u0442\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u2014 \u0441\u0442\u043e\u0438\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 GPU.<\/p>\n<h4>\u0411\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u044b CUDA<\/h4>\n<p>  \u0418\u0442\u0430\u043a, \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439 CUDA:<br \/>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/9d5\/29e\/19f\/9d529e19f57c4232bf9713eb8c2e96ab.jpg\"\/>  <\/p>\n<ul>\n<li><b>\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e (device)<\/b> \u2014 GPU. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0440\u043e\u043b\u044c \u00ab\u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u043d\u043e\u0433\u043e\u00bb \u2014 \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u0435\u043c\u0443 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 CPU.<\/li>\n<li><b>\u0425\u043e\u0441\u0442 (host)<\/b> \u2014 CPU. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u0440\u043e\u043b\u044c \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\/\u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. \u0418 \u0434\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 CUDA \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0442\u0430\u043a \u0438 \u0445\u043e\u0441\u0442 \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u043e\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c. <\/li>\n<li><b>\u042f\u0434\u0440\u043e (kernel)<\/b> \u2014 \u0437\u0430\u0434\u0430\u0447\u0430, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u0430\u044f \u0445\u043e\u0441\u0442\u043e\u043c \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435. <\/li>\n<\/ul>\n<p>  \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 CUDA \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u0442\u0435 \u043a\u043e\u0434 \u043d\u0430 \u0441\u0432\u043e\u0435\u043c \u043b\u044e\u0431\u0438\u043c\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (<a href=\"http:\/\/en.wikipedia.org\/wiki\/CUDA#Language_bindings\">\u0441\u043f\u0438\u0441\u043e\u043a<\/a> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0421 \u0438 \u0421++), \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 CUDA \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0445\u043e\u0441\u0442\u0430 \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043e\u0433\u043e\u0432\u043e\u0440\u043a\u0430: \u043a\u043e\u0434 \u0434\u043b\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 &#8216;CUDA-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c\u0438&#8217;.<\/p>\n<h4>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u044d\u0442\u0430\u043f\u044b CUDA-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h4>\n<p>  <\/p>\n<ol>\n<li>\u0425\u043e\u0441\u0442 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0443\u0436\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435. <\/li>\n<li>\u0425\u043e\u0441\u0442 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0441\u0432\u043e\u0435\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430. <\/li>\n<li>\u0425\u043e\u0441\u0442 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u044f\u0434\u0435\u0440 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435. <\/li>\n<li>\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u044f\u0434\u0440\u0430. <\/li>\n<li>\u0425\u043e\u0441\u0442 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0441\u0432\u043e\u044e \u043f\u0430\u043c\u044f\u0442\u044c. <\/li>\n<\/ol>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u043b\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f GPU \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u044f\u0434\u0435\u0440, \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u043c\u0443 \u043d\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0431\u044b\u043b\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435.<\/p>\n<h4>\u042f\u0434\u0440\u0430<\/h4>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u044f\u0434\u0435\u0440 \u0438 \u0438\u0445 \u0437\u0430\u043f\u0443\u0441\u043a\u0430. \u0412\u0430\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u2014 <b>\u044f\u0434\u0440\u0430 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u043a\u0430\u043a (\u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438) \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/b> \u2014 \u0442\u043e-\u0435\u0441\u0442\u044c \u0432\u044b \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 \u043a\u043e\u0434\u0435 \u0441\u0430\u043c\u0438\u0445 \u044f\u0434\u0435\u0440. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e, \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 <b>GPU \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043f\u0438\u0439 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u044f\u0434\u0440\u0430 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445<\/b> \u2014 \u0430 \u0442\u043e\u0447\u043d\u0435\u0435, \u0432\u044b \u0441\u0430\u043c\u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0435 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c. \u0418 \u0434\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0432\u043e\u043f\u0440\u043e\u0441\u0443 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f GPU \u2014 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 (\u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443) \u2014 \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435.<br \/>  \u041a\u043e\u0434 \u0434\u043b\u044f \u044f\u0434\u0435\u0440 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432 \u0442\u0430\u043a\u0438\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445:  <\/p>\n<ol>\n<li>\u0412\u043d\u0443\u0442\u0440\u0438 \u044f\u0434\u0435\u0440 \u0432\u044b \u0438\u043c\u0435\u0435\u0442\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0437\u043d\u0430\u0442\u044c \u00ab\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u00bb \u0438\u043b\u0438, \u043f\u0440\u043e\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043f\u043e\u0442\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u0443 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043c\u044b \u0434\u043e\u0431\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u044f\u0434\u0440\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043e\u0442\u043e\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e. \u041a\u0441\u0442\u0430\u0442\u0438, \u0442\u0430\u043a\u0430\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"http:\/\/en.wikipedia.org\/wiki\/SIMD\">SIMD<\/a> (Single Instruction Multiple Data) \u2014 \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u043e \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<li>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432 \u043a\u043e\u0434\u0435 \u044f\u0434\u0440\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438.<\/li>\n<\/ol>\n<p>  \u041a\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043e \u044f\u0434\u0440\u043e? \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 GPU \u044d\u0442\u043e \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 <b>Graphics<\/b> Processing Unit, \u0442\u043e \u044d\u0442\u043e, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u0432\u043b\u0438\u044f\u043b\u043e \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c CUDA, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432:  <\/p>\n<ul>\n<li>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0441\u0435\u0442\u043a\u0438 (grid), \u0432 3D \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u0445: <i>grid_x, grid_y, grid_z<\/i>. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0441\u0435\u0442\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 <i>grid_x*grid_y*grid_z<\/i> \u0431\u043b\u043e\u043a\u043e\u0432. <\/li>\n<li>\u041f\u043e\u0442\u043e\u043c \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0431\u043b\u043e\u043a\u0430 \u0432 3D \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u0445: <i>block_x, block_y, block_z<\/i>. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u0431\u043b\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 <i>block_x*block_y*block_z<\/i> \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0418\u0442\u043e\u0433\u043e, \u0438\u043c\u0435\u0435\u043c <i>grid_x*grid_y*grid_z*block_x*block_y*block_z<\/i> \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0412\u0430\u0436\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u0431\u043b\u043e\u043a\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043e \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 GPU \u2014 \u0442\u0438\u043f\u0438\u0447\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 512 (\u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0440\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438) \u0438 1024 (\u0431\u043e\u043b\u0435\u0435 \u043d\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438).<\/li>\n<li>\u0412\u043d\u0443\u0442\u0440\u0438 \u044f\u0434\u0440\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 <b>threadIdx<\/b> \u0438 <b>blockIdx<\/b> \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 <b>x, y, z<\/b> \u2014 \u043e\u043d\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 3D \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043f\u043e\u0442\u043e\u043a\u0430 \u0432 \u0431\u043b\u043e\u043a\u0435 \u0438 \u0431\u043b\u043e\u043a\u0430 \u0432 \u0441\u0435\u0442\u043a\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 <b>blockDim<\/b> \u0438 <b>gridDim<\/b> \u0441 \u0442\u0435\u043c\u0438 \u0436\u0435 \u043f\u043e\u043b\u044f\u043c\u0438 \u2014 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0431\u043b\u043e\u043a\u0430 \u0438 \u0441\u0435\u0442\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. <\/li>\n<\/ul>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 2D \u0438 3D \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b 2D \u043b\u0438\u0431\u043e 3D \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0431\u043b\u043e\u043a\u0430 (\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u043c\u043e\u0434\u0435\u043b\u0438 GPU) \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u0435\u0442\u043a\u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0440\u044b\u0442\u043e \u0432\u0441\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441 \u0438\u0437\u0431\u044b\u0442\u043a\u043e\u043c \u2014 \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430\u0446\u0435\u043b\u043e \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0431\u043b\u043e\u043a\u0430.<\/p>\n<h4>\u041f\u0438\u0448\u0435\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 CUDA<\/h4>\n<p>  \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0435\u043e\u0440\u0438\u0438, \u0432\u0440\u0435\u043c\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434. \u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 CUDA \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u041e\u0421 \u2014 <a href=\"http:\/\/docs.nvidia.com\/cuda\/index.html\">docs.nvidia.com\/cuda\/index.html<\/a>. \u0422\u0430\u043a\u0436\u0435, \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/opencv.org\">OpenCV<\/a>, \u0430 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 CPU \u0438 GPU \u2014 <a href=\"http:\/\/openmp.org\/wp\/\">OpenMP<\/a>.<br \/>  \u0417\u0430\u0434\u0430\u0447\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0443\u044e: \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0446\u0432\u0435\u0442\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/\u041e\u0442\u0442\u0435\u043d\u043a\u0438_\u0441\u0435\u0440\u043e\u0433\u043e\">\u043e\u0442\u0442\u0435\u043d\u043a\u0438 \u0441\u0435\u0440\u043e\u0433\u043e<\/a>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u0430 <i>pix<\/i> \u0432 \u0441\u0435\u0440\u043e\u0439 \u0448\u043a\u0430\u043b\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435: <i>Y<\/i> = <i>0.299*pix.R + 0.587*pix.G + 0.114*pix.B<\/i>.<br \/>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u043a\u0435\u043b\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">main.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;chrono&gt; #include &lt;iostream&gt; #include &lt;cstring&gt; #include &lt;string&gt;  #include &lt;opencv2\/core\/core.hpp&gt; #include &lt;opencv2\/highgui\/highgui.hpp&gt; #include &lt;opencv2\/opencv.hpp&gt; #include &lt;vector_types.h&gt;  #include &quot;openMP.hpp&quot; #include &quot;CUDA_wrappers.hpp&quot; #include &quot;common\/image_helpers.hpp&quot;  using namespace cv; using namespace std;  int main( int argc, char** argv ) {   using namespace std::chrono;    if( argc != 2)   {     cout &lt;&lt;&quot; Usage: convert_to_grayscale imagefile&quot; &lt;&lt; endl;     return -1;   }    Mat image, imageGray;   uchar4 *imageArray;   unsigned char *imageGrayArray;    prepareImagePointers(argv[1], image, &imageArray, imageGray, &imageGrayArray, CV_8UC1);    int numRows = image.rows, numCols = image.cols;    auto start = system_clock::now();   RGBtoGrayscaleOpenMP(imageArray, imageGrayArray, numRows, numCols);   auto duration = duration_cast&lt;milliseconds&gt;(system_clock::now() - start);   cout&lt;&lt;&quot;OpenMP time (ms):&quot; &lt;&lt; duration.count() &lt;&lt; endl;    memset(imageGrayArray, 0, sizeof(unsigned char)*numRows*numCols);      RGBtoGrayscaleCUDA(imageArray, imageGrayArray, numRows, numCols);    return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0443\u0442 \u0432\u0441\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u2014 \u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c, \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438 \u0432 \u043e\u0442\u0442\u0435\u043d\u043a\u0430\u0445 \u0441\u0435\u0440\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442<br \/>   \u0441 OpenMP \u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 CUDA, \u0437\u0430\u043c\u0435\u0440\u044f\u0435\u043c \u0432\u0440\u0435\u043c\u044f. \u0424\u0443\u043d\u043a\u0446\u0438\u044f <i>prepareImagePointers<\/i> \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">prepareImagePointers<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template &lt;class T1, class T2&gt; void prepareImagePointers(const char * const inputImageFileName,                           cv::Mat& inputImage,                            T1** inputImageArray,                            cv::Mat& outputImage,                           T2** outputImageArray,                            const int outputImageType) {   using namespace std;   using namespace cv;    inputImage = imread(inputImageFileName, IMREAD_COLOR);    if (inputImage.empty())    {     cerr &lt;&lt; &quot;Couldn't open input file.&quot; &lt;&lt; endl;     exit(1);   }    \/\/allocate memory for the output   outputImage.create(inputImage.rows, inputImage.cols, outputImageType);    cvtColor(inputImage, inputImage, cv::COLOR_BGR2BGRA);    *inputImageArray = (T1*)inputImage.ptr&lt;char&gt;(0);   *outputImageArray  = (T2*)outputImage.ptr&lt;char&gt;(0);  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u042f \u043f\u043e\u0448\u0435\u043b \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u044c: \u0434\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0438\u043a\u0441\u0435\u043b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u2014 \u0442\u043e-\u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0441 CUDA \u0432\u0441\u0442\u0430\u0435\u0442 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u0430\u044f \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f CUDA \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 OpenMP \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430, \u0430 \u043c\u044b \u0436\u0435 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0447\u0442\u043e CUDA \u0431\u044b\u0441\u0442\u0440\u0435\u0435:) \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f CUDA \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u044f, \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u2014 \u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u0412 \u0441\u0432\u043e\u0435 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u0438\u0435 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0437\u0430\u0434\u0430\u0447 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0434\u043e\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0438 CUDA \u0431\u0443\u0434\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0434\u0430\u0436\u0435 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. <br \/>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u0434\u043b\u044f OpenMP \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">openMP.hpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;stdio.h&gt;  #include &lt;omp.h&gt; #include &lt;vector_types.h&gt;  void RGBtoGrayscaleOpenMP(uchar4 *imageArray, unsigned char *imageGrayArray, int numRows, int numCols) {     #pragma omp parallel for collapse(2)     for (int i = 0; i &lt; numRows; ++i)     {         for (int j = 0; j &lt; numCols; ++j)         {             const uchar4 pixel = imageArray[i*numCols+j];             imageGrayArray[i*numCols+j] = 0.299f*pixel.x + 0.587f*pixel.y+0.114f*pixel.z;         }     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0441\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u044f\u043c\u043e\u043b\u0438\u043d\u0435\u0439\u043d\u043e \u2014 \u043c\u044b \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443 <a href=\"http:\/\/supercomputingblog.com\/openmp\/tutorial-parallel-for-loops-with-openmp\/\"><i>omp parallel for<\/i><\/a> \u043a \u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u2014 \u0432 \u044d\u0442\u043e\u043c \u0432\u0441\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u0430 \u0438 \u043c\u043e\u0449\u044c OpenMP. \u042f \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c <a href=\"https:\/\/software.intel.com\/en-us\/articles\/openmp-loop-scheduling\"><i>schedule<\/i><\/a>, \u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u0431\u0435\u0437 \u043d\u0435\u0433\u043e.<br \/>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a CUDA. \u0422\u0443\u0442 \u0440\u0430\u0441\u043f\u0438\u0448\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0434 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0438\u0445 \u0441 CPU \u043d\u0430 GPU \u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0434 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">void RGBtoGrayscaleCUDA(const uchar4 * const h_imageRGBA, unsigned char* const h_imageGray, size_t numRows, size_t numCols) {   uchar4 *d_imageRGBA;   unsigned char *d_imageGray;   const size_t numPixels = numRows * numCols;   cudaSetDevice(0);   checkCudaErrors(cudaGetLastError());   \/\/allocate memory on the device for both input and output   checkCudaErrors(cudaMalloc(&d_imageRGBA, sizeof(uchar4) * numPixels));   checkCudaErrors(cudaMalloc(&d_imageGray, sizeof(unsigned char) * numPixels));    \/\/copy input array to the GPU   checkCudaErrors(cudaMemcpy(d_imageRGBA, h_imageRGBA, sizeof(uchar4) * numPixels, cudaMemcpyHostToDevice)); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 CUDA \u2014 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 CPU \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 <i>h_<\/i> (<b>h<\/b>ost), \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u0430 GPU \u2014 \u0441 <i>d_<\/i> (<b>d<\/b>evice). <i>checkCudaErrors<\/i> \u2014 \u043c\u0430\u043a\u0440\u043e\u0441, \u0432\u0437\u044f\u0442 \u0441 <a href=\"https:\/\/github.com\/udacity\/cs344\/blob\/master\/Problem%20Sets\/Problem%20Set%201\/utils.h\">github-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a> Udacity \u043a\u0443\u0440\u0441\u0430. \u0418\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;cuda.h&gt;  #define checkCudaErrors(val) check( (val), #val, __FILE__, __LINE__)  template&lt;typename T&gt; void check(T err, const char* const func, const char* const file, const int line) {   if (err != cudaSuccess) {     std::cerr &lt;&lt; &quot;CUDA error at: &quot; &lt;&lt; file &lt;&lt; &quot;:&quot; &lt;&lt; line &lt;&lt; std::endl;     std::cerr &lt;&lt; cudaGetErrorString(err) &lt;&lt; &quot; &quot; &lt;&lt; func &lt;&lt; std::endl;     exit(1);   } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <i>cudaMalloc<\/i> \u2014 \u0430\u043d\u0430\u043b\u043e\u0433 <i>malloc<\/i> \u0434\u043b\u044f GPU, <i>cudaMemcpy<\/i> \u2014 \u0430\u043d\u0430\u043b\u043e\u0433 <i>memcpy<\/i>, \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432 \u0432\u0438\u0434\u0435 enum-\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u0438\u043f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, cudaMemcpyDeviceToDevice.<br \/>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u0435\u0442\u043a\u0438 \u0438 \u0431\u043b\u043e\u043a\u0430 \u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u044f\u0434\u0440\u043e, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432 \u0438\u0437\u043c\u0435\u0440\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\"> dim3 blockSize;   dim3 gridSize;   int threadNum;    cudaEvent_t start, stop;   cudaEventCreate(&start);   cudaEventCreate(&stop);    threadNum = 1024;   blockSize = dim3(threadNum, 1, 1);   gridSize = dim3(numCols\/threadNum+1, numRows, 1);   cudaEventRecord(start);   rgba_to_grayscale_simple&lt;&lt;&lt;gridSize, blockSize&gt;&gt;&gt;(d_imageRGBA, d_imageGray, numRows, numCols);   cudaEventRecord(stop);   cudaEventSynchronize(stop);   cudaDeviceSynchronize(); checkCudaErrors(cudaGetLastError());   float milliseconds = 0;   cudaEventElapsedTime(&milliseconds, start, stop);   std::cout &lt;&lt; &quot;CUDA time simple (ms): &quot; &lt;&lt; milliseconds &lt;&lt; std::endl; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0444\u043e\u0440\u043c\u0430\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 \u044f\u0434\u0440\u0430 \u2014 <i>kernel_name&lt;&lt;&lt;gridSize, blockSize&gt;&gt;&gt;<\/i>. \u041a\u043e\u0434 \u0441\u0430\u043c\u043e\u0433\u043e \u044f\u0434\u0440\u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0439:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">rgba_to_grayscale_simple<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">__global__ void rgba_to_grayscale_simple(const uchar4* const d_imageRGBA,                               unsigned char* const d_imageGray,                               int numRows, int numCols) {     int y = blockDim.y*blockIdx.y + threadIdx.y;     int x = blockDim.x*blockIdx.x + threadIdx.x;     if (x&gt;=numCols || y&gt;=numRows)       return;     const int offset = y*numCols+x;     const uchar4 pixel = d_imageRGBA[offset];     d_imageGray[offset] = 0.299f*pixel.x + 0.587f*pixel.y+0.114f*pixel.z; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b <i>y<\/i> \u0438 <i>x<\/i> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 <b>threadIdx<\/b>, <b>blockIdx<\/b> \u0438 <b>blockDim<\/b>, \u043d\u0443 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 <i>if (x&gt;=numCols || y&gt;=numRows)<\/i> \u2014 \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430\u0446\u0435\u043b\u043e \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0431\u043b\u043e\u043a\u043e\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u00ab\u0432\u044b\u0445\u043e\u0434\u0438\u0442\u044c \u0437\u0430 \u0440\u0430\u043c\u043a\u0438\u00bb \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u2014 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u044d\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430. \u0422\u0430\u043a\u0436\u0435, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044f\u0434\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c <i> __global__ <\/i>.<br \/>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 \u2014 c\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430\u0437\u0430\u0434 \u0441 GPU \u043d\u0430 CPU \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">  checkCudaErrors(cudaMemcpy(h_imageGray, d_imageGray, sizeof(unsigned char) * numPixels, cudaMemcpyDeviceToHost));   cudaFree(d_imageGray);   cudaFree(d_imageRGBA); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, CUDA \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c C++ \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u043b\u044f host-\u043a\u043e\u0434\u0430 \u2014 \u0442\u0430\u043a \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438.<br \/>  \u0418\u0442\u0430\u043a, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u043c:  <\/p>\n<pre><code class=\"bash\">OpenMP time (ms):45 CUDA time simple (ms): 43.1941 <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043a\u0430\u043a-\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u044e\u0449\u0435:) \u0410 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u0441\u0435 \u0442\u0430 \u0436\u0435 \u2014 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u043e\u043c \u2014 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u044b\u0441\u044f\u0447\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 CPU \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u2014 OpenMP \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0430\u043b\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (8 \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435) \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043f\u043e\u0440\u043e\u0432\u043d\u0443 \u2014 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u044b \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u044f\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430 \u0432\u0441\u0435 100%, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0441 GPU \u043c\u044b, \u043f\u043e \u0441\u0443\u0442\u0438, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u0441\u044e \u0435\u0433\u043e \u043c\u043e\u0449\u044c. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u2014 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u043e\u0432 \u0432 \u044f\u0434\u0440\u0435. \u041d\u043e\u0432\u043e\u0435, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435, \u044f\u0434\u0440\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">rgba_to_grayscale_optimized<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#define WARP_SIZE 32  __global__ void rgba_to_grayscale_optimized(const uchar4* const d_imageRGBA,                                  unsigned char* const d_imageGray,                                  int numRows, int numCols,                                  int elemsPerThread) {     int y = blockDim.y*blockIdx.y + threadIdx.y;     int x = blockDim.x*blockIdx.x + threadIdx.x;     const int loop_start =  (x\/WARP_SIZE * WARP_SIZE)*(elemsPerThread-1)+x;     for (int i=loop_start, j=0; j&lt;elemsPerThread && i&lt;numCols; i+=WARP_SIZE, ++j)     {       const int offset = y*numCols+i;       const uchar4 pixel = d_imageRGBA[offset];       d_imageGray[offset] = 0.299f*pixel.x + 0.587f*pixel.y+0.114f*pixel.z;     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u044f\u0434\u0440\u043e\u043c. \u0415\u0441\u043b\u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c <i>elemsPerThread<\/i> \u043f\u0438\u043a\u0441\u0435\u043b\u043e\u0432, \u043f\u0440\u0438\u0447\u0435\u043c \u043d\u0435 \u043f\u043e\u0434\u0440\u044f\u0434, \u0430 \u0441 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0432 WARP_SIZE \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 WARP_SIZE, \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d\u043e \u0440\u0430\u0432\u043d\u043e 32, \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u043f\u043e\u0431\u043e\u0434\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u044f\u0445, \u0441\u0435\u0439\u0447\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0430\u0436\u0443 \u0447\u0442\u043e \u044d\u0442\u0438\u043c \u043c\u044b \u0434\u043e\u0431\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 <i>elemsPerThread<\/i> \u043f\u0438\u043a\u0441\u0435\u043b\u043e\u0432 \u0441 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0432 WARP_SIZE \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 x-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0435\u0433\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432 \u0431\u043b\u043e\u043a\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0435 \u0447\u0435\u043c \u0440\u0430\u043d\u044c\u0448\u0435.<br \/>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u044f\u0434\u0440\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">  threadNum=128;   const int elemsPerThread = 16;   blockSize = dim3(threadNum, 1, 1);   gridSize = dim3(numCols \/ (threadNum*elemsPerThread) + 1, numRows, 1);   cudaEventRecord(start);   rgba_to_grayscale_optimized&lt;&lt;&lt;gridSize, blockSize&gt;&gt;&gt;(d_imageRGBA, d_imageGray, numRows, numCols, elemsPerThread);   cudaEventRecord(stop);   cudaEventSynchronize(stop);   cudaDeviceSynchronize(); checkCudaErrors(cudaGetLastError());   milliseconds = 0;   cudaEventElapsedTime(&milliseconds, start, stop);   std::cout &lt;&lt; &quot;CUDA time optimized (ms): &quot; &lt;&lt; milliseconds &lt;&lt; std::endl; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u043b\u043e\u043a\u043e\u0432 \u043f\u043e x-\u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a <i>numCols \/ (threadNum*elemsPerThread) + 1<\/i> \u0432\u043c\u0435\u0441\u0442\u043e <i>numCols \/ threadNum + 1<\/i>. \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u0430\u043a \u0436\u0435.<br \/>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:  <\/p>\n<pre><code class=\"bash\">OpenMP time (ms):44 CUDA time simple (ms): 53.1625 CUDA time optimized (ms): 15.9273 <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432 2.76 \u0440\u0430\u0437\u0430 (\u043e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e) \u2014 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e. \u0414\u0430-\u0434\u0430, \u044d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u2014 \u0441 \u043d\u0435\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 CPU. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430, \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 GPU \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u044c \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 CPU. <br \/>  \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u0441\u0435, \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435 GPU \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u043c\u0443\u043d\u0438\u043a\u0430\u0446\u0438\u0438.<br \/>  \u0412\u0435\u0441\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/bitbucket.org\/VladyslavGorbatiuk\/cuda-parallel-programming-code\">bitbucket<\/a>.      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/company\/epam_systems\/blog\/245503\/\"> http:\/\/habrahabr.ru\/company\/epam_systems\/blog\/245503\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4>\u0415\u0449\u0435 \u043e\u0434\u043d\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043e CUDA \u2014 \u0437\u0430\u0447\u0435\u043c?<\/h4>\n<p>   \u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0431\u044b\u043b\u043e \u0443\u0436\u0435 \u043d\u0435\u043c\u0430\u043b\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e CUDA \u2014 <a href=\"http:\/\/habrahabr.ru\/post\/119435\/\">\u0440\u0430\u0437<\/a>, <a href=\"http:\/\/habrahabr.ru\/post\/54707\/\">\u0434\u0432\u0430<\/a> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u043e\u0438\u0441\u043a \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u00abCUDA <a href=\"http:\/\/http.developer.nvidia.com\/GPUGems3\/gpugems3_ch39.html\">scan<\/a>\u00bb \u0432\u044b\u0434\u0430\u043b \u0432\u0441\u0435\u0433\u043e 2 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c scan \u043d\u0430 GPU \u2014 \u0430 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0432\u0448\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u043c \u043a\u0443\u0440\u0441\u043e\u043c \u043d\u0430 Udacity \u2014 <a href=\"https:\/\/www.udacity.com\/course\/cs344\">Intro to Parallel Programming<\/a>, \u044f \u0438 \u0440\u0435\u0448\u0438\u043b\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u0443\u044e \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439 \u043e CUDA. \u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0441\u0435\u0440\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u043a\u0443\u0440\u0441\u0435, \u0438 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u2014 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0439\u0442\u0438 \u0435\u0433\u043e.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-245503","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/245503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=245503"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/245503\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=245503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=245503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=245503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}