Example #1
0
//------------------------------------------------------------------------------
// Perform testcases for a 1 column table, a 2 column table, etc, up to
// a table having "maxCols" columns.
//------------------------------------------------------------------------------
void testSizes()   
{

	// Prompt for schema.
	cout << "Enter Schema or Enter for " << schema << ":  ";
	string tmpSchema;
	getline(cin, tmpSchema);
	if(tmpSchema.length() > 0)
	{
		schema = tmpSchema;
	}

	// Prompt for table.
	cout << "Enter Table or Enter for " << colstable << ":  ";
	string tmpTable;
	getline(cin, tmpTable);
	if(tmpTable.length() > 0)
	{
		colstable = tmpTable;
	}

	timer.start("Total");
	int maxCols = 9;
	cout << endl;
	for(int i = 7; i <= maxCols; i++) {
		cout << endl << "Running test " << i << " of " << maxCols << endl;
		stringstream ss;
		ss << "Delivery test for " << dataSize << " rows and " << i << " columns";
		timer.start(ss.str());
		deliverTest(i);
		timer.stop(ss.str());
	}
	timer.stop("Total");
	timer.finish();
}
Example #2
0
ADD_TEST(StopWatchTest, TestAll) {
	
	Stopwatch sw;
	sw.start();
	this_thread::sleep_for(chrono::milliseconds(200));
	sw.stop();
	Int64 d = sw.elapsed();
	CHECK(d > 180000);
	CHECK(d < 300000);

	sw.start();
	this_thread::sleep_for(chrono::milliseconds(100));
	sw.stop();
	d = sw.elapsed();
	CHECK(d > 280000);
	CHECK(d < 400000);
	
	this_thread::sleep_for(chrono::milliseconds(100));
	sw.stop();
	d = sw.elapsed();
	CHECK(d > 380000);
	CHECK(d < 500000);
	
	sw.restart();
	sw.start();
	this_thread::sleep_for(chrono::milliseconds(200));
	sw.stop();
	d = sw.elapsed();
	CHECK(d > 180000);
	CHECK(d < 300000);
}
void
EventDeliveryManager::gather_events( bool done )
{
  // IMPORTANT: Ensure that gather_events(..) is called from a single thread and
  //            NOT from a parallel OpenMP region!!!

  // Stop watch for time measurements within this function
  static Stopwatch stw_local;

  stw_local.reset();
  stw_local.start();
  collocate_buffers_( done );
  stw_local.stop();
  time_collocate_ += stw_local.elapsed();
  stw_local.reset();
  stw_local.start();
  if ( off_grid_spiking_ )
  {
    kernel().mpi_manager.communicate(
      local_offgrid_spikes_, global_offgrid_spikes_, displacements_ );
  }
  else
  {
    kernel().mpi_manager.communicate(
      local_grid_spikes_, global_grid_spikes_, displacements_ );
  }
  stw_local.stop();
  time_communicate_ += stw_local.elapsed();
}
Example #4
0
void testTimerHandler()
{
	LOGT("<testTimerHandler>");

	Timer t1, t2;
	TimerHandler handler;
	handler.attach(t1, timeout1);
	handler.attach(t2, timeout2);

	t1.setInterval(1);
	t2.setInterval(2);

	sw1.start();
	sw2.start();

	t1.start();
	t2.start();

	Thread::sleep(15);
	handler.detach(t2);
	Thread::sleep(30);

	t1.stop();
	t2.stop();

	Thread::sleep(105);
}
Example #5
0
	//--------------------------------------------------------------------------
	// ZDL benchmark functions
	//--------------------------------------------------------------------------
 	void ZDL_bench_1set_seq()
	{
		typedef ElementType Element;

		uint i;
		uint numOfProducers = NUM_PRODUCERS;
		uint numOfConsumers = NUM_CONSUMERS;
		ZDL<Element> zdl(numOfConsumers, fRm);
	    zdl.setMultipleProducers(true);		
		zdl.setElementMode(1); // RID_VALUE
		pthread_t producer[numOfProducers];
		pthread_t consumer[numOfConsumers];
		ThreadParms producerThreadParms[NUM_PRODUCERS];
		ThreadParms consumerThreadParms[NUM_CONSUMERS];
		struct timespec ts1, ts2, diff;
        
        timer.start("zdl-produce_1set_seq");
		clock_gettime(CLOCK_REALTIME, &ts1);
		for (i = 0; i < numOfProducers; i++)
		{
			producerThreadParms[i].zdl          = &zdl;
			producerThreadParms[i].threadNumber = i;
            producerThreadParms[i].count        = ::count1Set;
		    pthread_create(&producer[i], NULL,
				ZDL_producer_1set_seq<Element>, &producerThreadParms[i]);
		}
		for (i = 0; i < numOfProducers; i++)
		    pthread_join(producer[i], NULL);
		zdl.endOfInput();
		timer.stop("zdl-produce_1set_seq");
		
		timer.start("zdl-consume_1set_seq");
		for (i = 0; i < numOfConsumers; i++)
		{
			consumerThreadParms[i].zdl          = &zdl;
			consumerThreadParms[i].threadNumber = i;
            consumerThreadParms[i].count        = 0;
		    pthread_create(&consumer[i], NULL,
				ZDL_consumer<Element>, &consumerThreadParms[i]);
		}
		for (i = 0; i < numOfConsumers; i++)
		    pthread_join(consumer[i], NULL);   
		clock_gettime(CLOCK_REALTIME, &ts2);
        timer.stop("zdl-consume_1set_seq");	

        timer.finish();	
		timespec_sub(ts1, ts2, diff);
        cout << "# of Producers: " << numOfProducers << endl;
        cout << "# of Consumers: " << numOfConsumers << endl;
		cout << "ZDL_bench_1set_seq: producer & consumer passed " << 
			zdl.totalSize() << " elements in " << diff.tv_sec << "s " <<
			diff.tv_nsec << "ns" << endl;

		ZDL_printFileStats<Element>(&zdl);
		validateResults(::count1Set*NUM_PRODUCERS);
	}
