Beispiel #1
0
TEST_P(HogDetect, Accuracy)
{
    PRINT_PARAM(devInfo);

    ASSERT_NO_THROW(
        CV_GpuHogDetectTestRunner runner;
        runner.run();
    );
Beispiel #2
0
TEST_P(AddArray, Accuracy) 
{
    PRINT_PARAM(devInfo);
    PRINT_TYPE(type);
    PRINT_PARAM(size);
    
    cv::Mat dst_gold;
    cv::add(mat1, mat2, dst_gold);

    cv::Mat dst;

    ASSERT_NO_THROW(
        cv::gpu::GpuMat gpuRes;

        cv::gpu::add(cv::gpu::GpuMat(mat1), cv::gpu::GpuMat(mat2), gpuRes);

        gpuRes.download(dst);
    );
Beispiel #3
0
TEST_P(SURF, EmptyDataTest)
{
    PRINT_PARAM(devInfo);

    cv::gpu::SURF_GPU fdetector;

    cv::gpu::GpuMat image;
    std::vector<cv::KeyPoint> keypoints;
    std::vector<float> descriptors;

    ASSERT_NO_THROW(
        fdetector(image, cv::gpu::GpuMat(), keypoints, descriptors);
    );
Beispiel #4
0
TEST_P(Merge, Accuracy)
{
    if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
        return;

    PRINT_PARAM(devInfo);
    PRINT_TYPE(type);
    PRINT_PARAM(size);

    cv::Mat dst;

    ASSERT_NO_THROW(
        std::vector<cv::gpu::GpuMat> dev_src;
        cv::gpu::GpuMat dev_dst;

        for (size_t i = 0; i < src.size(); ++i)
        dev_src.push_back(cv::gpu::GpuMat(src[i]));

        cv::gpu::merge(dev_src, dev_dst);

        dev_dst.download(dst);
    );
Beispiel #5
0
TEST_P(StereoBlockMatching, Regression) 
{
    PRINT_PARAM(devInfo);
    
    cv::Mat disp;

    ASSERT_NO_THROW(
        cv::gpu::GpuMat dev_disp;
        cv::gpu::StereoBM_GPU bm(0, 128, 19);

        bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), dev_disp);
        
        dev_disp.download(disp);
    );
Beispiel #6
0
int main(int argc, char *argv[]) {



//global timing
clock_t start_g=clock(), diff_g;


//////////////////////////test function starts\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

char buffer[1024];
FILE *fp = fopen("dist.in", "r");
int num, i;
char comment[20];
char arr_data[800];
int fin_num;
for(i=0; i<799; i++){arr_data[i] = 'x';}
int run = 0;



//read file into num of test, comments and number char array
while (fgets(buffer, sizeof(buffer), fp) != NULL) {
  
  sscanf(buffer, "%i;%s %s", &num, comment, arr_data);  
  printf( "\n%i:  %s\n", num, arr_data  );

  int k = 0;
//count the number of numbers in the char array
  int num_count = 1; //one comma less then numbers
  while(arr_data[k] != 0 ) {
    if(arr_data[k] == ',') {num_count++;}
    k++;
    }

  printf("Nums in the array: %i", num_count);
//initialise double array
  int data[num_count]; // = {[0 ... num_coun] = 0};

  //converting char array to int array
  int acc_len = 0;
  for(i=0; i<num_count; i++){
    fin_num = 0;
    int num_len = 0;
    while(arr_data[acc_len+num_len] != ',' && arr_data[acc_len+num_len] != 0){num_len++;}
    //printf("\n%i's num lenght is %i ,", i, num_len);
    acc_len = acc_len + num_len +1;
    //printf("  start of next number is %i", acc_len);
    int decim;
    for(decim = acc_len - num_len -1; decim < acc_len -1; decim++){
        int d = arr_data[decim] - '0';
        int pow_c;
        int out = 1;
           for(pow_c = 0; pow_c <acc_len-decim-2; pow_c++) {out = out*10;}
        //printf("\nNumber %i for %i", out*d, d);  //(acc_len-decim-2)
        fin_num = fin_num + out*d;
        //printf("\nResulting number:  \n%i on inter %i", fin_num, decim);
        if(decim == acc_len -2) {
          data[i] = fin_num; 
          //printf("NUM FROM ARRAY: %i", data[i]);
          }
       }
      //printf("\n");
      }
  printf("\nPrinting array as int array: ");
  for(i=0; i<num_count; i++){
    printf("%i,", data[i]);}
    printf("\n");
//transferring data to X array
int X[num_count];

  for(i=0; i<num_count; i++){
    X[i] = data[i];}
//////////////////////////end of file to array parsing\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


int x_n = (int)(sizeof(X)/sizeof(*X));   
int depth = (int) ((log(x_n)+0.1)/log(2)); 

double tree[depth][x_n];
double cdf[x_n];
int histogram[sizeof(X)/sizeof(*X)] ;
int ddd;
for (ddd=0; ddd<x_n; ddd++) {histogram[ddd] =0;}
int hist[sizeof(X)/sizeof(*X)] ;
int step_size;
int num_of_points;
int position_num;

int i, j;

//pdf to cdf

cdf[0] = X[0];
for (i = 1; i < x_n; i++)  {
cdf[i] = cdf[i - 1] + X[i]; 
}

//normalised cdf
for (i = 0; i < x_n; i++)  {
cdf[i] = cdf[i]/cdf[x_n-1]; 
}

//print cdf
printf("cdf: ");
for(i = 0; i < x_n; i++) { printf("%g ",  cdf[i]); }
printf("\n");

// cdf to tree array
printf("TREE OUTPUT:\n ");
for(i = 0; i < depth; i++)  {

  step_size = x_n/pow(2, i);
  num_of_points = pow(2, i);
  position_num;

  for(j = 0; j < num_of_points; j++)  {
    if(j == 0) {position_num = step_size *(j + 1)* 0.5 - 1;} 
    else {position_num = step_size *j + step_size * 0.5 - 1;}  
    tree[i][j] = cdf[position_num];
    printf(" %g |", tree[i][j]);
  }
printf("\n");

}

printf("\n");

//tree array check
/*
for ( i = 0; i < depth; i++ ) { 
  printf("\n");
  for ( j = 0; j < x_n; j++ )  {  
    printf("T[%d][%d] = %f  ", i,j, tree[i][j] );
    }
}  */


// tree walk
//int err_count = 0;

int jj;

//global timing






//sgenrand(time(NULL));
int curr_pos, check;
int chunk; /* Repeat experiment in chunks. */
srand(SEED);

printf("# Info: $Header: /home/ma/p/pruess/.cvsroot/manna_range/dmitry_20151021/manna_stack_clean_edited.c,v 1.2 2015/10/21 11:37:00 pruess Exp $\n");
preamble(argc, argv);

PRINT_PARAM(SEED, "%lu");
PRINT_PARAM(LENGTH, "%lu");
PRINT_PARAM(DROP_LOCATION, "%lu");
PRINT_PARAM(total_malloced, "%lli");


printf("# Info: Expected avalanche size: <s>(x) = 1+(1/2) (<s>(x+1)+<s>(x-1)), BC <s>(0)=0, <s>(L+1)=0, solved by <s>(x)=(L+1-x)x/2.\n");
printf("# Info: Here L=LENGTH=%lu and x=DROP_LOCATION+1=%lu, so expect %g\n", LENGTH, DROP_LOCATION+1, ((double)(DROP_LOCATION+1))*((double)(LENGTH-DROP_LOCATION))/2.);


for (chunk=1; ((chunk<=NUM_CHUNKS) || (NUM_CHUNKS<0)); chunk++) {
MOMENTS_INIT(size);
for (drop = 0; drop < N_ROLLS; drop++) {  // big droppping cycle

long long int size=0;

#if (0)

#define PUSH(a) stack[stack_used++]=(a)
#define POP(a)  (a)=stack[--stack_used]

if(lattice[DROP_LOCATION] == 0) {
      lattice[DROP_LOCATION] = 1;
      }
 else {
      PUSH(DROP_LOCATION); 
      PUSH(DROP_LOCATION);
      lattice[DROP_LOCATION] = 0;
      size++;
 }

/* If validated, optimse by turning stack operations into macros, 
 * optime random number drawing (rather than having doubles in the tree
 * have integers there and draw an integer to compare against),
 * optimise the shuffling of particles. 
 *
 * I have added MOMENT macros for size. */

  while(stack_used != 0) {
    POP(curr_pos);
/* This code with the "check" looks clumsy. I suppose
 * you are "following through" topplings? I would think
 * there is no point doing this later. Anyway, we validate
 * this code and take it from there. */
    do {

double test_num = ((double)rand())/((double)RAND_MAX);

//tree walk
int x_pos = 0, y_pos = 0;

for(y_pos = 0; y_pos < depth ; y_pos++)  {
  if (test_num > tree[y_pos][x_pos])  {x_pos = (x_pos+1) * 2 - 1; } else {x_pos = x_pos * 2;}
  //printf("\nThe current position is : %i, %i", y_pos, x_pos);
  }

      curr_pos = curr_pos+ x_pos-1; //move_ball(curr_pos);
      //printf("\nshift: %i, RAND: %f", x_pos-1, test_num);
 
      if((curr_pos>=0) && (curr_pos<LENGTH)) {
        if(lattice[curr_pos] == 0)  {
          lattice[curr_pos] = 1;
          }
        else  {
          size++;
          lattice[curr_pos] = 0;
          PUSH(curr_pos);
        }
    } 
    else {break;}
  }while( (lattice[curr_pos] != 1));
}/* end of while(stack_used != 0) look */
#endif

#if (1)
{
int npos;

#define PUSH(a) stack[stack_used++]=(a)
#define POP(a)  (a)=stack[--stack_used]

if (lattice[DROP_LOCATION]++==1) {
  PUSH(DROP_LOCATION);

    while(stack_used) {
      POP(curr_pos);
      do {
        size++;
	lattice[curr_pos]-=2;

double test_num = ((double)rand())/((double)RAND_MAX);

// start of tree walk 
//tree walk
int x_pos = 0, y_pos = 0;

for(y_pos = 0; y_pos < depth ; y_pos++)  {
  if (test_num > tree[y_pos][x_pos])  {x_pos = (x_pos+1) * 2 - 1; } else {x_pos = x_pos * 2;}
  //printf("\nThe current position is : %i, %i", y_pos, x_pos);
  }

      npos = curr_pos+ x_pos-1; //move_ball(curr_pos);

//end of tree walk

	if ((npos>=0) && (npos<LENGTH)) {
	  if (lattice[npos]++==1) {PUSH(npos);}
	}

test_num = ((double)rand())/((double)RAND_MAX);


// start of tree walk 
//tree walk
x_pos = 0, y_pos = 0;

for(y_pos = 0; y_pos < depth ; y_pos++)  {
  if (test_num > tree[y_pos][x_pos])  {x_pos = (x_pos+1) * 2 - 1; } else {x_pos = x_pos * 2;}
  //printf("\nThe current position is : %i, %i", y_pos, x_pos);
  }

      npos = curr_pos+ x_pos-1; //move_ball(curr_pos);

//end of tree walk
        
	if ((npos>=0) && (npos<LENGTH)) {
	  if (lattice[npos]++==1) {PUSH(npos);}
	}
      } while (lattice[curr_pos]>1);
    }
  }
}
#endif

//printf("size is %i\n", size);
MOMENTS(size,size);
} /* end of iterations loop */
MOMENTS_OUT(size);

} /* chunk */
postamble();
}
}
Beispiel #7
0
int main(int argc, char *argv[]) {
  //sgenrand(time(NULL));
 int k, curr_pos, check;
int chunk; /* Repeat experiment in chunks. */
srand(SEED);

printf("# Info: $Header: /home/ma/p/pruess/.cvsroot/manna_range/dmitry_20151021/manna_stack_clean_edited.c,v 1.2 2015/10/21 11:37:00 pruess Exp $\n");
preamble(argc, argv);

PRINT_PARAM(SEED, "%lu");
PRINT_PARAM(LENGTH, "%lu");
PRINT_PARAM(DROP_LOCATION, "%lu");
PRINT_PARAM(total_malloced, "%lli");


printf("# Info: Expected avalanche size: <s>(x) = 1+(1/2) (<s>(x+1)+<s>(x-1)), BC <s>(0)=0, <s>(L+1)=0, solved by <s>(x)=(L+1-x)x/2.\n");
printf("# Info: Here L=LENGTH=%lu and x=DROP_LOCATION+1=%lu, so expect %g\n", LENGTH, DROP_LOCATION+1, ((double)(DROP_LOCATION+1))*((double)(LENGTH-DROP_LOCATION))/2.);


for (chunk=1; ((chunk<=NUM_CHUNKS) || (NUM_CHUNKS<0)); chunk++) {
MOMENTS_INIT(size);
for (drop = 0; drop < N_ROLLS; drop++) {  // big droppping cycle

size=0;

/*
printf("(%i.)", drop);
 for(k = 0; k<LENGTH; k++) {
    printf("\%i", lattice[k]); 
    }
 printf("\n");
*/

#if (1)
 if(check_cell(DROP_LOCATION) == 0) {
      lattice[DROP_LOCATION] = 1;
      }
 else {
      stack_push(DROP_LOCATION); 
      stack_push(DROP_LOCATION);
      lattice[DROP_LOCATION] = 0;
 }

/* If validated, optimse by turning stack operations into macros, 
 * optime random number drawing (rather than having doubles in the tree
 * have integers there and draw an integer to compare against),
 * optimise the shuffling of particles. 
 *
 * I have added MOMENT macros for size. */

  while(stack_used != 0) {
    curr_pos = stack_pop();


/* This code with the "check" looks clumsy. I suppose
 * you are "following through" topplings? I would think
 * there is no point doing this later. Anyway, we validate
 * this code and take it from there. */
    do {
      curr_pos = move_ball(curr_pos);

      if(curr_pos >= LENGTH || curr_pos < 0)  {
        check = 0 ;
        }
/* Why not just "else" instead of the "if"? */
      if(curr_pos < LENGTH && curr_pos >= 0) {
        check = check_cell(curr_pos);
        
        if (check == 1) {
          stack_push(curr_pos);
          }
      else {
        check = 0;
        }

    } 
  }while(check != 0);


  }/* end of while(stack_used != 0) look */
#endif

#if (0)
{
int npos;

#define PUSH(a) stack[stack_used++]=(a)
#define POP(a)  (a)=stack[--stack_used]

if (lattice[DROP_LOCATION]++==1) {
  PUSH(DROP_LOCATION);

    while(stack_used) {
      size++;
      POP(curr_pos);
      do {
	lattice[curr_pos]-=2;
	npos=curr_pos+ ( (rand()>RAND_MAX/2) ? 1 : -1);
	if ((npos>=0) && (npos<LENGTH)) {
	  if (lattice[npos]++==1) {PUSH(npos);}
	}
	if ((npos>=0) && (npos<LENGTH)) {
	  if (lattice[npos]++==1) {PUSH(npos);}
	}
      } while (lattice[curr_pos]>1);
    }
  }
}
#endif

//printf("size is %i\n", size);
MOMENTS(size,size);
} /* end of iterations loop */
MOMENTS_OUT(size);
} /* chunk */
}
int main(int argc, char** argv) {

  printf("*** DRAM to DRAM copy microbenchmark - baremtal ***\n");
  PRINT_PARAM(REGION_SIZE);
  PRINT_PARAM(ITERATIONS);
  
  int i;
  unsigned long j;
  // Allocate the src and dst regions
  //volatile uint8_t * const src = (uint8_t *) 0;
  //volatile uint8_t * const dst = (uint8_t *) src + REGION_SIZE;

  for (i = 0; i < ITERATIONS; i++) {
    // Source and destination addresses
    //unsigned long s = 0;
    //unsigned long d = 0;

    // Start timer
    //time_t start, end;
    //start=clock();

    for (j = 0; j < REGION_SIZE; j++) {

#ifdef READ_WRIE

#ifdef RAND_READ
      s = rand() % REGION_SIZE;
#else
      s += STRIDE;
      if (s>=REGION_SIZE)
	s = s%REGION_SIZE+1;
#endif

#ifdef RAND_WRITE 
      d = rand() % REGION_SIZE;
#else
      d += STRIDE;
      if (d>=REGION_SIZE)
	d = d%REGION_SIZE+1;
#endif

       // copy the chunk
      dst[d] = src[s];
      
#elif defined(READ)
      // TODO
#else      
      // TODO
#endif
      
    }
    
    // Stop timer, print report
    //end=clock();
    //double secs = ((end-start)/CLOCKS_PER_SEC);
    //double usecs_per_byte = (secs / REGION_SIZE) * MILLION;
    //printf("Run %d\t = %f s (%.9f us/B)\n", i, secs, usecs_per_byte);
    
  }

  return 0;
}
int main(int argc, char** argv) {

  printf("*** DRAM to DRAM copy microbenchmark - with OS ***\n");
  PRINT_PARAM(ITERATIONS);
  PRINT_PARAM(CHUNK_SIZE);
  PRINT_PARAM(REGION_SIZE);
  PRINT_PARAM(REGION_CHUNKS);
  PRINT_PARAM(READ_RAND);
  PRINT_PARAM(WRITE_RAND);
#if defined(READ_SEQ) || defined(WRITE_SEQ)
  PRINT_PARAM(STRIDE_SIZE);
  PRINT_PARAM(STRIDE_CHUNKS);
#endif
  
  int i;
  unsigned long j;
  // Allocate the src and dst regions 
  // (uint16_t because chunk size is 16B)
  uint16_t *src = (uint16_t *) malloc(REGION_SIZE);
  assert(src);
  uint16_t *dst = (uint16_t *) malloc(REGION_SIZE);
  assert(dst);
  // Source and destination addresses
  unsigned long s = 0;
  unsigned long d = 0;
  // Timer
  //time_t start, end;
  struct timeval tvs, tve;

  // Disable caching
  //dCacheDisable();

  // Start timer
  //start=clock();
  gettimeofday(&tvs, NULL);

  for (i = 0; i < ITERATIONS; i++) {
    for (j = 0; j < REGION_CHUNKS; j++) {

#ifdef READ_WRITE
      //printf("j=%lu \t dst addr=%p \t src addr=%p\n", j, dst+d, src+s);
      // Copy 16B
      memcpy(dst, src, CHUNK_SIZE);
      //dst[d] = src[s];

#ifdef RAND_READ
      s = rand() % REGION_CHUNKS;
#else
      s += STRIDE_CHUNKS;
      if (s >= REGION_CHUNKS)
	s = s % REGION_CHUNKS + 1;
#endif

#ifdef RAND_WRITE 
      d = rand() % REGION_SIZE;
#else
      d += STRIDE_CHUNKS;
      if (d >= REGION_CHUNKS)
	d = d % REGION_CHUNKS + 1;
#endif
            
#elif defined(READ)
      // TODO
#else      
      // TODO
#endif
      
    }
    
    // Reset addresses
    s = 0;
    d = 0;
    // Flush cache
    // TODO
  }

  // Stop timer, print report
  //end=clock();
  gettimeofday(&tve, NULL);
  double secs = tve.tv_usec - tvs.tv_usec;
  //double secs = ((end-start)/CLOCKS_PER_SEC);
  double usecs_per_byte = (secs / REGION_SIZE) * MILLION;
  //printf("Run %d\t = %f s (%.9f us/B)\n", i, secs, usecs_per_byte);
  printf("total time = %f s (%.9f us/B)\n", secs, usecs_per_byte);

  // Free memory resources
  free(src);
  free(dst);

  return 0;
}