Exemplo n.º 1
0
char * run(void)

	{
	char	buf[80];
	int		arsize;
	long	arsize2d,memreq,nreps;
	size_t	malloc_arg;

	while (1)
		{
//		  printf("Enter array size (q to quit) [200]:  ");
//		  fgets(buf,79,stdin);
//		  if (buf[0]=='q' || buf[0]=='Q')
//			  break;
//		  if (buf[0]=='\0' || buf[0]=='\n')
//			  arsize=200;
//		  else
//			  arsize=atoi(buf);
		arsize = 200;
		arsize/=2;
		arsize*=2;
		if (arsize<10)
			{
			printf("Too small.\n");
			continue;
			}
		arsize2d = (long)arsize*(long)arsize;
		memreq=arsize2d*sizeof(REAL)+(long)arsize*sizeof(REAL)+(long)arsize*sizeof(int);
		printf("Memory required:  %ldK.\n",(memreq+512L)>>10);
		malloc_arg=(size_t)memreq;
		if (malloc_arg!=memreq || (mempool=malloc(malloc_arg))==NULL)
			{
			printf("Not enough memory available for given array size.\n\n");
			continue;
			}
		sprintf(buf, "\n\nLINPACK benchmark, %s precision.\n",PREC);
		pass_jni_msg(buf);
		sprintf(buf, "Machine precision:  %d digits.\n",BASE10DIG);
		pass_jni_msg(buf);
		sprintf(buf, "Array size %d X %d.\n",arsize,arsize);
		pass_jni_msg(buf);
		sprintf(buf, "Average rolled and unrolled performance:\n\n");
		pass_jni_msg(buf);
		sprintf(buf, "	  Reps Time(s) DGEFA   DGESL  OVERHEAD	  MFLOPS\n");
		pass_jni_msg(buf);
		sprintf(buf, "----------------------------------------------------\n");
		pass_jni_msg(buf);
		nreps=1;
		while (linpack(nreps,arsize)<10.)
			nreps*=2;
		free(mempool);
		printf("\n");
		return "Done!";
		}
	}
Exemplo n.º 2
0
/*
 * Do the benchmarks and print the results to the console
 */
