Search in sources :

Example 1 with OpUnitMask

use of org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask in project linuxtools by eclipse.

the class TestInfoParse method testParse.

@Test
public void testParse() {
    // $NON-NLS-1$
    assertEquals("/var/lib/oprofile/samples/", info.getDefault(OpInfo.DEFAULT_SAMPLE_DIR));
    // $NON-NLS-1$
    assertEquals("/var/lib/oprofile/lock", info.getDefault(OpInfo.DEFAULT_LOCK_FILE));
    // $NON-NLS-1$
    assertEquals("/var/lib/oprofile/samples/oprofiled.log", info.getDefault(OpInfo.DEFAULT_LOG_FILE));
    // $NON-NLS-1$
    assertEquals("/var/lib/oprofile/complete_dump", info.getDefault(OpInfo.DEFAULT_DUMP_STATUS));
    assertTrue(info.getTimerMode());
    assertEquals(800, info.getCPUSpeed(), 0);
    assertEquals(2, info.getNrCounters());
    OpEvent[] ctr0_events = info.getEvents(0), ctr1_events = info.getEvents(1);
    assertEquals(3, ctr0_events.length);
    assertEquals(3, ctr1_events.length);
    OpEvent ctr0_e1 = ctr0_events[0], ctr0_e2 = ctr0_events[1], ctr0_e3 = ctr0_events[2], ctr1_e1 = ctr1_events[0], ctr1_e2 = ctr1_events[1], ctr1_e3 = ctr1_events[2];
    // events must be ordered alphabetically
    assertEquals(6000, ctr0_e1.getMinCount());
    // $NON-NLS-1$
    assertEquals("CPU_CLK_UNHALTED", ctr0_e1.getText());
    // $NON-NLS-1$
    assertEquals("Clock cycles when not halted", ctr0_e1.getTextDescription());
    assertEquals(500, ctr0_e2.getMinCount());
    // $NON-NLS-1$
    assertEquals("DTLB_MISSES", ctr0_e2.getText());
    // $NON-NLS-1$
    assertEquals("DTLB miss events", ctr0_e2.getTextDescription());
    assertEquals(6000, ctr0_e3.getMinCount());
    // $NON-NLS-1$
    assertEquals("INST_RETIRED_ANY_P", ctr0_e3.getText());
    // $NON-NLS-1$
    assertEquals("number of instructions retired", ctr0_e3.getTextDescription());
    assertEquals(500, ctr1_e1.getMinCount());
    // $NON-NLS-1$
    assertEquals("EIST_TRANS_ALL", ctr1_e1.getText());
    // $NON-NLS-1$
    assertEquals("Intel(tm) Enhanced SpeedStep(r) Technology transitions", ctr1_e1.getTextDescription());
    assertEquals(500, ctr1_e2.getMinCount());
    // $NON-NLS-1$
    assertEquals("L2_LINES_OUT", ctr1_e2.getText());
    // $NON-NLS-1$
    assertEquals("number of recovered lines from L2", ctr1_e2.getTextDescription());
    assertEquals(500, ctr1_e3.getMinCount());
    // $NON-NLS-1$
    assertEquals("L2_M_LINES_IN", ctr1_e3.getText());
    // $NON-NLS-1$
    assertEquals("number of modified lines allocated in L2", ctr1_e3.getTextDescription());
    OpUnitMask ctr0_e1_mask = ctr0_e1.getUnitMask(), ctr0_e2_mask = ctr0_e2.getUnitMask(), ctr0_e3_mask = ctr0_e3.getUnitMask(), ctr1_e1_mask = ctr1_e1.getUnitMask(), ctr1_e2_mask = ctr1_e2.getUnitMask(), ctr1_e3_mask = ctr1_e3.getUnitMask();
    assertEquals(0, ctr0_e1_mask.getMaskValue());
    assertEquals(OpUnitMask.EXCLUSIVE, ctr0_e1_mask.getType());
    assertEquals(3, ctr0_e1_mask.getNumMasks());
    assertEquals(0, ctr0_e1_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("Unhalted core cycles", ctr0_e1_mask.getText(0));
    assertEquals(1, ctr0_e1_mask.getMaskFromIndex(1));
    // $NON-NLS-1$
    assertEquals("Unhalted bus cycles", ctr0_e1_mask.getText(1));
    assertEquals(2, ctr0_e1_mask.getMaskFromIndex(2));
    // $NON-NLS-1$
    assertEquals("Unhalted bus cycles of this core while the other core is halted", ctr0_e1_mask.getText(2));
    assertEquals(15, ctr0_e2_mask.getMaskValue());
    assertEquals(OpUnitMask.BITMASK, ctr0_e2_mask.getType());
    assertEquals(4, ctr0_e2_mask.getNumMasks());
    assertEquals(1, ctr0_e2_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("ANY\tMemory accesses that missed the DTLB.", ctr0_e2_mask.getText(0));
    assertEquals(2, ctr0_e2_mask.getMaskFromIndex(1));
    // $NON-NLS-1$
    assertEquals("MISS_LD\tDTLB misses due to load operations.", ctr0_e2_mask.getText(1));
    assertEquals(4, ctr0_e2_mask.getMaskFromIndex(2));
    // $NON-NLS-1$
    assertEquals("L0_MISS_LD L0 DTLB misses due to load operations.", ctr0_e2_mask.getText(2));
    assertEquals(8, ctr0_e2_mask.getMaskFromIndex(3));
    // $NON-NLS-1$
    assertEquals("MISS_ST\tTLB misses due to store operations.", ctr0_e2_mask.getText(3));
    assertEquals(0, ctr0_e3_mask.getMaskValue());
    assertEquals(OpUnitMask.MANDATORY, ctr0_e3_mask.getType());
    assertEquals(1, ctr0_e3_mask.getNumMasks());
    assertEquals(0, ctr0_e3_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("No unit mask", ctr0_e3_mask.getText(0));
    assertEquals(1, ctr1_e1_mask.getMaskValue());
    assertEquals(OpUnitMask.INVALID, ctr1_e1_mask.getType());
    assertEquals(1, ctr1_e1_mask.getNumMasks());
    // -1 because of invalid mask type
    assertEquals(-1, ctr1_e1_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("No unit mask", ctr1_e1_mask.getText(0));
    assertEquals(112, ctr1_e2_mask.getMaskValue());
    assertEquals(OpUnitMask.BITMASK, ctr1_e2_mask.getType());
    assertEquals(5, ctr1_e2_mask.getNumMasks());
    assertEquals(192, ctr1_e2_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("core: all cores", ctr1_e2_mask.getText(0));
    assertEquals(64, ctr1_e2_mask.getMaskFromIndex(1));
    // $NON-NLS-1$
    assertEquals("core: this core", ctr1_e2_mask.getText(1));
    assertEquals(48, ctr1_e2_mask.getMaskFromIndex(2));
    // $NON-NLS-1$
    assertEquals("prefetch: all inclusive", ctr1_e2_mask.getText(2));
    assertEquals(16, ctr1_e2_mask.getMaskFromIndex(3));
    // $NON-NLS-1$
    assertEquals("prefetch: Hardware prefetch only", ctr1_e2_mask.getText(3));
    assertEquals(0, ctr1_e2_mask.getMaskFromIndex(4));
    // $NON-NLS-1$
    assertEquals("prefetch: exclude hardware prefetch", ctr1_e2_mask.getText(4));
    assertEquals(64, ctr1_e3_mask.getMaskValue());
    assertEquals(OpUnitMask.EXCLUSIVE, ctr1_e3_mask.getType());
    assertEquals(2, ctr1_e3_mask.getNumMasks());
    assertEquals(192, ctr1_e3_mask.getMaskFromIndex(0));
    // $NON-NLS-1$
    assertEquals("All cores", ctr1_e3_mask.getText(0));
    assertEquals(64, ctr1_e3_mask.getMaskFromIndex(1));
    // $NON-NLS-1$
    assertEquals("This core", ctr1_e3_mask.getText(1));
    assertNull(ctr0_e1_mask.getText(-1));
    assertEquals(0, info_0ctr.getNrCounters());
}
Also used : OpEvent(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent) OpUnitMask(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask) Test(org.junit.Test)

Example 2 with OpUnitMask

use of org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask in project linuxtools by eclipse.

the class TestInfoParse method testUnitMask.

@Test
public void testUnitMask() {
    // test types of masks setting/unsetting
    OpUnitMask mask_bit1 = info.getEvents(0)[1].getUnitMask(), // mask_bit2 = info.getEvents(1)[1].getUnitMask(),
    mask_exl = info.getEvents(0)[0].getUnitMask(), mask_mand = info.getEvents(0)[2].getUnitMask(), mask_invalid = info.getEvents(1)[0].getUnitMask();
    // bitmask 1 test -- bitmasks all mutually exclusive
    assertEquals(15, mask_bit1.getMaskValue());
    mask_bit1.setMaskValue(0);
    mask_bit1.setMaskFromIndex(0);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(3));
    assertEquals(1, mask_bit1.getMaskValue());
    mask_bit1.setMaskFromIndex(1);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(3));
    assertEquals(3, mask_bit1.getMaskValue());
    mask_bit1.setMaskFromIndex(2);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(3));
    assertEquals(7, mask_bit1.getMaskValue());
    mask_bit1.setMaskFromIndex(3);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(3));
    assertEquals(15, mask_bit1.getMaskValue());
    mask_bit1.unSetMaskFromIndex(1);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(3));
    mask_bit1.unSetMaskFromIndex(2);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(3));
    mask_bit1.unSetMaskFromIndex(3);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(3));
    mask_bit1.setMaskFromIndex(2);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(3));
    assertEquals(5, mask_bit1.getMaskValue());
    mask_bit1.unSetMaskFromIndex(1);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(3));
    mask_bit1.unSetMaskFromIndex(3);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(3));
    assertEquals(5, mask_bit1.getMaskValue());
    mask_bit1.setMaskFromIndex(2);
    assertEquals(true, mask_bit1.isMaskSetFromIndex(0));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(1));
    assertEquals(true, mask_bit1.isMaskSetFromIndex(2));
    assertEquals(false, mask_bit1.isMaskSetFromIndex(3));
    assertEquals(5, mask_bit1.getMaskValue());
    mask_bit1.setMaskValue(OpUnitMask.SET_DEFAULT_MASK);
    assertEquals(15, mask_bit1.getMaskValue());
    // bitmask 2 test -- bitmasks overlap
    /* bug related to overlapping bitmasks eclipse bz 261917 */
    // assertEquals(112, mask_bit2.getMaskValue());
    // mask_bit2.setMaskValue(0);
    // mask_bit2.setMaskFromIndex(0);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(4));
    // //        assertEquals(192, mask_bit2.getMaskValue());
    // 
    // mask_bit2.setMaskFromIndex(1);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(4));
    // //        assertEquals(3, mask_bit2.getMaskValue());
    // 
    // mask_bit2.setMaskFromIndex(2);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(4));
    // //        assertEquals(7, mask_bit2.getMaskValue());
    // 
    // mask_bit2.setMaskFromIndex(3);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(4));
    // //        assertEquals(15, mask_bit2.getMaskValue());
    // 
    // mask_bit2.setMaskFromIndex(4);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(4));
    // //        assertEquals(15, mask_bit2.getMaskValue());
    // 
    // mask_bit2.unSetMaskFromIndex(1);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(4));
    // 
    // mask_bit2.unSetMaskFromIndex(2);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(4));
    // 
    // mask_bit2.unSetMaskFromIndex(3);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(4));
    // 
    // mask_bit2.unSetMaskFromIndex(4);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(4));
    // 
    // mask_bit2.setMaskFromIndex(2);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(4));
    // //        assertEquals(5, mask_bit2.getMaskValue());
    // 
    // mask_bit2.unSetMaskFromIndex(1);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(4));
    // 
    // mask_bit2.unSetMaskFromIndex(3);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(4));
    // //        assertEquals(5, mask_bit2.getMaskValue());
    // 
    // mask_bit2.setMaskFromIndex(2);
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(0));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(1));
    // assertEquals(true, mask_bit2.isMaskSetFromIndex(2));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(3));
    // assertEquals(false, mask_bit2.isMaskSetFromIndex(4));
    // //        assertEquals(5, mask_bit2.getMaskValue());
    // 
    // mask_bit2.setMaskValue(OpUnitMask.SET_DEFAULT_MASK);
    // assertEquals(112, mask_bit2.getMaskValue());
    // exclusive test
    assertEquals(0, mask_exl.getMaskValue());
    assertEquals(true, mask_exl.isMaskSetFromIndex(0));
    assertEquals(false, mask_exl.isMaskSetFromIndex(1));
    assertEquals(false, mask_exl.isMaskSetFromIndex(2));
    mask_exl.setMaskFromIndex(1);
    assertEquals(false, mask_exl.isMaskSetFromIndex(0));
    assertEquals(1, mask_exl.getMaskValue());
    mask_exl.unSetMaskFromIndex(1);
    assertEquals(1, mask_exl.getMaskValue());
    mask_exl.setMaskFromIndex(2);
    assertEquals(2, mask_exl.getMaskValue());
    mask_exl.setDefaultMaskValue();
    assertEquals(0, mask_exl.getMaskValue());
    // mandatory test
    assertEquals(0, mask_mand.getMaskValue());
    assertEquals(false, mask_mand.isMaskSetFromIndex(0));
    mask_mand.setMaskFromIndex(0);
    assertEquals(0, mask_mand.getMaskValue());
    mask_mand.unSetMaskFromIndex(0);
    assertEquals(0, mask_mand.getMaskValue());
    mask_mand.setMaskValue(10);
    mask_mand.setDefaultMaskValue();
    assertEquals(0, mask_mand.getMaskValue());
    // invalid test
    assertEquals(1, mask_invalid.getMaskValue());
    assertEquals(false, mask_invalid.isMaskSetFromIndex(0));
    mask_invalid.setMaskFromIndex(0);
    assertEquals(1, mask_invalid.getMaskValue());
    mask_invalid.unSetMaskFromIndex(0);
    assertEquals(1, mask_invalid.getMaskValue());
    mask_invalid.setMaskValue(0);
    mask_invalid.setDefaultMaskValue();
    assertEquals(1, mask_invalid.getMaskValue());
}
Also used : OpUnitMask(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask) Test(org.junit.Test)

