当前位置: 首页>>代码示例>>C++>>正文


C++ CStopWatch::startTimer方法代码示例

本文整理汇总了C++中CStopWatch::startTimer方法的典型用法代码示例。如果您正苦于以下问题:C++ CStopWatch::startTimer方法的具体用法?C++ CStopWatch::startTimer怎么用?C++ CStopWatch::startTimer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CStopWatch的用法示例。


在下文中一共展示了CStopWatch::startTimer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: log

void ToneMappingDrago03::toneMapping_Drago03(Image<float> *img, float *avLum, float *maxLum, unsigned int *pic, float bias)
{
	image = img;
	picture = pic;

	avLuminance = avLum;
	maxLuminance = maxLum;

	normMaxLum = *maxLum / *avLum; // normalize maximum luminance by average luminance
	const float LOG05 = -0.693147f; // log(0.5)

	divider = log10(normMaxLum + 1.0f);
	biasP = log(bias)/LOG05;
	logFile("divider = %f biasP = %f \n", divider, biasP);

	localWorkSize[0] = BLOCK_SIZE;
	localWorkSize[1] = BLOCK_SIZE;
	
	//round values on upper value
	logFile("%d %d \n", image->getHeight(), image->getWidth());
	globalWorkSize[0] = roundUp(BLOCK_SIZE, image->getHeight());
	globalWorkSize[1] = roundUp(BLOCK_SIZE, image->getWidth());

	//core->runComputeUnit();
	
	
	
	CStopWatch timer;
	timer.startTimer();
	calctoneMapping_Drago03CPU();
	timer.stopTimer();
	logFile("ToneMappingCPU,calc_time, , ,%f, \n", timer.getElapsedTime());
}
开发者ID:mihailo,项目名称:HDRTool,代码行数:33,代码来源:ToneMappingDrago03.cpp

示例2: l1_ls_inpainting

MeshCoordinates l1_ls_inpainting(CMesh& mesh, const std::vector<int>& missing_idx, ParaL1LsInpainting& para)
{
    const int totalVertCount = mesh.vertCount();
    MeshLaplacian graphLaplacian;
    graphLaplacian.constructUmbrella(&mesh);
    int eigenCount = para.eigen_count;    // -1 means full decomposition
    if (eigenCount == -1) eigenCount = totalVertCount - 1;

    ZGeom::EigenSystem es;
    graphLaplacian.meshEigenDecompose(eigenCount, &g_engineWrapper, es);

    ZGeom::Dictionary dictMHB;
    computeDictionary(DT_Fourier, es, dictMHB);

    ZGeom::DenseMatrixd matCoordOld = mesh.getVertCoordinates().toDenseMatrix();
    ZGeom::DenseMatrixd matDict = dictMHB.toDenseMatrix();

    CStopWatch timer;
    timer.startTimer();
    ZGeom::DenseMatrixd matCoordInpainted = matlab_inpaintL1LS(matCoordOld, matDict, missing_idx, para.lambda, para.tol);
    timer.stopTimer("-- L1_Ls inpainting time: ");

    MeshCoordinates coordInpainted;
    coordInpainted.fromDenseMatrix(matCoordInpainted);
    return coordInpainted;
}
开发者ID:sunyzm,项目名称:ZGeometry,代码行数:26,代码来源:hole_fairing.cpp

示例3: sizeof

void ConversionRGB2RGBE::getDataFromOpenCLMemory()
{
	clFinish(core->getCqCommandQueue());
	CStopWatch timer;
	timer.startTimer();
	
	unsigned int size = image->getHeight() * image->getWidth() * sizeof(cl_uint);
	cl_int ciErr1;			// Error code var
	// Synchronous/blocking read of results, and check accumulated errors
	ciErr1 = clEnqueueReadBuffer(core->getCqCommandQueue(), cl_intChannelR, CL_TRUE, 0, 
		size, channelR, 0, NULL, NULL);
	ciErr1 |= clEnqueueReadBuffer(core->getCqCommandQueue(), cl_intChannelG, CL_TRUE, 0, 
		size, channelG, 0, NULL, NULL);
	ciErr1 |= clEnqueueReadBuffer(core->getCqCommandQueue(), cl_intChannelB, CL_TRUE, 0, 
		size, channelB, 0, NULL, NULL);
	ciErr1 |= clEnqueueReadBuffer(core->getCqCommandQueue(), cl_intChannelE, CL_TRUE, 0, 
		size, channelE, 0, NULL, NULL);
	
	clFinish(core->getCqCommandQueue());
	timer.stopTimer();
	logFile("gpuRGB2RGBE,data_out,%d,%d,%f, \n", image->getHeight(), image->getWidth(), timer.getElapsedTime());

    logFile("clEnqueueReadBuffer ...\n\n"); 
    if (ciErr1 != CL_SUCCESS)
    {
		logFile("%d :Error in clEnqueueReadBuffer, Line %u in file %s !!!\n\n", ciErr1, __LINE__, __FILE__);
    }
}
开发者ID:mihailo,项目名称:HDRTool,代码行数:28,代码来源:ConversionRGB2RGBE.cpp

