{"id":282302,"date":"2016-12-11T11:10:04","date_gmt":"2016-12-11T08:10:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=282302"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2016-12-11T08:10:04","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=282302","title":{"rendered":"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 GPU-\u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432 \u043d\u0430 Python \u0438 C"},"content":{"rendered":"<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/708\/b36\/2bd\/708b362bd5a14b8b8f4d5c3ca04561f1.png\" \/><\/div>\n<p>  Python \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0440\u044f\u0434\u043e\u043c \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u044c \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u043c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u044c\u044e\u043d\u0438\u0442\u0438. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0432\u0441\u0435\u043c \u043c\u0435\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0442\u043e\u043d\u0430 \u0447\u0430\u0441\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u201c\u0442\u044f\u0436\u0435\u043b\u044b\u0445\u201d \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u0414\u043b\u044f \u0440\u044f\u0434\u0430 \u0437\u0430\u0434\u0430\u0447 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432 \u043f\u0443\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 CUDA \u0434\u043b\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 GPU. \u0426\u0435\u043b\u044c \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f python \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432 \u043d\u0430 GPU \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 python-\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 C.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u041f\u043e \u0440\u043e\u0434\u0443 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u044f \u0447\u0430\u0441\u0442\u0435\u043d\u044c\u043a\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e CUDA \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 GPU, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0447\u0435\u0442\u044b \u043d\u0430 \u043f\u0438\u0442\u043e\u043d\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0431\u044b\u0441\u0442\u0440\u043e, \u0433\u0438\u0431\u043a\u043e, \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e, <s>\u043c\u043e\u043b\u043e\u0434\u0435\u0436\u043d\u043e<\/s>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043e\u0434\u043d\u0430\u043a\u043e, \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u0447\u0435\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0447\u0430\u0441\u043e\u0432 \u0434\u043e \u0441\u0443\u0442\u043e\u043a. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a Numba \u0438 PyCUDA \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432 \u043d\u0430 GPU \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u043e\u0432\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430<\/h2>\n<p>  \u0412\u044b\u0431\u043e\u0440 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u044b\u043b \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447, \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 python. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u0434\u0430\u0447\u0430 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A3%D1%80%D0%B0%D0%B2%D0%BD%D0%B5%D0%BD%D0%B8%D0%B5_%D1%82%D0%B5%D0%BF%D0%BB%D0%BE%D0%BF%D1%80%D0%BE%D0%B2%D0%BE%D0%B4%D0%BD%D0%BE%D1%81%D1%82%D0%B8\">\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u043f\u043b\u043e\u043f\u0440\u043e\u0432\u043e\u0434\u043d\u043e\u0441\u0442\u0438 <\/a> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"http:\/\/agora.guru.ru\/abrau2010\/pdf\/346.pdf\">\u044f\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0435\u0447\u043d\u043e-\u0440\u0430\u0437\u043d\u043e\u0441\u0442\u043d\u043e\u0439 \u0441\u0445\u0435\u043c\u044b<\/a>. \u0417\u0430\u0434\u0430\u0447\u0430 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0437\u043b\u043e\u0432 \u0440\u0430\u0441\u0447\u0435\u0442\u043d\u043e\u0439 \u0441\u0435\u0442\u043a\u0438 \u043f\u043e x \u0438 y \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0438 \u0440\u0430\u0432\u043d\u043e n. \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<h2>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h2>\n<p>  \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u043e\u043c:<\/p>\n<pre><code class=\"python\">\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b u0 \u0438 u, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0448\u0430\u0433\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430 \u0434\u0435\u0432\u0430\u0439\u0441\u0435 \u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b u0 \u0438 u \u0441 \u0445\u043e\u0441\u0442\u0430 \u043d\u0430 \u0434\u0435\u0432\u0430\u0439\u0441 for(i = 0; i &lt; nstp\/2; i++)     \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 u \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0437\u043d\u0430\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 u0 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0448\u0430\u0433\u0435     \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 u0 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0437\u043d\u0430\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 u \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u0448\u0430\u0433\u0435 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 (u0) \u0441 \u0434\u0435\u0432\u0430\u0439\u0441\u0430 \u043d\u0430 \u0445\u043e\u0441\u0442 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440 \u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/code><\/pre>\n<p>  \u0412\u043e \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0438\u0436\u0435 \u0447\u0438\u0441\u043b\u043e \u0443\u0437\u043b\u043e\u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0435\u0442\u043a\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 (n) \u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043e\u0442 512 \u0434\u043e 4096, \u0430 nstp = 5000.<\/p>\n<h2>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0430 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435:<\/p>\n<blockquote><p>Intel&reg; Core(TM)2 Quad CPU Q9650 @ 3.00GHz, 8 Gb \u041e\u0417\u0423<br \/>  GPU: Nvidia GTX 580<br \/>  \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430: Ubuntu 16.04 LTS \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0439 CUDA 7.5<\/p><\/blockquote>\n<p>  <\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 C<\/h2>\n<p>  \u0412\u0441\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 python-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 C, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u043d\u0430 C<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;stdio.h&gt; #include &lt;time.h&gt; #include &lt;cuda_runtime.h&gt;  #define BLOCK_SIZE 16  int N = 512; \/\/1024; \/\/2048; double L = 1.0; double h = L\/N; double h2 = h*h; double tau = 0.1*h2; double th2 = tau\/h2; int nstp = 5000;  __constant__ int dN; __constant__ double dth2;  __global__ void NextStpGPU(double *u0, double *u) {     int i = blockDim.x * blockIdx.x + threadIdx.x;     int j = blockDim.y * blockIdx.y + threadIdx.y;      double uim1, uip1, ujm1, ujp1, u00, d2x, d2y;      if (i &gt; 0)     \tuim1 = u0[(i - 1) + dN*j];     else     \tuim1 = 0.0;      if (i &lt; dN - 1)     \tuip1 = u0[(i + 1) + dN*j];     else     \tuip1 = 0.0;      if (j &gt; 0)     \tujm1 = u0[i + dN*(j - 1)];     else     \tujm1 = 0.0;      if (j &lt; dN - 1)     \tujp1 = u0[i + dN*(j + 1)];     else     \tujp1 = 1.0;      u00 = u0[i + dN*j];     d2x = (uim1 - 2.0*u00 + uip1);     d2y = (ujm1 - 2.0*u00 + ujp1);     u[i + dN*j] = u00 + dth2*(d2x + d2y);  }  int main(void) {    size_t size = N * N * sizeof(double);    double pStart, pEnd, pD;    int i;      double *h_u0 = (double *)malloc(size);     double *h_u1 = (double *)malloc(size);      for (i = 0; i &lt; N*N; ++i)     {     \th_u0[i] = 0.0;         h_u1[i] = 0.0;     }     pStart = (double) clock();     double *d_u0 = NULL;    cudaMalloc((void **)&d_u0, size);    double *d_u1 = NULL;    cudaMalloc((void **)&d_u1, size);     cudaMemcpy(d_u0, h_u0, size, cudaMemcpyHostToDevice);    cudaMemcpy(d_u1, h_u1, size, cudaMemcpyHostToDevice);     cudaMemcpyToSymbol(dN, &N, sizeof(int));    cudaMemcpyToSymbol(dth2, &th2, sizeof(double));     dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE, 1);    dim3 dimGrid(N\/BLOCK_SIZE, N\/BLOCK_SIZE, 1);     for(i = 0; i &lt; int(nstp\/2); i++)    {         NextStpGPU&lt;&lt;&lt;dimGrid,dimBlock&gt;&gt;&gt;(d_u0, d_u1); \tNextStpGPU&lt;&lt;&lt;dimGrid,dimBlock&gt;&gt;&gt;(d_u1, d_u0);    }     cudaMemcpy(h_u0, d_u0, size, cudaMemcpyDeviceToHost);    cudaFree(d_u0);    cudaFree(d_u1);        pEnd = (double) clock();    pD = (pEnd-pStart)\/CLOCKS_PER_SEC;    printf(&quot;Calculation time on GPU = %f sec\\n&quot;, pD);    }         free(h_u0);    free(h_u1);      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0420\u0430\u0441\u0447\u0435\u0442\u044b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u0447\u0442\u043e \u0434\u043b\u044f N = 512 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f C-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 GPU \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 0.27 \u0441\u0435\u043a\u0443\u043d\u0434 \u043f\u0440\u043e\u0442\u0438\u0432 33.06 \u0441\u0435\u043a\u0443\u043d\u0434 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0430 CPU. \u0422\u043e \u0435\u0441\u0442\u044c \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 CPU\/GPU \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 120 \u0440\u0430\u0437. \u0421 \u0440\u043e\u0441\u0442\u043e\u043c N \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u043d\u0435 \u0443\u0431\u044b\u0432\u0430\u0435\u0442.<\/p>\n<h2>Python with Numba<\/h2>\n<p>  \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"http:\/\/numba.pydata.org\/\">Numba<\/a> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c jit (just-in-time) \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 \u043f\u0438\u0442\u043e\u043d\u0435 \u0432 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434 \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u044b\u0439 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441 C \u0438\u043b\u0438 Fortran \u043a\u043e\u0434\u043e\u043c. Numba \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u0438 \u0437\u0430\u043f\u0443\u0441\u043a python-\u043a\u043e\u0434\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 CPU, \u043d\u043e \u0438 \u043d\u0430 GPU, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u0442\u0438\u043b\u044c \u0438 \u0432\u0438\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 Numba, \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u0442\u043e \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u0438\u043c. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"> from numba import cuda import numpy as np import matplotlib.pyplot as plt from time import time  n = 512 blockdim = 16, 16 griddim = int(n\/blockdim[0]), int(n\/blockdim[1])  L = 1. h = L\/n dt = 0.1*h**2 nstp = 5000  @cuda.jit(&quot;void(float64[:,:], float64[:,:])&quot;) def nextstp_gpu(u0, u):     i,j = cuda.grid(2)          if i &gt; 0:         uim1 = u0[i-1,j]     else:         uim1 = 0.     if i &lt; n-1:         uip1 = u0[i+1,j]     else:         uip1 = 0.     if j &gt; 0:         ujm1 = u0[i,j-1]     else:         ujm1 = 0.     if j &lt; n-1:         ujp1 = u0[i,j+1]     else:         ujp1 = 1.              d2x = (uim1 - 2.*u0[i,j] + uip1)     d2y = (ujm1 - 2.*u0[i,j] + ujp1)     u[i,j] = u0[i,j] + (dt\/h**2)*(d2x + d2y)  u0 = np.full((n,n), 0., dtype = np.float64) u = np.full((n,n), 0., dtype = np.float64)  st = time()  d_u0 = cuda.to_device(u0) d_u = cuda.to_device(u) for i in xrange(0, int(nstp\/2)):     nextstp_gpu[griddim,blockdim](d_u0, d_u)     nextstp_gpu[griddim,blockdim](d_u, d_u0)      cuda.synchronize() u0 = d_u0.copy_to_host() print 'time on GPU = ', time() - st <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0442\u043c\u0435\u0442\u0438\u043c \u0442\u0443\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u043e\u0447\u0435 \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0435\u0441\u043b\u0438 \u0432 C-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442 \u043d\u0430\u0441 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432\u0441\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 N) \u043f\u0443\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u0440\u043e\u0434\u0435 <code>cudaMemcpyToSymbol(dN, &N, sizeof(int));<\/code> \u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u0430\u043a \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 python-\u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041d\u0443 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u043d\u0430\u043d\u0438\u0439 \u044f\u0437\u044b\u043a\u0430 C \u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b GPU.<\/p>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043b\u0435\u0433\u043a\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u0434\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 n*n, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0434\u0430\u043b\u0435\u0435 \u044d\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"> from numba import cuda import numpy as np import matplotlib.pyplot as plt from time import time  n = 512 blockdim = 16, 16 griddim = int(n\/blockdim[0]), int(n\/blockdim[1])  L = 1. h = L\/n dt = 0.1*h**2 nstp = 5000  @cuda.jit(&quot;void(float64[:], float64[:])&quot;) def nextstp_gpu(u0, u):     i,j = cuda.grid(2)              u00 = u0[i + n*j]     if i &gt; 0:         uim1 = u0[i-1 + n*j]     else:         uim1 = 0.     if i &lt; n-1:         uip1 = u0[i+1 + n*j]     else:         uip1 = 0.     if j &gt; 0:         ujm1 = u0[i + n*(j-1)]     else:         ujm1 = 0.     if j &lt; n-1:         ujp1 = u0[i + n*(j+1)]     else:         ujp1 = 1.              d2x = (uim1 - 2.*u00 + uip1)     d2y = (ujm1 - 2.*u00 + ujp1)     u[i + n*j] = u00 + (dt\/h\/h)*(d2x + d2y)  u0 = np.full(n*n, 0., dtype = np.float64) u = np.full(n*n, 0., dtype = np.float64)  st = time()  d_u0 = cuda.to_device(u0) d_u = cuda.to_device(u) for i in xrange(0, int(nstp\/2)):     nextstp_gpu[griddim,blockdim](d_u0, d_u)     nextstp_gpu[griddim,blockdim](d_u, d_u0)  cuda.synchronize() u0 = d_u0.copy_to_host() print 'time on GPU = ', time() - st <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h2>PyCUDA<\/h2>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u0438\u0437 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0431\u044b\u043b\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"https:\/\/documen.tician.de\/pycuda\/\">PyCUDA<\/a>. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 Numba \u0437\u0434\u0435\u0441\u044c \u043e\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u044f\u0434\u0440\u0430 \u043d\u0430 C, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0435\u0437 \u0437\u043d\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043d\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044f\u0434\u0440\u0430 \u043d\u0430 C \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c PyCUDA \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u043c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\"> import pycuda.driver as cuda import pycuda.autoinit from pycuda.compiler import SourceModule import numpy as np import matplotlib.pyplot as plt from time import time  n = 512 blockdim = 16, 16 griddim = int(n\/blockdim[0]), int(n\/blockdim[1])  L = 1. h = L\/n dt = 0.1*h**2 nstp = 5000  mod = SourceModule(&quot;&quot;&quot;     __global__ void NextStpGPU(int* dN, double* dth2, double *u0, double *u)     {         int i = blockDim.x * blockIdx.x + threadIdx.x;         int j = blockDim.y * blockIdx.y + threadIdx.y;          double uim1, uip1, ujm1, ujp1, u00, d2x, d2y;         uim1 = exp(-10.0);         if (i &gt; 0)     \t       uim1 = u0[(i - 1) + dN[0]*j];         else     \t       uim1 = 0.0;          if (i &lt; dN[0] - 1)     \t       uip1 = u0[(i + 1) + dN[0]*j];         else     \t       uip1 = 0.0;          if (j &gt; 0)     \t       ujm1 = u0[i + dN[0]*(j - 1)];         else     \t       ujm1 = 0.0;          if (j &lt; dN[0] - 1)     \t       ujp1 = u0[i + dN[0]*(j + 1)];         else     \t       ujp1 = 1.0;          u00 = u0[i + dN[0]*j];         d2x = (uim1 - 2.0*u00 + uip1);         d2y = (ujm1 - 2.0*u00 + ujp1);         u[i + dN[0]*j] = u00 + dth2[0]*(d2x + d2y);     }     &quot;&quot;&quot;)  u0 = np.full(n*n, 0., dtype = np.float64) u = np.full(n*n, 0., dtype = np.float64) nn = np.full(1, n, dtype = np.int64) th2 = np.full(1, dt\/h\/h, dtype = np.float64)  st = time()  u0_gpu = cuda.to_device(u0) u_gpu = cuda.to_device(u) n_gpu = cuda.to_device(nn) th2_gpu = cuda.to_device(th2)  func = mod.get_function(&quot;NextStpGPU&quot;) for i in xrange(0, int(nstp\/2)):     func(n_gpu, th2_gpu, u0_gpu, u_gpu,           block=(blockdim[0],blockdim[1],1),grid=(griddim[0],griddim[1],1))     func(n_gpu, th2_gpu, u_gpu, u0_gpu,           block=(blockdim[0],blockdim[1],1),grid=(griddim[0],griddim[1],1))  u0 = cuda.from_device_like(u0_gpu, u0)  print 'time on GPU = ', time() - st <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0432\u0441\u0435 \u043a\u0430\u043a \u0447\u0438\u0441\u0442\u044b\u0439 \u043f\u0438\u0442\u043e\u043d \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 C-\u043a\u043e\u0434\u0430.<\/p>\n<h2>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h2>\n<p>  \u041d\u0430 \u0420\u0438\u0441\u0443\u043d\u043a\u0435 1 \u0438 \u0432 \u0422\u0430\u0431\u043b\u0438\u0446\u0435 1 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b (\u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445) \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u0435\u0442\u043a\u0438 n, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 C-\u043a\u043e\u0434\u0430 (\u043a\u0440\u0438\u0432\u0430\u044f CUDA C) \u0438 python-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Numba \u0438 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 (Numba 2DArr), \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Numba \u0438 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 (Numba 1DArr), \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 PyCUDA (\u043a\u0440\u0438\u0432\u0430\u044f PyCUDA). <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/714\/8dc\/811\/7148dc81141d4289bee3c0ce1607de0b.png\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1\" \/><\/div>\n<p>  <i>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1<\/i>  <\/p>\n<table>\n<caption>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 1<\/caption>\n<tr>\n<th>n<\/th>\n<th>Cuda C<\/th>\n<th>Numba 2DArr<\/th>\n<th>Numba 1DArr<\/th>\n<th>PyCUDA<\/th>\n<\/tr>\n<tr>\n<td>512<\/td>\n<td>0.25<\/td>\n<td>0.8<\/td>\n<td>0.66<\/td>\n<td>0.216<\/td>\n<\/tr>\n<tr>\n<td>1024<\/td>\n<td>0.77<\/td>\n<td>3.26<\/td>\n<td>1.03<\/td>\n<td>0.808<\/td>\n<\/tr>\n<tr>\n<td>2048<\/td>\n<td>2.73<\/td>\n<td>12.23<\/td>\n<td>4.07<\/td>\n<td>2.87<\/td>\n<\/tr>\n<tr>\n<td>3073<\/td>\n<td>6.1<\/td>\n<td>27.3<\/td>\n<td>9.12<\/td>\n<td>6.6<\/td>\n<\/tr>\n<tr>\n<td>4096<\/td>\n<td>11.05<\/td>\n<td>55.88<\/td>\n<td>16.27<\/td>\n<td>12.02<\/td>\n<\/tr>\n<\/table>\n<p>  \u041d\u0430 \u0420\u0438\u0441\u0443\u043d\u043a\u0435 2 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \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 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 python-\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f C-\u043a\u043e\u0434\u0430. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0440\u0438\u0441\u0443\u043d\u043a\u043e\u0432, \u0441\u0430\u043c\u043e\u0439 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0439, \u0438\u0437 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0445, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Numba \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c. \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u043a\u0430 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0440\u043e\u0435\u043a\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044e \u043a\u043e\u0434\u0430. \u0421\u0430\u043c\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 PyCUDA. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u043a\u0430\u043a \u043e\u0442\u043c\u0435\u0447\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u043b\u0435\u0435 \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044f\u0434\u0440\u0430 \u043d\u0430 C. \u041e\u0434\u043d\u0430\u043a\u043e \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043e\u043a\u0443\u043f\u0430\u044e\u0442\u0441\u044f \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 python-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432\u0441\u0435\u0433\u043e \u043d\u0430 5-8% \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430 C.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/6ef\/bd0\/33f\/6efbd033fbe043b2a894efdb085e16fd.png\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2\" \/><\/div>\n<p>  <i>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2<\/i><\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>  \u0427\u0443\u0434\u0435\u0441 \u043d\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u0438 \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u0441\u0430\u043c\u044b\u043c\u0438 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c\u0438. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f python-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u043e\u0439 \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u0442\u043e\u0433\u043e C-\u043a\u043e\u0434\u0430. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u0430\u044e\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0432\u044b\u0431\u043e\u0440 \u043c\u0435\u0436\u0434\u0443 \u0431\u043e\u043b\u0435\u0435 \u0438 \u043c\u0435\u043d\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438. \u042d\u0442\u043e\u0442 \u0432\u044b\u0431\u043e\u0440, \u043e\u0434\u043d\u0430\u043a\u043e, \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441 \u043c\u0435\u0436\u0434\u0443 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  \u00bb <a href=\"http:\/\/numba.pydata.org\/\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Numba<\/a><br \/>  \u00bb <a href=\"http:\/\/numba.pydata.org\/numba-doc\/0.13\/CUDAJit.html\">\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Numba<\/a><br \/>  \u00bb <a href=\"https:\/\/documen.tician.de\/pycuda\/\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 PyCUDA<\/a><br \/>  \u00bb <a href=\"https:\/\/wiki.tiker.net\/PyCuda\/Examples\">\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f PyCUDA<\/a><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/317328\/\"> https:\/\/habrahabr.ru\/post\/317328\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/708\/b36\/2bd\/708b362bd5a14b8b8f4d5c3ca04561f1.png\" \/><\/div>\n<p>  Python \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0440\u044f\u0434\u043e\u043c \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u044c \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u043c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u044c\u044e\u043d\u0438\u0442\u0438. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0432\u0441\u0435\u043c \u043c\u0435\u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0442\u043e\u043d\u0430 \u0447\u0430\u0441\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u201c\u0442\u044f\u0436\u0435\u043b\u044b\u0445\u201d \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u0414\u043b\u044f \u0440\u044f\u0434\u0430 \u0437\u0430\u0434\u0430\u0447 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432 \u043f\u0443\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 CUDA \u0434\u043b\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 GPU. \u0426\u0435\u043b\u044c \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f python \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432 \u043d\u0430 GPU \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 python-\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 C.  <\/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-282302","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282302","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=282302"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/282302\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}