<?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 what is the CPUID test for KNCNI? in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/what-is-the-CPUID-test-for-KNCNI/m-p/1043266#M46914</link>
    <description>&lt;P&gt;I'm using icc (ICC) 15.0.1 20141023 on a Haswell-based system.&amp;nbsp; My software library has CPU-specific code using either SSE2, SSE41, AVX2, or KNCNI intrinsics.&amp;nbsp; icc is successfully compiling the KNC code so I need to disable its execution at runtime.&amp;nbsp; I'm familiar with using CPUID to test at runtime whether an ISA is supported, having done so for SSE2, SSE41, and AVX2.&amp;nbsp; The intel intrinsics guide lists the CPUID as KNCNI but I can't find any CPUID documentation indicating which bit this corresponds to in the registers.&lt;/P&gt;

&lt;P&gt;Which CPUID bit index indicates KNCNI?&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jan 2015 23:27:14 GMT</pubDate>
    <dc:creator>Jeff_D_2</dc:creator>
    <dc:date>2015-01-07T23:27:14Z</dc:date>
    <item>
      <title>what is the CPUID test for KNCNI?</title>
      <link>https://community.intel.com/t5/Software-Archive/what-is-the-CPUID-test-for-KNCNI/m-p/1043266#M46914</link>
      <description>&lt;P&gt;I'm using icc (ICC) 15.0.1 20141023 on a Haswell-based system.&amp;nbsp; My software library has CPU-specific code using either SSE2, SSE41, AVX2, or KNCNI intrinsics.&amp;nbsp; icc is successfully compiling the KNC code so I need to disable its execution at runtime.&amp;nbsp; I'm familiar with using CPUID to test at runtime whether an ISA is supported, having done so for SSE2, SSE41, and AVX2.&amp;nbsp; The intel intrinsics guide lists the CPUID as KNCNI but I can't find any CPUID documentation indicating which bit this corresponds to in the registers.&lt;/P&gt;

&lt;P&gt;Which CPUID bit index indicates KNCNI?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2015 23:27:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/what-is-the-CPUID-test-for-KNCNI/m-p/1043266#M46914</guid>
      <dc:creator>Jeff_D_2</dc:creator>
      <dc:date>2015-01-07T23:27:14Z</dc:date>
    </item>
    <item>
      <title>I might be answering my own</title>
      <link>https://community.intel.com/t5/Software-Archive/what-is-the-CPUID-test-for-KNCNI/m-p/1043267#M46915</link>
      <description>&lt;P&gt;I might be answering my own question here but I would like feedback if the following approach is INCORRECT.&lt;/P&gt;

&lt;P&gt;Since the highest value in EAX supported by Knights Corner is 04H (according to appendix B in the Knights Corner Instruction Set Reference&lt;BR /&gt;
	Manual) -- and since it is the &lt;EM&gt;&lt;STRONG&gt;only&lt;/STRONG&gt;&lt;/EM&gt; processor that evaluates to 04H -- can I test at runtime if I am running on KNC with the following code?&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;#include &amp;lt;stdint.h&amp;gt;
#if defined(_MSC_VER)
# include &amp;lt;intrin.h&amp;gt;
#endif

static void run_cpuid(uint32_t eax, uint32_t ecx, uint32_t* abcd)
{
#if defined(_MSC_VER)
    __cpuidex(abcd, eax, ecx);
#else
    uint32_t ebx, edx;
# if defined( __i386__ ) &amp;amp;&amp;amp; defined ( __PIC__ )
     /* in case of PIC under 32-bit EBX cannot be clobbered */
    __asm__ ( "movl %%ebx, %%edi \n\t cpuid \n\t xchgl %%ebx, %%edi" : "=D" (ebx),
# else
    __asm__ ( "cpuid" : "+b" (ebx),
# endif
              "+a" (eax), "+c" (ecx), "=d" (edx) );
    abcd[0] = eax; abcd[1] = ebx; abcd[2] = ecx; abcd[3] = edx;
#endif
}

static int check_knc()
{
    uint32_t info[4];
    uint32_t nIds;

    run_cpuid(0, 0, info);
    nIds = info[0];

    /* Highest CPUID Source Operand for KNC Processors is 4 */
    return (nIds == 4);
}

&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 00:16:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/what-is-the-CPUID-test-for-KNCNI/m-p/1043267#M46915</guid>
      <dc:creator>Jeff_D_2</dc:creator>
      <dc:date>2015-01-08T00:16:17Z</dc:date>
    </item>
    <item>
      <title>I recommend you use a compile</title>
      <link>https://community.intel.com/t5/Software-Archive/what-is-the-CPUID-test-for-KNCNI/m-p/1043268#M46916</link>
      <description>&lt;P&gt;I recommend you use a&amp;nbsp;compile-time test (i.e., an #ifdef in C), not a run-time test. Testing for KNCNI at runtime doesn't really make any sense, since the mere fact that the O/S allowed you to run a binary with the ELF machine type for x86-64 (EM_X86_64 == 0x3e) implies KNCNI is &lt;EM&gt;not &lt;/EM&gt;supported, and similarly its allowing you to run a binary with the&amp;nbsp;ELF machine type for Knights Corner (EM_K1OM ==&amp;nbsp;0xb5) would have implied KNCNI &lt;EM&gt;was&lt;/EM&gt; supported.&lt;/P&gt;

&lt;P&gt;There is no CPUID flag bit that indicates support for KNCNI like there is for SSE2 or AVX; the question of compatibility is not that simple. The Knights Corner instruction set is &lt;STRONG&gt;not&lt;/STRONG&gt; simply the union of the x86-64 instruction set and KNCNI--there are incompatibilities outside the new vector instructions, and of course the calling conventions are inherently incompatible for functions&amp;nbsp;taking&amp;nbsp;floating point arguments. These incompatibilities are why the ELF machine types for x86-64 and Knights Corner are different; that they are&amp;nbsp;means Linux for Knights Corner will refuse to run programs built for x86-64, and Linux for x86-64 will refuse to run programs built for Knights Corner--similarly to how&amp;nbsp;both will refuse to&amp;nbsp;run programs built for ARM or&amp;nbsp;PowerPC. It also means that the linker will refuse to combine object files&amp;nbsp;for x86-64 and Knights Corner together into a single&amp;nbsp;executable or shared library (although it can be forced to do so, which I guess you've done).&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2015 00:39:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/what-is-the-CPUID-test-for-KNCNI/m-p/1043268#M46916</guid>
      <dc:creator>Evan_P_Intel</dc:creator>
      <dc:date>2015-01-08T00:39:24Z</dc:date>
    </item>
  </channel>
</rss>