示例4: unzip

int HuffmanCode::unzip(char* inputFile, char* outputFile) {
	CStopWatch time;
	time.startTimer();


    cout << "unzipping..."<<endl;

    // Declare variable
    Writer *writer = new Writer(outputFile);	// Writer ref object
    Reader *reader = new Reader(inputFile);		// Reader ref object
    HCZHeader *header = new HCZHeader;

	char **codemap;								// Map of chareacter code
	Node* huffmantree = new Node;				// huffmantree
	int totalChar;
	int totalBit;
	header->getTotal(totalChar, totalBit);

	// Check if file is right format
	if( header->read(reader) != -2){


		// Initialize the table of character code
		codemap = new char*[256];
		for(int i = 0; i < 256; i++){
			codemap[i] = new char[16];
			memset(codemap[i],'\0',16);
		}

		for(int i = 0, nbit; i < 256; i++){
			header->get((char)i,nbit,codemap[char2Int(i)]);
		}
		for(int i = 0; i< 256; i++){
			if(codemap[i][0] != '\0'){
				convertMaptoHuffman(huffmantree, codemap, (char)i, totalChar);
			}
		}

		int bodysize = header->getBodySize();
		while(bodysize){
			deCode(reader, writer, huffmantree, bodysize);
		}






	}
	delete reader;
	delete writer;
	delete header;

	cout<<"done!"<<endl;
    time.stopTimer();
    cout<<"Excution time: "<<time.getElapsedTime()<<"s"<<endl;
    return UN_IMPLEMENT;
}
开发者ID:laituanmanh32,项目名称:2rd-Semester-code,代码行数:58,代码来源:HuffmanCode.cpp

示例5: computeMeshesFeaturePoints

void computeMeshesFeaturePoints(const std::vector<std::string>& mesh_filenames, std::string eigen_path, std::string output_path)
{
    ZGeom::MatlabEngineWrapper eng;
    eng.open();
    auto pwd = initial_path<path>();
    eng.eval("cd " + pwd.string());
    eng.eval("mkdir " + output_path);
    eng.eval("cd " + output_path);
    cout << "# Total meshes: " << mesh_filenames.size() << "\n" << endl;

    CStopWatch timer;
    timer.startTimer();

    int count = 0;
    for (string mesh_file : mesh_filenames)
    {
        count++;
        cout << count << ": " << mesh_file << endl;
        try {
            if (!fileExist(mesh_file)) {
                throw runtime_error("File not exist!");
            }
            CMesh mesh;
            mesh.load(mesh_file);

            string mesh_name = mesh.getMeshName();
            string eigen_file_path = eigen_path + "/" + mesh_name + ".eigen.mat";

            EigenSystem es;
            es.loadFromMat(&eng, eigen_file_path);

            double t_min = 4 * std::log(10.0) / es.getAllEigVals().back(), t_max = 4 * std::log(10.0) / es.getEigVal(1);
            int nScales = 4;
            const double tMultiplier = std::pow(t_max / t_min, 1.0 / double(nScales - 1));
            std::vector<double> hks_scales(nScales);
            for (int s = 0; s < nScales; ++s) {
                hks_scales[s] = t_min * std::pow(tMultiplier, s);
            }

            set<int> all_features;
            for (int s = 0; s < nScales; ++s) {
                vector<double> values = calHeatKernelSignature(es, hks_scales[s]);
                vector<int> features = extractMeshExtrema(mesh, values, 2);
                for (int fi : features) all_features.insert(fi);
            }

            string out_file_path = output_path + "/" + mesh_name + ".feature";
            ofstream ofs(output_path.c_str());

        }
        catch (runtime_error* e){
            cerr << "Fail to process " + mesh_file << ": " << e->what() << endl;
        }
    } 

    cout << "\n";
    timer.stopTimer("Total time: ");
}
开发者ID:sunyzm,项目名称:ZGeometry,代码行数:58,代码来源:zmesh.cpp

