PDA

Click to See Complete Forum and Search --> : Speed up?


billrogers
May 15th, 2002, 10:24 AM
Anyone see a way to speed this function up??


void MpEvent(UINT32 eventID, UINT32 buffer)
{
int l;
UINT32 *row;
if(mlb.logBuffer != NULL)
{
row = mlb.logBuffer[mlb.numEvent];
row[0] = HWCLK32BIT;
row[1] = SWCLK32BIT;
row[2] = eventID;
row[3] = buffer;
++mlb.numEvent;
/* check to see if the end of the log buffer was reached */
if(mlb.numEvent >= mlb.maxEvents)
{
mlb.looped = TRUE;
mlb.numEvent = 0;
}
}
else
{
/* We should never get here because the only way to free the log buffer
* is by calling MpLogFree, which turns logging off as well */
printf("There is no buffer allocated for main path event logging\n");
}

}



Any help appreciated...
Thanks
Bill

Jop
May 15th, 2002, 04:44 PM
Is it that slow than? ;)

billrogers
May 16th, 2002, 09:32 AM
no it really isnt too slow, but all the more faster is better... ;)

I am thinking of putting that whole function into assembly. The compiler is not very efficent, keeps recalculating the address of mlb.numEvent, when it really only needs to do it once and store that in a register, dumb thing. so that should give me a performance boost of sorts.

abdul
May 16th, 2002, 11:24 AM
Maybe it'll be a bit faster if you replace


if(mlb.numEvent >= mlb.maxEvents)
{
mlb.looped = TRUE;
mlb.numEvent = 0;
}



with


mlb.numEvent >= mlb.maxEvents ? mlb.looped = TRUE : mlb.numEvent = 0;

billrogers
May 16th, 2002, 02:30 PM
Sorry that wouldn't work, the ? and : is a "if a then b else x"
not a "if a then b and c"

abdul
May 16th, 2002, 02:37 PM
Oh never mind...

billrogers
May 17th, 2002, 08:14 AM
not a problem, a wrong solution is not a bad idea, just another solution that shows what doesn't work

CornedBee
May 24th, 2002, 08:15 AM
I think the only thing you can do to speed this up is getting a better compiler.

Maybe this is a little bit faster:
instead of

row[0] = HWCLK32BIT;
row[1] = SWCLK32BIT;
row[2] = eventID;
row[3] = buffer;


do

*row = HWCLK32BIT;
++row;
*row = SWCLK32BIT;
++row;
*row = eventID;
++row;
*row = buffer;


But you'd have to check that. The 386 supports direct indexing which is supposed to be very fast, but you can never be sure.