{"id":261897,"date":"2015-07-20T18:57:02","date_gmt":"2015-07-20T14:57:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=261897"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=261897","title":{"rendered":"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 Intel Xeon Phi: \u00ab\u0440\u043e\u0434\u043d\u043e\u0439\u00bb \u043a\u043e\u0434"},"content":{"rendered":"<p>     \t\u0412 <a href=\"http:\/\/habrahabr.ru\/post\/262019\/\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c Intel Xeon Phi \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f offload \u2013 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0445\u043e\u0441\u0442\u0435, \u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u00ab\u0440\u043e\u0434\u043d\u043e\u0433\u043e\u00bb \u043a\u043e\u0434\u0430, \u0441 \u0446\u0435\u043b\u044c\u044e \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0434\u0430\u0435\u0442 \u0438 \u0447\u0435\u043c \u0433\u0440\u043e\u0437\u0438\u0442. \u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u043f\u043e\u0441\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Fortran \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u043a\u043b\u0430\u043c\u043e\u0439 \u0438\u043b\u0438 \u0430\u043d\u0442\u0438\u0440\u0435\u043a\u043b\u0430\u043c\u043e\u0439 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430, \u0430 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043b\u0438\u0447\u043d\u044b\u0439 \u043e\u043f\u044b\u0442 \u0430\u0432\u0442\u043e\u0440\u0430.<br \/>  \u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437, \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0442\u0435\u043b (n-body problem). \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 \u043d\u0430 CPU \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f, \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430 MIC (\u0434\u0430\u043b\u0435\u0435 MIC-\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c Intel Xeon Phi).  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c OpenMP<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>\/*---------------------------------------------------------*\/ \/*                  N-Body simulation benchmark            *\/ \/*                   written by M.S.Ozhgibesov             *\/ \/*                         04 July 2015                    *\/ \/*---------------------------------------------------------*\/ #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;math.h&gt; #include &lt;string.h&gt; #include &lt;time.h&gt; #include &lt;omp.h&gt;  #define HOSTLEN 50  int numProc;  \/\/ Initial conditions void initCoord(float *rA, float *vA, float *fA, \\                float initDist, int nBod, int nI);  \/\/ Forces acting on each body void forces(float *rA, float *fA, int nBod);  \/\/ Calculate velocities and update coordinates void integration(float *rA, float *vA, float *fA, int nBod);  int main(int argc, const char * argv[]) {    int const nI = 32;               \/\/ Number of bodies in X, Y and Z directions    int const nBod = nI*nI*nI;       \/\/ Total Number of bodies    int const maxIter = 20;          \/\/ Total number of iterations (time steps)    float const initDist = 1.0;      \/\/ Initial distance between the bodies    float *rA;                       \/\/ Coordinates    float *vA;                       \/\/ Velocities    float *fA;                       \/\/ Forces    int iter;    double startTime0, endTime0;    char host[HOSTLEN];     rA = (float*)malloc(3*nBod*sizeof(float));    fA = (float*)malloc(3*nBod*sizeof(float));    vA = (float*)malloc(3*nBod*sizeof(float));     gethostname(host, HOSTLEN);    printf(&quot;Host name: %s\\n&quot;, host);    numProc = omp_get_num_procs();    printf(&quot;Available number of processors: %d\\n&quot;, numProc);     \/\/ Setup initial conditions    initCoord(rA, vA, fA, initDist, nBod, nI);     startTime0 = omp_get_wtime();    \/\/ Main loop    for ( iter = 0; iter &lt; maxIter; iter++ ) {       forces(rA, fA, nBod);        integration(rA, vA, fA, nBod);    }     endTime0 = omp_get_wtime();     printf(&quot;\\nTotal time = %10.4f [sec]\\n&quot;, endTime0 - startTime0);     free(rA);    free(vA);    free(fA); \treturn 0; }  \/\/ Initial conditions void initCoord(float *rA, float *vA, float *fA, \\                float initDist, int nBod, int nI) {    int i, j, k;    float Xi, Yi, Zi;    float *rAx = &rA[     0];        \/\/----    float *rAy = &rA[  nBod];        \/\/ Pointers on X, Y, Z components of coordinates    float *rAz = &rA[2*nBod];        \/\/----    int ii = 0;     memset(fA, 0.0, 3*nBod*sizeof(float));    memset(vA, 0.0, 3*nBod*sizeof(float));     for (i = 0; i &lt; nI; i++) {       Xi = i*initDist;       for (j = 0; j &lt; nI; j++) {          Yi = j*initDist;          for (k = 0; k &lt; nI; k++) {             Zi = k*initDist;             rAx[ii] = Xi;             rAy[ii] = Yi;             rAz[ii] = Zi;             ii++;          }       }    } }  \/\/ Forces acting on each body void forces(float *rA, float *fA, int nBod) {    int i, j;    float Xi, Yi, Zi;    float Xij, Yij, Zij;             \/\/ X[j] - X[i] and so on    float Rij2;                      \/\/ Xij^2+Yij^2+Zij^2    float invRij2, invRij6;          \/\/ 1\/rij^2; 1\/rij^6    float *rAx = &rA[     0];        \/\/----    float *rAy = &rA[  nBod];        \/\/ Pointers on X, Y, Z components of coordinates    float *rAz = &rA[2*nBod];        \/\/----    float *fAx = &fA[     0];        \/\/----    float *fAy = &fA[  nBod];        \/\/ Pointers on X, Y, Z components of forces    float *fAz = &fA[2*nBod];        \/\/----    float magForce;                  \/\/ Force magnitude    float const EPS = 1.E-10;         \/\/ Small value to prevent 0\/0 if i==j     #pragma omp parallel for num_threads(numProc) private(Xi, Yi, Zi, \\                Xij, Yij, Zij, magForce, invRij2, invRij6, j, i)    for (i = 0; i &lt; nBod; i++) {       Xi = rAx[i];       Yi = rAy[i];       Zi = rAz[i];       fAx[i] = 0.0;       fAy[i] = 0.0;       fAz[i] = 0.0;       for (j = 0; j &lt; nBod; j++) {          Xij = rAx[j] - Xi;          Yij = rAy[j] - Yi;          Zij = rAz[j] - Zi;          Rij2 = Xij*Xij + Yij*Yij + Zij*Zij;          invRij2 = Rij2\/((Rij2 + EPS)*(Rij2 + EPS));          invRij6 = invRij2*invRij2*invRij2;          magForce = 6.f*invRij2*(2.f*invRij6 - 1.f)*invRij6;          fAx[i]+= Xij*magForce;          fAy[i]+= Yij*magForce;          fAz[i]+= Zij*magForce;       }    } }  \/\/ Integration of coordinates an velocities void integration(float *rA, float *vA, float *fA, int nBod) {    int i;    float const dt = 0.01;              \/\/ Time step    float const mass = 1.0;             \/\/ mass of a body    float const mdthalf = dt*0.5\/mass;    float *rAx = &rA[     0];    float *rAy = &rA[  nBod];    float *rAz = &rA[2*nBod];    float *vAx = &vA[     0];    float *vAy = &vA[  nBod];    float *vAz = &vA[2*nBod];    float *fAx = &fA[     0];    float *fAy = &fA[  nBod];    float *fAz = &fA[2*nBod];     #pragma omp parallel for num_threads(numProc) private(i)    for (i = 0; i &lt; nBod; i++) {       rAx[i]+= (vAx[i] + fAx[i]*mdthalf)*dt;       rAy[i]+= (vAy[i] + fAy[i]*mdthalf)*dt;       rAz[i]+= (vAz[i] + fAz[i]*mdthalf)*dt;        vAx[i]+= fAx[i]*dt;       vAy[i]+= fAy[i]*dt;       vAz[i]+= fAz[i]*dt;    } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u043e\u0434 \u043d\u0430 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:  <\/p>\n<ul>\n<li>\u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0432 \u00ab\u0440\u043e\u0434\u043d\u043e\u0439\u00bb (native) \u043a\u043e\u0434 \u0434\u043b\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b MIC \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u043f\u0446\u0438\u044e -mmic<\/li>\n<li>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0434\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\/\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0443 (offload), \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u0445\u043e\u0441\u0442\u0435, \u0430 \u0447\u0430\u0441\u0442\u044c \u043d\u0430 Xeon Phi<\/li>\n<\/ul>\n<p>  \u0412 <a href=\"http:\/\/habrahabr.ru\/post\/262019\/\">\u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437<\/a> \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0430\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0443, \u0432 \u044d\u0442\u043e\u0442 \u0436\u0435 \u0440\u0430\u0437 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u00ab\u0440\u043e\u0434\u043d\u043e\u0439\u00bb \u043a\u043e\u0434 \u0434\u043b\u044f MIC.<br \/>  \u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438\u043c\u0435\u044e\u0449\u0443\u044e\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0447\u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b:  <\/p>\n<ul>\n<li>MIC \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0447\u0435\u043c \u0445\u043e\u0441\u0442;<\/li>\n<li>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u00ab\u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0445\u00bb \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u0432;<\/li>\n<li>\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0441\u0432\u0435\u0434\u0435\u043d\u043e \u043a \u043d\u0443\u043b\u044e \u2014 \u043a\u0430\u0436\u0434\u0430\u044f \u0442\u0430\u043a\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u044d\u0442\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0445\u043e\u0441\u0442\u0443, \u0430 \u044d\u0442\u043e, \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 CUDA, \u043e\u0447\u0435\u043d\u044c \u00ab\u0434\u043e\u0440\u043e\u0433\u043e\u0435\u00bb \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435.<\/li>\n<\/ul>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f MIC \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c scp (Intel Xeon Phi \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u044e Linux-\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u0443\u044e \u043c\u0438\u043a\u0440\u043e-\u041e\u0421) \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f.<\/p>\n<h1>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435\/\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 MIC<\/h1>\n<p>  <\/p>\n<ol>\n<li>\u041f\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c (\u043f\u0443\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 micuser), \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u0435\u043c ssh \u043a\u043b\u044e\u0447\u0438:<br \/> \n<pre><code class=\"bash\">$ ssh-keygen<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u043a\u0443\u0434\u0430 \u0438\u0445 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438: \/home\/micuser\/.ssh\/  <\/li>\n<li>\u041f\u043e\u0434 \u0440\u0443\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043b\u044f MIC:<br \/> \n<pre><code class=\"bash\">$ micctrl \u2013-useradd=micuser \u2013-uid=500 \u2013-gid=500 \u2013-sshkeys=\/home\/micuser\/.ssh\/<\/code><\/pre>\n<p>  \u0433\u0434\u0435 uid \u0438 gid \u044d\u0442\u043e user ID \u0438 group ID.  <\/li>\n<\/ol>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 ssh \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u0442\u043e \u0437\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u0442 \u2013 \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c. <a href=\"https:\/\/software.intel.com\/sites\/default\/files\/managed\/bd\/53\/System_Administration_Guide_Intel%28R%29XeonPhi%28TM%29Coprocessor.pdf\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Xeon Phi.<\/a> <a href=\"http:\/\/themerakisoul.blogspot.sg\/2015\/03\/how-to-add-user-to-xeon-phi-co-processor.html\">\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 MIC<\/a>: \u043b\u043e\u0433\u0438\u043d\u0438\u043c\u0441\u044f root-\u043e\u043c \u043d\u0430 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0442\u043e\u043b\u044c\u043a\u043e root \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a MIC \u043f\u043e ssh) \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0447\u0435\u0440\u0435\u0437 useradd. \u0412\u0442\u043e\u0440\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b \u2013 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0443, \u0430 \u043d\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c\u0438 \u0433\u043b\u044e\u043a\u0430\u043c\u0438.<\/p>\n<h1>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u00ab\u041c\u0410\u0419\u041a\u00bb<\/h1>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0434\u043b\u044f CPU \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 MIC \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f CPU-\u0448\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043a\u0438, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435. \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0434\u043b\u044f MIC, \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:  <\/p>\n<pre><code class=\"bash\"> $ icc nbody_CPU.c -mmic -openmp -O3 -o nbdMIC.run  $ scp nbdMIC.run mic0: $ ssh mic0 $ .\/nbdMIC.run  .\/nbdMIC.run: error while loading shared libraries: libiomp5.so: cannot open shared object file: No such file or directory <\/code><\/pre>\n<p>  \u0412\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0441\u043c\u0435\u0448\u043d\u043e \u2013 \u0433\u0434\u0435-\u0442\u043e \u043d\u0430\u043a\u043e\u0441\u044f\u0447\u0438\u043b\u0438! \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043f\u043e\u0447\u0442\u0438 \u043d\u0435\u0433\u0434\u0435 \u2013 \u0441\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e Xeon Phi \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0441\u043e \u0441\u0432\u043e\u0435\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0438 \u043e\u043d\u043e, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043e\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442! \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435: \u043d\u0443\u0436\u043d\u043e \u0438\u0445 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 MIC \u043a\u0430\u043a \u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u0412\u044b\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0445\u043e\u0441\u0442 \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c (\u043e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043d\u0435 \u0430\u0431\u044b \u043a\u0430\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0430 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u0434\u043b\u044f MIC):  <\/p>\n<pre><code class=\"bash\"> $ scp \/opt\/intel\/composer_xe_2013_sp1.2.144\/compiler\/lib\/mic\/libiomp5.so mic0:\/tmp\/ $ ssh mic0 $ echo $LD_LIBRARY_PATH $ export LD_LIBRARY_PATH=\/tmp $ .\/nbdMIC.run  Host name: mic0.local Available number of processors: 240 Total time =     1.0823 [sec] <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0434\u0432\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0432\u0435\u0449\u0438:  <\/p>\n<ol>\n<li>\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 240 (<a href=\"http:\/\/ark.intel.com\/products\/71992\/Intel-Xeon-Phi-Coprocessor-5110P-8GB-1_053-GHz-60-core\">Intel Xeon 5110P \u0438\u043c\u0435\u0435\u0442 60 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044f\u0434\u0435\u0440<\/a>), \u0430 \u043d\u0435 236 \u043a\u0430\u043a \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438;<\/li>\n<li>\u00ab\u0420\u043e\u0434\u043d\u043e\u0439\u00bb \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 ~1.3x \u0440\u0430\u0437\u0430 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0447\u0435\u043c \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0439 (1.08\u0441\u0435\u043a \u043f\u0440\u043e\u0442\u0438\u0432 1.44\u0441\u0435\u043a).<\/li>\n<\/ol>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0441 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u043e\u0439<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/49c\/768\/3ac\/49c7683acf0a4347af218865bf47cf2c.png\"\/>  <\/div>\n<\/div>\n<p>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438, <a href=\"https:\/\/software.intel.com\/en-us\/articles\/best-known-methods-for-using-openmp-on-intel-many-integrated-core-intel-mic-architecture\">\u043e\u0434\u043d\u043e \u044f\u0434\u0440\u043e \u043e\u0442\u0434\u0430\u0435\u0442\u0441\u044f offload daemon<\/a> \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0445\u043e\u0441\u0442\u043e\u043c, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u201c\u0440\u043e\u0434\u043d\u043e\u0439\u201d \u043a\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438.<br \/>  \u041f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0445\u043e\u0441\u0442\u043e\u043c \u0438 MIC (\u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043d\u0430 \u043f\u0435\u0447\u0430\u0442\u044c), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430(\u043d\u0435 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u0432\u0441\u0435 \u0436\u0435).<br \/>  \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e \u0432\u044b\u0448\u0435, \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0441\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u043d\u044b \u0433\u0434\u0435-\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f, \u043d\u043e \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0435\u0433\u043e SSD\/HDD (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 5110P). \u041a\u0443\u0434\u0430 \u0436\u0435 \u0442\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f? \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442: \u0432 RAM \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\u0438\u043a \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u0410 \u0435\u0441\u043b\u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u0432 \u043f\u0430\u0440\u0443 \u0433\u0438\u0433\u0430\u0431\u0430\u0439\u0442? \u0414\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043f\u043a\u0443 \u0441 \u0445\u043e\u0441\u0442\u0430 \u043d\u0430 MIC.<br \/>  \u0423\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u0430\u043d\u044f\u0442\u0438\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab\u0432\u044b\u0443\u0436\u0438\u0432\u0430\u043d\u0438\u0435\u00bb \u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 micnativeloadex \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/software.intel.com\/en-us\/articles\/building-a-native-application-for-intel-xeon-phi-coprocessors\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h1>\u0427\u0435\u0442\u044b\u0440\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e Fortran<\/h1>\n<p>  \u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043f\u0435\u0440\u0432\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c Intel Xeon Phi, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434 C. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f, \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0430\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044f\u0437\u044b\u043a\u0430 Fortran, \u043e\u0434\u043d\u0430\u043a\u043e \u0431\u0435\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0432 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0447\u0435\u0433\u043e \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u043f\u0440\u043e\u0441\u044c\u0431\u0430 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Fortran, \u0447\u0442\u043e \u044f\u0437\u044b\u043a\u0430 C \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e\u0439, \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 Fortran \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Fortran \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f CPU<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>!---------------------------------------------------------! !                  N-Body simulation benchmark            ! !                   written by M.S.Ozhgibesov             ! !                         14 July 2015                    ! !---------------------------------------------------------!    program nbody_CPU       use omp_lib       implicit none       integer, parameter:: nI = 32        ! Number of bodies in X, Y and Z directions         integer, parameter:: nBod = nI**3   ! Total Number of bodies       integer, parameter:: maxIter = 20   ! Total number of iterations (time steps)       integer:: numProc                   ! Number of available processors       integer:: iter       character(len=50):: host       real(4), parameter:: initDist = 1.0 ! Initial distance between the bodies       real(4), allocatable:: rA(:)        ! Coordinates       real(4), allocatable:: vA(:)        ! Velocities       real(4), allocatable:: fA(:)        ! Forces       real(8):: startTime0, endTime0       common\/ourCommonData\/numProc        allocate(rA(3*nBod), vA(3*nBod), fA(3*nBod))        call hostnm(host)       write(*,'(A11,A50)')&quot;Host name: &quot;, host       numProc = omp_get_num_procs()       write(*,'(A32,I4)')&quot;Available number of processors: &quot;,numProc        ! Setup initial conditions       call initCoord(rA, vA, fA, initDist, nBod, nI)        ! Main loop       startTime0 = omp_get_wtime()       do iter = 1, maxIter          call forces(rA, vA, nBod)           call integration(rA, vA, fA, nBod)       enddo       endTime0 = omp_get_wtime()       write(*,'(A13,F10.4,A6)'), &quot;Total time = &quot;, endTime0 - startTime0,&quot; [sec]&quot;        deallocate(rA, vA, fA)    end program      ! Initial conditions    subroutine initCoord(rA, vA, fA, initDist, nBod, nI)       implicit none       integer:: i, j, k, ii       integer:: nI, nBod       integer:: initDist       integer:: numProc       real(4):: Xi, Yi,Zi       real(4):: rA(*), fA(*), vA(*)        fA(1:3*nBod) = 0.E0       vA(1:3*nBod) = 0.E0        ii = 1       do i = 1, nI          Xi = i*(initDist - 1)          do j = 1, nI             Yi = j*(initDist - 1)             do k = 1, nI                Zi = k*(initDist - 1)                rA(ii       ) = Xi                rA(ii+  nBod) = Yi                rA(ii+2*nBod) = Zi                ii = ii + 1             enddo          enddo       enddo     end subroutine initCoord     ! Forces acting on each body    subroutine forces(rA, fA, nBod)       use omp_lib       implicit none       integer:: i, j       integer:: nI, nBod       integer:: numProc       real(4):: Xi, Yi, Zi       real(4):: Xij, Yij, Zij             ! X[j] - X[i] and so on       real(4):: Rij2                      ! Xij^2+Yij^2+Zij^2       real(4):: invRij2, invRij6          ! 1\/rij^2; 1\/rij^6       real(4):: rA(*), fA(*)       real(4):: magForce                  ! Force magnitude       real(4):: fAix, fAiy, fAiz       real(4), parameter:: EPS = 1.E-10   ! Small value to prevent 0\/0 if i==j       common\/ourCommonData\/numProc        !$OMP PARALLEL NUM_THREADS(numProc) &       !$OMP PRIVATE(Xi, Yi, Zi, Xij, Yij, Zij, magForce, invRij2, invRij6, i, j)&       !$OMP PRIVATE(fAix, fAiy, fAiz)       !$OMP DO       do i = 1, nBod          Xi = rA(i       )          Yi = rA(i+  nBod)          Zi = rA(i+2*nBod)          fAix = 0.E0          fAiy = 0.E0          fAiz = 0.E0          do j = 1, nBod             Xij = rA(j       ) - Xi             Yij = rA(j+  nBod) - Yi             Zij = rA(j+2*nBod) - Zi             Rij2 = Xij*Xij + Yij*Yij + Zij*Zij             invRij2 = Rij2\/((Rij2 + EPS)**2)             invRij6 = invRij2*invRij2*invRij2             magForce = 6.0*invRij2*(2.0*invRij6 - 1.0)*invRij6             fAix = fAix + Xij*magForce             fAiy = fAiy + Yij*magForce             fAiz = fAiz + Zij*magForce          enddo          fA(i       ) = fAix          fA(i+  nBod) = fAiy          fA(i+2*nBod) = fAiz       enddo       !$OMP END PARALLEL     end subroutine forces     subroutine integration(rA, vA, fA, nBod)       use omp_lib       implicit none       integer:: i       integer:: nI, nBod       integer:: numProc       real(4), parameter:: dt = 0.01            ! Time step       real(4), parameter:: mass = 1.0           ! mass of a body       real(4), parameter:: mdthalf = dt*0.5\/mass       real(4):: rA(*), vA(*), fA(*)       common\/ourCommonData\/numProc        !$OMP PARALLEL NUM_THREADS(numProc) PRIVATE(i)       !$OMP DO       do i = 1, 3*nBod          rA(i) = (rA(i) + fA(i)*mdthalf)*dt          vA(i) = fA(i)*dt       enddo       !$OMP END PARALLEL     end subroutine integration <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Fortran \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043d\u0430 Xeon Phi<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>!---------------------------------------------------------! !                  N-Body simulation benchmark            ! !                   written by M.S.Ozhgibesov             ! !                         14 July 2015                    ! !---------------------------------------------------------!    program nbody_XeonPhi       use omp_lib       implicit none       integer, parameter:: nI = 32        ! Number of bodies in X, Y and Z directions         integer, parameter:: nBod = nI**3   ! Total Number of bodies       integer, parameter:: maxIter = 20   ! Total number of iterations (time steps)       integer:: numProc       integer:: iter       character(len=50):: host       real(4), parameter:: initDist = 1.0 ! Initial distance between the bodies       real(4), allocatable:: rA(:)        ! Coordinates       real(4), allocatable:: vA(:)        ! Velocities       real(4), allocatable:: fA(:)        ! Forces       real(8):: startTime0, endTime0       common\/ourCommonData\/numProc          allocate(rA(3*nBod), vA(3*nBod), fA(3*nBod))        ! Mark variable numProc as needing to be allocated       ! on both the host and device       !DIR$ ATTRIBUTES OFFLOAD:mic::numProc, hostnm       !DIR$ OFFLOAD BEGIN TARGET(mic) OUT(host, numProc)       call hostnm(host)        numProc = omp_get_num_procs()       !DIR$ END OFFLOAD        write(*,'(A11,A50)')&quot;Host name: &quot;, host       write(*,'(A32,I4)')&quot;Available number of processors: &quot;,numProc        ! Setup initial conditions       call initCoord(rA, vA, fA, initDist, nBod, nI)        ! Mark routines integration and forces as needing both       ! host and coprocessor version       !DIR$ ATTRIBUTES OFFLOAD:mic::integration, forces        ! Main loop       startTime0 = omp_get_wtime()       !DIR$ OFFLOAD BEGIN TARGET(mic) INOUT(rA,fA,vA:length(3*nBod))       do iter = 1, maxIter          call forces(rA, vA, nBod)           call integration(rA, vA, fA, nBod)       enddo       !DIR$ END OFFLOAD       endTime0 = omp_get_wtime()        write(*,'(A13,F10.4,A6)'), &quot;Total time = &quot;, endTime0 - startTime0,&quot; [sec]&quot;        deallocate(rA, vA, fA)    end program nbody_XeonPhi      ! Initial conditions    subroutine initCoord(rA, vA, fA, initDist, nBod, nI)       implicit none       integer:: i, j, k, ii       integer:: nI, nBod       integer:: initDist       integer:: numProc       real(4):: Xi, Yi,Zi       real(4):: rA(*), fA(*), vA(*)        fA(1:3*nBod) = 0.D0       vA(1:3*nBod) = 0.D0       ii = 1       do i = 1, nI          Xi = i*(initDist - 1)          do j = 1, nI             Yi = j*(initDist - 1)             do k = 1, nI                Zi = k*(initDist - 1)                rA(ii       ) = Xi                rA(ii+  nBod) = Yi                rA(ii+2*nBod) = Zi                ii = ii + 1             enddo          enddo       enddo     end subroutine initCoord     ! Forces acting on each body    !DIR$ ATTRIBUTES OFFLOAD:mic:: forces    subroutine forces(rA, fA, nBod)       implicit none       integer:: i, j       integer:: nI, nBod       integer:: numProc       real(4):: Xi, Yi, Zi       real(4):: Xij, Yij, Zij             ! X[j] - X[i] and so on       real(4):: Rij2                      ! Xij^2+Yij^2+Zij^2       real(4):: invRij2, invRij6          ! 1\/rij^2; 1\/rij^6       real(4):: rA(*), fA(*)       real(4):: magForce                  ! Force magnitude       real(4):: fAix, fAiy, fAiz       real(4), parameter:: EPS = 1.E-10   ! Small value to prevent 0\/0 if i==j       common\/ourCommonData\/numProc        !$OMP PARALLEL NUM_THREADS(numProc) &       !$OMP PRIVATE(Xi, Yi, Zi, Xij, Yij, Zij, magForce, invRij2, invRij6, i, j)&       !$OMP PRIVATE(fAix, fAiy, fAiz)       !$OMP DO       do i = 1, nBod          Xi = rA(i       )          Yi = rA(i+  nBod)          Zi = rA(i+2*nBod)          fAix = 0.E0          fAiy = 0.E0          fAiz = 0.E0          do j = 1, nBod             Xij = rA(j       ) - Xi             Yij = rA(j+  nBod) - Yi             Zij = rA(j+2*nBod) - Zi             Rij2 = Xij*Xij + Yij*Yij + Zij*Zij             invRij2 = Rij2\/((Rij2 + EPS)**2)             invRij6 = invRij2*invRij2*invRij2             magForce = 6.0*invRij2*(2.0*invRij6 - 1.0)*invRij6             fAix = fAix + Xij*magForce             fAiy = fAiy + Yij*magForce             fAiz = fAiz + Zij*magForce          enddo          fA(i       ) = fAix          fA(i+  nBod) = fAiy          fA(i+2*nBod) = fAiz       enddo       !$OMP END PARALLEL     end subroutine forces     !DIR$ ATTRIBUTES OFFLOAD:mic::integration    subroutine integration(rA, vA, fA, nBod)       implicit none       integer:: i       integer:: nI, nBod       integer:: numProc       real(4), parameter:: dt = 0.01            ! Time step       real(4), parameter:: mass = 1.0           ! mass of a body       real(4), parameter:: mdthalf = dt*0.5\/mass       real(4):: rA(*), vA(*), fA(*)       common\/ourCommonData\/numProc        !$OMP PARALLEL NUM_THREADS(numProc) PRIVATE(i)       !$OMP DO       do i = 1, 3*nBod          rA(i) = (rA(i) + fA(i)*mdthalf)*dt          vA(i) = fA(i)*dt       enddo       !$OMP END PARALLEL     end subroutine integration <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h1>\u0412\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/h1>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u00ab\u0440\u043e\u0434\u043d\u044b\u043c\u00bb \u043a\u043e\u0434\u043e\u043c, \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u043e\u0434\u0435, \u0434\u0430\u0436\u0435 \u043f\u0440\u043e\u0449\u0435 \u0447\u0435\u043c \u0441 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u2013 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u044e\u0449\u0443\u044e\u0441\u044f \u0434\u043b\u044f CPU \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u00ab\u0440\u043e\u0434\u043d\u0430\u044f\u00bb \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0434\u0430\u0436\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0447\u0435\u043c offload. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0442\u043e \u0438\u0445 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f MIC \u0438\u043b\u0438 \u0436\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443. \u0422\u0430\u043a\u0436\u0435, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043b\u044e\u0431\u044b\u0435 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440 \u0444\u0430\u0439\u043b\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 RAM, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438 \u0442\u0430\u043a \u043d\u0435 \u043c\u043d\u043e\u0433\u043e.<br \/>  \u0412 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043a \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b \u043f\u043e\u0434\u043d\u044f\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \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 Xeon Phi \u0438 CUDA GPU, \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0437\u0430\u0434\u0430\u0447\u0438, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0436\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0442\u043e \u0436\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0443\u0441\u0438\u043b\u0438\u044f \u0434\u0435\u0432\u0430\u0439\u0441\u043e\u0432.     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/263121\/\"> http:\/\/habrahabr.ru\/post\/263121\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u0412 <a href=\"http:\/\/habrahabr.ru\/post\/262019\/\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u043e \u0441 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c Intel Xeon Phi \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f offload \u2013 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0445\u043e\u0441\u0442\u0435, \u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u00ab\u0440\u043e\u0434\u043d\u043e\u0433\u043e\u00bb \u043a\u043e\u0434\u0430, \u0441 \u0446\u0435\u043b\u044c\u044e \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0434\u0430\u0435\u0442 \u0438 \u0447\u0435\u043c \u0433\u0440\u043e\u0437\u0438\u0442. \u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u043f\u043e\u0441\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u0447\u0435\u0442\u044b\u0440\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Fortran \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c.  <\/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-261897","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/261897","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=261897"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/261897\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=261897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=261897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=261897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}