示例6: displayGame

//--------------------------------------------------------------
// Purpose  : This main loop calls functions to get input, 
//            update and render the game at a specific frame rate
//            You should not be modifying this unless you know what you are doing.
// Input    : void
// Output   : void
//--------------------------------------------------------------
void displayGame( void )
{
    g_Timer.startTimer();    // Start timer to calculate how long it takes to render this frame
    while (!g_bQuitGame)      // run this loop until user wants to quit 
    {        
        getInput();                         // get keyboard input
        update(g_Timer.getElapsedTime());   // update the game
        render();                           // render the graphics output to screen
        g_Timer.waitUntil(gc_uFrameTime);   // Frame rate limiter. Limits each frame to a specified time in ms.      
    }    
}
开发者ID:TanGlennda,项目名称:SP1,代码行数:18,代码来源:main.cpp

示例7: clSetKernelArg

void ToneMappingDrago03::setInputDataToOpenCLMemory()
{
	int height = image->getHeight();
	int width = image->getWidth();
	
	cl_int ciErr1;				
	// Set the Argument values
	ciErr1 = clSetKernelArg(core->getOpenCLKernel(), 0, 
		sizeof(cl_int), (void*)&width);
	ciErr1 |= clSetKernelArg(core->getOpenCLKernel(), 1, 
		sizeof(cl_int), (void*)&height);
	ciErr1 |= clSetKernelArg(core->getOpenCLKernel(), 2, 
		sizeof(cl_mem), (void*)&cl_floatImage);
    ciErr1 |= clSetKernelArg(core->getOpenCLKernel(), 3, 
		sizeof(cl_mem), (void*)&cl_picture);
	ciErr1 |= clSetKernelArg(core->getOpenCLKernel(), 4, 
		sizeof(cl_float), (void*)avLuminance);
	ciErr1 |= clSetKernelArg(core->getOpenCLKernel(), 5, 
		sizeof(cl_float), (void*)&normMaxLum);
    ciErr1 |= clSetKernelArg(core->getOpenCLKernel(), 6, 
		sizeof(cl_float), (void*)&biasP);
	ciErr1 |= clSetKernelArg(core->getOpenCLKernel(), 7, 
		sizeof(cl_float), (void*)&divider);
   
    logFile("clSetKernelArg 0 - 7...\n\n"); 
    if (ciErr1 != CL_SUCCESS)
    {
		logFile("%d :Error in clSetKernelArg, Line %u in file %s !!!\n\n", ciErr1, __LINE__, __FILE__);
    }

    // --------------------------------------------------------
    // Start Core sequence... copy input data to GPU, compute, copy results back

	clFinish(core->getCqCommandQueue());
	CStopWatch timer;
	timer.startTimer();

    // Asynchronous write of data to GPU device
	unsigned int size = sizeof(cl_float) * image->getHeight() * image->getWidth() * RGB_NUM_OF_CHANNELS;
	ciErr1 = clEnqueueWriteBuffer(core->getCqCommandQueue(), cl_floatImage, CL_TRUE, 0, 
		size, image->getImage(), 0, NULL, NULL);

	clFinish(core->getCqCommandQueue());
	timer.stopTimer();
	logFile("gpuDrago,data_in,%d,%d,%f, \n", height, width, timer.getElapsedTime());

    logFile("clEnqueueWriteBuffer ...\n"); 
    if (ciErr1 != CL_SUCCESS)
    {
		logFile("%d :Error in clEnqueueWriteBuffer, Line %u in file %s !!!\n\n", ciErr1, __LINE__, __FILE__);
    }
}
开发者ID:mihailo,项目名称:HDRTool,代码行数:52,代码来源:ToneMappingDrago03.cpp

