Beispiel #1
0
int main()
{
  BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;
  {
    typedef boost::chrono::high_resolution_clock Clock;
    {
      typedef int T;
      boost::promise<T> p;
      boost::shared_future<T> f((p.get_future()));
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
      boost::thread(func1, boost::move(p)).detach();
#else
      func1(boost::move(p));
#endif
      BOOST_TEST(f.valid());
      f.wait();
      BOOST_TEST(f.valid());
      Clock::time_point t0 = Clock::now();
      f.wait();
      Clock::time_point t1 = Clock::now();
      BOOST_TEST(f.valid());
      BOOST_TEST(t1 - t0 < ms(50));
    }
    {
      typedef int& T;
      boost::promise<T> p;
      boost::shared_future<T> f((p.get_future()));
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
      boost::thread(func3, boost::move(p)).detach();
#else
      func3(boost::move(p));
#endif
      BOOST_TEST(f.valid());
      f.wait();
      BOOST_TEST(f.valid());
      Clock::time_point t0 = Clock::now();
      f.wait();
      Clock::time_point t1 = Clock::now();
      BOOST_TEST(f.valid());
      BOOST_TEST(t1 - t0 < ms(50));
    }
    {
      typedef void T;
      boost::promise<T> p;
      boost::shared_future<T> f((p.get_future()));
#if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK && defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
      boost::thread(func5, boost::move(p)).detach();
#else
      func5(boost::move(p));
#endif
      BOOST_TEST(f.valid());
      f.wait();
      BOOST_TEST(f.valid());
      Clock::time_point t0 = Clock::now();
      f.wait();
      Clock::time_point t1 = Clock::now();
      BOOST_TEST(f.valid());
      BOOST_TEST(t1 - t0 < ms(50));
    }
  }
  BOOST_THREAD_LOG << BOOST_THREAD_END_LOG;

  return boost::report_errors();
}
Beispiel #2
0
void filter(int *array, int X, int Y, int Z, int * seed, int N, FILE *ofp){
	long long func_start = get_time();
	double xr = round(Y/2.0);
	double yr = round(X/2.0);
	
	int radius = 5;
	int diameter = radius*2-1;
	int *radiusMatrix = (int *)malloc(diameter*diameter*sizeof(int));
	fillMatrix(radiusMatrix, radius);
	
	int Ones = 0;
	int x, y;
	for(x = 0; x < diameter; x++){
		for(y = 0; y < diameter; y++){
			if(radiusMatrix[x*diameter + y] == 1)
				Ones++;
		}
	}

	double * objxy = (double *)malloc(Ones*2*sizeof(double));
	getNeighbors(radiusMatrix, Ones, objxy, radius);
	
	double *weights = (double *)malloc(sizeof(double)*N);
	double *arrayX = (double *)malloc(sizeof(double)*N);
	double *arrayY = (double *)malloc(sizeof(double)*N);
	
	func0(weights, arrayX, arrayY, xr, yr, N);

	double * probability = (double *)malloc(sizeof(double)*N);
	double * x_j = (double *)malloc(sizeof(double)*N);
	double * y_j = (double *)malloc(sizeof(double)*N);
	double * cfd = (double *)malloc(sizeof(double)*N);
	double * u = (double *)malloc(sizeof(double)*N);
	int * index = (int*)malloc(sizeof(int)*Ones*N);
	
	int i, j;
	for(i = 1; i < Z; i++) {
		func1(seed, array, arrayX, arrayY, probability, objxy, index, Ones, i, X, Y, Z, N);

		func2(weights, probability, N);
		
		double x_e = 0;
		double y_e = 0;

		func3(arrayX, arrayY, weights, &x_e, &y_e, N);
		fprintf(ofp, "%f\n", x_e);
		fprintf(ofp, "%f\n", y_e);
		
		cfd[0] = weights[0];
		for(j = 1; j < N; j++){
			cfd[j] = weights[j] + cfd[j-1];
		}
		double u1 = (1/((double)(N)))*rand1(seed, 0);
		
		func4(u, u1, N);

		func5(x_j, y_j, arrayX, arrayY, weights, cfd, u, N);
	}

	long long func_end = get_time();
	printf("FUNC TIME : %f\n", elapsed_time(func_start, func_end));
	//fflush();

	for(i=0; i<Ones*2; i++) {
		fprintf(ofp, "%f\n", objxy[i]);
	}
	for(i=0; i<N; i++) {
		fprintf(ofp, "%f %f %f %f %f %f %f %f\n", 
			weights[i], arrayX[i], arrayY[i],
			probability[i], x_j[i], y_j[i],
			cfd[i], u[i]);
	}
	for(i=0; i<Ones*N; i++) {
		fprintf(ofp, "%d\n", index[i]);
	}
   		 
	free(radiusMatrix);
	free(objxy);
	free(weights);
	free(probability);
	free(x_j);
	free(y_j);
	free(arrayX);
	free(arrayY);
	free(cfd);
	free(u);
	free(index);    
}
Beispiel #3
0
void func2() {
   int i = 7;
   printf("\t\t[in func2] i = %d\n", i);
   func3();
   printf("\t\t[back in func2] i = %d\n", i);
}
Beispiel #4
0
int main(){
	int i;
	func3();

	scanf("%d", &i);
}
Beispiel #5
0
int func3()
{
   func2();
   func3();
   return(0);
}
Beispiel #6
0
/* GCC should automatically detect attributes for these functions.
   At -O3 They'll be inlined, but that's ok.  */
