<?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 Hello, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/cblas-sgemm-pack-result-is-not-consistent-with-cblas-gemm/m-p/1130115#M25542</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Since A is already packed, please specify CblasPacked instead of CblasNoTrans.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; cblas_sgemm_compute(CblasRowMajor, CblasPacked, CblasNoTrans, m, n, k, packA, lda, b, ldb, beta, c, ldc);&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Sep 2017 17:44:32 GMT</pubDate>
    <dc:creator>Kazushige_G_Intel</dc:creator>
    <dc:date>2017-09-25T17:44:32Z</dc:date>
    <item>
      <title>cblas_sgemm_pack result is not consistent with cblas_gemm</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/cblas-sgemm-pack-result-is-not-consistent-with-cblas-gemm/m-p/1130114#M25541</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I wrote a short code to call sgemm_pack to speed up. But the result is not consistent with cblas_sgemm.&lt;/P&gt;

&lt;P&gt;For example,&lt;/P&gt;

&lt;P&gt;Matrix A (2 x 2): [1.0, 2.0, 3.0, 4.0]&lt;/P&gt;

&lt;P&gt;Matrix B (2 x 1): [1.0, 2.0]&lt;/P&gt;

&lt;P&gt;With the row major, Matrix C (2 x 1) = A * B = [5, 11]. But with sgemm_pack + sgemm_compute, the result is [0.0, 0.0].&lt;/P&gt;

&lt;P&gt;Could you please take a look. Any advice is welcomed.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;---&lt;/P&gt;

&lt;P&gt;Environments: I use parallel &amp;nbsp;studio xe. the version is&amp;nbsp;2017.1.132.&lt;/P&gt;

&lt;P&gt;Build command:&amp;nbsp;icc gemm_pack.c -I${MKLROOT}/include -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl -std=c99&lt;/P&gt;

&lt;P&gt;---&lt;/P&gt;

&lt;P&gt;The sample code,&lt;/P&gt;

&lt;PRE class="brush:;"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;mkl.h&amp;gt;

void print(float* a, int length, const char* name)
{
  int i = 0;
  for (i = 0; i &amp;lt; length; i++) {
    printf("%s[%d] = %f\n", name, i, a&lt;I&gt;);
  }
}

int main(void)
{
  int m = 2;
  int n = 1;
  int k = 2;

  float *a, *b, *c;
  a = (float*)malloc(sizeof(float) * m * k);
  b = (float*)malloc(sizeof(float) * k * n);
  c = (float*)malloc(sizeof(float) * m * n);

  int i = 0;
  for (i = 0; i &amp;lt; m *k; i++) {
    a&lt;I&gt; = i + 1;
  }
  for (i = 0; i &amp;lt; k * n; i++) {
    b&lt;I&gt; = i + 1;
  }

  float alpha = 1.0f;
  float beta = 0.0f;
  int lda = k;
  int ldb = n;
  int ldc = n;

  printf("========================SGEMM_PACK========================\n");
  print(a, m * k, "a");
  print(b, k * n, "b");
  float *packA = cblas_sgemm_alloc(CblasAMatrix, m, n, k);
  cblas_sgemm_pack(CblasRowMajor, CblasAMatrix, CblasNoTrans, m, n, k, alpha, a, lda, packA);

  cblas_sgemm_compute(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k, packA, lda, b, ldb, beta, c, ldc);

  cblas_sgemm_free(packA);
  print(c, m * n, "c");

  printf("========================SGEMM========================\n");
  print(a, m * k, "a");
  print(b, k * n, "b");
  cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc);
  print(c, m * n, "c");

  return 0;
}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 03:52:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/cblas-sgemm-pack-result-is-not-consistent-with-cblas-gemm/m-p/1130114#M25541</guid>
      <dc:creator>Yanzhang_W_Intel</dc:creator>
      <dc:date>2017-09-25T03:52:53Z</dc:date>
    </item>
    <item>
      <title>Hello,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/cblas-sgemm-pack-result-is-not-consistent-with-cblas-gemm/m-p/1130115#M25542</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Since A is already packed, please specify CblasPacked instead of CblasNoTrans.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp; cblas_sgemm_compute(CblasRowMajor, CblasPacked, CblasNoTrans, m, n, k, packA, lda, b, ldb, beta, c, ldc);&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 17:44:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/cblas-sgemm-pack-result-is-not-consistent-with-cblas-gemm/m-p/1130115#M25542</guid>
      <dc:creator>Kazushige_G_Intel</dc:creator>
      <dc:date>2017-09-25T17:44:32Z</dc:date>
    </item>
  </channel>
</rss>

