<?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 Getting Time Usage out of threads in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Getting-Time-Usage-out-of-threads/m-p/896350#M4018</link>
    <description>Hi I'm working on a game where we have a background loading thread outside of the main game loop. I have gotten rid of all the lock problems between threads, but it still seems to get hitches when we're loading large chunks of data, but I can't find any other stalls. When I run Multi-Core it runs pretty smoothly, but then I shut off Multi-Core in my Bios and I noticed much bigger spikes. If I run at a lower priority it helps alot but then it takes too long to load the data in a 3second load at normal priority is taking 20seconds at below-normal. We are using Win32 threads. Is there a way for me to track the time Windows is spending in each thread that way I could see if windows is in the background thread for 200ms before switching back to the main thread?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Keith&lt;BR /&gt;</description>
    <pubDate>Wed, 29 Nov 2006 09:07:20 GMT</pubDate>
    <dc:creator>kpatella</dc:creator>
    <dc:date>2006-11-29T09:07:20Z</dc:date>
    <item>
      <title>Getting Time Usage out of threads</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Getting-Time-Usage-out-of-threads/m-p/896350#M4018</link>
      <description>Hi I'm working on a game where we have a background loading thread outside of the main game loop. I have gotten rid of all the lock problems between threads, but it still seems to get hitches when we're loading large chunks of data, but I can't find any other stalls. When I run Multi-Core it runs pretty smoothly, but then I shut off Multi-Core in my Bios and I noticed much bigger spikes. If I run at a lower priority it helps alot but then it takes too long to load the data in a 3second load at normal priority is taking 20seconds at below-normal. We are using Win32 threads. Is there a way for me to track the time Windows is spending in each thread that way I could see if windows is in the background thread for 200ms before switching back to the main thread?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Keith&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Nov 2006 09:07:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Getting-Time-Usage-out-of-threads/m-p/896350#M4018</guid>
      <dc:creator>kpatella</dc:creator>
      <dc:date>2006-11-29T09:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Time Usage out of threads</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Getting-Time-Usage-out-of-threads/m-p/896351#M4019</link>
      <description>&lt;P&gt;It sounds like you need to create two Mutex objects. In IVF (I will let you convert to CPP)&lt;/P&gt;
&lt;P&gt;integer(HANDLE) :: DataReady = NULL&lt;BR /&gt;integer(HANDLE) :: DataConsumed = NULL&lt;BR /&gt;...&lt;/P&gt;
&lt;P&gt;subroutine IOthread&lt;BR /&gt; DataReady = CreateMutex(NULL, TRUE, NULL)&lt;BR /&gt; do while(.true.)&lt;BR /&gt; if(.not. ReadData()) exit&lt;BR /&gt; if(ReleaseMutex(DataReady) .eq. 0) call error('??')&lt;BR /&gt; do while(DataConsumed .eq. NULL)&lt;BR /&gt; sleep(1) ! Other thread not yet initialized&lt;BR /&gt; end do&lt;BR /&gt; if(WaitForSingleObject(DataConsumed, 5000) .ne. 0) call error('??')&lt;BR /&gt; if(ReleaseMutex(DataConsumed) .eq. 0) call error('??')&lt;BR /&gt; end do&lt;BR /&gt;end subroutine IOthread&lt;/P&gt;
&lt;P&gt;subroutine ComputeThread&lt;BR /&gt; DataConsumed = CreateMutex(NULL, TRUE, NULL)&lt;BR /&gt; do while(.true.)&lt;BR /&gt; do while(DataReady .eq. NULL)&lt;BR /&gt; sleep(1) ! Other thread not yet initialized&lt;BR /&gt; end do&lt;BR /&gt; if(WaitForSingleObject(DataReady, 5000) .ne. 0) call error('??')&lt;BR /&gt; if(ReleaseMutex(DataReady) .eq. 0) call error('??')&lt;BR /&gt; callCopyData&lt;BR /&gt; if(ReleaseMutex(DataConsumed) .eq. 0) call error('??')&lt;BR /&gt;call ProcessData&lt;BR /&gt; end do&lt;BR /&gt;end subroutine ComputeThread&lt;/P&gt;
&lt;P&gt;Or something to the effect.&lt;/P&gt;
&lt;P&gt;Also look at CreateEvent. This can be used similar to the mutex but you can have the event created as AutoReset. This could eliminate two ReleaseMutex. Although programming the AutoReset would be simpler, the Mutex I believe has less overhead.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Dec 2006 04:49:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Getting-Time-Usage-out-of-threads/m-p/896351#M4019</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2006-12-02T04:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Time Usage out of threads</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Getting-Time-Usage-out-of-threads/m-p/896352#M4020</link>
      <description>&lt;P&gt;That sounds for me as if you do not need help in thread safe code, but in a proper info function reporting user/kernel/real time consumptions for your running threads.&lt;/P&gt;
&lt;P&gt;Under Win32, just take "GetThreadTimes" ... there's also a "GetProcessTimes" for accounting every horse in the stable.&lt;/P&gt;
&lt;P&gt;I'm currently in a similar situation, developing some service concept under Win32 (VC++ has just thebest GUI), but the result has to work on "adult systems" and I fail to find an equivalent for pthread implementations. Theres just the standard "times()" which does not care for threads at all and reports process times. It's not important, but I'd like to have the ressource usage of each service thread for getting hints for the workload of each service type.&lt;/P&gt;
&lt;P&gt;Does anybody have an idea ?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2006 01:26:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Getting-Time-Usage-out-of-threads/m-p/896352#M4020</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2006-12-28T01:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Time Usage out of threads</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Getting-Time-Usage-out-of-threads/m-p/896353#M4021</link>
      <description>&lt;P&gt;On a Windows platform I conditionaly compile in my own timing code using QueryPerformanceCounter and QueryPerformanceFrequency. Alternately, you can use statistical sampling of runtime by use of thread profiling tools such as Intel's VTune, AMD's CodeAnalyst, et. al.&lt;/P&gt;
&lt;P&gt;From your description of the problem it sounds like you have the Bart Simpson on a car trip problem: too much "Are we there yet, are we there yet". i.e. in the single core configuration, the data consumer of the disk I/O is likely burning up too much time checking an I/O done flag. Thread profiling can easily identify this situation. The correction for this is to change the communication method between threads. &lt;/P&gt;
&lt;P&gt;1) Using event in lieu of "spin wait" loops.&lt;BR /&gt;2) Reducing spin count counts (in appropriate places)&lt;BR /&gt;3) In wait for I/O loop insert appropriate "pause"&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2006 22:13:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Getting-Time-Usage-out-of-threads/m-p/896353#M4021</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2006-12-29T22:13:02Z</dc:date>
    </item>
  </channel>
</rss>

