<?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 You can check these articles: in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074263#M120104</link>
    <description>&lt;P&gt;You can check these articles:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.howtogeek.com/howto/windows-vista/start-an-application-assigned-to-a-specific-cpu-in-windows-vista/"&gt;http://www.howtogeek.com/howto/windows-vista/start-an-application-assigned-to-a-specific-cpu-in-windows-vista/&lt;/A&gt;&lt;BR /&gt;
	&lt;A href="http://www.howtogeek.com/121775/how-to-force-windows-applications-to-use-a-specific-cpu/"&gt;http://www.howtogeek.com/121775/how-to-force-windows-applications-to-use-a-specific-cpu/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I'm not sure if there is a windows api to change the affinity from within&amp;nbsp;the program. Maybe someone else can help on this.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jan 2017 14:55:55 GMT</pubDate>
    <dc:creator>Nikitopoulos__Theodo</dc:creator>
    <dc:date>2017-01-19T14:55:55Z</dc:date>
    <item>
      <title>How to determine which core a program runs on?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074262#M120103</link>
      <description>&lt;P&gt;I have a single threaded program which I would like to run multiple times, and ideally I would like it to start up on any free core - though I realize that may not be possible. I know how to bind the program to a specific core for multi-threaded programs using &amp;nbsp;&lt;SPAN style="font-size: 13.008px;"&gt;SETENVQQ and OpenMP, but that does not seem to work when I only use 1 thread, so how do you bind a single threaded program to a specific core/logicalproccessor?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 10:36:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074262#M120103</guid>
      <dc:creator>Tue_B_</dc:creator>
      <dc:date>2017-01-19T10:36:01Z</dc:date>
    </item>
    <item>
      <title>You can check these articles:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074263#M120104</link>
      <description>&lt;P&gt;You can check these articles:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.howtogeek.com/howto/windows-vista/start-an-application-assigned-to-a-specific-cpu-in-windows-vista/"&gt;http://www.howtogeek.com/howto/windows-vista/start-an-application-assigned-to-a-specific-cpu-in-windows-vista/&lt;/A&gt;&lt;BR /&gt;
	&lt;A href="http://www.howtogeek.com/121775/how-to-force-windows-applications-to-use-a-specific-cpu/"&gt;http://www.howtogeek.com/121775/how-to-force-windows-applications-to-use-a-specific-cpu/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I'm not sure if there is a windows api to change the affinity from within&amp;nbsp;the program. Maybe someone else can help on this.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 14:55:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074263#M120104</guid>
      <dc:creator>Nikitopoulos__Theodo</dc:creator>
      <dc:date>2017-01-19T14:55:55Z</dc:date>
    </item>
    <item>
      <title>Have you looked at</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074264#M120105</link>
      <description>&lt;P&gt;Have you looked at SetProcessAffinityMask?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 16:13:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074264#M120105</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2017-01-19T16:13:43Z</dc:date>
    </item>
    <item>
      <title>Quote:Repeat Offender wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074265#M120106</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Repeat Offender wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Have you looked at SetProcessAffinityMask?&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;I have now, but I'm still not exactly sure whether this can do what I want. What I'm currently doing is using:&lt;/P&gt;

&lt;P&gt;SETENVQQ("OMP_PLACES={0},{1},{2}")&lt;/P&gt;

&lt;P&gt;But this does not get respected if I'm only using 1 thread, and so I'm not really sure how I would use SetProcessAffinityMask.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 08:39:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074265#M120106</guid>
      <dc:creator>Tue_B_</dc:creator>
      <dc:date>2017-01-20T08:39:05Z</dc:date>
    </item>
    <item>
      <title>Now, hopefully you're not</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074266#M120107</link>
      <description>&lt;P&gt;Now, hopefully you're not using OMP because I don't know whether that would play nice with code that asks the OS to reserve a specific CPU for its purposes. What I was thinking of was something like&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program affinity
&amp;nbsp;&amp;nbsp; use IFWIN
&amp;nbsp;&amp;nbsp; implicit none
&amp;nbsp;&amp;nbsp; integer, parameter :: dp = kind(1.0d0)
&amp;nbsp;&amp;nbsp; integer(HANDLE) Process
&amp;nbsp;&amp;nbsp; integer(DWORD_PTR) AffinityMask
&amp;nbsp;&amp;nbsp; integer Core
&amp;nbsp;&amp;nbsp; integer(DWORD) i
&amp;nbsp;&amp;nbsp; real(dp) x, sum
&amp;nbsp;&amp;nbsp; integer(BOOL) Retval
&amp;nbsp;&amp;nbsp; integer(DWORD) iError

