SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Technology Stocks : Intel Corporation (INTC)
INTC 45.51+10.7%Jan 9 9:30 AM EST

 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext  
To: Charles Gryba who wrote (150399)11/30/2001 12:23:57 AM
From: kapkan4u   of 186894
 
<Kap, if you have a little binary you can send it to me, I have access to P4s, XPs and Tualatins.>

Just build this c source as p4_id.exe and run on the command line as say:

"p4_id.exe 100000 20000 > p4_gen.c"

This will generate a p4_gen.c file that has a loop and a switch. The first argument to p4_id.exe (100000) determines the number of iterations and the second (20000) determines the number of cases in the switch. You can try different number of iterations and cases to see were the P4 performance falls of the cliff.

Kap

#include "stdafx.h"

int main(int argc, char* argv[])
{
int i, iterations = 100000, max_index = 1000;
char name[20] = "p4_id.exe";

if (argc != 3) {
printf("invokation error: p4_id.exe iterations max_index\n");
printf("iterations: number of times the switch statement is executed in the loop\n");
printf("max_index: number of cases the program will generate in the switch statement\n");
}

sscanf(argv[1], "%d", &iterations, &max_index);
sscanf(argv[2], "%d", &max_index);


printf("#include <time.h>\n");
printf("#include <stdlib.h>\n");

printf("int main() {\n");
printf("int i, sum;\n");
printf("srand( (unsigned)time( NULL ) );\n");
printf("for( i = 0; i < %d; i++ )\n",iterations);
printf("switch ( rand() %% %d ){\n", max_index);
for (i = 0; i < max_index; i++)
printf("case %d: sum += %d; break;\n", i, i + 1);
printf("default: sum = sum; }\n");
printf("return 0;\n}\n");
return 0;
}
Report TOU ViolationShare This Post
 Public ReplyPrvt ReplyMark as Last ReadFilePrevious 10Next 10PreviousNext