Skip to content

Commit dd4b827

Browse files
committed
Version 1.5.1 - Add changes to support different cpuinfo outputs.
1 parent bbbc219 commit dd4b827

10 files changed

Lines changed: 678 additions & 15 deletions

File tree

src/test/java/vanilla/java/affinity/AffinityLockTest.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
public class AffinityLockTest {
3030
@Test
3131
public void dumpLocksI7() throws IOException {
32-
AffinityLock.cpuLayout(VanillaCpuLayout.fromCpuInfo("cpuinfo.i7"));
32+
AffinityLock.cpuLayout(VanillaCpuLayout.fromCpuInfo("i7.cpuinfo"));
3333
AffinityLock[] locks = {
3434
new AffinityLock(0, true, false),
3535
new AffinityLock(1, false, false),
@@ -66,7 +66,7 @@ public void dumpLocksI7() throws IOException {
6666

6767
@Test
6868
public void dumpLocksI3() throws IOException {
69-
AffinityLock.cpuLayout(VanillaCpuLayout.fromCpuInfo("cpuinfo.i3"));
69+
AffinityLock.cpuLayout(VanillaCpuLayout.fromCpuInfo("i3.cpuinfo"));
7070
AffinityLock[] locks = {
7171
new AffinityLock(0, true, false),
7272
new AffinityLock(1, false, true),
@@ -87,6 +87,25 @@ public void dumpLocksI3() throws IOException {
8787
locks[1].assignedThread.interrupt();
8888
}
8989

90+
91+
@Test
92+
public void dumpLocksCoreDuo() throws IOException {
93+
AffinityLock.cpuLayout(VanillaCpuLayout.fromCpuInfo("core.duo.cpuinfo"));
94+
AffinityLock[] locks = {
95+
new AffinityLock(0, true, false),
96+
new AffinityLock(1, false, true),
97+
};
98+
locks[1].assignedThread = new Thread(new InterrupedThread(), "engine");
99+
locks[1].assignedThread.start();
100+
101+
final String actual = AffinityLock.dumpLocks0(locks);
102+
assertEquals("0: General use CPU\n" +
103+
"1: Thread[engine,5,main] alive=true\n", actual);
104+
System.out.println(actual);
105+
106+
locks[1].assignedThread.interrupt();
107+
}
108+
90109
@Test
91110
public void assignReleaseThread() throws IOException {
92111
if (AffinityLock.RESERVED_AFFINITY == 0) {

src/test/java/vanilla/java/affinity/impl/VanillaCpuLayoutTest.java

Lines changed: 79 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,92 @@
2828
*/
2929
public class VanillaCpuLayoutTest {
3030

31-
public static final String EXPECTED = "0: CpuInfo{socketId=0, coreId=0, threadId=0}\n" +
32-
"1: CpuInfo{socketId=0, coreId=1, threadId=0}\n" +
33-
"2: CpuInfo{socketId=0, coreId=2, threadId=0}\n" +
34-
"3: CpuInfo{socketId=0, coreId=3, threadId=0}\n" +
35-
"4: CpuInfo{socketId=0, coreId=0, threadId=1}\n" +
36-
"5: CpuInfo{socketId=0, coreId=1, threadId=1}\n" +
37-
"6: CpuInfo{socketId=0, coreId=2, threadId=1}\n" +
38-
"7: CpuInfo{socketId=0, coreId=3, threadId=1}\n";
39-
4031
@Test
41-
public void testFromCpuInfo() throws IOException {
42-
final InputStream i7 = getClass().getClassLoader().getResourceAsStream("cpuinfo.i7");
32+
public void testFromCpuInfoI7() throws IOException {
33+
final InputStream i7 = getClass().getClassLoader().getResourceAsStream("i7.cpuinfo");
4334
VanillaCpuLayout vcl = VanillaCpuLayout.fromCpuInfo(i7);
44-
assertEquals(EXPECTED, vcl.toString());
35+
assertEquals("0: CpuInfo{socketId=0, coreId=0, threadId=0}\n" +
36+
"1: CpuInfo{socketId=0, coreId=1, threadId=0}\n" +
37+
"2: CpuInfo{socketId=0, coreId=2, threadId=0}\n" +
38+
"3: CpuInfo{socketId=0, coreId=3, threadId=0}\n" +
39+
"4: CpuInfo{socketId=0, coreId=0, threadId=1}\n" +
40+
"5: CpuInfo{socketId=0, coreId=1, threadId=1}\n" +
41+
"6: CpuInfo{socketId=0, coreId=2, threadId=1}\n" +
42+
"7: CpuInfo{socketId=0, coreId=3, threadId=1}\n", vcl.toString());
43+
}
44+
45+
46+
@Test
47+
public void testFromCpuInfoOthers() throws IOException {
48+
{
49+
final InputStream is = getClass().getClassLoader().getResourceAsStream("amd64.dual.core.cpuinfo");
50+
VanillaCpuLayout vcl = VanillaCpuLayout.fromCpuInfo(is);
51+
assertEquals("0: CpuInfo{socketId=0, coreId=0, threadId=0}\n" +
52+
"1: CpuInfo{socketId=0, coreId=1, threadId=0}\n", vcl.toString());
53+
}
54+
{
55+
final InputStream is = getClass().getClassLoader().getResourceAsStream("core.duo.cpuinfo");
56+
VanillaCpuLayout vcl = VanillaCpuLayout.fromCpuInfo(is);
57+
assertEquals("0: CpuInfo{socketId=0, coreId=0, threadId=0}\n" +
58+
"1: CpuInfo{socketId=0, coreId=1, threadId=0}\n", vcl.toString());
59+
}
60+
{
61+
final InputStream is = getClass().getClassLoader().getResourceAsStream("amd64.quad.core.cpuinfo");
62+
VanillaCpuLayout vcl = VanillaCpuLayout.fromCpuInfo(is);
63+
assertEquals("0: CpuInfo{socketId=0, coreId=0, threadId=0}\n" +
64+
"1: CpuInfo{socketId=0, coreId=1, threadId=0}\n" +
65+
"2: CpuInfo{socketId=0, coreId=2, threadId=0}\n" +
66+
"3: CpuInfo{socketId=0, coreId=3, threadId=0}\n", vcl.toString());
67+
}
68+
{
69+
final InputStream is = getClass().getClassLoader().getResourceAsStream("dual.xeon.cpuinfo");
70+
VanillaCpuLayout vcl = VanillaCpuLayout.fromCpuInfo(is);
71+
assertEquals("0: CpuInfo{socketId=0, coreId=0, threadId=0}\n" +
72+
"1: CpuInfo{socketId=0, coreId=0, threadId=1}\n" +
73+
"2: CpuInfo{socketId=3, coreId=3, threadId=0}\n" +
74+
"3: CpuInfo{socketId=3, coreId=3, threadId=1}\n", vcl.toString());
75+
}
76+
{
77+
final InputStream is = getClass().getClassLoader().getResourceAsStream("i3.cpuinfo");
78+
VanillaCpuLayout vcl = VanillaCpuLayout.fromCpuInfo(is);
79+
assertEquals("0: CpuInfo{socketId=0, coreId=0, threadId=0}\n" +
80+
"1: CpuInfo{socketId=0, coreId=2, threadId=0}\n" +
81+
"2: CpuInfo{socketId=0, coreId=0, threadId=1}\n" +
82+
"3: CpuInfo{socketId=0, coreId=2, threadId=1}\n", vcl.toString());
83+
}
84+
{
85+
final InputStream is = getClass().getClassLoader().getResourceAsStream("q6600.noht.cpuinfo");
86+
VanillaCpuLayout vcl = VanillaCpuLayout.fromCpuInfo(is);
87+
assertEquals("0: CpuInfo{socketId=0, coreId=0, threadId=0}\n" +
88+
"1: CpuInfo{socketId=0, coreId=2, threadId=0}\n" +
89+
"2: CpuInfo{socketId=0, coreId=1, threadId=0}\n" +
90+
"3: CpuInfo{socketId=0, coreId=3, threadId=0}\n", vcl.toString());
91+
}
92+
{
93+
final InputStream is = getClass().getClassLoader().getResourceAsStream("dual.E5405.cpuinfo");
94+
VanillaCpuLayout vcl = VanillaCpuLayout.fromCpuInfo(is);
95+
assertEquals("0: CpuInfo{socketId=0, coreId=0, threadId=0}\n" +
96+
"1: CpuInfo{socketId=0, coreId=1, threadId=0}\n" +
97+
"2: CpuInfo{socketId=0, coreId=2, threadId=0}\n" +
98+
"3: CpuInfo{socketId=0, coreId=3, threadId=0}\n" +
99+
"4: CpuInfo{socketId=1, coreId=4, threadId=0}\n" +
100+
"5: CpuInfo{socketId=1, coreId=5, threadId=0}\n" +
101+
"6: CpuInfo{socketId=1, coreId=6, threadId=0}\n" +
102+
"7: CpuInfo{socketId=1, coreId=7, threadId=0}\n", vcl.toString());
103+
}
45104
}
46105

47106
@Test
48107
public void testFromProperties() throws IOException {
49108
final InputStream i7 = getClass().getClassLoader().getResourceAsStream("i7.properties");
50109
VanillaCpuLayout vcl = VanillaCpuLayout.fromProperties(i7);
51-
assertEquals(EXPECTED, vcl.toString());
110+
assertEquals("0: CpuInfo{socketId=0, coreId=0, threadId=0}\n" +
111+
"1: CpuInfo{socketId=0, coreId=1, threadId=0}\n" +
112+
"2: CpuInfo{socketId=0, coreId=2, threadId=0}\n" +
113+
"3: CpuInfo{socketId=0, coreId=3, threadId=0}\n" +
114+
"4: CpuInfo{socketId=0, coreId=0, threadId=1}\n" +
115+
"5: CpuInfo{socketId=0, coreId=1, threadId=1}\n" +
116+
"6: CpuInfo{socketId=0, coreId=2, threadId=1}\n" +
117+
"7: CpuInfo{socketId=0, coreId=3, threadId=1}\n", vcl.toString());
52118
}
53119
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
processor : 0
2+
vendor_id : AuthenticAMD
3+
cpu family : 15
4+
model : 107
5+
model name : Athlon 64 Dual Core 5000+
6+
stepping : 2
7+
cpu MHz : 2599.998
8+
cache size : 512 KB
9+
physical id : 0
10+
siblings : 2
11+
core id : 0
12+
cpu cores : 2
13+
fpu : yes
14+
fpu_exception : yes
15+
cpuid level : 1
16+
wp : yes
17+
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3dnowprefetch
18+
bogomips : 5204.18
19+
TLB size : 1024 4K pages
20+
clflush size : 64
21+
cache_alignment : 64
22+
address sizes : 40 bits physical, 48 bits virtual
23+
power management: ts fid vid ttp tm stc 100mhzsteps
24+
25+
processor : 1
26+
vendor_id : AuthenticAMD
27+
cpu family : 15
28+
model : 107
29+
model name : Athlon 64 Dual Core 5000+
30+
stepping : 2
31+
cpu MHz : 2599.998
32+
cache size : 512 KB
33+
physical id : 0
34+
siblings : 2
35+
core id : 1
36+
cpu cores : 2
37+
fpu : yes
38+
fpu_exception : yes
39+
cpuid level : 1
40+
wp : yes
41+
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3dnowprefetch
42+
bogomips : 5200.04
43+
TLB size : 1024 4K pages
44+
clflush size : 64
45+
cache_alignment : 64
46+
address sizes : 40 bits physical, 48 bits virtual
47+
power management: ts fid vid ttp tm stc 100mhzsteps
48+
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
processor : 0
2+
vendor_id : AuthenticAMD
3+
cpu family : 16
4+
model : 4
5+
model name : Quad-Core AMD Opteron(tm) Processor 2374 HE
6+
stepping : 2
7+
cpu MHz : 2194.255
8+
cache size : 512 KB
9+
physical id : 0
10+
siblings : 4
11+
core id : 0
12+
cpu cores : 4
13+
apicid : 0
14+
initial apicid : 0
15+
fpu : yes
16+
fpu_exception : yes
17+
cpuid level : 5
18+
wp : yes
19+
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt
20+
bogomips : 4388.50
21+
TLB size : 1024 4K pages
22+
clflush size : 64
23+
cache_alignment : 64
24+
address sizes : 48 bits physical, 48 bits virtual
25+
power management: ts ttp tm stc 100mhzsteps hwpstate
26+
27+
processor : 1
28+
vendor_id : AuthenticAMD
29+
cpu family : 16
30+
model : 4
31+
model name : Quad-Core AMD Opteron(tm) Processor 2374 HE
32+
stepping : 2
33+
cpu MHz : 2194.255
34+
cache size : 512 KB
35+
physical id : 0
36+
siblings : 4
37+
core id : 1
38+
cpu cores : 4
39+
apicid : 1
40+
initial apicid : 1
41+
fpu : yes
42+
fpu_exception : yes
43+
cpuid level : 5
44+
wp : yes
45+
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt
46+
bogomips : 4389.05
47+
TLB size : 1024 4K pages
48+
clflush size : 64
49+
cache_alignment : 64
50+
address sizes : 48 bits physical, 48 bits virtual
51+
power management: ts ttp tm stc 100mhzsteps hwpstate
52+
53+
processor : 2
54+
vendor_id : AuthenticAMD
55+
cpu family : 16
56+
model : 4
57+
model name : Quad-Core AMD Opteron(tm) Processor 2374 HE
58+
stepping : 2
59+
cpu MHz : 2194.255
60+
cache size : 512 KB
61+
physical id : 0
62+
siblings : 4
63+
core id : 2
64+
cpu cores : 4
65+
apicid : 2
66+
initial apicid : 2
67+
fpu : yes
68+
fpu_exception : yes
69+
cpuid level : 5
70+
wp : yes
71+
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt
72+
bogomips : 4389.05
73+
TLB size : 1024 4K pages
74+
clflush size : 64
75+
cache_alignment : 64
76+
address sizes : 48 bits physical, 48 bits virtual
77+
power management: ts ttp tm stc 100mhzsteps hwpstate
78+
79+
processor : 3
80+
vendor_id : AuthenticAMD
81+
cpu family : 16
82+
model : 4
83+
model name : Quad-Core AMD Opteron(tm) Processor 2374 HE
84+
stepping : 2
85+
cpu MHz : 2194.255
86+
cache size : 512 KB
87+
physical id : 0
88+
siblings : 4
89+
core id : 3
90+
cpu cores : 4
91+
apicid : 3
92+
initial apicid : 3
93+
fpu : yes
94+
fpu_exception : yes
95+
cpuid level : 5
96+
wp : yes
97+
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt
98+
bogomips : 4389.05
99+
TLB size : 1024 4K pages
100+
clflush size : 64
101+
cache_alignment : 64
102+
address sizes : 48 bits physical, 48 bits virtual
103+
power management: ts ttp tm stc 100mhzsteps hwpstate
104+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
processor : 0
2+
vendor_id : GenuineIntel
3+
cpu family : 6
4+
model : 23
5+
model name : Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz
6+
stepping : 6
7+
cpu MHz : 800.000
8+
cache size : 3072 KB
9+
physical id : 0
10+
siblings : 2
11+
core id : 0
12+
cpu cores : 2
13+
apicid : 0
14+
initial apicid : 0
15+
fpu : yes
16+
fpu_exception : yes
17+
cpuid level : 10
18+
wp : yes
19+
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm ida
20+
bogomips : 4787.93
21+
clflush size : 64
22+
cache_alignment : 64
23+
address sizes : 36 bits physical, 48 bits virtual
24+
power management:
25+
26+
processor : 1
27+
vendor_id : GenuineIntel
28+
cpu family : 6
29+
model : 23
30+
model name : Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz
31+
stepping : 6
32+
cpu MHz : 800.000
33+
cache size : 3072 KB
34+
physical id : 0
35+
siblings : 2
36+
core id : 1
37+
cpu cores : 2
38+
apicid : 1
39+
initial apicid : 1
40+
fpu : yes
41+
fpu_exception : yes
42+
cpuid level : 10
43+
wp : yes
44+
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 lahf_lm ida
45+
bogomips : 4787.96
46+
clflush size : 64
47+
cache_alignment : 64
48+
address sizes : 36 bits physical, 48 bits virtual
49+
power management:
50+

0 commit comments

Comments
 (0)