<?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 Is that Ubuntu 5.4.0?  if, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078177#M22667</link>
    <description>&lt;P&gt;Is that Ubuntu 5.4.0?&amp;nbsp; if, yes, pls have a look at the system requirements - &lt;A href="https://software.intel.com/en-us/articles/intel-mkl-113-system-requirements"&gt;https://software.intel.com/en-us/articles/intel-mkl-113-system-requirements.&lt;/A&gt; You may see list of &lt;SPAN style="color: rgb(102, 102, 102); text-transform: none; line-height: 19.6px; text-indent: 0px; letter-spacing: normal; font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px;"&gt;Supported operating systems&amp;nbsp;: ...... Ubunty* 12.04, 13.10 and 14.04 .....&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Aug 2016 09:35:32 GMT</pubDate>
    <dc:creator>Gennady_F_Intel</dc:creator>
    <dc:date>2016-08-01T09:35:32Z</dc:date>
    <item>
      <title>Ubuntu mkl_set_num_threads ignored</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078176#M22666</link>
      <description>&lt;P&gt;Good afternoon!&lt;/P&gt;

&lt;P&gt;I have the following code:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;/*
********************************************************************************
*&amp;nbsp;&amp;nbsp; Copyright(C) 2004-2011 Intel Corporation. All Rights Reserved.
*&amp;nbsp;&amp;nbsp; 
*&amp;nbsp;&amp;nbsp; The source code, information&amp;nbsp; and&amp;nbsp; material ("Material") contained herein is
*&amp;nbsp;&amp;nbsp; owned&amp;nbsp; by Intel Corporation or its suppliers or licensors, and title to such
*&amp;nbsp;&amp;nbsp; Material remains&amp;nbsp; with Intel Corporation&amp;nbsp; or its suppliers or licensors. The
*&amp;nbsp;&amp;nbsp; Material&amp;nbsp; contains proprietary information&amp;nbsp; of&amp;nbsp; Intel or&amp;nbsp; its&amp;nbsp; suppliers and
*&amp;nbsp;&amp;nbsp; licensors. The&amp;nbsp; Material is protected by worldwide copyright laws and treaty
*&amp;nbsp;&amp;nbsp; provisions. No&amp;nbsp; part&amp;nbsp; of&amp;nbsp; the&amp;nbsp; Material&amp;nbsp; may&amp;nbsp; be&amp;nbsp; used,&amp;nbsp; copied, reproduced,
*&amp;nbsp;&amp;nbsp; modified, published, uploaded, posted, transmitted, distributed or disclosed
*&amp;nbsp;&amp;nbsp; in any way&amp;nbsp; without Intel's&amp;nbsp; prior&amp;nbsp; express written&amp;nbsp; permission. No&amp;nbsp; license
*&amp;nbsp;&amp;nbsp; under&amp;nbsp; any patent, copyright&amp;nbsp; or&amp;nbsp; other intellectual property rights&amp;nbsp; in the
*&amp;nbsp;&amp;nbsp; Material&amp;nbsp; is&amp;nbsp; granted&amp;nbsp; to&amp;nbsp; or&amp;nbsp; conferred&amp;nbsp; upon&amp;nbsp; you,&amp;nbsp; either&amp;nbsp; expressly,&amp;nbsp; by
*&amp;nbsp;&amp;nbsp; implication, inducement,&amp;nbsp; estoppel or&amp;nbsp; otherwise.&amp;nbsp; Any&amp;nbsp; license&amp;nbsp; under&amp;nbsp; such
*&amp;nbsp;&amp;nbsp; intellectual&amp;nbsp; property&amp;nbsp; rights must&amp;nbsp; be express&amp;nbsp; and&amp;nbsp; approved&amp;nbsp; by&amp;nbsp; Intel in
*&amp;nbsp;&amp;nbsp; writing.
*&amp;nbsp;&amp;nbsp; 
*&amp;nbsp;&amp;nbsp; *Third Party trademarks are the property of their respective owners.
*&amp;nbsp;&amp;nbsp; 
*&amp;nbsp;&amp;nbsp; Unless otherwise&amp;nbsp; agreed&amp;nbsp; by Intel&amp;nbsp; in writing, you may not remove&amp;nbsp; or alter
*&amp;nbsp;&amp;nbsp; this&amp;nbsp; notice or&amp;nbsp; any other notice embedded&amp;nbsp; in Materials by Intel or Intel's
*&amp;nbsp;&amp;nbsp; suppliers or licensors in any way.
*
********************************************************************************
*&amp;nbsp;&amp;nbsp; Content : Simple MKL Matrix Multiply C example
*
********************************************************************************/

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;time.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include "mkl.h"


void print_arr(int N, char * name, double* array);
void init_arr(int N, double* a);
void Dgemm_multiply(double* a,double*&amp;nbsp; b,double*&amp;nbsp; c, int N);
int num_threads=1;

