<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Gennady, I run with 4 mpi in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146779#M26752</link>
    <description>&lt;P&gt;Gennady, I run with 4 mpi processes, but I am quite certain the extra message is there even with a single core run.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Oct 2018 06:48:22 GMT</pubDate>
    <dc:creator>davydden1</dc:creator>
    <dc:date>2018-10-23T06:48:22Z</dc:date>
    <item>
      <title>problem with pdsyevx when calculating some eigenvalues only</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146777#M26750</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;I see the following terminal output when using pdsyevx from Intel MKL 2019.0.117 with mpich 3.2.1 to calculate only some eigenvalues:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;{    0,    0}:  On entry to 
PDORMTR parameter number   12 had an illegal value 
{    0,    0}:  On entry to 
PDORMTR parameter number   12 had an illegal value 
{    0,    0}:  On entry to 
PDORMTR parameter number   12 had an illegal value &lt;/PRE&gt;

&lt;P&gt;whereas no warnings in given when using openblas 0.3.3 + netlib-scalapack 2.0.2 + openmpi 3.1.2. &amp;nbsp;For both setups GCC 7.3.0 from Ubuntu 18.04.1 LTS is used.&lt;/P&gt;

&lt;P&gt;Note that I do NOT call pdormtr manually, it must be called from within pdsyevx. It looks like its implementation in Intel MKL has some issues for this case.&lt;/P&gt;

&lt;P&gt;Below is a MWE that demonstrates the problem.&lt;/P&gt;

&lt;PRE class="brush:cpp; class-name:dark;"&gt;#include &amp;lt;mpi.h&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;iomanip&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;sstream&amp;gt;
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;functional&amp;gt;
using namespace std;

// test program to compute last 5 eigenvalues without eigenvectors for symmetric operators
//
// compile with:
// mpic++ -std=c++11 example.cc -o example -lscalapack -lopenblas
// mpic++ -std=c++11 example.cc -o example -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64 -lmkl_intel_lp64 -lmkl_core -lmkl_sequential


extern "C" {
  /* Cblacs declarations */
  void Cblacs_pinfo(int *, int *);
  void Cblacs_get(int, int, int *);
  void Cblacs_gridinit(int *, const char *, int, int);
  void Cblacs_gridinfo(int, int *, int *, int *,int *);
  void Cblacs_pcoord(int, int, int *, int *);
  void Cblacs_gridexit(int);
  void Cblacs_barrier(int, const char *);
  void Cdgerv2d(int, int, int, double *, int, int, int);
  void Cdgesd2d(int, int, int, double *, int, int, int);

  int numroc_ (const int *n, const int *nb, const int *iproc, const int *isproc, const int *nprocs);

  void pdpotrf_(const char *UPLO,
                const int *N,
                double *A, const int *IA, const int *JA, const int *DESCA,
                int *INFO);

  void descinit_ (int *desc, const int *m, const int *n, const int *mb, const int *nb, const int *irsrc, const int *icsrc, const int *ictxt, const int *lld, int *info);

  int indxl2g_ (const int *indxloc, const int *nb, const int *iproc, const int *isrcproc, const int *nprocs);

  void pdpotri_(const char *UPLO,
                const int *N,
                double *A, const int *IA, const int *JA, const int *DESCA,
                int *INFO);

  void
  pdsyevx_(const char *  jobz,
           const char *  range,
           const char *  uplo,
           const int *   n,
           double *      A,
           const int *   ia,
           const int *   ja,
           const int *   desca,
           const double *VL,
           const double *VU,
           const int *   il,
           const int *   iu,
           const double *abstol,
           const int *   m,
           const int *   nz,
           double *      w,
           double *      orfac,
           double *      Z,
           const int *   iz,
           const int *   jz,
           const int *   descz,
           double *      work,
           int *         lwork,
           int *         iwork,
           int *         liwork,
           int *         ifail,
           int *         iclustr,
           double *      gap,
            int * info);

    double
    pdlamch_(const int *ictxt, const char *cmach);
}

