Changes

Jump to: navigation, search

GPU610/OctoPig

865 bytes added, 00:32, 21 February 2013
Chad's Profiling Findings
After profiling I determined that 99% of the run was being spent in two functions, 89% and 10% respectively. The code for the two functions is below.
<source lang="cpp">
void Program::update(int numItrs) {
for (int i = 0; i < numItrs; ++i)
{
int sy = map[mapWidth * yPos + xPos];
int st = state;
int idx = (numStates * sy + st) * 3;
st = table[idx + 0];
sy = table[idx + 1];
int ac = table[idx + 2];
 
// Update the current state
state = st;
 
// Write the new symbol
map[mapWidth * yPos + xPos] = sy;
 
// Perform the transition action
switch (ac)
{
case ACTION_LEFT:
xPos += 1;
if (xPos >= mapWidth)
xPos -= mapWidth;
break;
 
case ACTION_RIGHT:
xPos -= 1;
if (xPos < 0)
xPos += mapWidth;
break;
 
case ACTION_UP:
yPos -= 1;
if (yPos < 0)
yPos += mapHeight;
break;
 
case ACTION_DOWN:
yPos += 1;
if (yPos >= mapHeight)
yPos -= mapHeight;
break;
 
default:
error("invalid action: " + ac);
}
 
itrCount++;
}
}
</source>
1
edit

Navigation menu