int main(int argc, char* argv[])
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;
&amp;nbsp;clock_t start, stop;
&amp;nbsp;int N;
&amp;nbsp;double* a;
&amp;nbsp;double* b;
&amp;nbsp;double* c;
&amp;nbsp;if(argc &amp;lt; 2)
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;printf("No. of threads available is :%d\n",mkl_get_max_threads());
&amp;nbsp;&amp;nbsp;printf("Enter matrix size N=");
&amp;nbsp;&amp;nbsp;//please enter small number first to ensure that the 
&amp;nbsp;&amp;nbsp;//multiplication is correct! and then you may enter 
&amp;nbsp;&amp;nbsp;//a "reasonably" large number say like 500 or even 1000
&amp;nbsp;&amp;nbsp;scanf("%d",&amp;amp;N);
&amp;nbsp;&amp;nbsp;printf("Enter number of threads:");
&amp;nbsp;&amp;nbsp;scanf("%d",&amp;amp;num_threads);
&amp;nbsp;
&amp;nbsp;}
&amp;nbsp;else
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;N = atoi(argv[1]);
&amp;nbsp;&amp;nbsp;num_threads = atoi(argv[2]);

&amp;nbsp;}
&amp;nbsp;mkl_set_num_threads(num_threads);

&amp;nbsp;a=(double*) malloc( sizeof(double)*N*N );
&amp;nbsp;b=(double*) malloc( sizeof(double)*N*N );
&amp;nbsp;c=(double*) malloc( sizeof(double)*N*N );

&amp;nbsp;init_arr(N,a);
&amp;nbsp;init_arr(N,b);

&amp;nbsp;//DGEMM Multiply
&amp;nbsp;//reallocate to force cash to be flushed
&amp;nbsp;a=(double*) malloc( sizeof(double)*N*N );
&amp;nbsp;b=(double*) malloc( sizeof(double)*N*N );
&amp;nbsp;c=(double*) malloc( sizeof(double)*N*N );
&amp;nbsp;init_arr(N,a);
&amp;nbsp;init_arr(N,b);

&amp;nbsp;start = clock();
&amp;nbsp;Dgemm_multiply(a,b,c,N);
&amp;nbsp;stop = clock();

&amp;nbsp;printf("Dgemm_multiply(). Elapsed time = %g seconds using %d threads\n",
&amp;nbsp;&amp;nbsp;((double)(stop - start)) / CLOCKS_PER_SEC, num_threads);
&amp;nbsp;//print simple test case of data to be sure multiplication is correct
&amp;nbsp;if (N &amp;lt; 7) {
&amp;nbsp;&amp;nbsp;print_arr(N,"a", a);
&amp;nbsp;&amp;nbsp;print_arr(N,"b", b);
&amp;nbsp;&amp;nbsp;print_arr(N,"c", c);
&amp;nbsp;}

&amp;nbsp;free(a);
&amp;nbsp;free(b);
&amp;nbsp;free(c);

&amp;nbsp;return 0;
}


//DGEMM way. The PREFERED way, especially for large matrices
void Dgemm_multiply(double* a,double*&amp;nbsp; b,double*&amp;nbsp; c, int N)
{&amp;nbsp;

&amp;nbsp;double alpha = 1.0, beta = 0.;
&amp;nbsp;int incx = 1;
&amp;nbsp;int incy = N;
&amp;nbsp;cblas_dgemm(CblasRowMajor,CblasNoTrans,CblasNoTrans,N,N,N,alpha,b,N,a,N,beta,c,N);
}

//initialize array with random data
void init_arr(int N, double* a)
{&amp;nbsp;
&amp;nbsp;int i,j;
&amp;nbsp;for (i=0; i&amp;lt; N;i++) {
&amp;nbsp;&amp;nbsp;for (j=0; j&amp;lt;N;j++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;a[i*N+j] = (i+j+1)%10; //keep all entries less than 10. pleasing to the eye!
&amp;nbsp;&amp;nbsp;}
&amp;nbsp;}
}

