The timed_thread collects results of 100 runs into an array and then prints them.
This has been run for ref clock settings of 100, 200 and 400 MHz.
Here are the results:
Code: Select all
Sys Clk = 400MHz Ref Clk = 100MHz
---------------------------------
Thread Clocks
8 10
7 8/9
6 7/8
5 6/7
4 5
3 5
2 5
1 5
Sys Clk = 400MHz Ref Clk = 200MHz
---------------------------------
Thread Clocks
8 20
7 17/18
6 15
5 12/13
4 10
3 10
2 10
1 10
Sys Clk = 400MHz Ref Clk = 400MHz
---------------------------------
Same as 100MHz Ref Clk!!!
Code: Select all
#include <stdio.h>
#include <platform.h>
void waste_thread()
{
while(1);
}
int results[100];
int x;
void timed_thread()
{
long startTime, endTime;
timer t;
int i;
int loops = 100;
printf ("Determinism test:\n");
while (1)
{
for (i = 0; i < loops; i++)
{
// Start benchmark timer
t :> startTime;
x++;
// Stop benchmark timer
t :> endTime;
// Record reulting run time
results[i] = endTime - startTime;
}
for (i = 0; i < loops; i++)
{
printf ("Run time %d = %d timer ticks\n", i, results[i]);
}
}
}
int main()
{
par
{
on stdcore[0]: timed_thread();
on stdcore[0]: waste_thread();
on stdcore[0]: waste_thread();
on stdcore[0]: waste_thread();
on stdcore[0]: waste_thread();
on stdcore[0]: waste_thread();
//on stdcore[0]: waste_thread();
//on stdcore[0]: waste_thread();
}
return 0;
}
1) If you want execution determinism you need to have 1, 2, 3, 4 or 8 threads.
2) If you want execution determinism in a thread it should not use div or mod (not sure about mul) or it should be the only thread that uses div/mod.
3) Tweaking with the clocks does not buy much and probably causes some confusion and inconvenience.
4) Baring complications with div/mod we are looking at 10ns jitter here which should be OK in many cases.
5) XMOS' claims of 100% execution determinism are a trifle optimistic.
8) For real determinism on the real world I/O you need to use port timers and such. The subject of my next experiments....
Did I get this right so far?