<?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 Using Intel MKL with R (Similar to MATLAB Implementation) in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-Intel-MKL-with-R-Similar-to-MATLAB-Implementation/m-p/1520165#M35031</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've been using the Intel MKL library in MATLAB successfully to optimize a time-consuming subfunction. To do this, I set up the compiler and flags in MATLAB using the following commands:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;mex -setup
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020\windows

mex -v -g example.c -I"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020\windows\mkl\include" -L"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020\windows\mkl\lib\intel64" -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lmkl_cd&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I'm looking to achieve the same optimization in R, but I'm unsure of how to set up the Intel MKL library and compiler in R for a similar purpose.&amp;nbsp;&lt;SPAN&gt;I've installed Intel oneAPI and&amp;nbsp; I've followed the following steps to set up my environment:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Path to the Intel oneAPI toolkit 
oneapi_dir &amp;lt;- "C:/Program Files (x86)/Intel/oneAPI"
mkl_include_dir &amp;lt;- file.path(oneapi_dir, "mkl", "latest", "include")
mkl_lib_dir &amp;lt;- file.path(oneapi_dir, "mkl", "latest", "lib", "intel64")

# C code file
c_code_file &amp;lt;- "C:\\Users\\Desktop\\example.c"

#
output_executable &amp;lt;- "my_program"

# Define the compilation command with the output executable name
compile_command &amp;lt;- paste(
"icc -o", output_executable,
c_code_file,
paste("-I", mkl_include_dir, collapse = " "),
paste("-L", mkl_lib_dir, collapse = " "),
"-lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lmkl_cdft_core -lmkl_intel_thread -qopenmp"
)

# Compile the C code
system(compile_command)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However, when I run this script in R I get this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;system(compile_command)
[1] 127&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The c-code is:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;mkl.h&amp;gt;

int main() {
    // Define vector size and variables
    int n = 1000;
    double *x, *y;
    double result;

    // Allocate memory for the vectors
    x = (double*)malloc(n * sizeof(double));
    y = (double*)malloc(n * sizeof(double));

    // Initialize the vectors with some data (you can modify this)
    for (int i = 0; i &amp;lt; n; i++) {
        x[i] = i + 1.0;
        y[i] = 2.0 * (i + 1.0);
    }

    // Calculate the dot product of the vectors using MKL
    result = cblas_ddot(n, x, 1, y, 1);

    // Print the result
    printf("Dot product: %lf\n", result);

    // Free allocated memory
    free(x);
    free(y);

    return 0;
}&lt;/LI-CODE&gt;&lt;P&gt;Could someone please guide me on the equivalent steps to perform this in R? I'm particularly interested in how to configure R to use the Intel compiler and link to the MKL library.&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
    <pubDate>Mon, 04 Sep 2023 06:36:56 GMT</pubDate>
    <dc:creator>Maraki</dc:creator>
    <dc:date>2023-09-04T06:36:56Z</dc:date>
    <item>
      <title>Using Intel MKL with R (Similar to MATLAB Implementation)</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-Intel-MKL-with-R-Similar-to-MATLAB-Implementation/m-p/1520165#M35031</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've been using the Intel MKL library in MATLAB successfully to optimize a time-consuming subfunction. To do this, I set up the compiler and flags in MATLAB using the following commands:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;mex -setup
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020\windows

mex -v -g example.c -I"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020\windows\mkl\include" -L"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2020\windows\mkl\lib\intel64" -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lmkl_cd&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I'm looking to achieve the same optimization in R, but I'm unsure of how to set up the Intel MKL library and compiler in R for a similar purpose.&amp;nbsp;&lt;SPAN&gt;I've installed Intel oneAPI and&amp;nbsp; I've followed the following steps to set up my environment:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Path to the Intel oneAPI toolkit 
oneapi_dir &amp;lt;- "C:/Program Files (x86)/Intel/oneAPI"
mkl_include_dir &amp;lt;- file.path(oneapi_dir, "mkl", "latest", "include")
mkl_lib_dir &amp;lt;- file.path(oneapi_dir, "mkl", "latest", "lib", "intel64")

# C code file
c_code_file &amp;lt;- "C:\\Users\\Desktop\\example.c"

#
output_executable &amp;lt;- "my_program"

# Define the compilation command with the output executable name
compile_command &amp;lt;- paste(
"icc -o", output_executable,
c_code_file,
paste("-I", mkl_include_dir, collapse = " "),
paste("-L", mkl_lib_dir, collapse = " "),
"-lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lmkl_cdft_core -lmkl_intel_thread -qopenmp"
)

