<?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 Re: problem with multi-threading in pardiso in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-multi-threading-in-pardiso/m-p/852127#M6640</link>
    <description>Hi jj,&lt;BR /&gt;&lt;BR /&gt;We aresorry for the late reply. &lt;BR /&gt;&lt;BR /&gt;I believe there're no problems with threading into your application. In fact, progress routine returns information only for the master thread, but it does not mean that PARDISO uses only a single thread inside.&lt;BR /&gt;&lt;BR /&gt;In order to be sure, please set msglvl=1 into your main program. You should find a string like this one into your output:&lt;BR /&gt;&lt;BR /&gt;&amp;lt; Parallel Direct Factorization with #processors: &amp;gt; 4&lt;BR /&gt;&lt;BR /&gt;This is an actual number of threads used in PARDISO.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Konstantin</description>
    <pubDate>Fri, 17 Jul 2009 05:53:17 GMT</pubDate>
    <dc:creator>Konstantin_A_Intel</dc:creator>
    <dc:date>2009-07-17T05:53:17Z</dc:date>
    <item>
      <title>problem with multi-threading in pardiso</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-multi-threading-in-pardiso/m-p/852126#M6639</link>
      <description>I am not able to use multi-threading in pardiso. The following is the code I used in the program. In the solver progress message, I always get to use only thread 0. such as "In thread 0, at stage Pardiso: factor, steps passed (some percentage)". The matrix I used is huge and pardiso should use multi-threaded solver in my dual-core macbook pro (vista os). I am linking the program to pardiso using " mkl_intel_c.lib mkl_intel_thread.lib mkl_core.lib libguide40.lib". What else do I need to do in order to make use of multi-threaded pardiso solver.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;jj&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// testIntelParallel.cpp : Defines the entry point for the console application.&lt;BR /&gt;//&lt;BR /&gt;#include "stdafx.h"&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;MATH.H&gt;&lt;BR /&gt;#include &lt;WINDOWS.H&gt;&lt;BR /&gt;#include &lt;VECTOR&gt;&lt;BR /&gt;#include &lt;MAP&gt;&lt;BR /&gt;#include &lt;FSTREAM&gt;&lt;BR /&gt;using namespace std;&lt;BR /&gt;&lt;BR /&gt;// libguide40.lib is for dynamically linked OpenMP (threading)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/* PARDISO prototype. */&lt;BR /&gt;#if defined(_WIN32) || defined(_WIN64)&lt;BR /&gt;#define pardiso_ PARDISO&lt;BR /&gt;#else&lt;BR /&gt;#define PARDISO pardiso_&lt;BR /&gt;#endif&lt;BR /&gt;#if defined(MKL_ILP64)&lt;BR /&gt;#define MKL_INT long long&lt;BR /&gt;#else&lt;BR /&gt;#define MKL_INT int&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;extern "C" int mkl_get_max_threads();&lt;BR /&gt;extern "C" void MKL_Set_Num_Threads( int number );&lt;BR /&gt;&lt;BR /&gt;extern "C"  MKL_INT PARDISO&lt;BR /&gt;(void *, MKL_INT *, MKL_INT *, MKL_INT *, MKL_INT *, MKL_INT *,&lt;BR /&gt; double *, MKL_INT *, MKL_INT *, MKL_INT *, MKL_INT *, MKL_INT *,&lt;BR /&gt; MKL_INT *, double *, double *, MKL_INT *);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#define BUFLEN 16&lt;BR /&gt;extern "C" int MKL_PROGRESS( int* ithr, int* step, char* stage, int len )&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt; char buf[BUFLEN];&lt;BR /&gt;&lt;BR /&gt; if( len &amp;gt;= BUFLEN ) len = BUFLEN-1;&lt;BR /&gt;&lt;BR /&gt; strncpy( buf, stage, len );&lt;BR /&gt;&lt;BR /&gt; buf[len] = '\0';&lt;BR /&gt;&lt;BR /&gt; printf( "In thread %i, at stage %s, steps passed %i\n", *ithr, buf, *step );&lt;BR /&gt;&lt;BR /&gt; return 0;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;void test(int&amp;amp; nEqns, double*&amp;amp; values, int*&amp;amp; rowIndex, int*&amp;amp; columns, double*&amp;amp; rhs)&lt;BR /&gt;{&lt;BR /&gt; std::ifstream fileIn( "c:\\test.m", std::ios::binary );&lt;BR /&gt; if(std::ios::failbit &amp;amp; fileIn.rdstate()) {&lt;BR /&gt; return;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; fileIn.read( (char *) &amp;amp;nEqns, sizeof(int) );&lt;BR /&gt; rowIndex = new int[nEqns + 1];&lt;BR /&gt; fileIn.read( (char *) rowIndex, sizeof(int) *  (nEqns + 1));&lt;BR /&gt;&lt;BR /&gt; int nNonzeros = rowIndex[nEqns];&lt;BR /&gt; values = new double[nNonzeros];&lt;BR /&gt; columns = new int[nNonzeros];&lt;BR /&gt; rhs = new double[nEqns];&lt;BR /&gt;&lt;BR /&gt; fileIn.read( (char *) values, sizeof(double) *  nNonzeros);&lt;BR /&gt; fileIn.read( (char *) columns, sizeof(int) *  nNonzeros);&lt;BR /&gt; fileIn.read( (char *) rhs, sizeof(double) *  nEqns);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;MKL_INT main( void ) {&lt;BR /&gt;&lt;BR /&gt; MKL_INT nEqns;&lt;BR /&gt; MKL_INT nNonZeros;&lt;BR /&gt; double* a = 0;&lt;BR /&gt; int* ia = 0;&lt;BR /&gt; int* ja = 0;&lt;BR /&gt; double* b = 0;&lt;BR /&gt; double* x = 0;&lt;BR /&gt;&lt;BR /&gt; printf("construct stiffness matrix\n");&lt;BR /&gt;&lt;BR /&gt; test(nEqns, a, ia, ja, b);&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt; MKL_INT n = nEqns;&lt;BR /&gt;&lt;BR /&gt; x = new double[nEqns];&lt;BR /&gt; &lt;BR /&gt; printf("number of equations  = %d\n", nEqns);&lt;BR /&gt;&lt;BR /&gt; printf("number of CPUs  = %d\n", mkl_get_max_threads());&lt;BR /&gt; MKL_Set_Num_Threads(mkl_get_max_threads());  // multiple threads&lt;BR /&gt;&lt;BR /&gt; //MKL_INT mtype = -2; /* Real symmetric matrix */&lt;BR /&gt; MKL_INT mtype = 2; /* Positive Definite */&lt;BR /&gt; MKL_INT nrhs = 1; /* Number of right hand sides. */&lt;BR /&gt; /* Internal solver memory pointer pt, */&lt;BR /&gt; /* 32-bit: int pt[64]; 64-bit: long int pt[64] */&lt;BR /&gt; /* or void *pt[64] should be OK on both architectures */&lt;BR /&gt; void *pt[64];&lt;BR /&gt; /* Pardiso control parameters. */&lt;BR /&gt; MKL_INT iparm[64];&lt;BR /&gt; MKL_INT maxfct, mnum, phase, error, msglvl;&lt;BR /&gt; /* Auxiliary variables. */&lt;BR /&gt; MKL_INT i;&lt;BR /&gt; double ddum; /* Double dummy */&lt;BR /&gt; MKL_INT idum; /* Integer dummy. */&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; /* .. Setup Pardiso control parameters. */&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; for (i = 0; i &amp;lt; 64; i++) {&lt;BR /&gt; iparm&lt;I&gt; = 0;&lt;BR /&gt; }&lt;BR /&gt; iparm[0] = 1; /* No solver default */&lt;BR /&gt; iparm[1] = 2; /* Fill-in reordering from METIS */&lt;BR /&gt; /* Numbers of processors, value of MKL_NUM_THREADS  */&lt;BR /&gt; iparm[2] = mkl_get_max_threads();&lt;BR /&gt; iparm[3] = 0; /* No iterative-direct algorithm */&lt;BR /&gt; iparm[4] = 0; /* No user fill-in reducing permutation */&lt;BR /&gt; iparm[5] = 0; /* Write solution into x */&lt;BR /&gt; iparm[6] = 0; /* Not in use */&lt;BR /&gt; iparm[7] = 2; /* Max numbers of iterative refinement steps */&lt;BR /&gt; iparm[8] = 0; /* Not in use */&lt;BR /&gt; iparm[9] = 13; /* Perturb the pivot elements with 1E-13 */&lt;BR /&gt; iparm[10] = 1; /* Use nonsymmetric permutation and scaling MPS */&lt;BR /&gt; iparm[11] = 0; /* Not in use */&lt;BR /&gt; iparm[12] = 0; /* Maximum weighted matching algorithm is switched-off (default for symmetric). Try iparm[12] = 1 in case of inappropriate accuracy */&lt;BR /&gt; iparm[13] = 0; /* Output: Number of perturbed pivots */&lt;BR /&gt; iparm[14] = 0; /* Not in use */&lt;BR /&gt; iparm[15] = 0; /* Not in use */&lt;BR /&gt; iparm[16] = 0; /* Not in use */&lt;BR /&gt; iparm[17] = -1; /* Output: Number of nonzeros in the factor LU */&lt;BR /&gt; iparm[18] = -1; /* Output: Mflops for LU factorization */&lt;BR /&gt; iparm[19] = 0; /* Output: Numbers of CG Iterations */&lt;BR /&gt; maxfct = 1; /* Maximum number of numerical factorizations. */&lt;BR /&gt; mnum = 1; /* Which factorization to use. */&lt;BR /&gt; msglvl = 0; /* Print statistical information in file */&lt;BR /&gt; error = 0; /* Initialize error flag */&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; /* .. Initialize the internal solver memory pointer. This is only */&lt;BR /&gt; /* necessary for the FIRST call of the PARDISO solver. */&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; for (i = 0; i &amp;lt; 64; i++) {&lt;BR /&gt; pt&lt;I&gt; = 0;&lt;BR /&gt; }&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; /* .. Reordering and Symbolic Factorization. This step also allocates */&lt;BR /&gt; /* all memory that is necessary for the factorization. */&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; phase = 11;&lt;BR /&gt; PARDISO (pt, &amp;amp;maxfct, &amp;amp;mnum, &amp;amp;mtype, &amp;amp;phase, &amp;amp;n, a, ia, ja, &amp;amp;idum, &amp;amp;nrhs, iparm, &amp;amp;msglvl, &amp;amp;ddum, &amp;amp;ddum, &amp;amp;error);&lt;BR /&gt; if (error != 0) {&lt;BR /&gt; printf("\nERROR during symbolic factorization: %d", error);&lt;BR /&gt; exit(1);&lt;BR /&gt; }&lt;BR /&gt; printf("\nReordering completed ... ");&lt;BR /&gt; printf("\nNumber of nonzeros in factors = %d", iparm[17]);&lt;BR /&gt; printf("\nNumber of factorization MFLOPS = %d", iparm[18]);&lt;BR /&gt;&lt;BR /&gt; printf("\n************************************************************************************");&lt;BR /&gt; DWORD t1 = timeGetTime();&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; /* .. Numerical factorization. */&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; phase = 22;&lt;BR /&gt; PARDISO (pt, &amp;amp;maxfct, &amp;amp;mnum, &amp;amp;mtype, &amp;amp;phase, &amp;amp;n, a, ia, ja, &amp;amp;idum, &amp;amp;nrhs, iparm, &amp;amp;msglvl, &amp;amp;ddum, &amp;amp;ddum, &amp;amp;error);&lt;BR /&gt; if (error != 0) {&lt;BR /&gt; printf("\nERROR during numerical factorization: %d\n", error);&lt;BR /&gt; exit(2);&lt;BR /&gt; }&lt;BR /&gt; printf("\nFactorization completed ... ");&lt;BR /&gt;&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; /* .. Back substitution and iterative refinement. */&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; phase = 33;&lt;BR /&gt; iparm[7] = 2; /* Max numbers of iterative refinement steps. */&lt;BR /&gt;&lt;BR /&gt; FILE* fp;&lt;BR /&gt; fp=fopen("c:\\sol.txt","w");&lt;BR /&gt;&lt;BR /&gt; PARDISO (pt, &amp;amp;maxfct, &amp;amp;mnum, &amp;amp;mtype, &amp;amp;phase, &amp;amp;n, a, ia, ja, &amp;amp;idum, &amp;amp;nrhs, iparm, &amp;amp;msglvl, b, x, &amp;amp;error);&lt;BR /&gt; if (error != 0) {&lt;BR /&gt; printf("\nERROR during solution: %d\n", error);&lt;BR /&gt; exit(3);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; DWORD t2 = timeGetTime();&lt;BR /&gt; printf("\nSolve completed ... ");&lt;BR /&gt; printf("\n************************************************************************ time spent %d ... ", t2 - t1);&lt;BR /&gt; printf("\nThe solution of the system is: ");&lt;BR /&gt;&lt;BR /&gt; for (i = 0; i &amp;lt; n; i++) {&lt;BR /&gt; fprintf(fp, "\n x [%d] = %g", i, x&lt;I&gt; );&lt;BR /&gt; }&lt;BR /&gt; printf ("\n");&lt;BR /&gt;&lt;BR /&gt; fclose(fp);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; /* .. Termination and release of memory. */&lt;BR /&gt; /* -------------------------------------------------------------------- */&lt;BR /&gt; phase = -1; /* Release internal memory. */&lt;BR /&gt; PARDISO (pt, &amp;amp;maxfct, &amp;amp;mnum, &amp;amp;mtype, &amp;amp;phase, &amp;amp;n, &amp;amp;ddum, ia, ja, &amp;amp;idum, &amp;amp;nrhs, iparm, &amp;amp;msglvl, &amp;amp;ddum, &amp;amp;ddum, &amp;amp;error);&lt;BR /&gt;&lt;BR /&gt; delete []a;&lt;BR /&gt; delete []ia;&lt;BR /&gt; delete []ja;&lt;BR /&gt; delete []b;&lt;BR /&gt; delete []x;&lt;BR /&gt;&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/FSTREAM&gt;&lt;/MAP&gt;&lt;/VECTOR&gt;&lt;/WINDOWS.H&gt;&lt;/MATH.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Sun, 01 Feb 2009 04:59:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-multi-threading-in-pardiso/m-p/852126#M6639</guid>
      <dc:creator>jjforest</dc:creator>
      <dc:date>2009-02-01T04:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: problem with multi-threading in pardiso</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-multi-threading-in-pardiso/m-p/852127#M6640</link>
      <description>Hi jj,&lt;BR /&gt;&lt;BR /&gt;We aresorry for the late reply. &lt;BR /&gt;&lt;BR /&gt;I believe there're no problems with threading into your application. In fact, progress routine returns information only for the master thread, but it does not mean that PARDISO uses only a single thread inside.&lt;BR /&gt;&lt;BR /&gt;In order to be sure, please set msglvl=1 into your main program. You should find a string like this one into your output:&lt;BR /&gt;&lt;BR /&gt;&amp;lt; Parallel Direct Factorization with #processors: &amp;gt; 4&lt;BR /&gt;&lt;BR /&gt;This is an actual number of threads used in PARDISO.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Konstantin</description>
      <pubDate>Fri, 17 Jul 2009 05:53:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/problem-with-multi-threading-in-pardiso/m-p/852127#M6640</guid>
      <dc:creator>Konstantin_A_Intel</dc:creator>
      <dc:date>2009-07-17T05:53:17Z</dc:date>
    </item>
  </channel>
</rss>

