{"id":316209,"date":"2021-01-11T21:00:49","date_gmt":"2021-01-11T21:00:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=316209"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=316209","title":{"rendered":"\u0427\u0438\u0441\u0442\u044b\u0439 Cython VS nvc++: \u0436\u0436\u0435\u043c \u043c\u0435\u0442\u0430\u043b\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043b\u0430\u0441\u0442\u0438\u043d\u044b \u043d\u0430 GPU \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/0a\/ri\/fi\/0arifij2nrzjonpilf80zatmnjc.png\" alt=\"image\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c49\/551\/a1c\/c49551a1c30100c8a4791b284e63af26.gif\" alt=\"image\"><br \/>  <i>\u0411\u0443\u0434\u0435\u043c \u0433\u0440\u0435\u0442\u044c \u043c\u0435\u0442\u0430\u043b\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043b\u0430\u0441\u0442\u0438\u043d\u044b \u043d\u0430 GPU<\/i><\/p>\n<p>  \u0412\u0441\u0435 \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e Python \u043d\u0435 \u0431\u043b\u0435\u0449\u0435\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u044f\u0437\u044b\u043a \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u0435\u043d \u0441\u0432\u043e\u0435\u0439 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u043d\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043d\u0438\u0448\u0430 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u043c, \u0433\u0434\u0435 \u0432\u044b \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0435 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0445. \u0423\u0441\u043b\u043e\u0432\u043d\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0443\u043f\u0435\u0440\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 Rust \u0438\u043b\u0438 \u0421, \u043d\u043e 99% \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0436\u0434\u0430\u0442\u044c.<\/p>\n<p>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, Python \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u0435\u043d \u0435\u0449\u0435 \u0438 \u043a\u0430\u043a \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u0435\u0439. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0433\u043e \u043d\u0435\u0442\u043e\u0440\u043e\u043f\u043b\u0438\u0432\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041e\u0431\u044b\u0447\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u0435 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a\u0430\u043a NumPy.<\/p>\n<p>  \u041d\u043e \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u0447\u0443\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 CUDA \u0438 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0433\u0438\u0431\u0440\u0438\u0434 C++, stdpar \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 nvc++ \u043e\u0442 Nvidia. \u041d\u0443 \u0438 \u0437\u0430\u043e\u0434\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0434\u0432\u0435 \u0437\u0430\u0434\u0430\u0447\u0438: \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0447\u0438\u0441\u0435\u043b \u0438 \u043c\u0435\u0442\u043e\u0434 \u042f\u043a\u043e\u0431\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0433\u0440\u0435\u0432 \u043c\u0435\u0442\u0430\u043b\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u043b\u0430\u0441\u0442\u0438\u043d\u044b.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2><font color=\"#3AC1EF\">\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c C++ \u0438\u0437 Python<\/font><\/h2>\n<p>  \u041d\u0430\u0448 \u043a\u043e\u0434 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"python\"># distutils: language=c++ from libcpp.algorithm cimport sort  def cppsort(int[:] x):     sort(&amp;x[0], &amp;x[-1] + 1) <\/code><\/pre>\n<p>  \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043c\u044b \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e Cython \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c C++, \u0430 \u043d\u0435 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 C. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438\u0437 C++, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u0430\u043c\u0430 \u043b\u043e\u0433\u0438\u043a\u0430. \u041f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u043a\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b cppsort.pyx. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e py, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0435\u0433\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c cythonize \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438 Cython.<\/p>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0438\u043b\u0438 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 setup.py, \u0433\u0434\u0435 \u043c\u044b \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0412 setup.py \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">from setuptools import setup from Cython.Build import cythonize  setup(     ext_modules = cythonize(&quot;cppsort.pyx&quot;) ) <\/code><\/pre>\n<p>  \u041d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435:<\/p>\n<pre><code class=\"plaintext\">cythonize -i cppsort.pyx <\/code><\/pre>\n<p>  \u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/43b\/0b3\/c02\/43b0b3c02b07f6f46f3cb32d49d4bdce.png\" alt=\"image\"><\/p>\n<ol>\n<li>Cython \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442 python \u043a\u043e\u0434 \u0432 C++ \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 cppsort.cpp.<\/li>\n<li>C++ \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 g++) \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 C++ \u043a\u043e\u0434 \u0432 <a href=\"https:\/\/docs.python.org\/3\/extending\/building.html\">Python extension module<\/a><\/li>\n<li>Python extension module \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u0434 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u0438\u0439 \u043c\u043e\u0434\u0443\u043b\u044c.<\/li>\n<\/ol>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043c\u043e\u0436\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443:<\/p>\n<pre><code class=\"python\">from cppsort import cppsort import numpy as np  x = np.array([4, 3, 2, 1], dtype=&quot;int32&quot;) print(x) cppsort(x) print(x) <\/code><\/pre>\n<p>  \u041c\u0430\u0441\u0441\u0438\u0432 [4, 3, 2, 1] \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 [1, 2, 3, 4] \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e C++ std::sort.<\/p>\n<h2><font color=\"#3AC1EF\">\u0410 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430 GPU?<\/font><\/h2>\n<p>  \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b C++ \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/execution_policy_tag_t\">parallel execution policy<\/a>. \u042d\u0442\u043e\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0441\u043a\u0438\u0434\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b.<\/p>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c C++ \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u044d\u0442\u043e\u0439 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438:<\/p>\n<ol>\n<li> std::execution::seq: \u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u0430.<\/li>\n<li> std::execution::unseq: \u0412\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0432\u044b\u0437\u0432\u0430\u0432\u0448\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430.<\/li>\n<li> std::execution::par: \u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0442\u043e\u043a\u0430\u0445.<\/li>\n<li> std::execution::par_unseq: \u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0442\u043e\u043a\u0430\u0445. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d.<\/li>\n<\/ol>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u044b \u0441\u0430\u043c\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 race condition \u0438 deadlock. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 g++ \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u044f\u0434\u0440\u0430 CPU. \u041d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0437\u044f\u0442\u044c \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043e\u0442 Nvidia \u2014 nvc++ \u0438 \u0441\u043a\u043e\u0440\u043c\u0438\u0442\u044c \u0435\u043c\u0443 \u043e\u043f\u0446\u0438\u044e &quot;-stdpar&quot;. stdpar \u2014 \u044d\u0442\u043e C++ Standard Parallelism \u043e\u0442 Nvidia \u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 GPU.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0442\u0430\u043a \u043a\u0430\u043a GPU \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043c\u0430\u0441\u0441\u0438\u0432\u0443, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c\u0443 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 NumPy.<\/p>\n<pre><code class=\"python\">from libcpp.algorithm cimport sort, copy_n from libcpp.vector cimport vector from libcpp.execution cimport par  def cppsort(int[:] x):     cdef vector[int] temp     temp.resize(len(x))     copy_n(&amp;x[0], len(x), temp.begin())     sort(par, temp.begin(), temp.end())     copy_n(temp.begin(), len(x), &amp;x[0]) <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/281\/fd9\/9e8\/281fd99e88a3b67ae81bb9a972aee437.png\" alt=\"image\"><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u043e\u0432\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043d\u043e \u0443\u0436\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c nvc++. \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 setup.py \u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"plaintext\">CC=nvc++ python setup.py build_ext --inplace <\/code><\/pre>\n<p>  \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 \u043a\u043e\u0434 \u0438 \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c:<\/p>\n<pre><code class=\"python\">x = np.array([4, 3, 2, 1], dtype=&quot;int32&quot;) cppsort(x) # \u044d\u0442\u043e\u0442 \u043a\u0443\u0441\u043e\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 GPU <\/code><\/pre>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/font><\/h2>\n<p>  \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e GPU \u0445\u043e\u0440\u043e\u0448\u0438 \u0442\u0430\u043c, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043e\u0434\u043d\u043e\u0442\u0438\u043f\u043d\u044b\u0445 \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439. \u0422\u044f\u0436\u0435\u043b\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 GPU \u043d\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043c \u0432\u0430\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0432\u0435\u0440\u0445\u0435\u0434 \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0432\u0430\u043d\u0438\u044f, \u0432\u0432\u043e\u0434\/\u0432\u044b\u0432\u043e\u0434 \u043d\u0430 \u043c\u0435\u0436\u0434\u0443 CPU \u0438 GPU. \u0412 \u0438\u0442\u043e\u0433\u0435, \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c CPU, \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0434\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e. \u041d\u043e \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u0445 GPU \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043f\u0435\u0440\u0435\u0434\u0438.<\/p>\n<p>  <a href=\"https:\/\/github.com\/shwina\/stdpar-cython\/blob\/main\/sort.ipynb\">\u0412\u043e\u0442 \u0442\u0443\u0442<\/a> \u0435\u0441\u0442\u044c \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438. \u0417\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0431\u0440\u0430\u043b\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c NumPy, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u043a\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0440\u043e\u0441\u0442\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0433\u043e.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7u\/zr\/dl\/7uzrdl_bwdonzfjcvuscskhmqpm.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8f0\/6bf\/7e7\/8f06bf7e72b1b2efdb14bdfff0db828d.png\" alt=\"image\"><\/p>\n<p>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 GPU \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u0441\u0442\u0435\u0442, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442\u0441\u044f.<\/p>\n<h2><font color=\"#3AC1EF\">\u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u043d\u0430\u0433\u0440\u0435\u0432 \u043f\u043b\u0430\u0441\u0442\u0438\u043d\u044b<\/font><\/h2>\n<p>  \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u0443\u044e \u043a \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u043e\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u2014 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c \u043f\u043e \u043c\u0435\u0442\u043e\u0434\u0443 \u042f\u043a\u043e\u0431\u0438. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043e\u043d\u0438 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0432 2D-\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c49\/551\/a1c\/c49551a1c30100c8a4791b284e63af26.gif\" alt=\"image\"><\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"python\">&quot;&quot;&quot; simulates heat equation on rectangle returning a heat map at a number of times boundary and initial conditions are 0, source represents burner on a stove This program is based on the script FEniCS tutorial demo program: Diffusion of a Gaussian hill.        u'= Laplace(u) + f  in a square domain   u = u_D = 0            on the boundary   u = u_0 = 0            at t = 0   u_D = f = stove burner flame This program succesfully runs in the fenics docker image, see the book Solving PDEs in Python. to animate: convert -delay 4 -loop 100 heatequation10*.png heatstovelinn.gif to crop:convert heatstovelinn.gif -coalesce -repage 0x0 -crop 810x810+95+15 +repage heatstovelin.gif &quot;&quot;&quot; from fenics import * import time import matplotlib.pyplot as plt from matplotlib import cm   # Create mesh and define function space nx = ny = 100 mesh = RectangleMesh(Point(-2, -2), Point(2, 2), nx, ny) V = FunctionSpace(mesh, 'P', 1)  # Define boundary, source, initial def boundary(x, on_boundary):     return on_boundary   bc = DirichletBC(V, Constant(0), boundary) u_0 = interpolate(Constant(0), V) f = Expression('exp(-sqrt(pow((a*pow(x[0], 2) + a*pow(x[1], 2)-a*1),2)))', degree=2, a=5) #steep guassian centred on the unit sphere final_time = 0.035 num_pics = 72 for i in range(num_pics):     T =   final_time*(i+1.0)\/(num_pics+1)      #solve time even space     #T = final_time*1.1**(i-num_pics+1)        #solve time log  space     num_steps = 30     dt = T \/ num_steps # time step size      # Define variational problem     u = TrialFunction(V)     v = TestFunction(V)     F = u*v*dx + dt*dot(grad(u), grad(v))*dx - (u_0 + dt*f)*v*dx     a, L = lhs(F), rhs(F)      # Time-stepping     u = Function(V)     t = 0     for n in range(num_steps):         t += dt              #step         solve(a == L, u, bc) #solve         u_0.assign(u)        #update      #plot solution     plot(u,cmap=cm.hot,vmin=0,vmax=0.07)     plt.axis('off')     plt.savefig('heatequation10%s.png'%(i+10),figsize=(8, 8), dpi=220,bbox_inches='tight', pad_inches=0,transparent=True) <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0441\u043e\u043b\u0432\u0435\u0440 \u043d\u0430 Cython \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043f\u043e CUDA:<\/p>\n<pre><code class=\"python\"># distutils: language=c++ # cython: cdivision=True from libcpp.algorithm cimport swap from libcpp.vector cimport vector from libcpp cimport bool, float from libc.math cimport fabs from algorithm cimport for_each, any_of, copy from execution cimport par, seq   cdef cppclass avg:     float *T1     float *T2     int M, N       avg(float* T1, float *T2, int M, int N):         this.T1, this.T2, this.M, this.N = T1, T2, M, N     inline void call &quot;operator()&quot;(int i):         if (i % this.N != 0 and i % this.N != this.N-1):             this.T2[i] = (                 this.T1[i-this.N] + this.T1[i+this.N] + this.T1[i-1] + this.T1[i+1]) \/ 4.0 cdef cppclass converged:     float *T1     float *T2     float max_diff       converged(float* T1, float *T2, float max_diff):         this.T1, this.T2, this.max_diff = T1, T2, max_diff       inline bool call &quot;operator()&quot;(int i):         return fabs(this.T2[i] - this.T1[i]) &gt; this.max_diff   def jacobi_solver(float[:, :] data, float max_diff, int max_iter=10_000):     M, N  = data.shape[0], data.shape[1]     cdef vector[float] local     cdef vector[float] temp     local.resize(M*N)     temp.resize(M*N)     cdef vector[int] indices = range(N+1, (M-1)*N-1)     copy(seq, &amp;data[0, 0], &amp;data[-1, -1], local.begin())     copy(par, local.begin(), local.end(), temp.begin())     cdef int iterations = 0     cdef float* T1 = local.data()     cdef float* T2 = temp.data()       keep_going = True     while keep_going and iterations &lt; max_iter:         iterations += 1         for_each(par, indices.begin(), indices.end(), avg(T1, T2, M, N))         keep_going = any_of(par, indices.begin(), indices.end(), converged(T1, T2, max_diff))         swap(T1, T2)       if (T2 == local.data()):         copy(seq, local.begin(), local.end(), &amp;data[0, 0])     else:         copy(seq, temp.begin(), temp.end(), &amp;data[0, 0])     return iterations <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8ad\/5c3\/9ad\/8ad5c39ad0660cc92e99816503426d90.png\" alt=\"image\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d0e\/d26\/374\/d0ed263746acda3d60c80e16d7321b82.png\" alt=\"image\"><\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043e\u0442\u0440\u044b\u0432 GPU \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c.<\/p>\n<h2><font color=\"#3AC1EF\">\u041c\u0438\u043d\u0443\u0441\u044b<\/font><\/h2>\n<p>  <\/p>\n<ol>\n<li>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0447\u0438\u0441\u0442\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043d\u0430 Python \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \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.<\/li>\n<li>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043d\u0430 GPU, \u043a\u0443\u0434\u0430 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u0430 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438.<\/li>\n<\/ol>\n<p>  <a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=meklon&amp;utm_content=numbaCython#order\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ou\/g5\/kh\/oug5kh6sjydt9llengsiebnp40w.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\/ruvds\/blog\/536824\/\"> https:\/\/habr.com\/ru\/company\/ruvds\/blog\/536824\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/0a\/ri\/fi\/0arifij2nrzjonpilf80zatmnjc.png\" alt=\"image\"><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c49\/551\/a1c\/c49551a1c30100c8a4791b284e63af26.gif\" alt=\"image\"><br \/>  <i>\u0411\u0443\u0434\u0435\u043c \u0433\u0440\u0435\u0442\u044c \u043c\u0435\u0442\u0430\u043b\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043b\u0430\u0441\u0442\u0438\u043d\u044b \u043d\u0430 GPU<\/i><\/p>\n<p>  \u0412\u0441\u0435 \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e Python \u043d\u0435 \u0431\u043b\u0435\u0449\u0435\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u044f\u0437\u044b\u043a \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u0435\u043d \u0441\u0432\u043e\u0435\u0439 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u043d\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043d\u0438\u0448\u0430 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u043c, \u0433\u0434\u0435 \u0432\u044b \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0435 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0445. \u0423\u0441\u043b\u043e\u0432\u043d\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0443\u043f\u0435\u0440\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 Rust \u0438\u043b\u0438 \u0421, \u043d\u043e 99% \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0436\u0434\u0430\u0442\u044c.<\/p>\n<p>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, Python \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u0435\u043d \u0435\u0449\u0435 \u0438 \u043a\u0430\u043a \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u0435\u0439. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0433\u043e \u043d\u0435\u0442\u043e\u0440\u043e\u043f\u043b\u0438\u0432\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041e\u0431\u044b\u0447\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u0435 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a\u0430\u043a NumPy.<\/p>\n<p>  \u041d\u043e \u043c\u044b \u043f\u043e\u0439\u0434\u0435\u043c \u0447\u0443\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0441\u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430 CUDA \u0438 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0433\u0438\u0431\u0440\u0438\u0434 C++, stdpar \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 nvc++ \u043e\u0442 Nvidia. \u041d\u0443 \u0438 \u0437\u0430\u043e\u0434\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0434\u0432\u0435 \u0437\u0430\u0434\u0430\u0447\u0438: \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0447\u0438\u0441\u0435\u043b \u0438 \u043c\u0435\u0442\u043e\u0434 \u042f\u043a\u043e\u0431\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0433\u0440\u0435\u0432 \u043c\u0435\u0442\u0430\u043b\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u043b\u0430\u0441\u0442\u0438\u043d\u044b.  <\/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-316209","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316209","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=316209"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/316209\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=316209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=316209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=316209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}