コード例 #1
0
ファイル: ipc.c プロジェクト: rbandlam/systemish
int main()
{ 
	float real_time, proc_time,ipc;
	long long ins;
	float real_time_i, proc_time_i, ipc_i;
	long long ins_i;
	int retval;

	if((retval = PAPI_ipc(&real_time_i, &proc_time_i, &ins_i, &ipc_i)) < PAPI_OK) { 
		printf("Could not initialise PAPI_ipc \n");
		printf("retval: %d\n", retval);
		exit(1);
	}

	double ans = your_slow_code();

	if((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK) {    
		printf("retval: %d\n", retval);
		exit(1);
	}

	printf("Real_time: %f Proc_time: %f Total instructions: %lld IPC: %f\n", 
			real_time, proc_time, ins, ipc);

	/* clean up */
	PAPI_shutdown();
	printf("Ans = %f\n", ans);
	exit(0);
}
コード例 #2
0
ファイル: ipc.c プロジェクト: naps62/CPD_PAPI
int
main( int argc, char **argv )
{
	extern void dummy( void * );
	float matrixa[INDEX][INDEX], matrixb[INDEX][INDEX], mresult[INDEX][INDEX];
	float real_time, proc_time, ipc;
	long long ins;
	int retval;
	int i, j, k;

	tests_quiet( argc, argv );	/* Set TESTS_QUIET variable */


	/* Initialize the Matrix arrays */
	for( i = 0; i < INDEX; i++ ) {
	   for( j= 0; j < INDEX; j++ ) {
	       mresult[i][j] = 0.0;
	       matrixa[i][j] = matrixb[i][j] = ( float ) rand(  ) * ( float ) 1.1;
	   }
	}

	/* Setup PAPI library and begin collecting data from the counters */
	if ( ( retval = PAPI_ipc( &real_time, &proc_time, &ins, &ipc ) ) < PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_ipc", retval );

	/* Matrix-Matrix multiply */
	for ( i = 0; i < INDEX; i++ )
		for ( j = 0; j < INDEX; j++ )
			for ( k = 0; k < INDEX; k++ )
				mresult[i][j] = mresult[i][j] + matrixa[i][k] * matrixb[k][j];

	/* Collect the data into the variables passed in */
	if ( ( retval = PAPI_ipc( &real_time, &proc_time, &ins, &ipc ) ) < PAPI_OK )
		test_fail( __FILE__, __LINE__, "PAPI_ipc", retval );
	dummy( ( void * ) mresult );

	if ( !TESTS_QUIET ) {
		printf( "Real_time: %f Proc_time: %f Total ins: ", real_time,
				proc_time );
		printf( LLDFMT, ins );
		printf( " IPC: %f\n", ipc );
	}
   
           /* This should not happen unless the optimizer */
           /* gets too good                               */
        if (ins < INDEX*INDEX) {
	   test_fail( __FILE__, __LINE__, "Instruction count too low.", 
		      5 );
	}
           /* Something is broken, or else you have a really */
           /* slow processor                                 */
        if (ipc<0.01 ) {
	   test_fail( __FILE__, __LINE__, "IPC equals zero.", 
		      5 );
	}
   
	test_pass( __FILE__, NULL, 0 );
	exit( 1 );
}
コード例 #3
0
ファイル: goto.c プロジェクト: carriercomm/fastpp
int main(int argc, char **argv)
{
	printf("%lu\n", sizeof(struct ndn_bucket));
	struct ndn_bucket *ht;
	int i, j;
	int dst_ports[BATCH_SIZE], nb_succ = 0, dst_port_sum = 0;

	/** < Variables for PAPI */
	float real_time, proc_time, ipc;
	long long ins;
	int retval;

	red_printf("main: Initializing NDN hash table\n");
	ndn_init(URL_FILE, 0xf, &ht);
	red_printf("\tmain: Setting up NDN index done!\n");

	red_printf("main: Getting name array for lookups\n");
	int nb_names = ndn_get_num_lines(NAME_FILE);
	nb_names = nb_names - (nb_names % BATCH_SIZE);	/**< Align input to batch */

	struct ndn_name *name_arr = ndn_get_name_array(NAME_FILE);
	red_printf("\tmain: Constructed name array!\n");

	red_printf("main: Starting NDN lookups\n");

	/** < Init PAPI_TOT_INS and PAPI_TOT_CYC counters */
	if((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK) {
		printf("PAPI error: retval: %d\n", retval);
		exit(1);
	}

	for(i = 0; i < nb_names; i += BATCH_SIZE) {
		memset(dst_ports, -1, BATCH_SIZE * sizeof(int));
		process_batch(&name_arr[i], dst_ports, ht);

		for(j = 0; j < BATCH_SIZE; j ++) {
			#if NDN_DEBUG == 1
			printf("Name %s -> port %d\n", name_arr[i + j].name, dst_ports[j]);
			#endif
			nb_succ += (dst_ports[j] == -1) ? 0 : 1;
			dst_port_sum += dst_ports[j];
		}
	}

	if((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK) {
		printf("PAPI error: retval: %d\n", retval);
		exit(1);
	}

	red_printf("Time = %.4f s, Lookup rate = %.2f M/s | nb_succ = %d, sum = %d\n"
		"Instructions = %lld, IPC = %f\n",
		real_time, nb_names / (real_time * 1000000), nb_succ, dst_port_sum,
		ins, ipc);

	return 0;
}
コード例 #4
0
int main(int argc, char **argv)
{
   extern void dummy(void *);
   float matrixa[INDEX][INDEX], matrixb[INDEX][INDEX], mresult[INDEX][INDEX];
   float real_time, proc_time, ipc;
   long long ins;
   int retval;
   int i, j, k;

   tests_quiet(argc, argv);     /* Set TESTS_QUIET variable */


   /* Initialize the Matrix arrays */
   for (i = 0; i < INDEX * INDEX; i++) {
      mresult[0][i] = 0.0;
      matrixa[0][i] = matrixb[0][i] = rand() * (float) 1.1;
   }

   /* Setup PAPI library and begin collecting data from the counters */
   if ((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK)
      test_fail(__FILE__, __LINE__, "PAPI_ipc", retval);

   /* Matrix-Matrix multiply */
   for (i = 0; i < INDEX; i++)
      for (j = 0; j < INDEX; j++)
         for (k = 0; k < INDEX; k++)
            mresult[i][j] = mresult[i][j] + matrixa[i][k] * matrixb[k][j];

   /* Collect the data into the variables passed in */
   if ((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK)
      test_fail(__FILE__, __LINE__, "PAPI_ipc", retval);
   dummy((void *) mresult);

   if (!TESTS_QUIET) {
      printf("Real_time: %f Proc_time: %f Total ins: ", real_time, proc_time);
      printf(LLDFMT, ins);
      printf(" IPC: %f\n", ipc);
   }
   test_pass(__FILE__, NULL, 0);
   exit(1);
}
コード例 #5
0
ファイル: handopt.c プロジェクト: carriercomm/fastpp
int main(int argc, char **argv)
{
	int i;

	/** < Variables for PAPI */
	float real_time, proc_time, ipc;
	long long ins;
	int retval;

	red_printf("main: Initializing cuckoo hash table\n");
	cuckoo_init(&keys, &ht_index);

	red_printf("main: Starting lookups\n");
	/** < Init PAPI_TOT_INS and PAPI_TOT_CYC counters */
	if((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK) {    
		printf("PAPI error: retval: %d\n", retval);
		exit(1);
	}

	for(i = 0; i < NUM_KEYS; i += BATCH_SIZE) {
		process_batch(&keys[i]);
	}

	if((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK) {    
		printf("PAPI error: retval: %d\n", retval);
		exit(1);
	}

	red_printf("Time = %.4f s, rate = %.2f\n"
		"Instructions = %lld, IPC = %f\n"		
		"sum = %d, succ_1 = %d, succ_2 = %d, fail = %d\n", 
		real_time, NUM_KEYS / real_time,
		ins, ipc,
		sum, succ_1, succ_2, fail);

	return 0;
}
コード例 #6
0
ファイル: handopt.c プロジェクト: carriercomm/fastpp
int main(int argc, char **argv)
{
	int i;

	/** < Variables for PAPI */
	float real_time, proc_time, ipc;
	long long ins;
	int retval;

	red_printf("main: Initializing nodes for random walk\n");
	rand_walk_init(&nodes);

	red_printf("main: Starting random walks\n");
	/** < Init PAPI_TOT_INS and PAPI_TOT_CYC counters */
	if((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK) {    
		printf("PAPI error: retval: %d\n", retval);
		exit(1);
	}

	/** < Do a random-walk from every node in the graph */
	for(i = 0; i < NUM_NODES; i += BATCH_SIZE) {
		process_batch(&nodes[i]);
	}

	if((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK) {    
		printf("PAPI error: retval: %d\n", retval);
		exit(1);
	}

	red_printf("Time = %.4f, rate = %.2f sum = %lld\n"
		"Instructions = %lld, IPC = %f\n",
		real_time, NUM_NODES / real_time, sum,
		ins, ipc);

	return 0;
}
コード例 #7
0
ファイル: handopt.c プロジェクト: carriercomm/fastpp
/**< Usage: ./exe <use_random_prefixes> */
int main(int argc, char **argv)
{
	int i, j;

	assert(argc == 2);
	int use_random_prefixes = atoi(argv[1]);
	assert(use_random_prefixes == 1 || use_random_prefixes == 0);
	
	/**< Create the lmp6 struct */
	struct rte_lpm6_config ipv6_config;
	ipv6_config.max_rules = 1000000;
	ipv6_config.number_tbl8s = 1024 * 1024;
	struct rte_lpm6 *lpm = rte_lpm6_create(0, &ipv6_config);

	/**< Read the prefixes from a prefixes file */
	struct ipv6_prefix *prefix_arr;
	int num_prefixes;

	if(use_random_prefixes == 0) {
		/**< Generate prefixes at random: Real prefixes have great cache
		  *  behavior. */
		prefix_arr = ipv6_read_prefixes(PREFIX_FILE, &num_prefixes);
		printf("main: Read %d prefixes. Amplifying by %d.\n",
			num_prefixes, AMP_FACTOR);
	
		prefix_arr = ipv6_amp_prefixes(prefix_arr, num_prefixes, AMP_FACTOR);
		num_prefixes *= AMP_FACTOR;
	} else {
		num_prefixes = NUM_RAND_PREFIXES;
		prefix_arr = ipv6_gen_rand_prefixes(num_prefixes);
	}

	assert(num_prefixes < ipv6_config.max_rules);

	for(i = 0; i < num_prefixes; i ++) {
		int add_status = rte_lpm6_add(lpm,
			prefix_arr[i].bytes, prefix_arr[i].depth, prefix_arr[i].dst_port);

		if(add_status < 0) {
			printf("main: Failed to add IPv6 prefix %d. Status = %d\n",
				i, add_status);
			exit(-1);
		}

		if(i % 1000 == 0) {
			printf("main: Added prefixes = %d, total = %d\n", i, num_prefixes);
		}
	}

	printf("\tmain: Done inserting prefixes\n");
	
	/**< Generate probe IPv6 addresses from inserted prefixes */
	printf("main: Generating %d IPv6 addresses\n", NUM_IPS);
	struct ipv6_addr *addr_arr = ipv6_gen_addrs(NUM_IPS,
		prefix_arr, num_prefixes);

	printf("main: Starting lookups\n");

	/**< Variables for PAPI */
	float real_time, proc_time, ipc;
	long long ins;
	int retval;

	/**< Init PAPI_TOT_INS and PAPI_TOT_CYC counters */
	if((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK) {
		printf("PAPI error: retval: %d\n", retval);
		exit(1);
	}

	int16_t dst_port[BATCH_SIZE];
	int dst_port_sum = 0;
	for(i = 0; i < NUM_IPS; i += BATCH_SIZE) {
		rte_lpm6_lookup_handopt(lpm, (void *) addr_arr[i].bytes, dst_port, BATCH_SIZE);
		for(j = 0; j < BATCH_SIZE; j ++) {
			dst_port_sum += dst_port[j];
		}
	}

	if((retval = PAPI_ipc(&real_time, &proc_time, &ins, &ipc)) < PAPI_OK) {
		printf("PAPI error: retval: %d\n", retval);
		exit(1);
	}

	printf("Time = %.4f s, Lookup rate = %.2f M/s | dst_port_sum = %d\n"
		"Instructions = %lld, IPC = %f\n",
		real_time, NUM_IPS / (real_time * 1000000), dst_port_sum, ins, ipc);

	return 0;

}