X Tutup
Skip to content

Commit 56cf958

Browse files
committed
avoid nope in CLDevice.getPartitionAffinityDomain()
1 parent f9b1e5e commit 56cf958

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
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
@@ -790,7 +790,7 @@ public long getReferenceCount() {
790790
*/
791791
public AffinityDomain getPartitionAffinityDomain() {
792792
Pointer<?> memory = infos.getMemory(getEntity(), CL_DEVICE_PARTITION_TYPE);
793-
long type = memory.getSizeT();
793+
long type = memory == null ? 0 : memory.getSizeT();
794794
if (type != CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN) {
795795
return null;
796796
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,13 @@ public void testSplitByCounts() {
8888
public void testSplitByAffinity() {
8989
if (!device.getPartitionProperties().contains(CLDevice.PartitionType.ByAffinityDomain)) return;
9090

91-
CLDevice[] subDevices = device.createSubDevicesByAffinity(CLDevice.AffinityDomain.NextPartitionable);
92-
assertTrue(subDevices.length > 1);
93-
for (CLDevice subDevice : subDevices) {
94-
checkParent(device, subDevice);
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+
}
9598
}
9699
}
97100

0 commit comments

Comments
 (0)
X Tutup