Queryperformance Counter Question

Since i’ve upgraded my PC to an Intel system i’m getting the message below in the Renoise logfile. I’m seeing a “High Precision Event Timer” in the device manager, so i think it should be possible? What is this timer used for and is there anything i can do to use it again?

Timer: Can’t use ‘QueryPerformance’ counters. Falling back to a low resolution timer…

Ah, looked for that thread but didn’t found it.

Tried the hotfix, but no luck. I wrote a simple C test program, which uses the performance counter just fine it seems. How does Renoise decide if it’s available? If it’s only used for measuring CPU load it’s not really a problem i guess, just curious.

#define WIN32_LEAN_AND_MEAN  
  
#include <windows.h><br>
#include <stdio.h><br>
<br>
int main(void)<br>
{<br>
  LARGE_INTEGER liF, liStart, liEnd;<br>
  double dTime;<br>
  unsigned int iIterations = 0;<br>
<br>
  printf ("How many iterations should be measured? Enter a positive number: ");<br>
  scanf ("%u", &amp;iIterations);<br>
<br>
  if (QueryPerformanceFrequency(&amp;liF))<br>
  {<br>
	if (QueryPerformanceCounter(&amp;liStart))<br>
	{<br>
	  // code to measure<br>
<br>
	  int i = 0; while (i &lt;= iIterations) i++;<br>
<br>
	  // ---------------<br>
<br>
	  if (QueryPerformanceCounter(&amp;liEnd))<br>
	  {<br>
		 dTime = (double) (liEnd.QuadPart - liStart.QuadPart) * 1e6 / (double) liF.QuadPart;<br>
		 printf("Elapsed time is %g microseconds.\n", dTime);<br>
	  }<br>
	}<br>
  }<br>
  else<br>
	printf("QueryPerformanceFrequency() failed with errorcode %d.\n", GetLastError());<br>
<br>
  return 0;<br>
}<br>
<br>```

</stdio.h></windows.h>

We need high resolution timers for the MIDI timing and to decide which tracks should be bound to which CPU when calculating audio on multiple processors at once -> separate work load.

The problem of QueryPerformanceFrequency is that it sometimes uses the CPU clock in place of the real-time clock. SpeedStep and other energy saving stuff will throttle the cores individually, thus QueryPerformanceFrequency returns nonsense when queried first on one core, then another time on another core.

We use some CPUID magic to find out if can use QueryPerformanceFrequency or not. Maybe this check needs to be updated for the new CPUs.

Could you let us know your CPUID values? -> http://www.cpuid.com

Here is a screenshot:

Here is my little test program expanded to use multiple threads. It returns something like this:

http://www.beatslaughter.de/temp/PerformanceCounter.rar

How many threads should be created?  
Enter a positive number (max 16): 4  
How many iterations should be measured?  
Enter a positive number: 100000000  
  
Thread 1 returned ->  
  
Passed iterations: 100000000  
QueryPerformanceFrequency() returned: 840250FB78  
Seems safe to use the 'QueryPerformance' counters... > 15000000LL  
Elapsed time is 41678.9 microseconds.  
  
  
Thread 2 returned ->  
  
Passed iterations: 100000000  
QueryPerformanceFrequency() returned: 840260FB78  
Seems safe to use the 'QueryPerformance' counters... > 15000000LL  
Elapsed time is 41690.9 microseconds.  
  
  
Thread 4 returned ->  
  
Passed iterations: 100000000  
QueryPerformanceFrequency() returned: 840280FB78  
Seems safe to use the 'QueryPerformance' counters... > 15000000LL  
Elapsed time is 41668.3 microseconds.  
  
  
Thread 3 returned ->  
  
Passed iterations: 100000000  
QueryPerformanceFrequency() returned: 840270FB78  
Seems safe to use the 'QueryPerformance' counters... > 15000000LL  
Elapsed time is 41800.4 microseconds.  
  
  
  

Lets delay this to the next beta testing round. I’ve already updated our “if we can use QueryPerformanceFrequency guess” for the new CPUs. Maybe that already did the job…

No problem.