static void fd_seek(void)
{
	unsigned long flags;
	DPRINT(("fd_seek() to track %d (unit[SelectedDrive].track=%d)\n", ReqTrack,
		unit[SelectedDrive].track));
	if (unit[SelectedDrive].track == ReqTrack <<
	    unit[SelectedDrive].disktype->stretch) {
		fd_seek_done(0);
		return;
	}
	FDC1772_WRITE(FDC1772REG_DATA, ReqTrack <<
		      unit[SelectedDrive].disktype->stretch);
	udelay(25);
	save_flags(flags);
	clf();
	SET_IRQ_HANDLER(fd_seek_done);
	FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_SEEK | unit[SelectedDrive].steprate |
		/* DAG */
		(MotorOn?FDC1772CMDADD_H:0));

	restore_flags(flags);
	MotorOn = 1;
	set_head_settle_flag();
	START_TIMEOUT();
	/* wait for IRQ */
}
Example #2
0
static void arc_floppy_data_enable_dma(dmach_t channel, dma_t *dma)
{
	DPRINTK("arc_floppy_data_enable_dma\n");

	if (dma->using_sg)
		BUG();

	switch (dma->dma_mode) {
	case DMA_MODE_READ: { /* read */
		unsigned long flags;
		DPRINTK("enable_dma fdc1772 data read\n");
		local_save_flags_cli(flags);
		clf();
			
		memcpy ((void *)0x1c, (void *)&fdc1772_dma_read,
			&fdc1772_dma_read_end - &fdc1772_dma_read);
		fdc1772_setupdma(dma->buf.length, dma->buf.__address); /* Sets data pointer up */
		enable_fiq(FIQ_FLOPPYDATA);
		loacl_irq_restore(flags);
	   }
	   break;

	case DMA_MODE_WRITE: { /* write */
		unsigned long flags;
		DPRINTK("enable_dma fdc1772 data write\n");
		local_save_flags_cli(flags);
		clf();
		memcpy ((void *)0x1c, (void *)&fdc1772_dma_write,
			&fdc1772_dma_write_end - &fdc1772_dma_write);
		fdc1772_setupdma(dma->buf.length, dma->buf.__address); /* Sets data pointer up */
		enable_fiq(FIQ_FLOPPYDATA);

		local_irq_restore(flags);
	    }
	    break;
	default:
		printk ("enable_dma: dma%d not initialised\n", channel);
	}
}
Example #3
0
static void arc_floppy_data_enable_dma(dmach_t channel, dma_t *dma)
{
	DPRINTK("arc_floppy_data_enable_dma\n");
	switch (dma->dma_mode) {
	case DMA_MODE_READ: { /* read */
		extern unsigned char fdc1772_dma_read, fdc1772_dma_read_end;
		extern void fdc1772_setupdma(unsigned int count,unsigned int addr);
		unsigned long flags;
		DPRINTK("enable_dma fdc1772 data read\n");
		save_flags(flags);
		clf();
			
		memcpy ((void *)0x1c, (void *)&fdc1772_dma_read,
			&fdc1772_dma_read_end - &fdc1772_dma_read);
		fdc1772_setupdma(dma->buf.length, dma->buf.address); /* Sets data pointer up */
		enable_fiq(FIQ_FLOPPYDATA);
		restore_flags(flags);
	   }
	   break;

	case DMA_MODE_WRITE: { /* write */
		extern unsigned char fdc1772_dma_write, fdc1772_dma_write_end;
		extern void fdc1772_setupdma(unsigned int count,unsigned int addr);
		unsigned long flags;
		DPRINTK("enable_dma fdc1772 data write\n");
		save_flags(flags);
		clf();
		memcpy ((void *)0x1c, (void *)&fdc1772_dma_write,
			&fdc1772_dma_write_end - &fdc1772_dma_write);
		fdc1772_setupdma(dma->buf.length, dma->buf.address); /* Sets data pointer up */
		enable_fiq(FIQ_FLOPPYDATA;

		restore_flags(flags);
	    }
	    break;
	default:
		printk ("enable_dma: dma%d not initialised\n", channel);
	}
}
Example #4
0
static void arc_floppy_cmdend_enable_dma(dmach_t channel, dma_t *dma)
{
	/* Need to build a branch at the FIQ address */
	extern void fdc1772_comendhandler(void);
	unsigned long flags;

	DPRINTK("arc_floppy_cmdend_enable_dma\n");
	/*printk("enable_dma fdc1772 command end FIQ\n");*/
	save_flags(flags);
	clf();
	
	/* B fdc1772_comendhandler */
	*((unsigned int *)0x1c)=0xea000000 |
			(((unsigned int)fdc1772_comendhandler-(0x1c+8))/4);

	local_irq_restore(flags);
}
Example #5
0
//----------------------------------------------------------------------
void FLOCK::integrate()
{
    timers["integrate"]->start();
    euler_integration.execute(num,
        settings->GetSettingAs<float>("time_step"),
        cl_position_u,
        cl_position_s,
        cl_velocity_u,
        cl_velocity_s,
        cl_separation_s,
        cl_alignment_s,
        cl_cohesion_s,
        cl_goal_s,
        cl_avoid_s,
        cl_leaderfollowing_s,
        cl_rotation_u,
        cl_sort_indices,
        cl_FLOCKParameters,
        cl_GridParamsScaled,
        //debug
        clf_debug,
        cli_debug);

    // mymese debugging
#if 0
    if(num > 0)
    {
        vector<int4> cli(num);
        cli_debug.copyToHost(cli);

        vector<float4> clf(num);
        clf_debug.copyToHost(clf);

        for(int i = 0; i < 4; i++)
        {
            printf("w1 = %d\t w2 = %d\t w3 = %d\t w4 = %d\n", cli[i].x, cli[i].y, cli[i].z, cli[i].w);
            printf("clf[%d] = %f %f %f %f\n", i, clf[i].x, clf[i].y, clf[i].z, clf[i].w);
        }
		printf("num= %d\n", num);
        printf("\n\n");
    }
#endif

        timers["integrate"]->stop();
}
Example #6
0
    void Density::execute(int num,
                    //input
                    //Buffer<float4>& svars, 
                    Buffer<float4>& pos_s,
                    Buffer<float>& dens_s,
                    //output
                    Buffer<unsigned int>& ci_start,
                    Buffer<unsigned int>& ci_end,
                    //params
                    Buffer<SPHParams>& sphp,
                    Buffer<GridParams>& gp,
                    //debug params
                    Buffer<float4>& clf_debug,
                    Buffer<int4>& cli_debug)
    { 
        int iarg = 0;
        //k_density.setArg(iarg++, svars.getDevicePtr());
        k_density.setArg(iarg++, pos_s.getDevicePtr());
        k_density.setArg(iarg++, dens_s.getDevicePtr());
        k_density.setArg(iarg++, ci_start.getDevicePtr());
        k_density.setArg(iarg++, ci_end.getDevicePtr());
        k_density.setArg(iarg++, gp.getDevicePtr());
        k_density.setArg(iarg++, sphp.getDevicePtr());

        // ONLY IF DEBUGGING
        k_density.setArg(iarg++, clf_debug.getDevicePtr());
        k_density.setArg(iarg++, cli_debug.getDevicePtr());

        int local = 64;
        try
        {
            float gputime = k_density.execute(num, local);
            if(gputime > 0)
                timer->set(gputime);

        }

        catch (cl::Error er)
        {
            printf("ERROR(density): %s(%s)\n", er.what(), CL::oclErrorString(er.err()));
        }

#if 0 //printouts    
        //DEBUGING
        
        if(num > 0)// && choice == 0)
        {
            printf("============================================\n");
            printf("which == %d *** \n", choice);
            printf("***** PRINT neighbors diagnostics ******\n");
            printf("num %d\n", num);

            std::vector<int4> cli(num);
            std::vector<float4> clf(num);
            
            cli_debug.copyToHost(cli);
            clf_debug.copyToHost(clf);

            std::vector<float4> poss(num);
            std::vector<float4> dens(num);

            for (int i=0; i < num; i++)
            //for (int i=0; i < 10; i++) 
            {
                //printf("-----\n");
                printf("clf_debug: %f, %f, %f, %f\n", clf[i].x, clf[i].y, clf[i].z, clf[i].w);
                //if(clf[i].w == 0.0) exit(0);
                //printf("cli_debug: %d, %d, %d, %d\n", cli[i].x, cli[i].y, cli[i].z, cli[i].w);
                //		printf("pos : %f, %f, %f, %f\n", pos[i].x, pos[i].y, pos[i].z, pos[i].w);
            }
        }
#endif

    }
Example #7
0
    void LeapFrog::execute(int num,
                    float dt,
                    Buffer<float4>& pos_u,
                    Buffer<float4>& pos_s,
                    Buffer<float4>& vel_u,
                    Buffer<float4>& vel_s,
                    Buffer<float4>& veleval_u,
                    Buffer<float4>& force_s,
                    Buffer<float4>& xsph_s,
                    Buffer<float4>& color_u,
                    Buffer<float4>& color_s,
                    //Buffer<float4>& uvars, 
                    //Buffer<float4>& svars, 
                    Buffer<unsigned int>& indices,
                    //params
                    Buffer<SPHParams>& sphp,
                    //debug params
                    Buffer<float4>& clf_debug,
                    Buffer<int4>& cli_debug)
    {

        int iargs = 0;
        //k_leapfrog.setArg(iargs++, uvars.getDevicePtr());
        //k_leapfrog.setArg(iargs++, svars.getDevicePtr());
        k_leapfrog.setArg(iargs++, pos_u.getDevicePtr());
        k_leapfrog.setArg(iargs++, pos_s.getDevicePtr());
        k_leapfrog.setArg(iargs++, vel_u.getDevicePtr());
        k_leapfrog.setArg(iargs++, vel_s.getDevicePtr());
        k_leapfrog.setArg(iargs++, veleval_u.getDevicePtr());
        k_leapfrog.setArg(iargs++, force_s.getDevicePtr());
        k_leapfrog.setArg(iargs++, xsph_s.getDevicePtr());
        k_leapfrog.setArg(iargs++, color_u.getDevicePtr());
        k_leapfrog.setArg(iargs++, color_s.getDevicePtr());
        k_leapfrog.setArg(iargs++, indices.getDevicePtr());
        k_leapfrog.setArg(iargs++, sphp.getDevicePtr());
        k_leapfrog.setArg(iargs++, dt); //time step

        int local_size = 128;
        float gputime = k_leapfrog.execute(num, local_size);
        if(gputime > 0)
            timer->set(gputime);

#if 0 //printouts    
        //DEBUGING
        
        if(num > 0)// && choice == 0)
        {
            printf("***** leapfrog diagnostics ******\n");
            printf("num %d\n", num);

            std::vector<float4> clf(num);
			std::vector<float4> force(num);
            
            clf_debug.copyToHost(clf);
			force_s.copyToHost(force);


            for (int i=0; i < num && i<5; i++) 
            {
                printf("clf_debug: %f, %f, %f, %f\n", clf[i].x, clf[i].y, clf[i].z, clf[i].w);
				printf("force: %f, %f, %f, %f\n", force[i].x, force[i].y, force[i].z, force[i].w);
            }
			dout<<"size of sphparam = "<<sizeof(SPHParams)<<endl;
        }
#endif
} //namespace sph
Example #8
0
    void Lifetime::execute(int num,
                    float increment,
                    Buffer<float4>& pos_u,
                    Buffer<float4>& color_u, 
                    Buffer<float4>& color_s, 
                    Buffer<unsigned int>& indices,
                    Buffer<float4>& clf_debug,
                    Buffer<int4>& cli_debug)
    {

        int iargs = 0;
        k_lifetime.setArg(iargs++, num); //time step
        k_lifetime.setArg(iargs++, increment); //time step
        k_lifetime.setArg(iargs++, pos_u.getDevicePtr());
        k_lifetime.setArg(iargs++, color_u.getDevicePtr());
        k_lifetime.setArg(iargs++, color_s.getDevicePtr());
        k_lifetime.setArg(iargs++, indices.getDevicePtr());
        //lifetime.setArg(iargs++, color.getDevicePtr());
        k_lifetime.setArg(iargs++, clf_debug.getDevicePtr());
        k_lifetime.setArg(iargs++, cli_debug.getDevicePtr());



        int local_size = 128;
        float gputime = k_lifetime.execute(num, local_size);
        if(gputime > 0)
            timer->set(gputime);



#if 0

        if(num > 0)
        {
            printf("************ Lifetime**************\n");
            int nbc = num + 5;
            std::vector<int4> cli(nbc);
            std::vector<float4> clf(nbc);

            cli_debug.copyToHost(cli);
            clf_debug.copyToHost(clf);

            for (int i=0; i < nbc; i++)
            {
                //printf("-----\n");
                printf("clf_debug: %f, %f, %f, %f\n", clf[i].x, clf[i].y, clf[i].z, clf[i].w);
                //printf("cli_debug: %d, %d, %d, %d\n", cli[i].x, cli[i].y, cli[i].z, cli[i].w);
            }
        }

#endif

        /*
         * enables us to cut off after a couple iterations
         * by setting cut = 1 from some other function
        if(cut >= 1)
        {
            if (cut == 2) {exit(0);}
            cut++;
        }
        */


    }
Example #9
0
    void PRBEuler::execute(int num,
                    float dt,
                    /*Buffer<float4>& pos_u,
                    Buffer<float4>& pos_s,
                    Buffer<float4>& vel_u,
                    Buffer<float4>& vel_s,
                    Buffer<float4>& linear_force_s,
                    Buffer<float4>& torque_force_s,*/
                    Buffer<float4>& comLinearForce,
                    Buffer<float4>& comTorqueForce,
                    Buffer<float4>& comVel,
                    Buffer<float4>& comAngVel,
                    Buffer<float4>& comAngMomentum,
                    Buffer<float4>& comPos,
                    Buffer<float4>& comRot,
                    Buffer<float16>& inertialTensor,
                    Buffer<float>& rbMass,
                    float4 gravity,
                    int numRBs,
                    Buffer<ParticleRigidBodyParams>& prbp,
                    //debug params
                    Buffer<float4>& clf_debug,
                    Buffer<int4>& cli_debug)
    {

        int iargs = 0;
        k_euler.setArg(iargs++,comLinearForce.getDevicePtr());
        k_euler.setArg(iargs++,comTorqueForce.getDevicePtr());
        k_euler.setArg(iargs++,comVel.getDevicePtr());
        k_euler.setArg(iargs++,comAngVel.getDevicePtr());
        k_euler.setArg(iargs++,comAngMomentum.getDevicePtr());
        k_euler.setArg(iargs++,comPos.getDevicePtr());
        k_euler.setArg(iargs++,comRot.getDevicePtr());
        k_euler.setArg(iargs++,inertialTensor.getDevicePtr());
        k_euler.setArg(iargs++,rbMass.getDevicePtr());
        k_euler.setArg(iargs++, gravity);
        k_euler.setArg(iargs++, dt); //time step
        k_euler.setArg(iargs++, prbp.getDevicePtr());
        k_euler.setArg(iargs++, clf_debug.getDevicePtr());
        k_euler.setArg(iargs++, cli_debug.getDevicePtr());
	try
        {
            float gputime = k_euler.execute(numRBs);//, local_size);
            if(gputime > 0)
                timer->set(gputime);

        }
        catch (cl::Error er)
        {
            printf("ERROR(force ): %s(%s)\n", er.what(), CL::oclErrorString(er.err()));
        }
        //int local_size = 128;

#if 0 //printouts
        //DEBUGING

        if(numRBs > 0)// && choice == 0)
        {
            printf("============================================\n");
            printf("***** PRINT euler output ******\n");
            printf("num %d\n", numRBs);

            std::vector<int4> cli(numRBs);
            std::vector<float4> clf(numRBs);

            cli_debug.copyToHost(cli);
            clf_debug.copyToHost(clf);

            for (int i=0; i < numRBs; i++)
            //for (int i=0; i < 10; i++)
            {
                //printf("-----\n");
                printf("clf_debug: %08f, %08f, %08f, %08f\n", clf[i].x, clf[i].y, clf[i].z, clf[i].w);
                //if(clf[i].w == 0.0) exit(0);
                //printf("cli_debug: %d, %d, %d, %d\n", cli[i].x, cli[i].y, cli[i].z, cli[i].w);
                //		printf("pos : %f, %f, %f, %f\n", pos[i].x, pos[i].y, pos[i].z, pos[i].w);
            }
        }
#endif

    }
    void PRBSegmentedScan::execute(int num,
                    Buffer<float4>& pos_l,
                    //Buffer<float4>& veleval_s,
                    Buffer<int2>& particleIndex,
                    Buffer<float4>& linear_force_u,
                    Buffer<float4>& comLinearForce,
                    Buffer<float4>& comTorqueForce,
                    Buffer<float4>& comPos,
                    Buffer<float4>& comRot,
                    int numRBs,
                    Buffer<ParticleRigidBodyParams>& prbp,
                    //Buffer<float4>& torque_force_s,
                    //Buffer<unsigned int>& ci_start,
                    //Buffer<unsigned int>& ci_end,
                    //debug params
                    Buffer<float4>& clf_debug,
                    Buffer<int4>& cli_debug)
    {
        int iarg = 0;
        k_segmented_scan.setArg(iarg++, pos_l.getDevicePtr());
        k_segmented_scan.setArg(iarg++, particleIndex.getDevicePtr());
        //k_segmented_scan.setArg(iarg++, veleval_s.getDevicePtr());
        k_segmented_scan.setArg(iarg++, linear_force_u.getDevicePtr());
        k_segmented_scan.setArg(iarg++, comLinearForce.getDevicePtr());
        k_segmented_scan.setArg(iarg++, comTorqueForce.getDevicePtr());
        k_segmented_scan.setArg(iarg++, comPos.getDevicePtr());
        k_segmented_scan.setArg(iarg++, comRot.getDevicePtr());
        k_segmented_scan.setArg(iarg++, prbp.getDevicePtr());
        //k_segmented_scan.setArg(iarg++, torque_force_s.getDevicePtr());
        //k_segmented_scan.setArg(iarg++, ci_start.getDevicePtr());
        //k_segmented_scan.setArg(iarg++, ci_end.getDevicePtr());
        // ONLY IF DEBUGGING
        k_segmented_scan.setArg(iarg++, clf_debug.getDevicePtr());
        k_segmented_scan.setArg(iarg++, cli_debug.getDevicePtr());

        int local = 64;
        try
        {
            float gputime = k_segmented_scan.execute(numRBs);//, local);
            if(gputime > 0)
                timer->set(gputime);

        }

        catch (cl::Error er)
        {
            printf("ERROR(PRBSegmentedScan): %s(%s)\n", er.what(), CL::oclErrorString(er.err()));
        }

#if 0 //printouts
        //DEBUGING

        if(numRBs > 0)// && choice == 0)
        {
            printf("============================================\n");
            printf("***** PRINT Segmented Scan diagnostics ******\n");
            printf("numRBs %d\n", numRBs);

            std::vector<int4> cli(numRBs);
            std::vector<float4> clf(numRBs);

            cli_debug.copyToHost(cli);
            clf_debug.copyToHost(clf);

            for (int i=0; i < numRBs; i++)
            //for (int i=0; i < 10; i++)
            {
                //printf("-----\n");
                printf("clf_debug: %f, %f, %f, %f\n", clf[i].x, clf[i].y, clf[i].z, clf[i].w);
                //if(clf[i].w == 0.0) exit(0);
                //printf("cli_debug: %d, %d, %d, %d\n", cli[i].x, cli[i].y, cli[i].z, cli[i].w);
                //		printf("pos : %f, %f, %f, %f\n", pos[i].x, pos[i].y, pos[i].z, pos[i].w);
            }
        }
#endif
    }
Example #11
0
int main(int argc, const char *argv[])
{
    try {
        po::options_description desc("Allowed options");
        desc.add_options()
            ("help,h", "print this help message")
            ("config,c", po::value<std::string>()->required(), "path to config file")
            ("model,m", po::value<std::string>()->required(), "path to model file")
            ("input,i", po::value<std::string>()->required(), "path to image file")
        ;

        po::variables_map vm;
        po::store(po::parse_command_line(argc, argv, desc), vm);

        if (vm.count("help")) {
            std::cout << desc << std::endl;
            return 0; 
        }

        po::notify(vm);

        std::shared_ptr<TextDetector::ConfigurationManager> config(
        	new TextDetector::ConfigurationManager(
        		vm["config"].as<std::string>()));
        TextDetector::ConfigurationManager::set_instance(config);

        float threshold = config->get_threshold();

        srand(config->get_random_seed());

        // creates the models
        TextDetector::ModelManager model_manager(config);

        if (config->verbose())
            std::cout << "Read inputs" << std::endl;

        std::string input(vm["input"].as<std::string>());
        if (!fs::exists(input)) {
            std::cerr << "Input image not available" << std::endl;
            return 1;
        }

        TextDetector::MserDetector detector(config);

        TextDetector::AdaboostClassifier clf(vm["model"].as<std::string>());

        cv::Mat image = cv::imread(input);
        cv::Mat mask;

        clf.detect(image, mask);
        cv::Mat result_image;
        std::vector<cv::Rect> words = detector(image, result_image, mask > (255 * threshold));

        for (size_t i = 0; i < words.size(); i++) {
            cv::Rect r = words[i];
            cv::rectangle(result_image, r.tl(), r.br(), cv::Scalar(0, 0, 255), 4);
            std::cout << r.x << "," << r.y << "," << r.width << "," << r.height << std::endl;
        }
        cv::imshow("MASK", mask); 
        cv::imshow("RESULT", result_image); cv::waitKey(0);


    } catch (const std::exception &e) {
        std::cerr << "Error: " << e.what() << std::endl;
        return 1;
    }
    
    return 0;
}
Example #12
0
File: sysdep.c Project: pkgw/iraf
dsort(char *from, char *to)
#endif
{
	struct Memb {
		struct Memb *next;
		int n;
		char buf[32000];
		};
	typedef struct Memb memb;
	memb *mb, *mb1;
	register char *x, *x0, *xe;
	register int c, n;
	FILE *f;
	char **z, **z0;
	int nn = 0;

	f = opf(from, textread);
	mb = (memb *)Alloc(sizeof(memb));
	mb->next = 0;
	x0 = x = mb->buf;
	xe = x + sizeof(mb->buf);
	n = 0;
	for(;;) {
		c = getc(f);
		if (x >= xe && (c != EOF || x != x0)) {
			if (!n)
				return 126;
			nn += n;
			mb->n = n;
			mb1 = (memb *)Alloc(sizeof(memb));
			mb1->next = mb;
			mb = mb1;
			memcpy(mb->buf, x0, n = x-x0);
			x0 = mb->buf;
			x = x0 + n;
			xe = x0 + sizeof(mb->buf);
			n = 0;
			}
		if (c == EOF)
			break;
		if (c == '\n') {
			++n;
			*x++ = 0;
			x0 = x;
			}
		else
			*x++ = c;
		}
	clf(&f, from, 1);
	f = opf(to, textwrite);
	if (x > x0) { /* shouldn't happen */
		*x = 0;
		++n;
		}
	mb->n = n;
	nn += n;
	if (!nn) /* shouldn't happen */
		goto done;
	z = z0 = (char **)Alloc(nn*sizeof(char *));
	for(mb1 = mb; mb1; mb1 = mb1->next) {
		x = mb1->buf;
		n = mb1->n;
		for(;;) {
			*z++ = x;
			if (--n <= 0)
				break;
			while(*x++);
			}
		}
	qsort((char *)z0, nn, sizeof(char *), compare);
	for(n = nn, z = z0; n > 0; n--)
		fprintf(f, "%s\n", *z++);
	free((char *)z0);
 done:
	clf(&f, to, 1);
	do {
		mb1 = mb->next;
		free((char *)mb);
		}
		while(mb = mb1);
	return 0;
	}
Example #13
0
int main(int argc, char* argv[])
{
	device_use = 0;
	if(argc>1)
		device_use = atoi(argv[1]);
	
	static char* exampleImagePath = "..\\..\\..\\media\\kewell1.jpg";

	//create a random filterbank
	const int num_filters = 256;

	//number of pipeline passes
	const int num_iters = 125;

	const int filter_dim = 3;

	FilterBank fb(filter_dim, num_filters);
	fb.set_on_device();

	Classifier clf(128, 64, 8, 2, num_filters);

	//load the image on device
	cv::Mat exampleImage = cv::imread(exampleImagePath, 0);
	//convert to float
	exampleImage.convertTo(exampleImage, CV_32FC1);

	cv::resize(exampleImage, exampleImage, cv::Size(exampleImage.cols, exampleImage.rows));

	if(device_use==0)
		std::cout << "running on CPU" <<std::endl;
	else
		std::cout << "running on GPU" <<std::endl;
	std::cout << "Image dimensions:" << exampleImage.size().height <<" "<< exampleImage.size().width <<std::endl;
	
	//pull the data
	float* f_imData = (float*) exampleImage.data;
	DeviceMatrixCL::Ptr dmpCL = makeDeviceMatrixCL(exampleImage.size().height, exampleImage.size().width);
	DeviceMatrixCL_copyToDevice(*dmpCL, f_imData);


/*	for(int i=0; i<20; i++)
	{

	DeviceMatrixCL3D::Ptr ff_im = fb.apply_cl(dmpCL);
//	tic1= omp_get_wtime();

	DeviceMatrixCL::Ptr block_histogram = cell_histogram_dense_cl(
		ff_im, num_filters, 8, 0, 0, 
		exampleImage.size().height, exampleImage.size().width);
//	tic2= omp_get_wtime();

	DeviceMatrixCL::Ptr result = clf.apply(block_histogram);
	}
	*/
	double tic0, tic1, tic2, tic3;
	double tim1 = 0.0;
	double tim2 = 0.0;
	double tim3 = 0.0;

	for(int i=0; i<num_iters; i++)
	{
	tic0= omp_get_wtime();
	DeviceMatrixCL3D::Ptr ff_im = fb.apply_cl(dmpCL);
	tic1= omp_get_wtime();
	tim1 += tic1 - tic0;

	DeviceMatrixCL::Ptr block_histogram = cell_histogram_dense_cl(
		ff_im, num_filters, 8, 0, 0, 
		exampleImage.size().height, exampleImage.size().width);
	tic2= omp_get_wtime();
	tim2 += tic2 - tic1;

	DeviceMatrixCL::Ptr result = clf.apply(block_histogram);

	TheContext* tc = new TheContext();

	clFinish(tc->getMyContext()->cqCommandQueue);
	tic3 = omp_get_wtime();	
	tim3 += tic3 - tic2;
	}
	
	std::cout << "full pipeline time: " << tim1 + tim2 + tim3 << std::endl;
	std::cout << "filter pipeline time: " << tim1 << std::endl;
	std::cout << "histogram pipeline time: " << tim2 << std::endl;
	std::cout << "classifier pipeline time: " << tim3 << std::endl;

	return 0;
}
Example #14
0
    void RigidBodyForce::execute(int num,
                    Buffer<float>& density,
                    Buffer<float4>& pos_s,
                    Buffer<float4>& veleval_s,
                    Buffer<float4>& force_s,
                    Buffer<float>& mass_s,
                    Buffer<float4>& rb_pos_s,
                    Buffer<float4>& rb_velocity_s,
                    Buffer<float>& rb_mass_s,
                    Buffer<unsigned int>& ci_start,
                    Buffer<unsigned int>& ci_end,
                    //params
                    Buffer<SPHParams>& sphp,
                    Buffer<GridParams>& gp,
                    float stiffness,
                    float dampening,
                    float friction_dynamic,
                    float friction_static,
                    float friction_static_threshold,
                    //debug params
                    Buffer<float4>& clf_debug,
                    Buffer<int4>& cli_debug)
    {
        int iarg = 0;
        k_rigidbody_force.setArg(iarg++, density.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, pos_s.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, veleval_s.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, force_s.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, mass_s.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, rb_pos_s.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, rb_velocity_s.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, rb_mass_s.getDevicePtr());
        float16 rbParams;
        rbParams.m[0]=stiffness;
        rbParams.m[1]=dampening;
        rbParams.m[2]=friction_dynamic;
        rbParams.m[3]=friction_static;
        rbParams.m[4]=friction_static_threshold;
        k_rigidbody_force.setArg(iarg++, rbParams);
        k_rigidbody_force.setArg(iarg++, ci_start.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, ci_end.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, gp.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, sphp.getDevicePtr());

        // ONLY IF DEBUGGING
        k_rigidbody_force.setArg(iarg++, clf_debug.getDevicePtr());
        k_rigidbody_force.setArg(iarg++, cli_debug.getDevicePtr());

        int local = 64;
        try
        {
            float gputime = k_rigidbody_force.execute(num, local);
            if(gputime > 0)
                timer->set(gputime);

        }

        catch (cl::Error er)
        {
            printf("ERROR(rigidbody force ): %s(%s)\n", er.what(), CL::oclErrorString(er.err()));
        }

#if 0 //printouts
        //DEBUGING

        if(num > 0)// && choice == 0)
        {
            printf("============================================\n");
            printf("which == %d *** \n", choice);
            printf("***** PRINT neighbors diagnostics ******\n");
            printf("num %d\n", num);

            std::vector<int4> cli(num);
            std::vector<float4> clf(num);

            cli_debug.copyToHost(cli);
            clf_debug.copyToHost(clf);

            std::vector<float4> poss(num);
            std::vector<float4> dens(num);

            for (int i=0; i < num; i++)
            //for (int i=0; i < 10; i++)
            {
                //printf("-----\n");
                printf("clf_debug: %f, %f, %f, %f\n", clf[i].x, clf[i].y, clf[i].z, clf[i].w);
                //if(clf[i].w == 0.0) exit(0);
                //printf("cli_debug: %d, %d, %d, %d\n", cli[i].x, cli[i].y, cli[i].z, cli[i].w);
                //printf("pos : %f, %f, %f, %f\n", pos[i].x, pos[i].y, pos[i].z, pos[i].w);
            }
        }
#endif
    }