Example 3 with OpUnitMask

use of org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask in project linuxtools by eclipse.

the class OprofileTestingEventConfigTab method getOprofileCounter.

@Override
public OprofileCounter getOprofileCounter(int i) {
    // mock mask info
    MaskInfo maskInfo = new MaskInfo();
    // $NON-NLS-1$
    maskInfo.description = "mock mask info";
    maskInfo.value = 0;
    MaskInfo[] maskInfoDescriptions = { maskInfo };
    // mock mask
    OpUnitMask mask = new OpUnitMask();
    mask.setDefault(0);
    mask.setMaskDescriptions(maskInfoDescriptions);
    mask.setType(0);
    mask.setMaskFromIndex(0);
    mask.setMaskValue(0);
    // mock events
    OpEvent event = new OpEvent();
    event.setMinCount(1);
    // $NON-NLS-1$
    event.setText("mock-event");
    // $NON-NLS-1$
    event.setTextDescription("Mock Event");
    event.setUnitMask(mask);
    OpEvent[] events = { event };
    // mock counter
    OprofileCounter ctr = new OprofileCounter(i, events);
    ctr.setCount(1);
    ctr.setEvents(new OpEvent[] { event });
    return ctr;
}
Also used : MaskInfo(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask.MaskInfo) OprofileCounter(org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileCounter) OpEvent(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent) OpUnitMask(org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask)

Aggregations

OpUnitMask (org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask)3 OpEvent (org.eclipse.linuxtools.internal.oprofile.core.daemon.OpEvent)2 Test (org.junit.Test)2 MaskInfo (org.eclipse.linuxtools.internal.oprofile.core.daemon.OpUnitMask.MaskInfo)1 OprofileCounter (org.eclipse.linuxtools.internal.oprofile.launch.configuration.OprofileCounter)1