Example #6
0
	//--------------------------------------------------------------------------
	// test the saving and loading of a zdl file
	//--------------------------------------------------------------------------
	void load_save(){
	    typedef ElementType Element;

    	vector <Element> v;
    	for (uint i = 0; i < ::count1Set*8; i++)
    	    v.push_back(Element(i,i));
    	
    	vector<Element> v1;
    	vector<Element> v2;
    	vector<Element> v3;
    	
    	// save
    	ofstream f1;
    	ifstream f;
    	string filename = "zdl.txt";
    	uint64_t ctn = v.size();
    	f1.open(filename.c_str(), std::ios::binary);
    	f1.write((char *) &ctn, sizeof(ctn));
    	f1.write((char *) (v.begin().operator->()), sizeof(Element) * ctn);
    	f.close();
    	
    	// load
    	v1.push_back(Element(3,4));
    	f.open(filename.c_str(), std::ios::binary);
    	timer.start("read");
    	v1.resize(v1.size()+::count1Set*8);
    	f.read((char *) ((v1.begin()+1).operator->()), ctn * sizeof(Element));
    	cout << v1.size() << endl;
        timer.stop("read");
        cout << "E1: " << v1[0].first << endl;
        f.close();
        
        f.open(filename.c_str(), std::ios::binary);
        timer.start("assign");
        v2.assign(std::istream_iterator<Element>(f), 
        				std::istream_iterator<Element>());
        cout << v2.size() << endl;    				    
        timer.stop("assign");
        f.close();
        
        f.open(filename.c_str(), std::ios::binary);
        timer.start("insert");
        v3.insert(v3.end(), std::istream_iterator<Element>(f), 
        				std::istream_iterator<Element>());
        cout << v3.size() << endl;    				    
        timer.stop("insert");
        f.close();
        timer.finish();
    }