&amp;nbsp;&amp;nbsp; Process = GetCurrentProcess()
&amp;nbsp;&amp;nbsp; Core = 2 ! Set to run on core #2
&amp;nbsp;&amp;nbsp; AffinityMask = ishft(1_DWORD_PTR, Core)
&amp;nbsp;&amp;nbsp; Retval = SetProcessAffinityMask(Process,AffinityMask)
&amp;nbsp;&amp;nbsp; if(Retval == 0) then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iError = GetLastError()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; write(*,*) 'Failed with error code ',iError
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop
&amp;nbsp;&amp;nbsp; end if
&amp;nbsp;&amp;nbsp; sum = 0
&amp;nbsp;&amp;nbsp; do i = huge(i),1,-1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = i
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 1/x**2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum = sum+x
&amp;nbsp;&amp;nbsp; end do
&amp;nbsp;&amp;nbsp; write(*,*) huge(i),sum
end program affinity
&lt;/PRE&gt;

&lt;P&gt;Now, when I run the above and look in Resource Manager under the CPU tab, I see a spike in usage for CPU 2 and none for the others, so it looks like it is working.&lt;/P&gt;

&lt;P&gt;EDIT: If you wanted the process to use CPUs 0, 1, and 2, you could have coded&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;&amp;nbsp;&amp;nbsp; AffinityMask = iany(ishft(1_DWORD_PTR, [0,1,2]))
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 09:37:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074266#M120107</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2017-01-20T09:37:00Z</dc:date>
    </item>
    <item>
      <title>Quote:Repeat Offender wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074267#M120108</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Repeat Offender wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Now, hopefully you're not using OMP because I don't know whether that would play nice with code that asks the OS to reserve a specific CPU for its purposes. What I was thinking of was something like&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;program affinity
&amp;nbsp;&amp;nbsp; use IFWIN
&amp;nbsp;&amp;nbsp; implicit none
&amp;nbsp;&amp;nbsp; integer, parameter :: dp = kind(1.0d0)
&amp;nbsp;&amp;nbsp; integer(HANDLE) Process
&amp;nbsp;&amp;nbsp; integer(DWORD_PTR) AffinityMask
&amp;nbsp;&amp;nbsp; integer Core
&amp;nbsp;&amp;nbsp; integer(DWORD) i
&amp;nbsp;&amp;nbsp; real(dp) x, sum
&amp;nbsp;&amp;nbsp; integer(BOOL) Retval
&amp;nbsp;&amp;nbsp; integer(DWORD) iError

&amp;nbsp;&amp;nbsp; Process = GetCurrentProcess()
&amp;nbsp;&amp;nbsp; Core = 2 ! Set to run on core #2
&amp;nbsp;&amp;nbsp; AffinityMask = ishft(1_DWORD_PTR, Core)
&amp;nbsp;&amp;nbsp; Retval = SetProcessAffinityMask(Process,AffinityMask)
&amp;nbsp;&amp;nbsp; if(Retval == 0) then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iError = GetLastError()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; write(*,*) 'Failed with error code ',iError
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop
&amp;nbsp;&amp;nbsp; end if
&amp;nbsp;&amp;nbsp; sum = 0
&amp;nbsp;&amp;nbsp; do i = huge(i),1,-1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = i
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 1/x**2
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum = sum+x
&amp;nbsp;&amp;nbsp; end do
&amp;nbsp;&amp;nbsp; write(*,*) huge(i),sum
end program affinity
&lt;/PRE&gt;

&lt;P&gt;Now, when I run the above and look in Resource Manager under the CPU tab, I see a spike in usage for CPU 2 and none for the others, so it looks like it is working.&lt;/P&gt;

&lt;P&gt;EDIT: If you wanted the process to use CPUs 0, 1, and 2, you could have coded&lt;/P&gt;

&lt;PRE class="brush:fortran;"&gt;&amp;nbsp;&amp;nbsp; AffinityMask = iany(ishft(1_DWORD_PTR, [0,1,2]))
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thank you, this did exactly what I wanted!&lt;/P&gt;

&lt;P&gt;Is there any resource I could read about how it actually work, or what other commands I would be able to do with these kinds of things? I haven't been able to find anything about this, which is probably because I'm searching for this from a Fortran point of view.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 11:05:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074267#M120108</guid>
      <dc:creator>Tue_B_</dc:creator>
      <dc:date>2017-01-20T11:05:25Z</dc:date>
    </item>
    <item>
      <title>I don't know what to tell you</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074268#M120109</link>
      <description>&lt;P&gt;I don't know what to tell you further except to read the documentation provided in MSDN. For example, just search for&lt;/P&gt;

&lt;P&gt;SetProcessAffinityMask msdn&lt;/P&gt;

&lt;P&gt;And you will get all the information that I have. More general advice on using Google: try to state your query as an English sentence, including all or most of the keywords that you are really searching for, like you would be asking a person. Google thinks it's smarter than you and anthropomorphizing it in this way confirms its attitude and so gets you better service.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 17:14:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/How-to-determine-which-core-a-program-runs-on/m-p/1074268#M120109</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2017-01-20T17:14:32Z</dc:date>
    </item>
  </channel>
</rss>