int main(int argc, char **argv)
{
  int mpirank,nprocs;
  MPI_Init(&amp;amp;argc, &amp;amp;argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &amp;amp;mpirank);
  MPI_Comm_size(MPI_COMM_WORLD, &amp;amp;nprocs);
  const char uplo('L');
  const int first_process_row(0);
  const int first_process_column(0);

  const bool mpiroot = (mpirank == 0);

  /* Scalapack / Blacs Vars */
  const int N = 200, Nb = 32;
  int M = N, Mb = Nb;

  if (mpiroot)
    cout &amp;lt;&amp;lt; "Running with N=" &amp;lt;&amp;lt; N &amp;lt;&amp;lt; " Nb=" &amp;lt;&amp;lt; Nb &amp;lt;&amp;lt; std::endl;

  int procrows = 0, proccols = 0;
  {
    const int n_processes_heuristic = int(std::ceil((1.*N)/Nb))*
                                      int(std::ceil((1.*M)/Mb));
    const int Np = std::min(n_processes_heuristic, nprocs);
    const double ratio = 1.0;
    const int Pc = std::sqrt(ratio * Np);
    proccols = std::min (Np, std::max(2, Pc));
    procrows = Np / proccols ;
  }

  /* Begin Cblas context */
  int ctxt = 0, myrow = 0, mycol = 0, numproc = nprocs;
  // Cblacs_pinfo(&amp;amp;myid, &amp;amp;numproc);
  Cblacs_get(0, 0, &amp;amp;ctxt);
  Cblacs_gridinit(&amp;amp;ctxt, "Row-major", procrows, proccols);
  Cblacs_gridinfo( ctxt, &amp;amp;procrows, &amp;amp;proccols, &amp;amp;myrow, &amp;amp;mycol );

  if (mpiroot)
    cout &amp;lt;&amp;lt; "Process grid " &amp;lt;&amp;lt; procrows &amp;lt;&amp;lt; "x"&amp;lt;&amp;lt;proccols &amp;lt;&amp;lt; "&amp;lt;=" &amp;lt;&amp;lt; numproc &amp;lt;&amp;lt; std::endl;

  if ((myrow &amp;gt; -1) &amp;amp;&amp;amp; (mycol &amp;gt; -1))
    {
      if (mpiroot)
        cout &amp;lt;&amp;lt; "setup..." &amp;lt;&amp;lt; std::endl;

      // we won't need eigenvectors, use a sufficiently small distributed matrix on the same process grid:
      const int N_B = procrows;
      const int M_B = procrows;
      const int Nb_B = 1;
      const int Mb_B = 1;

      const int nrows_B = numroc_(&amp;amp;N_B, &amp;amp;Nb_B, &amp;amp;myrow, &amp;amp;first_process_row, &amp;amp;procrows);
      const int ncols_B = numroc_(&amp;amp;M_B, &amp;amp;Mb_B, &amp;amp;mycol, &amp;amp;first_process_column, &amp;amp;proccols);
      const int lda_B = max(1,nrows_B);

      int info=0;
      int descB[9];
      descinit_(descB, &amp;amp;N_B, &amp;amp;M_B, &amp;amp;Nb_B, &amp;amp;Mb_B,&amp;amp;first_process_row,&amp;amp;first_process_column,&amp;amp;ctxt, &amp;amp;lda_B, &amp;amp;info);
      if (info != 0)
        cerr &amp;lt;&amp;lt; "error in descinit_" &amp;lt;&amp;lt; std::endl;

      std::vector&amp;lt;double&amp;gt; B(nrows_B*ncols_B);

      // set the matrix:
      const int nrows = numroc_(&amp;amp;N, &amp;amp;Nb, &amp;amp;myrow, &amp;amp;first_process_row, &amp;amp;procrows);
      const int ncols = numroc_(&amp;amp;M, &amp;amp;Mb, &amp;amp;mycol, &amp;amp;first_process_column, &amp;amp;proccols);

      const int lda = max(1,nrows);
      int descA[9];
      descinit_(descA, &amp;amp;N, &amp;amp;M, &amp;amp;Nb, &amp;amp;Mb,&amp;amp;first_process_row,&amp;amp;first_process_column,&amp;amp;ctxt, &amp;amp;lda, &amp;amp;info);
      if (info != 0)
        cerr &amp;lt;&amp;lt; "error in descinit_" &amp;lt;&amp;lt; std::endl;

      std::vector&amp;lt;double&amp;gt; A(nrows*ncols);

      // set to SPD
      {
        int seed = 13;
        srand(seed);
        std::vector&amp;lt;double&amp;gt; global_A(N*M);
        auto gind = [&amp;amp;] (const int row, const int col)
        {
          return col*M+row;
        };

        for (unsigned int c = 0; c &amp;lt; N; ++c)
          for (unsigned int r = c; r &amp;lt; M; ++r)
            {
              const double val = ((double) rand())/ ((double)RAND_MAX);
              if (r==c)
                global_A[gind(r,c)] = val + N;
              else
                {
                  global_A[gind(r,c)] = val;
                  global_A[gind(c,r)] = val;
                }
            }

        int k = 0;
        for (int c=1; c &amp;lt;= ncols; ++c)
          {
            const int glob_c = indxl2g_ (&amp;amp;c, &amp;amp;Nb, &amp;amp;mycol, &amp;amp;first_process_column, &amp;amp;proccols) - 1;
            for (int r = 1; r &amp;lt;= nrows; ++r)
              {
                const int glob_r = indxl2g_ (&amp;amp;r, &amp;amp;Mb, &amp;amp;myrow, &amp;amp;first_process_row, &amp;amp;procrows) - 1;
                A&lt;K&gt; = global_A[gind(glob_r,glob_c)];
                k++;
              }
          }
      }

      const int submatrix_row = 1;
      const int submatrix_column = 1;

      double *A_loc = &amp;amp;A[0];
      double *B_loc = &amp;amp;B[0];

      std::vector&amp;lt;double&amp;gt; ev(N);

      char jobz = 'N';
      char range = 'I';
      double vl = 0, vu = 0;
      int il = N-5, iu = N; // last 5 eigenvalues
      int nz = 0;
      double abstol = 0;
      double orfac = 0;
      std::vector&amp;lt;int&amp;gt; ifail;
      std::vector&amp;lt;int&amp;gt; iclustr;
      std::vector&amp;lt;double&amp;gt; gap(nrows*ncols);

      // get work sizes:
      int lwork = -1;
      int liwork = -1;
      double *eigenvectors_loc = nullptr; // won't need eigenvectors at all
      std::vector&amp;lt;double&amp;gt; work(1);
      std::vector&amp;lt;int&amp;gt; iwork(1);

      char cmach = 'S';
      abstol = pdlamch_(&amp;amp;ctxt, &amp;amp;cmach);
      abstol *= 2;
      ifail.resize(N);
      iclustr.resize(2*procrows*proccols);
      gap.resize(procrows*proccols);

      info = 0;
      if (mpiroot)
        cout &amp;lt;&amp;lt; "pdsyevx_..." &amp;lt;&amp;lt; std::endl;

      pdsyevx_(&amp;amp;jobz,
                 &amp;amp;range,
                 &amp;amp;uplo,
                 &amp;amp;N,
                 A_loc,
                 &amp;amp;submatrix_row,
                 &amp;amp;submatrix_column,
                 descA,
                 &amp;amp;vl,
                 &amp;amp;vu,
                 &amp;amp;il,
                 &amp;amp;iu,
                 &amp;amp;abstol,
                 &amp;amp;N,
                 &amp;amp;nz,
                 &amp;amp;ev[0],
                 &amp;amp;orfac,
                 eigenvectors_loc,
                 &amp;amp;submatrix_row,
                 &amp;amp;submatrix_column,
                 descB,
                 &amp;amp;work[0],
                 &amp;amp;lwork,
                 &amp;amp;iwork[0],
                 &amp;amp;liwork,
                 &amp;amp;ifail[0],
                 &amp;amp;iclustr[0],
                 &amp;amp;gap[0],
                 &amp;amp;info);

      if (info != 0)
        {
          cerr &amp;lt;&amp;lt; "error in pdpotrf_ " &amp;lt;&amp;lt; info &amp;lt;&amp;lt; std::endl;
          return 1;
        }

      if (mpiroot)
        std::cout &amp;lt;&amp;lt; "done!" &amp;lt;&amp;lt; std::endl;

      Cblacs_gridexit(ctxt);
    }
  MPI_Finalize();
}
&lt;/K&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 10:24:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146777#M26750</guid>
      <dc:creator>davydden1</dc:creator>
      <dc:date>2018-10-22T10:24:46Z</dc:date>
    </item>
    <item>
      <title>David, how did you run the</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146778#M26751</link>
      <description>&lt;P&gt;David, how did you run the code?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 02:28:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146778#M26751</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2018-10-23T02:28:20Z</dc:date>
    </item>
    <item>
      <title>Gennady, I run with 4 mpi</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146779#M26752</link>
      <description>&lt;P&gt;Gennady, I run with 4 mpi processes, but I am quite certain the extra message is there even with a single core run.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 06:48:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146779#M26752</guid>
      <dc:creator>davydden1</dc:creator>
      <dc:date>2018-10-23T06:48:22Z</dc:date>
    </item>
    <item>
      <title>David, yes the problem is</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146780#M26753</link>
      <description>&lt;P&gt;David, yes the problem is reproduced and escalated. We will check with ScaLapack team and inform you in the case of any updates from the team. thanks for report.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 10:42:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146780#M26753</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2018-10-23T10:42:08Z</dc:date>
    </item>
    <item>
      <title>MKL v.2020 has been released</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146781#M26754</link>
      <description>&lt;P&gt;MKL v.2020 has been released and contains the fix of this problem either.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2019 03:09:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-pdsyevx-when-calculating-some-eigenvalues-only/m-p/1146781#M26754</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2019-12-17T03:09:20Z</dc:date>
    </item>
  </channel>
</rss>

