コード例 #1
0
ファイル: SL_vision_proc.c プロジェクト: Riba7/hoap-sl
/*!*****************************************************************************
 *******************************************************************************
\note  init_vision_processing
\date  June 1999
   
\remarks 

          initialization for vision processing

 *******************************************************************************
 Function Parameters: [in]=input,[out]=output

     none

 ******************************************************************************/
int
init_vision_processing(void)

{
  
  int i,j;
  static int firsttime = TRUE;

  stereo_mode = VISION_3D_MODE;
  
  if (firsttime) {
    firsttime = FALSE;
    blobpp = (BlobPP *) my_calloc(max_blobs+1,sizeof(BlobPP),MY_STOP);
  }

#if 1
  /* initialize matrices */
  if (!init_matrices())
      return FALSE;
#endif

  /* initialize filtering */
  if (!init_filters())
    return FALSE;
  
  /* initialize post processing */
  if (!init_pp((char *)vision_default_pp))
    return FALSE;
  
  return TRUE;
  
}
コード例 #2
0
ファイル: matmul.cpp プロジェクト: ryanjhuber/Mitos
int main(int argc, char **argv)
{
    int N = (argc == 2) ? atoi(argv[1]) : 1024;
    double *a,*b,*c;
    init_matrices(N,&a,&b,&c);
    matmul(N,a,b,c);
    return 0;
}
コード例 #3
0
ファイル: scm-render.cpp プロジェクト: rlk/scm
void scm_render::set_size(int w, int h)
{
    free_ogl();
    width  = w;
    height = h;
    init_ogl();
    init_matrices();
}
コード例 #4
0
ファイル: scm-render.cpp プロジェクト: rlk/scm
scm_render::scm_render(int w, int h) :
    width(w), height(h), blur(0), wire(false), frame0(0), frame1(0)
{
    init_ogl();
    init_matrices();

    for (int i = 0; i < 16; i++)
        midentity(previous_T[i]);
}
コード例 #5
0
ファイル: data_gatherer_double.c プロジェクト: dose78/CARMA
void trial(char* alg, int m, int k, int n, int threads, int max_depth, int num_iters, char* output) {
  int i, iter, success = 0, num_failures = 0;
  double *Gflops = (double*) malloc(num_iters * sizeof(double));
  double *cacheClearer = (double*) malloc(100000000); //L3 cache is less than 100MB
  for(i = 0; i < 12500000; i++) cacheClearer[i] = i;

  while (success == 0) {
    double *A[NUM_SMALL_MATRICES_MAX], *B[NUM_SMALL_MATRICES_MAX], *C[NUM_SMALL_MATRICES_MAX];
    // discover how many multiplies are needed and init them
    int num_matrices = init_matrices(m, k, n, A, B, C, max_depth);
    // printf("Num matrices required: %d\n", num_matrices);

    success = 1;
    for (iter = 0; iter < num_iters; iter++) {
      struct timeval start, end;
      clearCache(cacheClearer);
      gettimeofday(&start, NULL);
      for (i = 0; i < num_matrices; i++) {
        multiply(m, k, n, A[i], B[i], C[i], max_depth);
      }
      gettimeofday(&end, NULL);
      double seconds = (end.tv_sec - start.tv_sec) + 1.0e-6 * (end.tv_usec - start.tv_usec);
      Gflops[iter] = num_matrices * 2e-9 * m * k * n / seconds;
      printf("%s,%d,%d,%d,%d,%d,%f", alg, m, k, n, max_depth, threads, Gflops[iter]);

      if (seconds < 0.05 && num_failures < MAX_NUM_FAILURES) {
        printf(" WARNING: Matrix size may be too small to produce accurate timing data. Re-running...\n");
        num_failures++;
        success = 0;
        break;
      }
      printf("\n");
    }
    if (num_failures == MAX_NUM_FAILURES) {
      printf("ERROR: data at %s,%d,%d,%d,%d,%d should be gathered again\n", alg, m, k, n, max_depth, threads);
    }
    for (i=0; i<num_matrices; i++) free(A[i]);
    for (i=0; i<num_matrices; i++) free(B[i]);
    for (i=0; i<num_matrices; i++) free(C[i]);
  }

  FILE *f = fopen(output,"a");
  for (iter = 0; iter < num_iters; iter++) {
    fprintf(f,"%s,%d,%d,%d,%d,%d,%f\n", alg, m, k, n, max_depth, threads, Gflops[iter]);
  }
  fclose(f);

  free(Gflops);
  free(cacheClearer);

  // correctnessTest(m, k, n, max_depth);
}
コード例 #6
0
ファイル: gt_matrix.c プロジェクト: bharathravi/CFS-Userspace
int main()
{
	uthread_arg_t *uarg;
	int inx, i ,j;


	gtthread_app_init();

	init_matrices();
//	print_matrix(&A);
//	print_matrix(&B);
//	print_matrix(&C);
	gettimeofday(&tv1,NULL);
	j = 0;
	for (i=0; i<4; ++i) 
	{
		for(inx=0; inx<NUM_THREADS; inx++)
		{
			uarg = &uargs[inx];
			uarg->_A = &A[i];
			uarg->_B = &B[i];
			uarg->_C = &C[i];

			uarg->tid = inx;

			uarg->gid = i;  // Every matrix in a different group
                        uarg->matrix_size = sizes[i];

			uarg->start_row = (inx * sizes[i]/NUM_THREADS);
#ifdef GT_GROUP_SPLIT
		/* Wanted to split the columns by groups !!! */
			uarg->start_col = (uarg->gid * PER_GROUP_COLS);
#endif

			uthread_create(&utids[j], uthread_mulmat, uarg, uarg->gid);
			j++;
		}
	}
//	for(i=0; i < 100000; ++i) {
//		for(j=0; j<9000; ++j) {
//
//              }
//        }

	gtthread_app_exit();

//	print_matrix(&A);
//	print_matrix(&B);
//	print_matrix(&C);
	// fprintf(stderr, "********************************");
	return(0);
}
コード例 #7
0
ファイル: main.c プロジェクト: glegrain/RTAI
static int test_init(void) {
    int ierr;

    rt_set_oneshot_mode();

    printk("PGM STARTING\n");

    init_matrices();

    // Create real-time tasks
    ierr = rt_task_init_cpuid(&sens_task,  // task
                              senscode,    // rt_thread
                              0,           // data
                              STACK_SIZE,  // stack_size
                              3,           // priority
                              0,           // uses_fpu
                              0,           // signal
                              0);          // cpuid

    ierr = rt_task_init_cpuid(&act_task,   // task
                              actcode,     // rt_thread
                              0,           // data
                              STACK_SIZE,  // stack_size
                              4,           // priority
                              0,           // uses_fpu
                              0,           // signal
                              0);          // cpuid

    // init semaphores
    rt_typed_sem_init(&sensDone,  // semaphore pointer
                      0,          // initial value
                      BIN_SEM);   // semaphore type

    if (!ierr) {

        start_rt_timer(nano2count(TICK_PERIOD));
        now = rt_get_time();
        // Start tasks
        rt_task_make_periodic(&sens_task, now,  nano2count(PERIOD));
        //rt_task_resume(&act_task);

    }
    //return ierr;
    return 0; // pour ne pas faire planter le kernel
}
コード例 #8
0
ファイル: engine_brute.cpp プロジェクト: KillaPL/cnbody
  EngineBrute(Star **&stars, const int &stars_count_, const float &gravity_constant){
    stars_count = stars_count_;

    init_matrices();
    update_matrices(stars, gravity_constant);
  }