//print array to std out
void print_arr(int N, char * name, double* array)
{&amp;nbsp;
&amp;nbsp;int i,j;&amp;nbsp;
&amp;nbsp;printf("\n%s\n",name);
&amp;nbsp;for (i=0;i&amp;lt;N;i++){
&amp;nbsp;&amp;nbsp;for (j=0;j&amp;lt;N;j++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;printf("%g\t",array[N*i+j]);
&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;printf("\n");
&amp;nbsp;}
}
&lt;/PRE&gt;

&lt;P&gt;The compilation command is following:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;gcc -m64 -O2 -mpc80 -march=core2 mkl_lab_solution2.cpp -o test1&amp;nbsp; -I/opt/intel/mkl/include -Wl,--start-group /opt/intel/mkl/lib/intel64/libmkl_int
el_lp64.a /opt/intel/mkl/lib/intel64/libmkl_core.a /opt/intel/mkl/lib/intel64/libmkl_intel_thread.a /opt/intel/parallel_studio_xe_2016.3.067/compilers_and_libraries_2016/li
nux/compiler/lib/intel64/libiomp5.a&amp;nbsp; -Wl,--end-group -lm -ldl -lpthread -static-libstdc++ -w &lt;/PRE&gt;

&lt;P&gt;When I run the program I obtain the following results:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;user@ubuntu1:~/cpp/openmp$ ./test1 4096 1
Dgemm_multiply(). Elapsed time = 6.79888 seconds using 1 threads
user@ubuntu1:~/cpp/openmp$ ./test1 4096 2
Dgemm_multiply(). Elapsed time = 6.84065 seconds using 2 threads
user@ubuntu1:~/cpp/openmp$ ./test1 4096 2&lt;/PRE&gt;

&lt;P&gt;In Windows 10 using C++&amp;nbsp; from&amp;nbsp;Visual Studio 2015&amp;nbsp;and the same program I obtain:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;No. of threads available is :6
Enter matrix size N=4096
Enter number of threads:1
Dgemm_multiply(). Elapsed time = 10.803 seconds using 1 threads


No. of threads available is :6
Enter matrix size N=4096
Enter number of threads:2
Dgemm_multiply(). Elapsed time = 5.647 seconds using 2 threads​
&lt;/PRE&gt;

&lt;P&gt;The results of &lt;EM&gt;gcc -v &lt;/EM&gt;is :&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;user@ubuntu1:~/cpp/openmp$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.1' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,ja
va,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=po
six --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-
unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=
/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-
amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --w
ith-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.1) &lt;/PRE&gt;

&lt;P&gt;How obtain the same scaling in Ubuntu as in Windows?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 05:46:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078176#M22666</guid>
      <dc:creator>Ion_C_</dc:creator>
      <dc:date>2016-08-01T05:46:57Z</dc:date>
    </item>
    <item>
      <title>Is that Ubuntu 5.4.0?  if,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078177#M22667</link>
      <description>&lt;P&gt;Is that Ubuntu 5.4.0?&amp;nbsp; if, yes, pls have a look at the system requirements - &lt;A href="https://software.intel.com/en-us/articles/intel-mkl-113-system-requirements"&gt;https://software.intel.com/en-us/articles/intel-mkl-113-system-requirements.&lt;/A&gt; You may see list of &lt;SPAN style="color: rgb(102, 102, 102); text-transform: none; line-height: 19.6px; text-indent: 0px; letter-spacing: normal; font-family: Arial, Tahoma, Helvetica, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px;"&gt;Supported operating systems&amp;nbsp;: ...... Ubunty* 12.04, 13.10 and 14.04 .....&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 09:35:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078177#M22667</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2016-08-01T09:35:32Z</dc:date>
    </item>
    <item>
      <title>It's Ubuntu 16.04 with gcc 5</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078178#M22668</link>
      <description>&lt;P&gt;It's Ubuntu 16.04 with gcc 5.4.0&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 09:47:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078178#M22668</guid>
      <dc:creator>asd__asdqwe</dc:creator>
      <dc:date>2016-08-01T09:47:02Z</dc:date>
    </item>
    <item>
      <title>It is Ubuntu 16.04 server</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078179#M22669</link>
      <description>It is Ubuntu 16.04 server with gcc 5.4.0. But how control the  CPU scaling?
I have a C++ program which uses Intel MKL library in Amazon AWS Cloud and I need multicore support.</description>
      <pubDate>Mon, 01 Aug 2016 10:03:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078179#M22669</guid>
      <dc:creator>Ion_C_</dc:creator>
      <dc:date>2016-08-01T10:03:17Z</dc:date>
    </item>
    <item>
      <title>Hello,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078180#M22670</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I just compiled using the exact same configuration and got same result from comand line, 2 threads taking same time or even longer than 1 thread.&lt;/P&gt;

&lt;P&gt;So I used VTune to compare both executions, VTune pointed that the option with 2 threads run almost twice faster than 1 thread option ... so I found the answer:&lt;/P&gt;

&lt;P&gt;Looks like the clock function in linux&amp;nbsp; counts the time for each individual core usage, so the "real" time and and the user time are different things, you can refer to the result below:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;$&amp;gt; time ./test1 5000 1

Dgemm_multiply(). Elapsed time = 11.8785 seconds using 1 threads

real    0m12.222s
user    0m12.076s
sys    0m0.144s

$&amp;gt; time ./test1 5000 2
Dgemm_multiply(). Elapsed time = 14.0519 seconds using 2 threads

real    0m7.468s
user    0m14.276s
sys    0m0.156s&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 02:52:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Ubuntu-mkl-set-num-threads-ignored/m-p/1078180#M22670</guid>
      <dc:creator>George_Silva_Intel</dc:creator>
      <dc:date>2016-08-05T02:52:00Z</dc:date>
    </item>
  </channel>
</rss>

