Skip to content

Commit 42ec70c

Browse files
committed
Split device-splitting tests
1 parent 76c864b commit 42ec70c

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

Core/src/main/velocity/com/nativelibs4java/opencl/CLDevice.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ public CLDevice[] createSubDevicesByCounts(long... computeUnitsForEachSubDevice)
12021202
*/
12031203
public CLDevice[] createSubDevicesByAffinity(AffinityDomain affinityDomain) {
12041204
return createSubDevices(pointerToSizeTs(
1205-
CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, affinityDomain.value(), 0, 0
1205+
CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, affinityDomain.value(), 0
12061206
));
12071207
}
12081208

Core/src/test/java/com/nativelibs4java/opencl/DeviceTest.java

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,49 @@ public void testSplitByCounts() {
8484
assertArrayEquals(counts, actualCounts);
8585
}
8686

87-
@Test
88-
public void testSplitByAffinity() {
89-
if (!device.getPartitionProperties().contains(CLDevice.PartitionType.ByAffinityDomain)) return;
90-
91-
for (CLDevice.AffinityDomain domain : device.getPartitionAffinityDomains()) {
92-
CLDevice[] subDevices = device.createSubDevicesByAffinity(domain);
93-
assertTrue(subDevices.length > 1);
94-
for (CLDevice subDevice : subDevices) {
95-
checkParent(device, subDevice);
96-
assertEquals(domain, subDevice.getPartitionAffinityDomain());
97-
}
87+
public void checkSplitByAffinity(CLDevice.AffinityDomain domain) {
88+
if (!device.getPartitionProperties().contains(CLDevice.PartitionType.ByAffinityDomain)) {
89+
System.out.println("Split by affinity is not supported by device " + device);
90+
return;
91+
}
92+
if (!device.getPartitionAffinityDomains().contains(domain)) {
93+
System.out.println("Affinity domain " + domain + " not supported by device " + device);
94+
return;
95+
}
96+
97+
CLDevice[] subDevices = device.createSubDevicesByAffinity(domain);
98+
assertTrue(subDevices.length > 1);
99+
for (CLDevice subDevice : subDevices) {
100+
checkParent(device, subDevice);
101+
assertEquals(domain, subDevice.getPartitionAffinityDomain());
98102
}
99103
}
100104

105+
@Test
106+
public void testSplitByAffinity_NUMA() {
107+
checkSplitByAffinity(CLDevice.AffinityDomain.NUMA);
108+
}
109+
@Test
110+
public void testSplitByAffinity_L4Cache() {
111+
checkSplitByAffinity(CLDevice.AffinityDomain.L4Cache);
112+
}
113+
@Test
114+
public void testSplitByAffinity_L3Cache() {
115+
checkSplitByAffinity(CLDevice.AffinityDomain.L3Cache);
116+
}
117+
@Test
118+
public void testSplitByAffinity_L2Cache() {
119+
checkSplitByAffinity(CLDevice.AffinityDomain.L2Cache);
120+
}
121+
@Test
122+
public void testSplitByAffinity_L1Cache() {
123+
checkSplitByAffinity(CLDevice.AffinityDomain.L1Cache);
124+
}
125+
@Test
126+
public void testSplitByAffinity_NextPartitionable() {
127+
checkSplitByAffinity(CLDevice.AffinityDomain.NextPartitionable);
128+
}
129+
101130
private void checkParent(CLDevice parent, CLDevice child) {
102131
assertSame(parent, child.getParent());
103132
// Force a get info CL_DEVICE_PARENT_DEVICE.

0 commit comments

Comments
 (0)