示例8: Compute

void Compute()
{
    DivisorSummatoryFunctionOdd algorithm;
    CStopWatch timer;
    for (int i = 1; i <= 24; i++)
    {
        Integer n = Power(Integer(10), i);
        Integer x2 = sqrt(n);
        timer.startTimer();
        Integer s = algorithm.Evaluate(n, 1, x2);
        timer.stopTimer();
        std::string sRep = s.get_str();
        printf("i = %d, s = %s, elapsed = %.3f\n", i, sRep.c_str(), timer.getElapsedTime() * 1000);
    }
}
开发者ID:ricksladkey,项目名称:Dirichlet,代码行数:15,代码来源:PiModK.cpp

示例9: computeMeshesSpectrum

void computeMeshesSpectrum(const std::vector<std::string>& mesh_filenames, int eigen_num, std::string output_path)
{
    ZGeom::MatlabEngineWrapper eng;
    eng.open();
    auto pwd = initial_path<path>();
    eng.eval("cd " + pwd.string());
    eng.eval("mkdir " + output_path);
    eng.eval("cd " + output_path);
    cout << "# Total meshes: " << mesh_filenames.size() << "\n" << endl;

    CStopWatch timer;
    timer.startTimer();

    int count = 0;
    for (string mesh_file : mesh_filenames)
    {
        count++;
        cout << count << ": " << mesh_file << endl;
        try {
            if (!fileExist(mesh_file)) {
                throw runtime_error("File not exist!");
            }
            CMesh mesh;
            mesh.load(mesh_file);
            Laplacian cot_form_lap;
            cot_form_lap.constructCotFormula(&mesh);
            EigenSystem es;
            cot_form_lap.decompose(eigen_num, &eng, es, true);

            string mesh_name = mesh.getMeshName();
            string eigen_file_path = mesh_name + ".eigen.mat";            
            es.saveToMat(&eng, eigen_file_path);
            cout << eigen_file_path << " saved!" << endl;
        }
        catch (runtime_error* e){
            cerr << "Fail to process " + mesh_file << ": " << e->what() << endl;
        }
        catch (exception* e) {
            cerr << "Unknown error in processing " + mesh_file << endl;
        }
    }

    cout << "\n";
    timer.stopTimer("Total time: ");
}
开发者ID:sunyzm,项目名称:ZGeometry,代码行数:45,代码来源:zmesh.cpp

示例10: main

//#define Multi 1
int main()
{
	CStopWatch sw;
	sw.startTimer();
	std::ofstream fileout("results.txt");
	std::ifstream filein("hands.txt");
	std::string str;
	auto rowCount = 0;

#if Multi
	std::array<std::future<std::string>,MaxThreads-1> futures;
	auto count = 0;
	while (count <MaxThreads-1) {
		if (filein.eof()) break;
		std::getline(filein, str);
		rowCount++;
		//futures[count++] = std::async(ProcessThread, str);
		futures[count++] = std::async([str]{
			PokerHand pokerhand(str);
			auto result = EvaluateHand(pokerhand);
			return pokerhand.GetResult(result);
		});
		if (count == MaxThreads-1) {
			for (auto & e : futures) {
				fileout << e.get() << std::endl;
			}
			count = 0;
		}
	}
#else
	while (std::getline(filein, str))
	{
		PokerHand pokerhand(str);
		auto result = EvaluateHand(pokerhand);
		pokerhand.WriteResult(fileout, result);
		rowCount++;
	}

	#endif	fileout.close();
	filein.close();
	sw.stopTimer();
	std::cout << "Time to evaluate " << rowCount << " poker hands: " << sw.getElapsedTime() << std::endl;
	return 0;
}
开发者ID:David-H-Bolton,项目名称:PokerEval,代码行数:45,代码来源:pokereval.cpp

示例11: sizeof

