Ejemplo n.º 1
0
TInt DBmOmapChannel::BindInterrupt(MBMInterruptLatencyIsr* aIsr)
	{
	BM_ASSERT(!iIsr);
	BM_ASSERT(!iInterruptLatencyIsr);
	iInterruptLatencyIsr = aIsr;
	return BindInterrupt();
	}
Ejemplo n.º 2
0
void DBMLChannel::Dfc(TAny* ptr)
	{	
	DBMLChannel* lCh = (DBMLChannel*) ptr;
	BM_ASSERT(lCh->iPendingInterruptRequest);
	BM_ASSERT(lCh->iInterruptThread);
	NKern::ThreadRequestSignal(&lCh->iInterruptThread->iNThread);
	lCh->iPendingInterruptRequest = EFalse;
	}
Ejemplo n.º 3
0
const Field& State::at(int x, int y) const {
    BM_ASSERT(x >= 0);
    BM_ASSERT(y >= 0);
    BM_ASSERT(x < width);
    BM_ASSERT(y < height);

    return fields[x][y];
}
Ejemplo n.º 4
0
TInt DBMLChannel::KernelPreemptionLatencyThreadEntry(TAny* ptr)
	{
	DBMLChannel* lCh = (DBMLChannel*) ptr;
	lCh->KernelPreemptionLatencyThread();
	BM_ASSERT(0);
	return 0;
	}
Ejemplo n.º 5
0
State fromProto(const protocol::Global& g) {
    State res;

    res.tick = g.tick();
    res.our_doc_id = g.your_doc_id();

    res.width = g.width();
    res.height = g.height();

    res.fields =
        std::vector<std::vector<Field>>(res.width,
        std::vector<Field>(res.height));

    BM_ASSERT(g.fields_size() == int(res.width * res.height));
    for (uint32_t y = 0; y < res.height; ++y) {
        for (uint32_t x = 0; x < res.width; ++x) {
            res.fields[x][y] = fromProto(g.fields(y * res.width + x));
        }
    }

    if (g.has_error()) {
        res.error = fromProto(g.error());
    }
    return res;
}
Ejemplo n.º 6
0
FieldElement fromProto(const protocol::Field::ElementInfo& ei) {
    switch (fromProto(ei.type())) {
	case ElementType::FLUXCAPATITOR:
	    BM_ASSERT(ei.has_flux_capatitor());
	    return fromProto(ei.flux_capatitor());
	case ElementType::DOC:
	    BM_ASSERT(ei.has_doc());
	    return fromProto(ei.doc());
	case ElementType::ENEMY:
	    BM_ASSERT(ei.has_enemy());
	    return fromProto(ei.enemy());
	case ElementType::WALL:
	    return Wall{};
	case ElementType::CHEST:
	    BM_ASSERT(ei.has_chest());
	    return fromProto(ei.chest());
	case ElementType::DELOREAN:
	    BM_ASSERT(ei.has_delorean());
	    return fromProto(ei.delorean());
	case ElementType::CAPABILITY:
	    BM_ASSERT(ei.has_capability());
	    return fromProto(ei.capability());
        case ElementType::BLANK:
            LOGE("This should never happen (fromProto(FieldElement) blank)");
            return {};
    }
    BM_ASSERT(false);
}
Ejemplo n.º 7
0
void DBmOmapChannel::RequestInterrupt()
	{
	BM_ASSERT(iIsr || iInterruptLatencyIsr);
	TOmap::SetRegister32(KGPTimerBase+KHoGpTimer_TMAR, TOmap::Register32(KGPTimerBase+KHoGpTimer_TCRR) + KBMOmapInterruptDelayTicks);
	// Clear Match interrupt
	TOmap::SetRegister32(KGPTimerBase+KHoGpTimer_TISR, KHtGpTimer_TISR_Match);
	// Enable Match interrupt
	TOmap::SetRegister32(KGPTimerBase+KHoGpTimer_TIER, KHtGpTimer_TIER_Match);
	}
Ejemplo n.º 8
0
void DBmOmapChannel::Isr(TAny* ptr)
	{
	DBmOmapChannel* mCh = (DBmOmapChannel*) ptr;
	BM_ASSERT(mCh->iIsr || mCh->iInterruptLatencyIsr);
	if (mCh->iIsr)
		{
		mCh->iIsr->Isr(TUint(TOmap::Register32(KGPTimerBase + KHoGpTimer_TCRR)));
		}
	else
		{
		mCh->iInterruptLatencyIsr->InterruptLatencyIsr(TOmap::Register32(KGPTimerBase+KHoGpTimer_TCRR) - TOmap::Register32(KGPTimerBase+KHoGpTimer_TMAR));
		}
	TOmap::ModifyRegister32(KGPTimerBase+KHoGpTimer_TIER, KHtGpTimer_TIER_Match, KClear32);
	}