Example #7
0
void queuedBSBenchmark(int queueLength)
{
    ByteStream *bs;
    pthread_t threads[columns];
    uint i, rowCount = 1;
    JobStepAssociation inJs;

    for (i = 0; i < columns; ++i) {
        AnyDataListSPtr spdl1(new AnyDataList());

        FIFO<UintRowGroup>* dl1 = new FIFO<UintRowGroup>(1, fifoSize);

        dl1->OID(i);    // lineitem first col object id
        spdl1->fifoDL(dl1);
        inJs.outAdd(spdl1);

        pthread_create(&threads[i], 0, nextBandBenchProducer, dl1 );
        cout << "started thread " << i << endl;
    }

    DeliveryStep ds(inJs, JobStepAssociation(), 8);
	BSQueueMgr bsq(&ds, queueLength);
	stringstream ss;
	ss << "queuedBSBenchmark with " << columns << " columns and " << queueLength << " queue length\n";
	
    timer.start(ss.str());
	boost::thread(BSProjectThread(&bsq));
    while (rowCount != 0) {
        bs = bsq.getNextByteStream(rowCount);
		delete bs;
    }
    timer.stop(ss.str());
    for (i = 0; i < columns; ++i)
        pthread_join(threads[i], NULL);
}
    std::int64_t OneToOneSequencedBatchThroughputTest::run(Stopwatch& stopwatch)
    {
        m_taskScheduler->start(requiredProcessorCount());
        TestTools::ScopeExitFunctor atScopeExit([this] { m_taskScheduler->stop(); });

        auto signal = std::make_shared< Tests::ManualResetEvent >(false);
        auto expectedCount = m_batchEventProcessor->sequence()->value() + m_iterations * m_batchSize;
        m_handler->reset(signal, expectedCount);
        auto processorTask = m_executor->execute([this] { m_batchEventProcessor->run(); });
        stopwatch.start();

        auto&& rb = *m_ringBuffer;

        for (auto i = 0; i < m_iterations; ++i)
        {
            auto hi = rb.next(m_batchSize);
            auto lo = hi - (m_batchSize - 1);
            for (auto l = lo; l <= hi; ++l)
            {
                rb[l].value = (i);
            }
            rb.publish(lo, hi);
        }

        signal->waitOne();
        stopwatch.stop();
        PerfTestUtil::waitForEventProcessorSequence(expectedCount, m_batchEventProcessor);
        m_batchEventProcessor->halt();
        processorTask.wait_for(std::chrono::milliseconds(2000));

        PerfTestUtil::failIfNot(m_expectedResult, m_handler->value(),
                                "Handler should have processed " + std::to_string(m_expectedResult) + " events, but was: " + std::to_string(m_handler->value()));

        return m_batchSize * m_iterations;
    }
Example #9
0
bool await(const process::Future<T>& future, const Duration& duration)
{
  if (!process::Clock::paused()) {
    return future.await(duration);
  }

  // If the clock is paused, no new timers will expire.
  // Future::await(duration) may hang forever because it depends on
  // a timer to expire after 'duration'. We instead ensure all
  // expired timers are flushed and check if the future is satisfied.
  Stopwatch stopwatch;
  stopwatch.start();

  // Settle to make sure all expired timers are executed (not
  // necessarily finished, see below).
  process::Clock::settle();

  while (future.isPending() && stopwatch.elapsed() < duration) {
    // Synchronous operations and asynchronous process::Process
    // operations should finish when the above 'settle()' returns.
    // Other types of async operations such as io::write() may not.
    // Therefore we wait the specified duration for it to complete.
    // Note that nothing prevents the operations to schedule more
    // timeouts for some time in the future. These timeouts will
    // never be executed due to the paused process::Clock. In this
    // case we return after the stopwatch (system clock) runs out.
    os::sleep(Milliseconds(10));
  }

  return !future.isPending();
}
    void PingPongSequencedLatencyTest::run(Stopwatch& stopwatch, const std::shared_ptr< Tests::LatencyRecorder >& latencyRecorder)
    {
        m_taskScheduler->start(requiredProcessorCount());
        TestTools::ScopeExitFunctor atScopeExit([this] { m_taskScheduler->stop(); });

        auto globalSignal = std::make_shared< Tests::CountdownEvent >(3);
        auto signal = std::make_shared< Tests::ManualResetEvent >(false);
        m_pinger->reset(globalSignal, signal, latencyRecorder);
        m_ponger->reset(globalSignal);

        auto processorTask1 = m_executor->execute([this] { m_pongProcessor->run(); });
        auto processorTask2 = m_executor->execute([this] { m_pingProcessor->run(); });

        globalSignal->signal();
        globalSignal->wait();
        stopwatch.start();
        // running here
        signal->waitOne();
        stopwatch.stop();

        m_pingProcessor->halt();
        m_pongProcessor->halt();

        processorTask1.wait();
        processorTask2.wait();
    }