static int func2 (int a) { return i + a; } /* pure */
static int func3 (int a) { return a * 3; } /* const */
static int func4 (int a) { return func0(a) + a; } /* pure */
static int func5 (int a) { return a + func1(a); } /* const */
static int func6 (int a) { return func2(a) + a; } /* pure */
static int func7 (int a) { return a + func3(a); } /* const */
Beispiel #7
0
int main()
{
   int i;
   data *bob[100],*bob1;
void *_bob1_base=bob1;
void *_bob1_bound=NULL;

   char *a=(char *)malloc(100*sizeof(char));
void *_a_base=a;
void *_a_bound=a+100 * sizeof(char)/sizeof(char)-1;

   i=2;
   
   for(i=0;i<100;i++)
   {
      bob1=(data *)malloc(100*sizeof(data));
_bob1_base=bob1;
_bob1_bound=bob1+100 * sizeof(data)/sizeof(data)-1;

      if(bob1!=NULL)
      {
          bob1->age=i;
          if(20<strlen("Robert")) printf("buffer overflow at 17:47 in main\n");
          strcpy(bob1->name,"Robert");
          bob[_RV_insert_check(0,100,41,15,"main",i)]=bob1;
      }
   }
   for(i=0;i<10;i++)
   {
     printf("%s %d\n",bob[_RV_insert_check(0,100,46,27,"main",i)]->name,bob[_RV_insert_check(0,100,46,40,"main",i)]->age);
   }
   
   
   char *p1;
void *_p1_base=p1;
void *_p1_bound=NULL;
char *p2;
void *_p2_base=p2;
void *_p2_bound=NULL;

   char string[8]="ASDESFP";
   char *p3="DKLRTF";
void *_p3_base=p3;
void *_p3_bound=p3+7-1;

   p1=string+5;
_p1_base=&string[0];
_p1_bound=&string[8-1];

   p2=p3;
_p2_base=_p3_base;
_p2_bound=_p3_bound;

   func1(_p1_base,_p1_bound,p1);
   func1(&string[0],&string[8-1],string+5);
   func1(&string[0],&string[8-1],string+i+3);
   func1(&string[0],&string[8-1],5+string);
   func1(_p2_base,_p2_bound,p2);  //char [7]   "DKLRTF"  SSSSS
   func2(0,0,&bob1);
   func3(_a_base,_a_bound,a,_p3_base,_p3_bound,p3);
   return 1;
}
Beispiel #8
0
int main(int argc, const char *argv[]) {
  func();
  func2();
  func3();
}
Beispiel #9
0
void __attribute__((disable_tail_calls, noinline)) func2() { func3(); /* regular */ }
Beispiel #10
0
void
func4 (int p)
{
  func3 (p);
}