void StropBencher::bench() {

	float time;
	int i;
	char buf[120];

	sprintf(buf, "STROPS Benchmark started!");
	pass_jni_msg(buf);

	//double the amount of test runs until the test take more than RUNNING_TIME to perform
	for(i = 1; (time = this->appender(i, MAUTIL_STRING, 0)) < RUNNING_TIME; i*=2);
	sprintf(buf, "appending %d c_str:s to a std::string in ", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->appender(i, MAUTIL_STRING, 1)) < RUNNING_TIME; i*=2);
	sprintf(buf, "appending %d std::strings to a std::string in ", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->copy(i, MAUTIL_STRING)) < RUNNING_TIME; i*=2);
	sprintf(buf, "copying %d std::string to a std::string in ", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->find(i, MAUTIL_STRING, 0)) < RUNNING_TIME; i*=2);
	sprintf(buf, "searching for each character in the alphabet %d times using find()", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->find(i, MAUTIL_STRING, 1)) < RUNNING_TIME; i*=2);
	sprintf(buf, "searching for each character in the alphabet %d times using find_last_of()", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->find(i, MAUTIL_STRING, 2)) < RUNNING_TIME; i*=2);
	sprintf(buf, "searching for each character in the alphabet %d times using find_first_of()", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->find(i, MAUTIL_STRING, 3)) < RUNNING_TIME; i*=2);
	sprintf(buf, "searching for each character in the alphabet %d times using find_first_not_of()", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->substr(i, MAUTIL_STRING)) < RUNNING_TIME; i*=2);
	sprintf(buf, "substring a std::string and store in another std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->insert(i, MAUTIL_STRING, 0)) < RUNNING_TIME; i*=2);
	sprintf(buf, "Inserting a c_str in a std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);
	return;

	for(i = 1; (time = this->insert(i, MAUTIL_STRING, 1)) < RUNNING_TIME; i*=2);
	sprintf(buf, "Inserting a std::string in another std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->remove(i, MAUTIL_STRING)) < RUNNING_TIME; i*=2);
	sprintf(buf, "Removing parts of a std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->resize(i, MAUTIL_STRING)) < RUNNING_TIME; i*=2);
	sprintf(buf, "Resizing a std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->compare(i, MAUTIL_STRING, 0)) < RUNNING_TIME; i*=2);
	sprintf(buf, "Testing operator== on std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->compare(i, MAUTIL_STRING, 1)) < RUNNING_TIME; i*=2);
	sprintf(buf, "Testing operator!= on std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->compare(i, MAUTIL_STRING, 2)) < RUNNING_TIME; i*=2);
	sprintf(buf, "Testing operator<= on std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->compare(i, MAUTIL_STRING, 3)) < RUNNING_TIME; i*=2);
	sprintf(buf, "Testing operator>= on std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->compare(i, MAUTIL_STRING, 4)) < RUNNING_TIME; i*=2);
	sprintf(buf, "Testing operator< on std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	for(i = 1; (time = this->compare(i, MAUTIL_STRING, 5)) < RUNNING_TIME; i*=2);
	sprintf(buf, "Testing operator> on std::string %d times", ALOT*i);
	pass_jni_msg(buf);
	sprintf(buf, "Time: %1.2f seconds, %1.2f KSTROPS.\n", time, (float) (0.001f*ALOT*i)/(float) time);
	pass_jni_msg(buf);

	//freeze until 0 is pressed
	//FREEZE;
}
Exemplo n.º 3
0
static REAL linpack(long nreps,int arsize)

	{
	REAL  *a,*b;
	REAL   norma,t1,kflops,tdgesl,tdgefa,totalt,toverhead,ops;
	int	  *ipvt,n,info,lda;
	long   i,arsize2d;
	char   buf[80];

	lda = arsize;
	n = arsize/2;
	arsize2d = (long)arsize*(long)arsize;
	ops=((2.0*n*n*n)/3.0+2.0*n*n);
	a=(REAL *)mempool;
	b=a+arsize2d;
	ipvt=(int *)&b[arsize];
	tdgesl=0;
	tdgefa=0;
	totalt=second();
	for (i=0;i<nreps;i++)
		{
		matgen(a,lda,n,b,&norma);
		t1 = second();
		dgefa(a,lda,n,ipvt,&info,1);
		tdgefa += second()-t1;
		t1 = second();
		dgesl(a,lda,n,ipvt,b,0,1);
		tdgesl += second()-t1;
		}
	for (i=0;i<nreps;i++)
		{
		matgen(a,lda,n,b,&norma);
		t1 = second();
		dgefa(a,lda,n,ipvt,&info,0);
		tdgefa += second()-t1;
		t1 = second();
		dgesl(a,lda,n,ipvt,b,0,0);
		tdgesl += second()-t1;
		}
	totalt=second()-totalt;
	if (totalt<0.5 || tdgefa+tdgesl<0.2)
		return(0.);
	kflops=2.*nreps*ops/(1000.*(tdgefa+tdgesl));
	toverhead=totalt-tdgefa-tdgesl;
	if (tdgefa<0.)
		tdgefa=0.;
	if (tdgesl<0.)
		tdgesl=0.;
	if (toverhead<0.)
		toverhead=0.;

	sprintf(buf,"%8ld %6.2f %6.2f%% %6.2f%% %6.2f%%	 %9.3f\n",
			nreps,totalt,100.*tdgefa/totalt,
			100.*tdgesl/totalt,100.*toverhead/totalt,
			kflops/1000.0);

	/* Callback to Java to print buf */
	pass_jni_msg(buf);
	if(totalt > 10.)//only send data to server when bench is done
		pass_result("mflops", (float) (kflops/1000.0));

	return(totalt);
	}