Ejemplo n.º 9
0
MBMChild* BMProgram::SpawnRemoteChild(TBMSpawnArgs* args)
	{
	CRemoteChild* child = new CRemoteChild(this);
	BM_ERROR(KErrNoMemory, child);
	//
	// Create the child process and pass args as a UNICODE command line.
	// (we suppose that the args size is multiple of sizeof(TUint16))
	//
	BM_ASSERT((args->iSize % sizeof(TUint16)) == 0);
	TInt r = child->iChild.Create(RProcess().FileName(), TPtrC((TUint16*) args, args->iSize/sizeof(TUint16)));
	BM_ERROR(r, (r == KErrNone) );
	child->iChild.Logon(child->iExitStatus);
	child->iChild.Resume();
	return child;
	}
Ejemplo n.º 10
0
void DBMLChannel::KernelPreemptionLatencyThread()
	{
	for(;;)
		{
		NKern::WaitForAnyRequest();

		if(iKernelThreadExitSemaphore)
			break;

		TBMTicks now = PChannel()->TimerStamp();
		iTime = Delta(iTime, now);
		BM_ASSERT(iUserThread);
		NKern::ThreadRequestSignal(&iUserThread->iNThread);
		}

	NKern::FSSignal(iKernelThreadExitSemaphore);
	Kern::Exit(0); 
	}
Ejemplo n.º 11
0
ElementType fromProto(protocol::Field::ElementType et) {
    switch (et) {
        case protocol::Field::FLUXCAPATITOR:
	    return ElementType::FLUXCAPATITOR;
        case protocol::Field::DOC:
	    return ElementType::DOC;
        case protocol::Field::ENEMY:
	    return ElementType::ENEMY;
        case protocol::Field::WALL:
	    return ElementType::WALL;
        case protocol::Field::CHEST:
	    return ElementType::CHEST;
        case protocol::Field::DELOREAN:
	    return ElementType::DELOREAN;
        case protocol::Field::CAPABILITY:
	    return ElementType::CAPABILITY;
    }
    BM_ASSERT(false);
}
Ejemplo n.º 12
0
 const T& as() const {
     BM_ASSERT(is<T>());
     return boost::get<T>(element);
 }