Example #11
0
  void resourceOffers(const vector<Offer>& offers,
                      const vector<string>& pids)
  {
    if (aborted) {
      VLOG(1) << "Ignoring resource offers message because "
              << "the driver is aborted!";
      return;
    }

    VLOG(2) << "Received " << offers.size() << " offers";

    CHECK(offers.size() == pids.size());

    // Save the pid associated with each slave (one per offer) so
    // later we can send framework messages directly.
    for (size_t i = 0; i < offers.size(); i++) {
      UPID pid(pids[i]);
      // Check if parse failed (e.g., due to DNS).
      if (pid != UPID()) {
        VLOG(3) << "Saving PID '" << pids[i] << "'";
        savedOffers[offers[i].id()][offers[i].slave_id()] = pid;
      } else {
        VLOG(1) << "Failed to parse PID '" << pids[i] << "'";
      }
    }

    Stopwatch stopwatch;
    if (FLAGS_v >= 1) {
      stopwatch.start();
    }

    scheduler->resourceOffers(driver, offers);

    VLOG(1) << "Scheduler::resourceOffers took " << stopwatch.elapsed();
  }
Example #12
0
void doFollyDynamic(std::vector<std::string> strvec) 
{
	std::cout << "folly::dynamic" << std::endl;
	std::cout << "==============" << std::endl;

	std::vector<std::string>::iterator it = strvec.begin();
	std::vector<std::string>::iterator end = strvec.end();

	Stopwatch sw;
	sw.start();
	for (; it != end; ++it)
	{
		dynamic var(*it);
		
		int i = var.asInt();
	
		double d = var.asDouble();

		var = i;
		std::string s = var.asString().c_str();

		var = d;
		s = var.asString().c_str();
	}
	sw.stop();
	std::cout << "folly::dynamic: " << sw.elapsed()/1000.0 << " [ms]" << std::endl;
	
	std::cout << "==============" << std::endl;
}
Example #13
0
int main()
{
    Stopwatch sw;

    sw.start();

	size_t n = 600851475143;
    size_t z = n;
	vector<size_t> factors;

    size_t s = static_cast<size_t>(sqrt(n));
    for (size_t i = 2; i <= s; i++) {
        if (z % i == 0) {
            factors.push_back(i);
            z /= i;
            i = 2;
        }
        if (i == s && z != 1) {
            factors.push_back(z);
        }
    }

    cout << strjoin(factors, " * ") << endl;
    cout << sw.get();
	return 0;
}
Example #14
0
auto_release_ptr<CurveObject> CurveObjectReader::load_curve_file(
    const SearchPaths&      search_paths,
    const char*             name,
    const ParamArray&       params)
{
    auto_release_ptr<CurveObject> object = CurveObjectFactory::create(name, params);

    const string filepath = search_paths.qualify(params.get<string>("filepath"));
    const size_t split_count = params.get_optional<size_t>("presplits", 0);

    ifstream input;
    input.open(filepath.c_str());

    if (!input.is_open())
    {
        RENDERER_LOG_ERROR("failed to open curve file %s.", filepath.c_str());
        return object;
    }

    Stopwatch<DefaultWallclockTimer> stopwatch;
    stopwatch.start();

    size_t curve1_count;
    size_t curve3_count;
    input >> curve1_count;
    input >> curve3_count;

    object->reserve_curves1(curve1_count);
    object->reserve_curves3(curve3_count);

    for (size_t c = 0; c < curve1_count + curve3_count; ++c)
    {
        size_t control_point_count;
        input >> control_point_count;

        if (control_point_count != 2 && control_point_count != 4)
        {
            RENDERER_LOG_ERROR(
                "while loading curve file %s: only linear curves (2 control points) or cubic curves (4 control points) are currently supported.",
                filepath.c_str());
            return object;
        }

        if (control_point_count == 2)
        {
            GVector3 points[2];
            GScalar widths[2];

            for (size_t p = 0; p < control_point_count; ++p)
            {
                input >> points[p].x >> points[p].y >> points[p].z;
                input >> widths[p];
            }

            // We never presplit degree-1 curves.
            const CurveType1 curve(points, widths);
            object->push_curve1(curve);
        }
        else
        {
Example #15
0
CurveTree::CurveTree(const Arguments& arguments)
  : TreeType(AlignedAllocator<void>(System::get_l1_data_cache_line_size()))
  , m_arguments(arguments)
{
    // Retrieve construction parameters.
    const MessageContext message_context(
        format("while building curve tree for assembly \"{0}\"", m_arguments.m_assembly.get_path()));
    const ParamArray& params = m_arguments.m_assembly.get_parameters().child("acceleration_structure");
    const string algorithm = params.get_optional<string>("algorithm", "bvh", make_vector("bvh", "sbvh"), message_context);
    const double time = params.get_optional<double>("time", 0.5);

    // Start stopwatch.
    Stopwatch<DefaultWallclockTimer> stopwatch;
    stopwatch.start();

    // Build the tree.
    Statistics statistics;
    if (algorithm == "bvh")
        build_bvh(params, time, statistics);
    else throw ExceptionNotImplemented();

    // Print curve tree statistics.
    statistics.insert_size("nodes alignment", alignment(&m_nodes[0]));
    statistics.insert_time("total time", stopwatch.measure().get_seconds());
    RENDERER_LOG_DEBUG("%s",
        StatisticsVector::make(
            "curve tree #" + to_string(m_arguments.m_curve_tree_uid) + " statistics",
            statistics).to_string().c_str());
}
Example #16
0
void RunOCLNBody2ForKernel(
	float * arg_Mas, size_t arg_hst_ptrMas_dim1, float * arg_Forces_y, 
	size_t arg_hst_ptrForces_y_dim1, size_t arg_hst_ptrForces_y_dim2, float * arg_Pos, 
	size_t arg_hst_ptrPos_dim1, size_t arg_hst_ptrPos_dim2, float * arg_Forces_x, 
	size_t arg_hst_ptrForces_x_dim1, size_t arg_hst_ptrForces_x_dim2, size_t arg_N
	)
{
  if (isFirstTime)
    {
      hst_ptrMas = arg_Mas;
      hst_ptrMas_dim1 = arg_hst_ptrMas_dim1;
      hst_ptrForces_y = arg_Forces_y;
      hst_ptrForces_y_dim1 = arg_hst_ptrForces_y_dim1;
      hst_ptrForces_y_dim2 = arg_hst_ptrForces_y_dim2;
      hst_ptrPos = arg_Pos;
      hst_ptrPos_dim1 = arg_hst_ptrPos_dim1;
      hst_ptrPos_dim2 = arg_hst_ptrPos_dim2;
      hst_ptrForces_x = arg_Forces_x;
      hst_ptrForces_x_dim1 = arg_hst_ptrForces_x_dim1;
      hst_ptrForces_x_dim2 = arg_hst_ptrForces_x_dim2;
      N = arg_N;
      StartUpGPU();
      AllocateBuffers();
      compileKernelFromFile(
	"NBody2For", "NBody2For.cl", KernelString(), 
	true, &NBody2ForKernel, KernelDefines
	);
      SetArgumentsNBody2For();
    }
  timer.start();
  ExecNBody2For();
  cout << timer.stop() << endl;
}
  void generate()
  {
    watch.start();

    while (true) {
      Duration elapsed = watch.elapsed();

      if (duration.isSome() && elapsed >= duration.get()) {
        LOG(INFO) << "LoadGenerator generated " << messages
                  << " messages in " << elapsed << " (throughput = "
                  << (messages / elapsed.secs()) << " messages/sec)";

        LOG(INFO) << "Stopping LoadGenerator and scheduler driver";

        terminate(self());
        driver->stop();
        return;
      }

      Stopwatch reconcile;
      reconcile.start();

      driver->reconcileTasks(vector<TaskStatus>());

      messages++;

      // Compensate for the driver call overhead.
      os::sleep(std::max(
          Duration::zero(),
          Seconds(1) / qps - reconcile.elapsed()));
    }
  }
Example #18
0
TEST_P(Registrar_BENCHMARK_Test, performance)
{
  Registrar registrar(flags, state);
  AWAIT_READY(registrar.recover(master));

  vector<SlaveInfo> infos;

  Attributes attributes = Attributes::parse("foo:bar;baz:quux");
  Resources resources =
    Resources::parse("cpus(*):1.0;mem(*):512;disk(*):2048").get();

  size_t slaveCount = GetParam();

  // Create slaves.
  for (size_t i = 0; i < slaveCount; ++i) {
    // Simulate real slave information.
    SlaveInfo info;
    info.set_hostname("localhost");
    info.mutable_id()->set_value(
        std::string("201310101658-2280333834-5050-48574-") + stringify(i));
    info.mutable_resources()->MergeFrom(resources);
    info.mutable_attributes()->MergeFrom(attributes);
    infos.push_back(info);
  }

  // Admit slaves.
  Stopwatch watch;
  watch.start();
  Future<bool> result;
  foreach (const SlaveInfo& info, infos) {
    result = registrar.apply(Owned<Operation>(new AdmitSlave(info)));
  }
Example #19
0
  void lostSlave(const SlaveID& slaveId)
  {
    if (aborted) {
      VLOG(1) << "Ignoring lost slave message because the driver is aborted!";
      return;
    }

    if (from != master) {
      LOG(WARNING) << "Ignoring lost slave message from " << from
                   << "because it is not from the registered master ("
                   << master << ")";
      return;
    }

    VLOG(1) << "Lost slave " << slaveId;

    savedSlavePids.erase(slaveId);

    Stopwatch stopwatch;
    if (FLAGS_v >= 1) {
      stopwatch.start();
    }

    scheduler->slaveLost(driver, slaveId);

    VLOG(1) << "Scheduler::slaveLost took " << stopwatch.elapsed();
  }
bool MeshObjectWriter::write(
    const MeshObject&   object,
    const char*         object_name,
    const char*         filename)
{
    assert(filename);

    Stopwatch<DefaultWallclockTimer> stopwatch;
    stopwatch.start();

    try
    {
        GenericMeshFileWriter writer(filename);
        MeshObjectWalker walker(object, object_name);
        writer.write(walker);
    }
    catch (const exception& e)
    {
        RENDERER_LOG_ERROR(
            "failed to write mesh file %s: %s.",
            filename,
            e.what());
        return false;
    }

    stopwatch.measure();

    RENDERER_LOG_INFO(
        "wrote mesh file %s in %s.",
        filename,
        pretty_time(stopwatch.get_seconds()).c_str());

    return true;
}
Example #21
0
string OriCommand::cmd_merge(strstream &str)
{
#if defined(DEBUG) || defined(ORI_PERF)
    Stopwatch sw = Stopwatch();
    sw.start();
#endif /* DEBUG */

    FUSE_PLOG("Command: merge");

    string error;
    ObjectHash hash;
    strwstream resp;

    // Parse Command
    str.readHash(hash);

    RWKey::sp lock = priv->nsLock.writeLock();
    error = priv->merge(hash);
    lock.reset();

    if (error != "") {
        resp.writeUInt8(0);
        resp.writePStr(error);
    } else {
        resp.writeUInt8(1);
    }

#if defined(DEBUG) || defined(ORI_PERF)
    sw.stop();
    FUSE_PLOG("merge with: %s", hash.hex().c_str());
    FUSE_PLOG("merge elapsed %lluus", sw.getElapsedTime());
#endif /* DEBUG */

    return resp.str();
}
Example #22
0
void RegistrarProcess::update()
{
  if (operations.empty()) {
    return; // No-op.
  }

  CHECK(!updating);
  CHECK(error.isNone());
  CHECK_SOME(variable);

  // Time how long it takes to apply the operations.
  Stopwatch stopwatch;
  stopwatch.start();

  updating = true;

  // Create a snapshot of the current registry.
  Registry registry = variable.get().get();

  // Create the 'slaveIDs' accumulator.
  hashset<SlaveID> slaveIDs;
  foreach (const Registry::Slave& slave, registry.slaves().slaves()) {
    slaveIDs.insert(slave.info().id());
  }

  foreach (Owned<Operation> operation, operations) {
    // No need to process the result of the operation.
    (*operation)(&registry, &slaveIDs, flags.registry_strict);
  }
Example #23
0
		Ref<Image> Image::load_from_data (const Ptr<IData> data) {
			static Stopwatch t;
			static unsigned count = 0; ++count;

			Ref<Image> loaded_image;
			Shared<Buffer> buffer;

			t.start();

			buffer = data->buffer();

			switch (buffer->mimetype()) {
			case IMAGE_JPEG:
				loaded_image = load_jpeg_image(data);
				break;
			case IMAGE_PNG:
				loaded_image = load_png_image(data);
				break;
			//case Data::IMAGE_DDS:
			//	loaded_image = load_ddsimage(data);
			default:
				logger()->log(LOG_ERROR, "Could not load image: Unsupported image format.");
			}

			t.pause();

			logger()->log(LOG_INFO, LogBuffer() << "*** Total time to load " << count << " images: " << t.time() << "s");

			return loaded_image;
		}
Example #24
0
Try<Action> LevelDBStorage::read(uint64_t position)
{
  Stopwatch stopwatch;
  stopwatch.start();

  leveldb::ReadOptions options;

  string value;

  leveldb::Status status = db->Get(options, encode(position), &value);

  if (!status.ok()) {
    return Error(status.ToString());
  }

  google::protobuf::io::ArrayInputStream stream(value.data(), value.size());

  Record record;

  if (!record.ParseFromZeroCopyStream(&stream)) {
    return Error("Failed to deserialize record");
  }

  if (record.type() != Record::ACTION) {
    return Error("Bad record");
  }

  LOG(INFO) << "Reading position from leveldb took " << stopwatch.elapsed();

  return record.action();
}
void RunOCLKNearestForKernel(
	unsigned arg_dim, float * arg_test_patterns, size_t arg_hst_ptrtest_patterns_dim1, 
	size_t arg_hst_ptrtest_patterns_dim2, float * arg_dist_matrix, size_t arg_hst_ptrdist_matrix_dim1, 
	size_t arg_hst_ptrdist_matrix_dim2, float * arg_train_patterns, size_t arg_hst_ptrtrain_patterns_dim1, 
	size_t arg_hst_ptrtrain_patterns_dim2, unsigned arg_NTEST, unsigned arg_NTRAIN
	)
{
  if (isFirstTime)
    {
      dim = arg_dim;
      hst_ptrtest_patterns = arg_test_patterns;
      hst_ptrtest_patterns_dim1 = arg_hst_ptrtest_patterns_dim1;
      hst_ptrtest_patterns_dim2 = arg_hst_ptrtest_patterns_dim2;
      hst_ptrdist_matrix = arg_dist_matrix;
      hst_ptrdist_matrix_dim1 = arg_hst_ptrdist_matrix_dim1;
      hst_ptrdist_matrix_dim2 = arg_hst_ptrdist_matrix_dim2;
      hst_ptrtrain_patterns = arg_train_patterns;
      hst_ptrtrain_patterns_dim1 = arg_hst_ptrtrain_patterns_dim1;
      hst_ptrtrain_patterns_dim2 = arg_hst_ptrtrain_patterns_dim2;
      NTEST = arg_NTEST;
      NTRAIN = arg_NTRAIN;
      StartUpGPU();
      AllocateBuffers();
      cout << "$Defines " << KernelDefines << endl;
      compileKernel(
	"KNearestFor", "KNearestFor.cl", GetKernelCode(), 
	false, &KNearestForKernel, KernelDefines
	);
      SetArgumentsKNearestFor();
    }
  timer.start();
  ExecKNearestFor();
  cout << "$Time " << timer.stop() << endl;
}
Example #26
0
  void reregistered(const FrameworkID& frameworkId, const MasterInfo& masterInfo)
  {
    if (aborted) {
      VLOG(1) << "Ignoring framework re-registered message because "
              << "the driver is aborted!";
      return;
    }

    if (connected) {
      VLOG(1) << "Ignoring framework re-registered message because "
              << "the driver is already connected!";
      return;
    }

    VLOG(1) << "Framework re-registered with " << frameworkId;

    CHECK(framework.id() == frameworkId);

    connected = true;
    failover = false;

    Stopwatch stopwatch;
    if (FLAGS_v >= 1) {
      stopwatch.start();
    }

    scheduler->reregistered(driver, masterInfo);

    VLOG(1) << "Scheduler::reregistered took " << stopwatch.elapsed();
  }
Example #27
0
Try<Nothing> LevelDBStorage::persist(const Metadata& metadata)
{
  Stopwatch stopwatch;
  stopwatch.start();

  leveldb::WriteOptions options;
  options.sync = true;

  Record record;
  record.set_type(Record::METADATA);
  record.mutable_metadata()->CopyFrom(metadata);

  string value;

  if (!record.SerializeToString(&value)) {
    return Error("Failed to serialize record");
  }

  leveldb::Status status = db->Put(options, encode(0, false), value);

  if (!status.ok()) {
    return Error(status.ToString());
  }

  LOG(INFO) << "Persisting metadata (" << value.size()
            << " bytes) to leveldb took " << stopwatch.elapsed();

  return Nothing();
}
Example #28
0
void RunOCLJacobiForKernel(
	float * arg_X2, size_t arg_hst_ptrX2_dim1, size_t arg_hst_ptrX2_dim2, 
	float * arg_X1, size_t arg_hst_ptrX1_dim1, size_t arg_hst_ptrX1_dim2, 
	float * arg_B, size_t arg_hst_ptrB_dim1, size_t arg_hst_ptrB_dim2, 
	unsigned arg_wB, unsigned arg_wA)
{
  if (isFirstTime)
    {
      hst_ptrX2 = arg_X2;
      hst_ptrX2_dim1 = arg_hst_ptrX2_dim1;
      hst_ptrX2_dim2 = arg_hst_ptrX2_dim2;
      hst_ptrX1 = arg_X1;
      hst_ptrX1_dim1 = arg_hst_ptrX1_dim1;
      hst_ptrX1_dim2 = arg_hst_ptrX1_dim2;
      hst_ptrB = arg_B;
      hst_ptrB_dim1 = arg_hst_ptrB_dim1;
      hst_ptrB_dim2 = arg_hst_ptrB_dim2;
      wB = arg_wB;
      wA = arg_wA;
      StartUpGPU();
      AllocateBuffers();
      cout << "$Defines " << KernelDefines << endl;
      compileKernel(
	"JacobiFor", "JacobiFor.cl", GetKernelCode(), 
	false, &JacobiForKernel, KernelDefines
	);
      SetArgumentsJacobiFor();
    }
  timer.start();
  ExecJacobiFor();
  cout << "$Time " << timer.stop() << endl;
}
Example #29
0
void walk_tree()
{
    static Stopwatch timer;
    timer.start();
    
    scale_factor = sqrt(2.0*pow(((double)width/(bbmax-bbmin).max()), 2.0));
    
    vert_ls splats = sphere_tree->recurseToDepth(recursion_depth);
    
    splats.sort(testSize);
    
    maxSplatSize = scale_factor * (splats.front()->size - splats.back()-> size)/2.0;
    
    fastSplats.clear();    
    fastSplats.reserve(splats.size());
    
    for (vert_it it = splats.begin(); it != splats.end(); it++)
    {
        fastSplats.push_back(**it);
    }

    splatParts.clear();
    splatSizes.clear();
    
    partitionSizes(fastSplats.begin(), fastSplats.end(), 5);
    
    splatParts.push_back(fastSplats.end());
    
    cout << splatSizes.size() << endl;
    
    timer.stop();
    printf("Recursed to depth %u in %f seconds\n", recursion_depth, timer.time());
    printf("Displaying %lu splats, with %lu sizes\n", splats.size(), splatSizes.size() );
    timer.reset();
}
Example #30
0
bool Frame::write_image(
    const char*             file_path,
    const Image&            image,
    const ImageAttributes&  image_attributes) const
{
    assert(file_path);

    Image final_image(image);
    transform_to_output_color_space(final_image);

    Stopwatch<DefaultWallclockTimer> stopwatch;
    stopwatch.start();

    try
    {
        try
        {
            GenericImageFileWriter writer;
            writer.write(file_path, final_image, image_attributes);
        }
        catch (const ExceptionUnsupportedFileFormat&)
        {
            const string extension = lower_case(filesystem::path(file_path).extension());

            RENDERER_LOG_ERROR(
                "file format '%s' not supported, writing the image in OpenEXR format "
                "(but keeping the filename unmodified).",
                extension.c_str());

            EXRImageFileWriter writer;
            writer.write(file_path, final_image, image_attributes);
        }
    }
    catch (const ExceptionIOError&)
    {
        RENDERER_LOG_ERROR(
            "failed to write image file %s: i/o error.",
            file_path);

        return false;
    }
    catch (const Exception& e)
    {
        RENDERER_LOG_ERROR(
            "failed to write image file %s: %s.",
            file_path,
            e.what());

        return false;
    }

    stopwatch.measure();

    RENDERER_LOG_INFO(
        "wrote image file %s in %s.",
        file_path,
        pretty_time(stopwatch.get_seconds()).c_str());

    return true;
}