<?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 Q&amp;A: How to assign an application to a logical processor in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Q-A-How-to-assign-an-application-to-a-logical-processor/m-p/972888#M5520</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV align="left"&gt;&lt;/DIV&gt;
&lt;DIV align="left"&gt;&lt;/DIV&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;Here is a question received by Intel Software Network Support, as well as the response provided by our Application Engineers:&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Q. I was wondering if you knew of tools or a way to assign an application to a logical CPU? We want to optimize a new feature with the Intel Xeon processor and hyper-threaded processors where logical CPU utilization is monitored.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;&lt;FONT color="#336600"&gt;&lt;STRONG&gt;A.&lt;/STRONG&gt; We are not certain of your specific situation, so we are going to give several answers to your question.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;If you are trying to specify which processor a process (application) should run on from a system administrator point of view, where you do not have the ability to modify the application itself, and you are using a Microsoft* OS, you can simply use Windows* Task Manager. When the process is running press Ctrl+Shift+ESC, click the Processes tab, select the name of the process, right click, and choose "Set Affinity...". From there you can specify which processor you want the entire application to run on. I also know that there is a Microsoft* Windows* 2000 Datacenter Server version of their OS which has sophisticated controls over which process and threads run on which processors.&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;Programmatically, if you are using a Microsoft* OS, the Microsoft* Platform SDK contains APIs that allow developers to control which processor their process or threads will run on. The SetProcessAffinityMask &amp;lt;&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setprocessaffinitymask.asp" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setprocessaffinitymask.asp" target="_blank"&gt;http://msdn.microsoft.com/library/en-us/dllproc/base/setprocessaffinitymask.asp&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt; function is used to force all threads of the process to execute on the designated processor. The SetThreadAffinityMask &amp;lt;&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadaffinitymask.asp" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadaffinitymask.asp" target="_blank"&gt;http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadaffinitymask.asp&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt; function forces a particular thread to only be scheduled on a specific processor. You will need to use GetProcessAffinityMask &amp;lt;&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/getprocessaffinitymask.asp" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/getprocessaffinitymask.asp" target="_blank"&gt;http://msdn.microsoft.com/library/en-us/dllproc/base/getprocessaffinitymask.asp&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt; to determine which processors are available to your process, since as we mentioned earlier, the system administrator can limit which processors are available to the process.&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;There is also an Platform SDK API called SetThreadIdealProcessor &amp;lt;&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadidealprocessor.asp" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadidealprocessor.asp" target="_blank"&gt;http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadidealprocessor.asp&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt; which doesnt force the thread to run on the specific processor, but rather strongly suggests it to the OS. The OS can still run that thread on other processors, but would attempt when possible to run it on
 the designated processor.&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;You can use the GetSystemInfo &amp;lt;&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/sysinfo/base/getsysteminfo.asp" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/sysinfo/base/getsysteminfo.asp" target="_blank"&gt;http://msdn.microsoft.com/library/en-us/sysinfo/base/getsysteminfo.asp&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt; function to determine the number of processors on the computer. However to determine which processors logical processors are associated with which physical processor, we recommend the Intel Developer Services article "Detecting Support for Hyper-Threading Technology Enabled Processors" available at: &amp;lt;&lt;/FONT&gt;&lt;A href="http://www.intel.com/cd/ids/developer/asmo-na/eng/technologies/threading/hyperthreading/20416.htm" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://www.intel.com/cd/ids/developer/asmo-na/eng/technologies/threading/hyperthreading/20416.htm" target="_blank"&gt;http://www.intel.com/cd/ids/developer/asmo-na/eng/technologies/threading/hyperthreading/20416.htm&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt;&lt;BR /&gt;That article includes sample code that determines how many processors are on the system, whether they are HT enabled, and which logical processors belong to which physical processor. Also you will notice that to accomplish this, the sample uses SetProcessAffinityMask.&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;Programmatically on a Linux* OS, there are some thread affinity APIs included with Red Hat* Linux* 9.0 and a patch that can be applied to the Red Hat* Linux* 8.0 distribution. Details on the thread affinity patch are available at &amp;lt;&lt;/FONT&gt;&lt;A href="http://www.kernel.org/pub/linux/kernel/people/rml/cpu-affinity" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://www.kernel.org/pub/linux/kernel/people/rml/cpu-affinity" target="_blank"&gt;http://www.kernel.org/pub/linux/kernel/people/rml/cpu-affinity&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt;. The thread APIs:&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;int sched_setaffinity (pid_t pid, unsigned int len, unsigned long *new_mask_ptr)&lt;BR /&gt;int sched_getaffinity(pid_t pid, unsigned int len,unsigned long *user_mask_ptr)&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;===&lt;BR /&gt;Lexi S.&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face="Arial" color="black" size="2"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;IntelSoftware NetworkSupport&lt;/SPAN&gt;&lt;/FONT&gt;&lt;NAMESPACE prefix="o" ns="urn:schemas-microsoft-com:office:office"&gt;&lt;P&gt;&lt;/P&gt;&lt;/NAMESPACE&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face="Arial" color="black" size="2"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.intel.com/software" target="_blank"&gt;http://www.intel.com/software&lt;/A&gt; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face="Arial" color="black" size="2"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.intel.com/cd/ids/developer/asmo-na/eng/58987.htm" target="_blank"&gt;Contact us&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;Intel is a registered trademark of Intel Corporation or its subsidiaries in the United States and other countries.&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;*Other names and brands may be claimed as the property of others.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Message Edited by intel.software.network.support on &lt;SPAN class="date_text"&gt;12-07-2005&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;04:56 PM&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jan 2004 08:26:56 GMT</pubDate>
    <dc:creator>Intel_Software_Netw1</dc:creator>
    <dc:date>2004-01-30T08:26:56Z</dc:date>
    <item>
      <title>Q&amp;A: How to assign an application to a logical processor</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Q-A-How-to-assign-an-application-to-a-logical-processor/m-p/972888#M5520</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV align="left"&gt;&lt;/DIV&gt;