Ejemplo n.º 13
0
//
// The benchmark-suite entry point.
//
GLDEF_C TInt E32Main()
	{
	RTest test(_L("Benchmark Suite"));
	test.Title();

	AddProperty();
	AddThread();
	AddIpc();
	AddSync();
	AddOverhead();
	AddrtLatency();

	TInt r = User::LoadPhysicalDevice(KBMPddFileName);
	BM_ERROR(r, (r == KErrNone) || (r == KErrAlreadyExists));

	r = User::LoadLogicalDevice(KBMLddFileName);
	BM_ERROR(r, (r == KErrNone) || (r == KErrAlreadyExists));

	r = ::bmTimer.Open();
	BM_ERROR(r, (r == KErrNone));

	r = ::bmDriver.Open();
	BM_ERROR(r, (r == KErrNone));

	TBMTimeInterval::Init();

	TInt seconds = KBMSecondsPerProgram;

	TInt len = User::CommandLineLength();
	if (len)
		{
		//
		// Copy the command line in a buffer
		//
		TInt size = len * sizeof(TUint16);
		HBufC8* hb = HBufC8::NewMax(size);
		BM_ERROR(KErrNoMemory, hb);
		TPtr cmd((TUint16*) hb->Ptr(), len);
		User::CommandLine(cmd);
		//
		// Check for the TBMSpawnArgs magic number.
		//
		TBMSpawnArgs* args = (TBMSpawnArgs*) hb->Ptr();	
		if (args->iMagic == TBMSpawnArgs::KMagic)
			{
			//
			// This is a child process -  call it's entry point
			//
			return ::ChildMain(args);
			}
		else
			{
			//
			// A real command line - the time (in seconds) for each benchmark program.
			//
			TLex l(cmd);
			r = l.Val(seconds);
			if (r != KErrNone)
				{
				test.Printf(_L("Usage: bm_suite <seconds>\n"));
				BM_ERROR(r, 0);
				}
			}
		delete hb;
		}

	{
	TBMTicks ticks = 1;
	TBMNs ns;
	::bmTimer.TicksToNs(&ticks, &ns);
	test.Printf(_L("High resolution timer tick %dns\n"), TInt(ns));
	test.Printf(_L("High resolution timer period %dms\n"), BMNsToMs(TBMTimeInterval::iStampPeriodNs));
	}

	test.Start(_L("Performance Benchmark Suite"));

	BMProgram* prog = ::bmSuite;
	while (prog) {
		//
		// For each program from the benchmark-suite's list
		//

		//
		// Remember the number of open handles. Just for a sanity check ....
		//
		TInt start_thc, start_phc;
		RThread().HandleCount(start_phc, start_thc);

		test.Printf(_L("%S\n"), &prog->Name());
	
		//
		// A benchmark-suite's thread can run at any of three possible absolute priorities:
		//		KBMPriorityLow, KBMPriorityMid and KBMPriorityHigh.
		// The main thread starts individual benchmark programs at KBMPriorityMid
		//
		prog->iOrigAbsPriority = BMProgram::SetAbsPriority(RThread(), KBMPriorityMid);

		//
		// First of all figure out how many iteration would be required to run this program
		// for the given number of seconds.
		//
		TInt count;
		TBMNs ns = 0;
		TBMUInt64 iter = KBMCalibrationIter;
		for (;;) 
			{
			TBMTimeInterval ti;
			ti.Begin();
			prog->Run(iter, &count);
			ns = ti.EndNs();
				// run at least 100ms (otherwise, could be too much impricise ...)
			if (ns > BMMsToNs(100)) break;
			iter *= 2;
			}
		test.Printf(_L("%d iterations in %dms\n"), TInt(iter), BMNsToMs(ns));
		iter = (BMSecondsToNs(seconds) * iter) / ns;
		test.Printf(_L("Go for %d iterations ...\n"), TInt(iter));

		//
		// Now the real run ...
		//
		TBMResult* results = prog->Run(iter, &count);

			// Restore the original priority
		BMProgram::SetAbsPriority(RThread(), prog->iOrigAbsPriority);

		//
		// Now print out the results
		//
		for (TInt i = 0; i < count; ++i) 
			{
			if (results[i].iMax)
				{
				test.Printf(_L("%S. %d iterations; Avr: %dns; Min: %dns; Max: %dns\n"), 
							&results[i].iName, TInt(results[i].iIterations),
							TInt(results[i].iAverage), TInt(results[i].iMin), TInt(results[i].iMax));

				TInt j;
				BM_ASSERT((TBMResult::KHeadSize % 4) == 0);
				test.Printf(_L("Head:"));
				for (j = 0; j < TBMResult::KHeadSize; j += 4)
					{
					test.Printf(_L(" %d %d %d %d "), 
								TInt(results[i].iHead[j]), TInt(results[i].iHead[j+1]), 
								TInt(results[i].iHead[j+2]), TInt(results[i].iHead[j+3]));
					}
				test.Printf(_L("\n"));

				BM_ASSERT((TBMResult::KTailSize % 4) == 0);
				test.Printf(_L("Tail:"));
				for (j = 0; j < TBMResult::KTailSize; j += 4)
					{
					test.Printf(_L(" %d %d %d %d "), 
								TInt(results[i].iTail[j]), TInt(results[i].iTail[j+1]), 
								TInt(results[i].iTail[j+2]), TInt(results[i].iTail[j+3]));
					}
				test.Printf(_L("\n"));
				}
			else
				{
				test.Printf(_L("%S. %d iterations; Avr: %dns\n"), 
							&results[i].iName, TInt(results[i].iIterations), TInt(results[i].iAverage));
				}

			}

		//
		// Sanity check for open handles
		//
		TInt end_thc, end_phc;
		RThread().HandleCount(end_phc, end_thc);
		BM_ASSERT(start_thc == end_thc);
		BM_ASSERT(start_phc == end_phc);
			// and also for pending requests ...
		BM_ASSERT(RThread().RequestCount() == 0);

		prog = prog->Next();
//
//		This can be used to run forever ...
//
//		if (prog == NULL)
//			prog = ::bmSuite;
//
	}
	
	test.End();

	::bmDriver.Close();
	::bmTimer.Close();
	return 0;
	}