コード例 #9
0
ファイル: gt_matrix.c プロジェクト: pragya1990/gtthreads7
int main(int argc, char *argv[])
//int main()
{
	isCreditScheduler = 0;
	if(argc > 1)
		if(*argv[1] == '1')
			isCreditScheduler = 1;	
	
	isCreditScheduler = 1;
	uthread_arg_t *uarg;
	int inx,i;
	
//	kthread_block_signal(SIGVTALRM);
//	kthread_block_signal(SIGUSR1);
	gtthread_app_init();
	uthread_info_init(); // initialises the uthread info that is shared among all uthreads. Used for logging purposes.

	init_possible_groups();
	for(i=0;i<TOTAL_GROUPS;i++)
		init_matrices(&possible_groups[i]);

	//int current_matrix_size_index, current_row_index, current_credit_value_index, current_num_thread_per_group_index, current_num_group_index;
	int size, rows_per_thread, current_row = 0, group_id = 0;
	for(inx=0; inx<NUM_THREADS; inx++)
	{
		size = possible_groups[group_id].matrix_size;
		rows_per_thread = size / (THREADS_PER_GROUP);
		
		uarg = &uargs[inx];
		uarg->_A = matrices_A[group_id];
		uarg->_B = matrices_B[group_id];
		uarg->_C = matrices_C[group_id];

		uarg->tid = inx;
		uarg->gid = group_id;
		uarg->start_row = current_row;
		uarg->end_row = current_row + rows_per_thread;
		uarg->start_col = 0;
		uarg->end_col = size;
		int credit = matrices_A[group_id]->matrix_group->credit_value;

		printf("group_id: %d, current_row: %d, rows_per_thread: %d, size: %d, credits: %d, inx: %d, NUM_THREADS: %d\n", 
			group_id, current_row, rows_per_thread, size,  credit, inx, NUM_THREADS);

		current_row = current_row + rows_per_thread;
		if(current_row == size)
		{
			current_row = 0;
			group_id++;
		}
//#ifdef GT_GROUP_SPLIT
		// Wanted to split the columns by groups !!! *
		//uarg->start_col = (uarg->gid * PER_GROUP_COLS);
//#endif
	//	printf("going to uthread_create\n");
		uthread_create(&utids[inx], uthread_mulmat, uarg, uarg->gid, credit, possible_groups[group_id].matrix_size);
	//`	printf("exit from uthread_create\n");
	}
	
//	kthread_unblock_signal(SIGVTALRM);
//	kthread_unblock_signal(SIGUSR1);
	FILE *fp, *fp1;
	fp = fopen("stat.txt","w+");
	fp1 = fopen("stat1.txt","w+");
	gtthread_app_exit();
	print_statistics(fp,fp1);
	init_group_stats();
	print_group_stats(fp,fp1);
	verify_answer();
	fclose(fp);
	fclose(fp1);

//	for(i=0;i<TOTAL_GROUPS;i++)
//	{
//		int size = possible_groups[i].matrix_size;
//		printf("Matrix A, i:%d, size: %d, credits: %d\n", i, size, possible_groups[i].credit_value);
//		print_matrix(matrices_A[i], size);
//		printf("Matrix B, i:%d, size: %d, credits: %d\n", i, size, possible_groups[i].credit_value);
//		print_matrix(matrices_B[i], size);
//		printf("Matrix C, i:%d, size: %d, credits: %d\n", i, size, possible_groups[i].credit_value);
//		print_matrix(matrices_C[i], size);
//	}

	// print_matrix(&C);
	// fprintf(stderr, "********************************");
	return(0);
}
コード例 #10
0
void
img_makePalette(int cmapsize, int tablesize, int lookupsize,
		float lscale, float weight,
		int prevclrs, int doMac,
		unsigned char *reds,
		unsigned char *greens,
		unsigned char *blues,
		unsigned char *lookup)
{
    CmapEntry *pCmap;
    int i, ix;
#ifdef STATS
    double ave_dL, ave_dE;
    double max_dL, max_dE;
#endif /* STATS */
#ifdef TIMES
    clock_t start, mid, tbl, end;

    start = clock();
#endif /* TIMES */

    init_matrices();
    Lscale = lscale;
    Weight = weight;

    cmapmax = cmapsize;
    total = 0;
    for (i = 0; i < prevclrs; i++) {
	add_color(reds[i], greens[i], blues[i], TRUE);
    }

    add_color(0, 0, 0, TRUE);
    add_color(255,255,255, TRUE);

    /* do grays next; otherwise find_nearest may break! */
    init_grays();
    if (doMac) {
	init_mac_palette();
    }
    init_pastels();

    init_primaries();

    /* special case some blues */
    add_color(0,0,192,TRUE);
    add_color(0x30,0x20,0x80,TRUE);
    add_color(0x20,0x60,0xc0,TRUE);

    init_virt_cmap(lookupsize, tablesize);

    while (total < cmapsize) {
	handle_biggest_offenders(tablesize, cmapsize);
    }

    memcpy(reds, cmap_r, cmapsize);
    memcpy(greens, cmap_g, cmapsize);
    memcpy(blues, cmap_b, cmapsize);

#ifdef TIMES
    mid = clock();
#endif /* TIMES */

    pCmap = virt_cmap;
    for (i = 0; i < num_virt_cmap_entries; i++, pCmap++) {
	if (pCmap->nextidx < 0) {
	    continue;
	}
	if (pCmap->nextidx < total) {
	    ix = find_nearest(pCmap);
	}
    }

#ifdef TIMES
    tbl = clock();
#endif /* TIMES */

    pCmap = virt_cmap;
    if (tablesize != lookupsize) {
	int r, g, b;
	for (r = 0; r < lookupsize; ++r)
	{
	    for (g = 0; g < lookupsize; ++g)
	    {
		for (b = 0; b < lookupsize; ++b, pCmap++)
		{
		    float L, U, V;
		    float bestd = 0;
		    CmapEntry *pTest;

		    if (pCmap->nextidx >= 0) {
			continue;
		    }
#ifdef DEBUG
		    if (r == g && g == b) {
			jio_fprintf(stderr, "GRAY VALUE!?\n");
		    }
#endif /* DEBUG */
		    L = pCmap->L;
		    U = pCmap->U;
		    V = pCmap->V;
		    for (i = 0; i < 8; i++) {
			int ri, gi, bi;
			float d, t;
			ri = (i & 1) ? prevtest[r] : nexttest[r];
			gi = (i & 2) ? prevtest[g] : nexttest[g];
			bi = (i & 4) ? prevtest[b] : nexttest[b];
			pTest = &virt_cmap[((ri * lookupsize)
					    + gi) * lookupsize
					   + bi];
#ifdef DEBUG
			if (pTest->nextidx < 0) {
			    jio_fprintf(stderr, "OOPS!\n");
			}
#endif /* DEBUG */
			ix = pTest->bestidx;
			t = Ltab[ix] - L; d  = t * t * Lscale;
			if (i != 0 && d > bestd) continue;
			t = Utab[ix] - U; d += t * t;
			if (i != 0 && d > bestd) continue;
			t = Vtab[ix] - V; d += t * t;
			if (i != 0 && d > bestd) continue;
			bestd = d;
			pCmap->bestidx = ix;
		    }
		}
	    }
	}
    }
    pCmap = virt_cmap;
    for (i = 0; i < num_virt_cmap_entries; i++) {
	*lookup++ = (pCmap++)->bestidx;
    }

#ifdef TIMES
    end = clock();
#endif /* TIMES */

#ifdef STATS
    max_dL = 0.0;
    max_dE = 0.0;
    ave_dL = 0.0;
    ave_dE = 0.0;

    pCmap = virt_cmap;
    for (i = 0; i < num_virt_cmap_entries; i++, pCmap++) {
	double t, dL, dU, dV, dE;
	if (pCmap->nextidx < 0) {
	    int ix = pCmap->bestidx;
	    dL = pCmap->L - Ltab[ix]; dL *= dL;
	    dU = pCmap->U - Utab[ix]; dU *= dU;
	    dV = pCmap->V - Vtab[ix]; dV *= dV;
	    dE = dL * Lscale + dU + dV;
	    dE = WEIGHT_DIST(dE, pCmap->L);
	} else {
	    dL = pCmap->dL;
	    dE = pCmap->dE;
	}

	if (dL > max_dL) max_dL = dL;
	t = UNWEIGHT_DIST(dE,dL) - dL*(Lscale-1);
	if (t > max_dE) max_dE = t;

	ave_dL += (dL > 0) ? sqrt(dL) : 0.0;
	ave_dE += (t > 0) ? sqrt(t) : 0.0;
    }

    jio_fprintf(stderr, "colors=%d, tablesize=%d, cubesize=%d, ",
	    cmapsize, tablesize, lookupsize);
    jio_fprintf(stderr, "Lscale=%5.3f, Weight=%5.3f mac=%s\n",
	    (double)lscale, (double)weight, doMac ? "true" : "false");
    jio_fprintf(stderr, "Worst case error dL = %5.3f, dE = %5.3f\n", 
	    sqrt(max_dL), sqrt(max_dE));
    jio_fprintf(stderr, "Average error dL = %5.3f, dE = %5.3f\n", 
	    ave_dL / num_virt_cmap_entries,  ave_dE / num_virt_cmap_entries);
#endif /* STATS */
#ifdef TIMES
    jio_fprintf(stderr, "%f seconds to find colors\n",
	    (double)(mid - start) / CLOCKS_PER_SEC);
    jio_fprintf(stderr, "%f seconds to finish nearest colors\n",
	    (double)(tbl - mid) / CLOCKS_PER_SEC);
    jio_fprintf(stderr, "%f seconds to make lookup table\n",
	    (double)(end - tbl) / CLOCKS_PER_SEC);
    jio_fprintf(stderr, "%f seconds total\n",
	    (double)(end - start) / CLOCKS_PER_SEC);
#endif /* TIMES */

    free(virt_cmap);
    virt_cmap = 0;
}
コード例 #11
0
ファイル: rb2rgb.c プロジェクト: jbmulligan/quip
static int install_white(SINGLE_QSP_ARG_DECL)
{
	int j,k;
	float wc[3];	/* white chromaticity */
	float uv[3];	/* unit vector */
	float *ptr;

	if( init_matrices(SINGLE_QSP_ARG) < 0 ) return(-1);

	/* we assume we already have the white point */
	if( ! know_white )
		error1("install_white:  white point not defined!?");


	for(j=0;j<3;j++) wc[j] = _white[j];
showvec(wc);
	rgb2rb(wc);	/* now we have the chromaticity of the white point */
advise("white transformed to opponent space");
showvec(wc);

	for(j=0;j<3;j++) uv[j] = wc[j];
	uv[0]+= 0.1;	/* take a step in the red cone direction */
	rb2rgb(uv);
	for(j=0;j<3;j++) uv[j] -= _white[j];

	/* now have an rgb vector for an red cone step */
	/* normalize this relative to the white point */
	/* this is to guarantee that amp. of +-1 won't overflow */
advise("red cone vector");
showvec(wc);

	wnorm(uv);

	/* now set the entries of the o2p matrix */
	for(j=0;j<3;j++) o2p_mat[j][0] = uv[j];

	for(j=0;j<3;j++) uv[j] = wc[j];
	uv[1]+= 0.1;	/* take a step in the blue cone  direction */
	rb2rgb(uv);
	for(j=0;j<3;j++) uv[j] -= _white[j];

	/* now have an rgb vector for a blue cone step */

	wnorm(uv);

	for(j=0;j<3;j++) o2p_mat[j][1] = uv[j];

	for(j=0;j<3;j++) uv[j] = _white[j];
	wnorm(uv);
	for(j=0;j<3;j++) o2p_mat[j][2] = uv[j];

	ptr = (float *)OBJ_DATA_PTR(o2p_dp);
	for(j=0;j<3;j++)
		for(k=0;k<3;k++)
			*ptr++ = o2p_mat[j][k];
	dp_copy(p2o_dp,o2p_dp);
	dt_invert(p2o_dp);
	ptr = (float *)OBJ_DATA_PTR(p2o_dp);
	for(j=0;j<3;j++)
		for(k=0;k<3;k++)
			p2o_mat[j][k] = *ptr++;

	return(0);
}