{"id":322696,"date":"2021-05-06T15:00:42","date_gmt":"2021-05-06T15:00:42","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=322696"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=322696","title":{"rendered":"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c GPU \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 JavaScript"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uy\/ov\/gi\/uyovgief8tl93q-pxd0lgx8nrke.jpeg\" alt=\"image\"><\/div>\n<p>  \u041c\u044b, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0440\u0435\u043c\u0438\u043c\u0441\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0451\u0442 \u043e \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0442\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u0434.<\/p>\n<p>  \u041d\u043e \u0434\u0443\u043c\u0430\u043b\u0438 \u043b\u0438 \u0432\u044b \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0449\u0438 GPU \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439?<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e <strong>\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f JavaScript<\/strong> \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <strong>GPU.js<\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u043a\u0430\u043a \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<h1>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 GPU.js \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0435\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c?<\/h1>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435, GPU.js \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f JavaScript, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 GPU \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 JavaScript. \u041e\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u044b, Node.js \u0438 TypeScript.<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0435\u0441\u043b\u0438 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u0438\u0447\u0438\u043d, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c GPU.js:<\/p>\n<ul>\n<li>\u0412 \u043e\u0441\u043d\u043e\u0432\u0435 GPU.js \u043b\u0435\u0436\u0438\u0442 JavaScript, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 JavaScript.<\/li>\n<li>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0431\u0435\u0440\u0451\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0437\u0430\u0434\u0430\u0447\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u044f\u0446\u0438\u0438 JavaScript \u043d\u0430 \u044f\u0437\u044b\u043a \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u0438 \u0438\u0445 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 GPU, \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u00ab\u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c\u0441\u044f\u00bb \u043a \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u0434\u0432\u0438\u0436\u043a\u0443 JavaScript. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u044f \u0441 GPU.js.<\/li>\n<li>GPU.js \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \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. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u043d\u0430 CPU, \u0438 \u043d\u0430 GPU.<\/li>\n<\/ul>\n<p>  \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0432\u0441\u0451 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435, \u044f \u043d\u0435 \u0432\u0438\u0436\u0443 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u0447\u0438\u043d \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f GPU.js. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u0435\u0433\u043e \u043e\u0441\u0432\u043e\u0438\u0442\u044c.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/p7\/-v\/hh\/p7-vhhhujbwlgc_1mrvjnkk8t2a.png\"><\/div>\n<p>  <\/p>\n<h1>\u041a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c GPU.js?<\/h1>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 GPU.js \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 JavaScript.<\/p>\n<h2>\u0414\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 Node<\/h2>\n<p>  <\/p>\n<pre><code class=\"javascript\">npm install gpu.js --save or yarn add gpu.js import { GPU } from ('gpu.js') --- or --- const { GPU } = require('gpu.js') --- or --- import { GPU } from 'gpu.js'; \/\/ Use this for TypeScript const gpu = new GPU();<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0414\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432<\/h2>\n<p>  <a href=\"https:\/\/raw.githubusercontent.com\/gpujs\/gpu.js\/master\/dist\/gpu-browser.min.js\" rel=\"noopener\">\u0421\u043a\u0430\u0447\u0430\u0439\u0442\u0435<\/a> GPU.js \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0438\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u0435\u0433\u043e CDN.<\/p>\n<pre><code class=\"javascript\">&lt;script src=&quot;dist\/gpu-browser.min.js&quot;&gt;&lt;\/script&gt; --- or --- &lt;script    src=&quot;https:\/\/unpkg.com\/gpu.js@latest\/dist\/gpu- browser.min.js&quot;&gt; &lt;\/script&gt; &lt;script    rc=&quot;https:\/\/cdn.jsdelivr.net\/npm\/gpu.js@latest\/dist\/gpu-browser.min.js&quot;&gt; &lt;\/script&gt; &lt;script&gt;  const gpu = new GPU();  ... &lt;\/script&gt;<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0432 Linux, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u043d\u0443\u0436\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b: <code>sudo apt install mesa-common-dev libxi-dev<\/code><\/p><\/blockquote>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043e\u0431 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0435 GPU.js. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 GPU \u0432 \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u044f \u043a\u0440\u0430\u0439\u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0438 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f\u0445 GPU.js. \u0418\u0442\u0430\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043e\u0441\u043d\u043e\u0432 GPU.js.<\/p>\n<h1>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/h1>\n<p>  \u0412 GPU.js \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u043d\u0430 GPU \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 JavaScript.<\/p>\n<pre><code class=\"javascript\">const exampleKernel = gpu.createKernel(function() {     ... }, settings);<\/code><\/pre>\n<p>  \u041f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 GPU.js. \u042f \u043d\u0430\u0437\u0432\u0430\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>exampleKernel<\/code>. \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>createKernel<\/code>, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0443\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 GPU.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>settings<\/code>.<\/p>\n<pre><code class=\"javascript\">const settings = {     output: [100] };<\/code><\/pre>\n<p>  \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0434\u0440\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c 1D, 2D \u0438\u043b\u0438 3D, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e \u0442\u0440\u0451\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432. \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u0442\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u044f\u0434\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>this.thread<\/code>.<\/p>\n<ul>\n<li>1D: [length] \u2014 <code>value[this.thread.x]<\/code><\/li>\n<li>2D: [width, height] \u2014 <code>value[this.thread.y][this.thread.x]<\/code><\/li>\n<li>3D: [width, height, depth] \u2014 <code>value[this.thread.z][this.thread.y][this.thread.x]<\/code><\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043b\u044e\u0431\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e JavaScript, \u043f\u043e \u0435\u0451 \u0438\u043c\u0435\u043d\u0438: <code>exampleKernel()<\/code><\/p>\n<h1>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u044f\u0434\u0440\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/h1>\n<p>  <\/p>\n<h2>\u0427\u0438\u0441\u043b\u043e<\/h2>\n<p>  \u0412\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 GPU.js \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 integer \u0438\u043b\u0438 float.<\/p>\n<pre><code class=\"javascript\">const exampleKernel = gpu.createKernel(function() {  const number1 = 10;  const number2 = 0.10;  return number1 + number2; }, settings);<\/code><\/pre>\n<p>  <\/p>\n<h2>Boolean<\/h2>\n<p>  \u0411\u0443\u043b\u0435\u0432\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 GPU.js, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e JavaScript.<\/p>\n<pre><code class=\"javascript\">const kernel = gpu.createKernel(function() {   const bool = true;   if (bool) {     return 1;   }else{     return 0;   } },settings);<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041c\u0430\u0441\u0441\u0438\u0432\u044b<\/h2>\n<p>  \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u044f\u0434\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0447\u0438\u0441\u0435\u043b \u043b\u044e\u0431\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0438\u0445.<\/p>\n<pre><code class=\"javascript\">const exampleKernel = gpu.createKernel(function() {  const array1 = [0.01, 1, 0.1, 10];  return array1; }, settings);<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0424\u0443\u043d\u043a\u0446\u0438\u0438<\/h2>\n<p>  \u0412 GPU.js \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u044f\u0434\u0435\u0440.<\/p>\n<pre><code class=\"javascript\">const exampleKernel = gpu.createKernel(function() {   function privateFunction() {     return [0.01, 1, 0.1, 10];   }   return privateFunction(); }, settings);<\/code><\/pre>\n<p>  <\/p>\n<h1>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0442\u0438\u043f\u044b \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h1>\n<p>  \u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0442\u0438\u043f\u0430\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u044f\u0434\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h2>\u0427\u0438\u0441\u043b\u0430<\/h2>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u044f\u0434\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 integer \u0438\u043b\u0438 float, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0441\u043c. \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0438\u0436\u0435.<\/p>\n<pre><code class=\"javascript\">const exampleKernel = gpu.createKernel(function(x) {  return x; }, settings); exampleKernel(25);<\/code><\/pre>\n<p>  <\/p>\n<h2>1D-, 2D- \u0438\u043b\u0438 3D-\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0447\u0438\u0441\u0435\u043b<\/h2>\n<p>  \u042f\u0434\u0440\u0430\u043c GPU.js \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 <code>Array<\/code>, <code>Float32Array<\/code>, <code>Int16Array<\/code>, <code>Int8Array<\/code>, <code>Uint16Array<\/code>, <code>uInt8Array<\/code>.<\/p>\n<pre><code class=\"javascript\">const exampleKernel = gpu.createKernel(function(x) {  return x; }, settings); exampleKernel([1, 2, 3]);<\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0434\u0435\u0440 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0436\u0430\u0442\u044b\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0435 (preflattened) 2D- \u0438 3D-\u043c\u0430\u0441\u0441\u0438\u0432\u044b. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e GPU.js <code>input<\/code>.<\/p>\n<pre><code class=\"javascript\">const { input } = require('gpu.js'); const value = input(flattenedArray, [width, height, depth]);<\/code><\/pre>\n<p>  <\/p>\n<h2>HTML-\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>  \u041f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c JavaScript, \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e GPU.js. \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 GPU.js \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0434\u0440\u0430 \u043e\u0434\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e HTML-\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<pre><code class=\"javascript\">\/\/Single Image const kernel = gpu.createKernel(function(image) {     ... })   .setGraphical(true)   .setOutput([100, 100]);  const image = document.createElement('img'); image.src = 'image1.png'; image.onload = () =&gt; {   kernel(image);     document.getElementsByTagName('body')[0].appendChild(kernel.canvas); }; \/\/Multiple Images const kernel = gpu.createKernel(function(image) {     const pixel = image[this.thread.z][this.thread.y][this.thread.x];     this.color(pixel[0], pixel[1], pixel[2], pixel[3]); })   .setGraphical(true)   .setOutput([100, 100]);  const image1 = document.createElement('img'); image1.src = 'image1.png'; image1.onload = onload; .... \/\/add another 2 images .... const totalImages = 3; let loadedImages = 0; function onload() {   loadedImages++;   if (loadedImages === totalImages) {     kernel([image1, image2, image3]);      document.getElementsByTagName('body')[0].appendChild(kernel.canvas);   } };<\/code><\/pre>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e, \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0441 GPU.js \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u041e\u043d\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043e\u0441\u043d\u043e\u0432\u044b, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GPU.js \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0435\u0451 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<h1>\u041f\u0435\u0440\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c GPU.js<\/h1>\n<p>  \u0421\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0432 \u0432\u0441\u0451 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435, \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 angular-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \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 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 GPU \u0438 CPU \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438\u0437 1000 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h2>\u0428\u0430\u0433 1 \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0438\u0437 1000 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/h2>\n<p>  \u042f \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e 2D-\u043c\u0430\u0441\u0441\u0438\u0432 \u0441 1000 \u0447\u0438\u0441\u0435\u043b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0438\u0445 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445.<\/p>\n<pre><code class=\"javascript\">generateMatrices() {  this.matrices = [[], []];  for (let y = 0; y &lt; this.matrixSize; y++) {   this.matrices[0].push([])   this.matrices[1].push([])   for (let x = 0; x &lt; this.matrixSize; x++) {    const value1 = parseInt((Math.random() * 10).toString())    const value2 = parseInt((Math.random() * 10).toString())    this.matrices[0][y].push(value1)    this.matrices[1][y].push(value2)   }  } }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0428\u0430\u0433 2 -\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044f\u0434\u0440\u0430<\/h2>\n<p>  \u042d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 GPU \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0451. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>multiplyMatrix<\/code>, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0443\u044e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0432\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0447\u0438\u0441\u0435\u043b \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0438\u0442 \u0434\u0432\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438 \u0432\u0435\u0440\u043d\u0451\u0442 \u043e\u0431\u0449\u0443\u044e \u0441\u0443\u043c\u043c\u0443, \u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 API \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"javascript\">gpuMultiplyMatrix() {   const gpu = new GPU();   const multiplyMatrix = gpu.createKernel(function (a: number[][], b: number[][], matrixSize: number) {    let sum = 0;       for (let i = 0; i &lt; matrixSize; i++) {     sum += a[this.thread.y][i] * b[i][this.thread.x];    }    return sum;   }).setOutput([this.matrixSize, this.matrixSize])   const startTime = performance.now();   const resultMatrix = multiplyMatrix(this.matrices[0],  this.matrices[1], this.matrixSize);      const endTime = performance.now();   this.gpuTime = (endTime - startTime) + &quot; ms&quot;;      console.log(&quot;GPU TIME : &quot;+ this.gpuTime);   this.gpuProduct = resultMatrix as number[][]; }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0428\u0430\u0433 3 \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 CPU<\/h2>\n<p>  \u042d\u0442\u043e \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f TypeScript \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u0445 \u0436\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432.<\/p>\n<pre><code class=\"javascript\">cpuMutiplyMatrix() {   const startTime = performance.now();   const a = this.matrices[0];   const b = this.matrices[1];   let productRow = Array.apply(null, new Array(this.matrixSize)).map(Number.prototype.valueOf, 0);   let product = new Array(this.matrixSize);      for (let p = 0; p &lt; this.matrixSize; p++) {     product[p] = productRow.slice();   }      for (let i = 0; i &lt; this.matrixSize; i++) {     for (let j = 0; j &lt; this.matrixSize; j++) {       for (let k = 0; k &lt; this.matrixSize; k++) {         product[i][j] += a[i][k] * b[k][j];       }     }   }   const endTime = performance.now();   this.cpuTime = (endTime \u2014 startTime) + \u201c ms\u201d;   console.log(\u201cCPU TIME : \u201c+ this.cpuTime);   this.cpuProduct = product; }<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u0434\u0435\u043c\u043e-\u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043c\u043e\u0451\u043c \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0435 <a href=\"https:\/\/github.com\/ChameeraD\/gpujs\">GitHub<\/a>.<\/p>\n<h1>CPU \u043f\u0440\u043e\u0442\u0438\u0432 GPU \u2014 \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<\/h1>\n<p>  \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u0430 \u043b\u0438 \u0432\u0441\u044f \u044d\u0442\u0430 \u0448\u0443\u043c\u0438\u0445\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 GPU.js \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 GPU. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u044f \u0441\u043e\u0437\u0434\u0430\u043b Angular-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fd\/bz\/bs\/fdbzbsrso1n7xg_6c0kpt89jdws.png\"><\/div>\n<p>  <i>CPU \u0438 GPU \u2014 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/i><\/p>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043d\u0430 GPU \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432\u0441\u0435\u0433\u043e 799 \u043c\u0441, \u0430 CPU \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c 7511 \u043c\u0441, \u043f\u043e\u0447\u0442\u0438 \u0432 10 \u0440\u0430\u0437 \u0434\u043e\u043b\u044c\u0448\u0435.<\/p>\n<p>  \u042f \u0440\u0435\u0448\u0438\u043b \u043d\u0430 \u044d\u0442\u043e\u043c \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u043f\u0440\u043e\u0432\u0451\u043b \u0442\u0435 \u0436\u0435 \u0442\u0435\u0441\u0442\u044b \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0435\u0449\u0451 \u043f\u0430\u0440\u044b \u0446\u0438\u043a\u043b\u043e\u0432, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/45\/jv\/10\/45jv102fbsbc3qnbwdymmi4dusm.png\"><\/div>\n<p>  <i>CPU \u0438 GPU<\/i><\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, \u0447\u0442\u043e CPU \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0435\u043c GPU. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u044f \u0441\u043d\u0438\u0437\u0438\u043b \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0434\u043e 10 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, CPU \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0435\u0433\u043e 0,14 \u043c\u0441, \u0430 GPU \u2014 108 \u043c\u0441.<\/p>\n<p>  \u041d\u043e \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0430 \u0447\u0451\u0442\u043a\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c, \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u043c GPU \u0438 CPU. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0430, GPU \u043f\u043e\u0431\u0435\u0436\u0434\u0430\u0435\u0442.<\/p>\n<h1>\u0412\u044b\u0432\u043e\u0434<\/h1>\n<p>  \u0418\u0437 \u043c\u043e\u0435\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e GPU.js \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0432\u044b\u0448\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c JavaScript-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u041d\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c \u0441 \u0443\u043c\u043e\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c GPU \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0432\u043f\u0443\u0441\u0442\u0443\u044e \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0430 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u0438 \u0441\u043d\u0438\u0437\u0438\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0447\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0430.<\/p>\n<hr>\n<p>  <\/p>\n<h4>\u041d\u0430 \u043f\u0440\u0430\u0432\u0430\u0445 \u0440\u0435\u043a\u043b\u0430\u043c\u044b<\/h4>\n<p>  <a href=\"https:\/\/vdsina.ru\/cloud-servers?partner=habr362\">VDS<\/a> \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438 \u0437\u0430\u0434\u0430\u0447 \u043b\u044e\u0431\u044b\u0445 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043e\u0432 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e \u043d\u0430\u0448\u0438 <b>\u044d\u043f\u0438\u0447\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u044b<\/b>! \u041d\u043e\u0432\u0435\u0439\u0448\u0438\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441. \u041f\u043e\u0441\u043f\u0435\u0448\u0438\u0442\u0435 \u0437\u0430\u043a\u0430\u0437\u0430\u0442\u044c!<\/p>\n<p>  \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 <a href=\"https:\/\/t.me\/vdsina\">\u043d\u0430\u0448 \u0447\u0430\u0442 \u0432 Telegram<\/a>.<\/p>\n<p>  <a href=\"https:\/\/vdsina.ru\/cloud-servers?partner=habr362\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/8p\/3v\/z4\/8p3vz47nluspfyc0axlkx88gdua.png\"><\/a><\/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=\"https:\/\/habr.com\/ru\/company\/vdsina\/blog\/555994\/\"> https:\/\/habr.com\/ru\/company\/vdsina\/blog\/555994\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uy\/ov\/gi\/uyovgief8tl93q-pxd0lgx8nrke.jpeg\" alt=\"image\"><\/div>\n<p>  \u041c\u044b, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u0440\u0435\u043c\u0438\u043c\u0441\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0451\u0442 \u043e \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0442\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u043e\u0434.<\/p>\n<p>  \u041d\u043e \u0434\u0443\u043c\u0430\u043b\u0438 \u043b\u0438 \u0432\u044b \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u043e\u0449\u0438 GPU \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439?<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e <strong>\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f JavaScript<\/strong> \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <strong>GPU.js<\/strong>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u043a\u0430\u043a \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<h1>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 GPU.js \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u0435\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c?<\/h1>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u043a\u0440\u0430\u0442\u0446\u0435, GPU.js \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f JavaScript, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 GPU \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 JavaScript. \u041e\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u044b, Node.js \u0438 TypeScript.<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0435\u0441\u043b\u0438 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u0438\u0447\u0438\u043d, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c GPU.js:<\/p>\n<ul>\n<li>\u0412 \u043e\u0441\u043d\u043e\u0432\u0435 GPU.js \u043b\u0435\u0436\u0438\u0442 JavaScript, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 JavaScript.<\/li>\n<li>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0431\u0435\u0440\u0451\u0442 \u043d\u0430 \u0441\u0435\u0431\u044f \u0437\u0430\u0434\u0430\u0447\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u0440\u0430\u043d\u0441\u043f\u0438\u043b\u044f\u0446\u0438\u0438 JavaScript \u043d\u0430 \u044f\u0437\u044b\u043a \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u0438 \u0438\u0445 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0432 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 GPU, \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u00ab\u043e\u0442\u043a\u0430\u0442\u0438\u0442\u044c\u0441\u044f\u00bb \u043a \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u0434\u0432\u0438\u0436\u043a\u0443 JavaScript. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u044f \u0441 GPU.js.<\/li>\n<li>GPU.js \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \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. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u043d\u0430 CPU, \u0438 \u043d\u0430 GPU.<\/li>\n<\/ul>\n<p>  \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0432\u0441\u0451 \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435, \u044f \u043d\u0435 \u0432\u0438\u0436\u0443 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u0447\u0438\u043d \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f GPU.js. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0437\u043d\u0430\u0435\u043c, \u043a\u0430\u043a \u0435\u0433\u043e \u043e\u0441\u0432\u043e\u0438\u0442\u044c.  <\/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-322696","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322696","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=322696"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322696\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}