Example #1
0
    def build_capability_array(self):
        "Build capabilites array (ctypes array of CPqosCapability objects)."

        capabilities = []

        if self.mon:
            mon_u = CPqosCapabilityUnion(mon=ctypes.pointer(self.mon))
            mon_cap = CPqosCapability(type=CPqosCapability.PQOS_CAP_TYPE_MON,
                                      u=mon_u)
            capabilities.append(mon_cap)

        if self.l3ca:
            l3ca_u = CPqosCapabilityUnion(l3ca=ctypes.pointer(self.l3ca))
            l3ca_cap = CPqosCapability(type=CPqosCapability.PQOS_CAP_TYPE_L3CA,
                                       u=l3ca_u)
            capabilities.append(l3ca_cap)

        if self.l2ca:
            l2ca_u = CPqosCapabilityUnion(l2ca=ctypes.pointer(self.l2ca))
            l2ca_cap = CPqosCapability(type=CPqosCapability.PQOS_CAP_TYPE_L2CA,
                                       u=l2ca_u)
            capabilities.append(l2ca_cap)

        if self.mba:
            mba_u = CPqosCapabilityUnion(mba=ctypes.pointer(self.mba))
            mba_cap = CPqosCapability(type=CPqosCapability.PQOS_CAP_TYPE_MBA,
                                      u=mba_u)
            capabilities.append(mba_cap)

        return ctypes_build_array(capabilities)
Example #2
0
    def test_get_type_mba(self, lib):
        "Tests get_type() method for MBA."

        mba = CPqosCapabilityMBA(mem_size=ctypes.sizeof(CPqosCapabilityMBA),
                                 num_classes=2,
                                 throttle_max=95,
                                 throttle_step=15,
                                 is_linear=1,
                                 ctrl=1,
                                 ctrl_on=0)
        mba_u = CPqosCapabilityUnion(mba=ctypes.pointer(mba))
        mba_cap = CPqosCapability(type=CPqosCapability.PQOS_CAP_TYPE_MBA,
                                  u=mba_u)

        _prepare_get_type(lib, mba_cap)

        pqos_cap = PqosCap()
        mba_capability = pqos_cap.get_type('mba')

        self.assertEqual(mba_capability.num_classes, 2)
        self.assertEqual(mba_capability.throttle_max, 95)
        self.assertEqual(mba_capability.throttle_step, 15)
        self.assertEqual(mba_capability.is_linear, True)
        self.assertEqual(mba_capability.ctrl, True)
        self.assertEqual(mba_capability.ctrl_on, False)
Example #3
0
    def test_get_type_l3ca(self, lib):
        "Tests get_type() method for L3 cache allocation."
        l3ca = CPqosCapabilityL3(mem_size=ctypes.sizeof(CPqosCapabilityL3),
                                 num_classes=2, num_ways=8, way_size=1024*1024,
                                 way_contention=0, cdp=1, cdp_on=0)
        l3ca_u = CPqosCapabilityUnion(l3ca=ctypes.pointer(l3ca))
        l3ca_cap = CPqosCapability(type=CPqosCapability.PQOS_CAP_TYPE_L3CA,
                                   u=l3ca_u)

        _prepare_get_type(lib, l3ca_cap)

        pqos_cap = PqosCap()
        l3ca_capability = pqos_cap.get_type('l3ca')

        self.assertEqual(l3ca_capability.num_classes, 2)
        self.assertEqual(l3ca_capability.num_ways, 8)
        self.assertEqual(l3ca_capability.way_size, 1024*1024)
        self.assertEqual(l3ca_capability.way_contention, 0)
        self.assertEqual(l3ca_capability.cdp, True)
        self.assertEqual(l3ca_capability.cdp_on, False)
Example #4
0
    def test_get_type_l2ca(self, lib):
        "Tests get_type() method for L2 cache allocation."
        l2ca = CPqosCapabilityL2(mem_size=ctypes.sizeof(CPqosCapabilityL2),
                                 num_classes=4, num_ways=16,
                                 way_size=2*1024*1024, way_contention=0, cdp=1,
                                 cdp_on=0)
        l2ca_u = CPqosCapabilityUnion(l2ca=ctypes.pointer(l2ca))
        l2ca_cap = CPqosCapability(type=CPqosCapability.PQOS_CAP_TYPE_L2CA,
                                   u=l2ca_u)

        _prepare_get_type(lib, l2ca_cap)

        pqos_cap = PqosCap()
        l2ca_capability = pqos_cap.get_type('l2ca')

        self.assertEqual(l2ca_capability.num_classes, 4)
        self.assertEqual(l2ca_capability.num_ways, 16)
        self.assertEqual(l2ca_capability.way_size, 2*1024*1024)
        self.assertEqual(l2ca_capability.way_contention, 0)
        self.assertEqual(l2ca_capability.cdp, True)
        self.assertEqual(l2ca_capability.cdp_on, False)