# Compile the C code
system(compile_command)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However, when I run this script in R I get this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;system(compile_command)
[1] 127&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The c-code is:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;mkl.h&amp;gt;

int main() {
    // Define vector size and variables
    int n = 1000;
    double *x, *y;
    double result;

    // Allocate memory for the vectors
    x = (double*)malloc(n * sizeof(double));
    y = (double*)malloc(n * sizeof(double));

    // Initialize the vectors with some data (you can modify this)
    for (int i = 0; i &amp;lt; n; i++) {
        x[i] = i + 1.0;
        y[i] = 2.0 * (i + 1.0);
    }

    // Calculate the dot product of the vectors using MKL
    result = cblas_ddot(n, x, 1, y, 1);

    // Print the result
    printf("Dot product: %lf\n", result);

    // Free allocated memory
    free(x);
    free(y);

    return 0;
}&lt;/LI-CODE&gt;&lt;P&gt;Could someone please guide me on the equivalent steps to perform this in R? I'm particularly interested in how to configure R to use the Intel compiler and link to the MKL library.&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2023 06:36:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-Intel-MKL-with-R-Similar-to-MATLAB-Implementation/m-p/1520165#M35031</guid>
      <dc:creator>Maraki</dc:creator>
      <dc:date>2023-09-04T06:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using Intel MKL with R (Similar to MATLAB Implementation)</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-Intel-MKL-with-R-Similar-to-MATLAB-Implementation/m-p/1521584#M35063</link>
      <description>&lt;P&gt;Hi Maraki,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for posting in Intel communities. Thanks for elaborating on your issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have tried running the shared code and below is the result.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dot product: 667667000.000000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please refer to the below links for compiling R code with MKL, extended support, and other linking-related details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How to use the BLAS and LAPACK libraries within Intel® oneAPI Math Kernel Library (oneMKL)&amp;nbsp;to improve the performance of R.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.intel.com/content/www/us/en/developer/articles/technical/using-onemkl-with-r.html" target="_blank" rel="noopener"&gt;https://www.intel.com/content/www/us/en/developer/articles/technical/using-onemkl-with-r.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other important data which might be useful to you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Building R with the Intel® Math Kernel Library (Intel® MKL)&amp;nbsp;BLAS and LAPACK to improve the performance of those parts of R that rely on matrix computations.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://www.intel.com/content/www/us/en/developer/articles/technical/extending-r-with-intel-mkl.html" target="_blank" rel="noopener"&gt;https://www.intel.com/content/www/us/en/developer/articles/technical/extending-r-with-intel-mkl.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Linking Intel MKL to R&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.intel.com/content/www/us/en/developer/articles/technical/quick-linking-intel-mkl-blas-lapack-to-r.html" target="_blank" rel="noopener"&gt;https://www.intel.com/content/www/us/en/developer/articles/technical/quick-linking-intel-mkl-blas-lapack-to-r.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please get back to us with the MKL version being used and your findings for the code being used by you?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Shanmukh.SS&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>Thu, 21 Sep 2023 09:12:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-Intel-MKL-with-R-Similar-to-MATLAB-Implementation/m-p/1521584#M35063</guid>
      <dc:creator>ShanmukhS_Intel</dc:creator>
      <dc:date>2023-09-21T09:12:12Z</dc:date>
    </item>
    <item>
      <title>Re:Using Intel MKL with R (Similar to MATLAB Implementation)</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-Intel-MKL-with-R-Similar-to-MATLAB-Implementation/m-p/1523692#M35122</link>
      <description>&lt;P&gt;Hi Maraki,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;A gentle reminder:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Has the information provided helped? Could you please get back to us if you have any updates on your issue?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Shanmukh.SS&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Sep 2023 10:53:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-Intel-MKL-with-R-Similar-to-MATLAB-Implementation/m-p/1523692#M35122</guid>
      <dc:creator>ShanmukhS_Intel</dc:creator>
      <dc:date>2023-09-14T10:53:45Z</dc:date>
    </item>
    <item>
      <title>Re:Using Intel MKL with R (Similar to MATLAB Implementation)</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-Intel-MKL-with-R-Similar-to-MATLAB-Implementation/m-p/1526154#M35155</link>
      <description>&lt;P&gt;Hi Maraki,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;A gentle reminder:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Has the information provided helped? Could you please get back to us if you have any updates on your issue?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Shanmukh.SS&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Sep 2023 09:12:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-Intel-MKL-with-R-Similar-to-MATLAB-Implementation/m-p/1526154#M35155</guid>
      <dc:creator>ShanmukhS_Intel</dc:creator>
      <dc:date>2023-09-21T09:12:49Z</dc:date>
    </item>
  </channel>
</rss>

