Beispiel #1
0
void CommonTestUtils::assertValues(const DeviceInformation& info, const DeviceType& expectedType, const QString& expectedName)
{
    QVERIFY  (info.getDeviceId() == DEVICEINFORMATION_DEVICE_ID);
    QCOMPARE (info.getDeviceNode(), DEVICEINFORMATION_DEVICE_NODE);
    QCOMPARE (info.getName(), expectedName);
    QVERIFY  (info.getProductId() == DEVICEINFORMATION_PRODUCT_ID);
    QVERIFY  (info.getTabletSerial() == DEVICEINFORMATION_TABLET_SERIAL);
    QVERIFY  (info.getType() == expectedType);
    QVERIFY  (info.getVendorId() == DEVICEINFORMATION_VENDOR_ID);
}
// HardwareInformation
// -------------------
HardwareInformation::HardwareInformation() {
	devices = new std::map<std::string, DeviceInformation*>();

	// the FPGA runs @  100MHz instead of 800MHz, so we need to corrent 
	// the timinigs for a comparison with the ARM processor
	unsigned int fpgaClockMultiplier = 8;


	// add timinigs for the ARM Cortex-A9 @ 800MHz
	DeviceInformation *cortexA9 = new DeviceInformation("Cortex-A9", DeviceInformation::CPU_LINUX);
	cortexA9->addInstructionInfo("ret",    0);
	cortexA9->addInstructionInfo("br",     0);
	cortexA9->addInstructionInfo("fadd",   4);
	cortexA9->addInstructionInfo("fsub",   4);
	cortexA9->addInstructionInfo("fmul",   6);
	cortexA9->addInstructionInfo("fdiv",  25);
	cortexA9->addInstructionInfo("or",     2);
	cortexA9->addInstructionInfo("alloca", 0);
	cortexA9->addInstructionInfo("load",   4);
	cortexA9->addInstructionInfo("store",  6);
	cortexA9->addInstructionInfo("getelementptr", 3);
	cortexA9->addInstructionInfo("zext",   1);
	cortexA9->addInstructionInfo("icmp",   3);
	cortexA9->addInstructionInfo("fcmp",   4);
	cortexA9->addInstructionInfo("select", 4);
	cortexA9->addInstructionInfo("phi",    0);
	cortexA9->addInstructionInfo("call",  50); // NOTE: approximation

	cortexA9->addCommunicationInfo("Cortex-A9", DataDependency,  455);
	cortexA9->addCommunicationInfo("Cortex-A9", OrderDependency, 220);
	cortexA9->addCommunicationInfo("xc7z020-1", DataDependency,  fpgaClockMultiplier * 275);
	cortexA9->addCommunicationInfo("xc7z020-1", OrderDependency, fpgaClockMultiplier * 115);

	devices->insert(std::pair<std::string, DeviceInformation*>(cortexA9->getName(), cortexA9));

	// add timinigs for the FPGA
	DeviceInformation *fpga = new DeviceInformation("xc7z020-1", DeviceInformation::FPGA_RECONOS);
	fpga->addInstructionInfo("ret",           fpgaClockMultiplier * 0);
	fpga->addInstructionInfo("br",            fpgaClockMultiplier * 0);
	fpga->addInstructionInfo("fadd",          fpgaClockMultiplier * 13);
	fpga->addInstructionInfo("fsub",          fpgaClockMultiplier * 13);
	fpga->addInstructionInfo("fmul",          fpgaClockMultiplier * 10);
	fpga->addInstructionInfo("fdiv",          fpgaClockMultiplier * 58);
	fpga->addInstructionInfo("or",            fpgaClockMultiplier * 1);
	fpga->addInstructionInfo("alloca",        fpgaClockMultiplier * 0);
	fpga->addInstructionInfo("load",          fpgaClockMultiplier * 40);
	fpga->addInstructionInfo("store",         fpgaClockMultiplier * 40);
	fpga->addInstructionInfo("getelementptr", fpgaClockMultiplier * 0);
	fpga->addInstructionInfo("zext",          fpgaClockMultiplier * 0);
	fpga->addInstructionInfo("icmp",          fpgaClockMultiplier * 1);
	fpga->addInstructionInfo("fcmp",          fpgaClockMultiplier * 3);
	fpga->addInstructionInfo("select",        fpgaClockMultiplier * 0);
	fpga->addInstructionInfo("phi",           fpgaClockMultiplier * 0);
	fpga->addInstructionInfo("call",          fpgaClockMultiplier * (1<<20)); 
	fpga->addInstructionInfo("call#sin",      fpgaClockMultiplier * (7+54+8));
	fpga->addInstructionInfo("call#cos",      fpgaClockMultiplier * (7+54+8));

	fpga->addCommunicationInfo("Cortex-A9", DataDependency,  fpgaClockMultiplier * 315);
	fpga->addCommunicationInfo("Cortex-A9", OrderDependency, fpgaClockMultiplier * 240);
	fpga->addCommunicationInfo("xc7z020-1", DataDependency,  fpgaClockMultiplier * 1);
	fpga->addCommunicationInfo("xc7z020-1", OrderDependency, fpgaClockMultiplier * 1);

	devices->insert(std::pair<std::string, DeviceInformation*>(fpga->getName(), fpga));


	// calculate the device independent communication costs 
	// -> average value of all devices for the communication cost types
	std::vector<std::string> targets;
	for (std::map<std::string, DeviceInformation*>::iterator it = devices->begin(); it != devices->end(); ++it)
		targets.push_back(it->first);

	unsigned int dataDepCostSum = 0, orderDepCostSum = 0, count = 0;
	for (std::map<std::string, DeviceInformation*>::iterator it = devices->begin(); it != devices->end(); ++it) {
		for (std::vector<std::string>::iterator targetIt = targets.begin(); targetIt != targets.end(); ++targetIt) {
			dataDepCostSum += it->second->getCommunicationInfo(*targetIt)->getCommunicationCost(DataDependency);
			orderDepCostSum += it->second->getCommunicationInfo(*targetIt)->getCommunicationCost(OrderDependency);
			count++;
		}
	}

	deviceIndependentComCosts[DataDependency] = dataDepCostSum/count;
	deviceIndependentComCosts[OrderDependency] = orderDepCostSum/count;
}