void ToneMappingDrago03::getDataFromOpenCLMemory()
{
	clFinish(core->getCqCommandQueue());
	CStopWatch timer;
	timer.startTimer();
	
	unsigned int size = image->getHeight() * image->getWidth() * sizeof(cl_uint) * RGB_NUM_OF_CHANNELS;
	cl_int ciErr1;			// Error code var
	// Synchronous/blocking read of results, and check accumulated errors
	ciErr1 = clEnqueueReadBuffer(core->getCqCommandQueue(), cl_picture, CL_TRUE, 0, 
		size, picture, 0, NULL, NULL);

	clFinish(core->getCqCommandQueue());
	timer.stopTimer();
	logFile("gpuDrago,data_out,%d,%d,%f, \n", image->getHeight(), image->getWidth(), timer.getElapsedTime());

    logFile("clEnqueueReadBuffer ...\n\n"); 
    if (ciErr1 != CL_SUCCESS)
    {
		logFile("%d :Error in clEnqueueReadBuffer, Line %u in file %s !!!\n\n", ciErr1, __LINE__, __FILE__);
    }
}
开发者ID:mihailo,项目名称:HDRTool,代码行数:22,代码来源:ToneMappingDrago03.cpp

示例12:

CDescriptorSet * CFeatureExtractor::getDescriptors(const IplImage * pImage)
{
	CStopWatch s; s.startTimer();

	const int nChannels = pImage->nChannels;

	if(nChannels == 1)
	{
		pGreyImg = const_cast<IplImage *>(pImage);
	}
	else
	{
		CHECK(!pGreyImg, "Haven't created a grey image for corner detection");
		//cvCvtColor(pImage, pGreyImg, CV_RGB2GRAY);
		greyScaler.greyScale(pImage, pGreyImg);
	}

	CDescriptorSet * pDS = getDescriptors_int(pImage);

	s.stopTimer();
	REPEAT(20, cout << "Extract corners and describe features took " << s.getElapsedTime() << " seconds\n");

	return pDS;
}
开发者ID:JustineSurGithub,项目名称:tom-cv,代码行数:24,代码来源:featureExtractor.cpp

示例13: main

int main(int argc, char *argv[])
{
    loadConfig();
	
    QSurfaceFormat format;
    format.setDepthBufferSize(24);
    format.setStencilBufferSize(8);
    format.setProfile(QSurfaceFormat::CompatibilityProfile);
    QSurfaceFormat::setDefaultFormat(format);

    QApplication a(argc, argv);
    QZGeometryWindow w;
    QObject::connect(&w, SIGNAL(displayQtVersion()), &a, SLOT(aboutQt()));

    CStopWatch timer;
    timer.startTimer();
    g_engineWrapper.open();
    timer.stopTimer("-- Matlab Initialization time: ", " --");

    if (!w.initialize(mesh_list_name)) std::exit(-1);

    w.show();
	return a.exec();
}
开发者ID:sunyzm,项目名称:ZGeometry,代码行数:24,代码来源:main.cpp

示例14: runWPAMTest