&lt;DIV align="left"&gt;&lt;/DIV&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;Here is a question received by Intel Software Network Support, as well as the response provided by our Application Engineers:&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Q. I was wondering if you knew of tools or a way to assign an application to a logical CPU? We want to optimize a new feature with the Intel Xeon processor and hyper-threaded processors where logical CPU utilization is monitored.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;&lt;FONT color="#336600"&gt;&lt;STRONG&gt;A.&lt;/STRONG&gt; We are not certain of your specific situation, so we are going to give several answers to your question.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;If you are trying to specify which processor a process (application) should run on from a system administrator point of view, where you do not have the ability to modify the application itself, and you are using a Microsoft* OS, you can simply use Windows* Task Manager. When the process is running press Ctrl+Shift+ESC, click the Processes tab, select the name of the process, right click, and choose "Set Affinity...". From there you can specify which processor you want the entire application to run on. I also know that there is a Microsoft* Windows* 2000 Datacenter Server version of their OS which has sophisticated controls over which process and threads run on which processors.&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;Programmatically, if you are using a Microsoft* OS, the Microsoft* Platform SDK contains APIs that allow developers to control which processor their process or threads will run on. The SetProcessAffinityMask &amp;lt;&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setprocessaffinitymask.asp" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setprocessaffinitymask.asp" target="_blank"&gt;http://msdn.microsoft.com/library/en-us/dllproc/base/setprocessaffinitymask.asp&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt; function is used to force all threads of the process to execute on the designated processor. The SetThreadAffinityMask &amp;lt;&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadaffinitymask.asp" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadaffinitymask.asp" target="_blank"&gt;http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadaffinitymask.asp&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt; function forces a particular thread to only be scheduled on a specific processor. You will need to use GetProcessAffinityMask &amp;lt;&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/getprocessaffinitymask.asp" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/getprocessaffinitymask.asp" target="_blank"&gt;http://msdn.microsoft.com/library/en-us/dllproc/base/getprocessaffinitymask.asp&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt; to determine which processors are available to your process, since as we mentioned earlier, the system administrator can limit which processors are available to the process.&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;There is also an Platform SDK API called SetThreadIdealProcessor &amp;lt;&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadidealprocessor.asp" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadidealprocessor.asp" target="_blank"&gt;http://msdn.microsoft.com/library/en-us/dllproc/base/setthreadidealprocessor.asp&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt; which doesnt force the thread to run on the specific processor, but rather strongly suggests it to the OS. The OS can still run that thread on other processors, but would attempt when possible to run it on
 the designated processor.&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;You can use the GetSystemInfo &amp;lt;&lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/sysinfo/base/getsysteminfo.asp" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/sysinfo/base/getsysteminfo.asp" target="_blank"&gt;http://msdn.microsoft.com/library/en-us/sysinfo/base/getsysteminfo.asp&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt; function to determine the number of processors on the computer. However to determine which processors logical processors are associated with which physical processor, we recommend the Intel Developer Services article "Detecting Support for Hyper-Threading Technology Enabled Processors" available at: &amp;lt;&lt;/FONT&gt;&lt;A href="http://www.intel.com/cd/ids/developer/asmo-na/eng/technologies/threading/hyperthreading/20416.htm" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://www.intel.com/cd/ids/developer/asmo-na/eng/technologies/threading/hyperthreading/20416.htm" target="_blank"&gt;http://www.intel.com/cd/ids/developer/asmo-na/eng/technologies/threading/hyperthreading/20416.htm&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt;&lt;BR /&gt;That article includes sample code that determines how many processors are on the system, whether they are HT enabled, and which logical processors belong to which physical processor. Also you will notice that to accomplish this, the sample uses SetProcessAffinityMask.&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;Programmatically on a Linux* OS, there are some thread affinity APIs included with Red Hat* Linux* 9.0 and a patch that can be applied to the Red Hat* Linux* 8.0 distribution. Details on the thread affinity patch are available at &amp;lt;&lt;/FONT&gt;&lt;A href="http://www.kernel.org/pub/linux/kernel/people/rml/cpu-affinity" target="_blank"&gt;&lt;FONT color="#336600" size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://www.kernel.org/pub/linux/kernel/people/rml/cpu-affinity" target="_blank"&gt;http://www.kernel.org/pub/linux/kernel/people/rml/cpu-affinity&lt;/A&gt;&lt;FONT color="#336600" size="2"&gt;&amp;gt;. The thread APIs:&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT color="#336600" size="2"&gt;int sched_setaffinity (pid_t pid, unsigned int len, unsigned long *new_mask_ptr)&lt;BR /&gt;int sched_getaffinity(pid_t pid, unsigned int len,unsigned long *user_mask_ptr)&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;===&lt;BR /&gt;Lexi S.&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face="Arial" color="black" size="2"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;IntelSoftware NetworkSupport&lt;/SPAN&gt;&lt;/FONT&gt;&lt;NAMESPACE prefix="o" ns="urn:schemas-microsoft-com:office:office"&gt;&lt;P&gt;&lt;/P&gt;&lt;/NAMESPACE&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face="Arial" color="black" size="2"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.intel.com/software" target="_blank"&gt;http://www.intel.com/software&lt;/A&gt; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face="Arial" color="black" size="2"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.intel.com/cd/ids/developer/asmo-na/eng/58987.htm" target="_blank"&gt;Contact us&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;Intel is a registered trademark of Intel Corporation or its subsidiaries in the United States and other countries.&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT size="2"&gt;*Other names and brands may be claimed as the property of others.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Message Edited by intel.software.network.support on &lt;SPAN class="date_text"&gt;12-07-2005&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;04:56 PM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jan 2004 08:26:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Q-A-How-to-assign-an-application-to-a-logical-processor/m-p/972888#M5520</guid>
      <dc:creator>Intel_Software_Netw1</dc:creator>
      <dc:date>2004-01-30T08:26:56Z</dc:date>
    </item>
  </channel>
</rss>