int runWPAMTest(int num){
    int dim = 9;
    CStopWatch timer;
    int devicecount = 0;
    int device = 0;
    printf("\n\nNumber of dimensions: %i\n",dim);
    printf("Number of particles: %i\n",num);
    unsigned int runs = 400;
    fmat x = randu<fmat>(dim,num);
    fmat result = zeros<fmat>(dim,num);
	frowvec evaluation = zeros<frowvec>(num);
    fmat temp;

    // CPU test
    //x.print();
    ModelWPAM cpuModel;
    cpuModel.initialize();
    timer.startTimer();
    for (unsigned int i=0;i<runs;++i)
    {
        result = cpuModel.ffun(&x);
        result = cpuModel.hfun(&result);
		evaluation = cpuModel.eval(&result);
    }

    timer.stopTimer();

    printf("CPU WPAM calculation done in %e seconds\n", (double)timer.getElapsedTime()/runs);
    //result.print();

    cudaGetDeviceCount(&devicecount);
    for (device = 0; device < devicecount; ++device)
    {
        cudaSetDevice(device);
        printf("GPU device id %i (no. %i of %i)\n", device, device+1, devicecount );

        // GPU test only one initialization
        //reset result
        result = zeros<fmat>(dim, num);
        ModelWPAMGPU gpgpuModel;
        gpgpuModel.initialize();
        timer.startTimer();

        for (unsigned int i=0;i<runs;++i)
        {
            result = gpgpuModel.ffun(&x);
			
            result = gpgpuModel.hfun(&result);

			evaluation = gpgpuModel.eval(&result);
        }

        timer.stopTimer();

        //result.print();

        printf("GPU WPAM calculation done in %e seconds with %s\n",
               (double)timer.getElapsedTime()/runs, cudaGetErrorString(cudaGetLastError()));
        //result.print();

    }

	cudaGetDeviceCount(&devicecount);
    for (device = 0; device < devicecount; ++device)
    {
        cudaSetDevice(device);
        printf("GPU device id %i (no. %i of %i)\n", device, device+1, devicecount );

        // GPU test only one initialization
        //reset result
        result = zeros<fmat>(dim, num);
        ModelWPAMGPU gpgpuModel;
        gpgpuModel.initialize();
        timer.startTimer();

        for (unsigned int i=0;i<runs;++i)
        {
			float* temp;
            temp = gpgpuModel.ffun_gpu(&x);
			
			temp = gpgpuModel.hfun_gpu(temp,(int)result.n_cols, (int)result.n_rows);
			
			evaluation = gpgpuModel.eval_gpu(temp, (int)result.n_cols);
			
			cudaFree(temp);
        }

        timer.stopTimer();

        //result.print();

        printf("GPU pointer WPAM calculation done in %e seconds with %s\n",
               (double)timer.getElapsedTime()/runs, cudaGetErrorString(cudaGetLastError()));
        //result.print();

    }

    device = 0;
    devicecount = 0;
    return 0;
//.........这里部分代码省略.........
开发者ID:chingoduc,项目名称:parallel-bayesian-toolbox,代码行数:101,代码来源:gpu_test.cpp

示例15: buildRunSpyNNakerLiveSpikeInjectionModel

bool buildRunSpyNNakerLiveSpikeInjectionModel(
		bool learning, int numVR, int numClasses,
		float * vrRateCodes, float * classActivationRateCodes,
		int numObservations, int observationExposureTimeMs,
		string outputDir,int clusterSize,
		vector<int> & classifierDecision) {

	//checkContents("vrRateCodes",vrRateCodes,numObservations * numVR,numVR,data_type_float,2);
	bool boardPresent = ping(SPINNAKER_BOARD_IP_ADDR);
	if (!boardPresent) {
		cerr << "Nothing appears to be connected on specified IP address of " << SPINNAKER_BOARD_IP_ADDR << endl;
		exit(-1);
	}

	//Build and kick off PyNN model running on spinnaker board
	vector<string> args;
	args.push_back((learning?"True":"False"));
	args.push_back(toString(numVR));
	args.push_back(toString(numClasses));
	args.push_back(toString(RN_FIRST_SPIKE_INJECTION_PORT)); //the (first) port where the spinnkaer RN poluation will listen for UDP spikes
	args.push_back(toString(RN_SPIKE_INJECTION_POP_LABEL)); //the name to be used for this pop. Needs to be matched as it is used to extract neuron id's from database
	args.push_back(toString(CLASS_ACTIVATION_SPIKE_INJECTION_PORT)); //the port where the spinnaker class activcation poluation will listen for UDP spikes during learning
	args.push_back(toString(CLASS_ACTIVATION_SPIKE_INJECTION_POP_LABEL));
	args.push_back(toString(numObservations));
	args.push_back(toString(observationExposureTimeMs));
	args.push_back(outputDir);
	args.push_back(toString(clusterSize));
	args.push_back(toString(PYNN_MODEL_EXTRA_STARTUP_WAIT_SECS));//start up wait should be added on to the run time to avoid finishing too early while spikes are still being sent

	//wait 1 second before running asychronously to give spike sender chance to start up and invoke handshake
	launchPythonScript(PYTHON_DIR,PYNN_MODEL_SCRIPT_LIVE_SPIKING, args, 1, 0, true, PYTHON_USE_PROFILER);


	//setup up holder for population injections
	vector<spinnio::SpikeInjectionPopulation*> sendPopulations;
	vector<spinnio::SpikeReceiverPopulation*> receivePopulations;

	//we may have to set up more than one sender popn as spinnaker seems to have a size limit
	vector<int>senderPopnSizes;
	separateAcross(numVR,MAX_SIZE_SPIKE_INJECTION_POP,senderPopnSizes);
	cout << senderPopnSizes.size() << " spike injection populations will be set up of sizes " << toString(senderPopnSizes,SPACE) << endl;
	for (int sendPop = 0; sendPop < senderPopnSizes.size(); ++sendPop) {
		string label = RN_SPIKE_INJECTION_POP_LABEL + toString(sendPop);
		int port  = RN_FIRST_SPIKE_INJECTION_PORT + sendPop;
		int size = senderPopnSizes[sendPop];
		spinnio::SpikeInjectionPopulation * spikeInjectionPopRN = new spinnio::SpikeInjectionPopulation(port,label, size);
		sendPopulations.push_back(spikeInjectionPopRN);
	}

	spinnio::SpikeInjectionPopulation * spikeInjectionPopClassActivation = NULL;
	if (learning) { //send activation also
		spikeInjectionPopClassActivation = new spinnio::SpikeInjectionPopulation(CLASS_ACTIVATION_SPIKE_INJECTION_PORT,CLASS_ACTIVATION_SPIKE_INJECTION_POP_LABEL, numClasses);
		sendPopulations.push_back(spikeInjectionPopClassActivation);

	} else { //testing
		//set up a receiver on one shared port for all the AN populations (i.e. one per class)
		string spinnReceivePopLabelTemplate = "popClusterAN_";
		int hostReceivePort = HOST_RECEIVE_PORT; //port on host where spikes for this pop will get sent
		for (unsigned int cls = 0; cls < numClasses; ++cls) {
			string label = spinnReceivePopLabelTemplate + toString(cls);
			spinnio::SpikeReceiverPopulation * spikeReceivePop = new spinnio::SpikeReceiverPopulation(hostReceivePort,label);
			receivePopulations.push_back(spikeReceivePop);
		}
	}


	string dbPath = PYTHON_DIR + toString("/application_generated_data_files/latest/input_output_database.db");

	//create controller that will synchronise spike train inputs for both populations at once
	spinnio::SpikeInjectionMultiPopulation * spikeInjectionMultiPop = new spinnio::SpikeInjectionMultiPopulation(SPINNAKER_DATABASE_PORT,SPINNAKER_BOARD_IP_ADDR,dbPath,DT,sendPopulations,receivePopulations);
	spikeInjectionMultiPop->waitUntilModelReady();//SpiNNaker will send another handshake to the database port whn model starts to run
	spikeInjectionMultiPop->endDatabaseCommunication();
	sleep(PYNN_MODEL_EXTRA_STARTUP_WAIT_SECS);

	vector<int> presentationTimesMs;
	CStopWatch timer;
	timer.startTimer();

	cout << "Sending observations: " << endl;
	for (int ob = 0; ob < numObservations; ++ob) {
		int offset = 0;
		for (int sendPop = 0; sendPop < senderPopnSizes.size(); ++sendPop) {
			spinnio::SpikeInjectionPopulation * spikeInjectionPopRN = sendPopulations[sendPop];
			int rateCodeIndex = (ob * numVR) + offset;
			spikeInjectionPopRN->setSpikeRates(& vrRateCodes[rateCodeIndex]);//point at the block of rate codes for this observation
			offset += spikeInjectionPopRN->getTotalNeurons();
		}
		if (learning) spikeInjectionPopClassActivation->setSpikeRates(& classActivationRateCodes[ob * numClasses]);

		//note the elapsed time (relative to the first observation)
		timer.stopTimer();
		double elapsedTimeMs = 1000.0 * timer.getElapsedTime();
		//these will be used as the time boundaries for evaluating the classifier output
		//presentationTimesMs.push_back(elapsedTimeMs);

		//tweak the time for next observation to keep on track with overall time. This helps with knowing how long the whole run will take. For ten thousand samples, a 1ms error puts it 10 sec away from the expected finish
		int expectedElapsedTimeMs = ob * observationExposureTimeMs; //this is where we should be
		int tweakMs = elapsedTimeMs - expectedElapsedTimeMs; //generally seems to jitter / fall behind around 1ms for every 200ms
		tweakMs = clip(tweakMs,-5,5);//Don't adjust by too much on any one observation.

//.........这里部分代码省略.........
开发者ID:alandiamond,项目名称:spinnaker-neuromorphic-classifier,代码行数:101,代码来源:experiment.cpp


注:本文中的CStopWatch::startTimer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。