Edit: Problem solved! rzymek's answer was helpful.
Question: For JOCL, how can I exclude some cores of CPU from the opencl calculations with device fission?(Java port of cl_device_partition_property seems to be corrupt for 0.1.9 version)
Edit: I found this:
clCreateSubDevices(devices[0][1],core , 1, cpuCores, coreIDs);
but java/jocl doesnt accept this:
cl_device_partition_property core=CL.CL_DEVICE_PARTITION_BY_COUNTS;
error is:
Type mismatch: cannot convert from int to cl_device_partition_property
Just tried null initialization then using variables own methods to set the property:
cl_device_partition_property core = null;
core.addProperty(CL_DEVICE_PARTITION_BY_COUNTS, platforms[0]);
Edit: now it gives
java.lang.NullPointerException,
error.
IT needs to be unsigned int (not cl_device_partition_property) but java doesnt have it.
New try with a constructor:
cl_device_partition_property core = new cl_device_partition_property();
error:
A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000007fedb6500bf, pid=4952, tid=4852
#
# JRE version: 7.0_21-b11
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.21-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [amdocl64.dll+0x1800bf] clGetSamplerInfo+0x1972f
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\javalar\buraya\paralelProje\hs_err_pid4952.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
[error occurred during error reporting , id 0xc0000005]
Another try:
cl_device_partition_property core = (CL_UNSIGNED_INT32)CL_DEVICE_PARTITION_BY_COUNTS;
error:
CL_UNSIGNED_INT32 cannot be resolved to a type
This did not work too:
Pointer xyz=Pointer.to(core); // jocl's pointer type.
clCreateSubDevices(device,xyz, 1, cpuCores, coreIDs);
Edit: problem solved! Thanks. Can partition my cpu now:
I think it's a missing feature of JOCL. I think you can try these two workarounds.
Say you want to set this property list:
{ CL_DEVICE_PARTITION_BY_COUNTS, 3, 1, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 }
(taken from Property List Examples at http://software.intel.com/en-us/articles/opencl-device-fission-for-cpu-performance).
Workaround 1:
cl_device_partition_property properties = new cl_device_partition_property();
properties.addProperty(CL.CL_DEVICE_PARTITION_BY_COUNTS, 3);
properties.addProperty(1, CL.CL_DEVICE_PARTITION_BY_COUNTS_LIST_END);
Explanation: The addProperty method just appends both the id and the value to end of the long[] array and converts it into a Buffer:
public void addProperty(long id, long value)
{
LongBuffer oldBuffer = (LongBuffer)getBuffer();
long newArray[] = new long[oldBuffer.capacity()+2];
oldBuffer.get(newArray, 0, oldBuffer.capacity());
newArray[oldBuffer.capacity()-1] = id;
newArray[oldBuffer.capacity()+0] = value;
newArray[oldBuffer.capacity()+1] = 0;
setBuffer(LongBuffer.wrap(newArray));
}
So any list can be created like:
addProperty(item[0], item[1]);
addProperty(item[2], item[3]);
addProperty(item[4], item[5]);
addProperty(item[6], 0);
Workaround 2:
Create a class in org.jcol
package to gain access to restricted method setBuffer
:
package org.jocl;
import java.nio.LongBuffer;
public class cl_device_partition_property_gateway {
public static void set(cl_device_partition_property properties, long[] newArray) {
properties.setBuffer(LongBuffer.wrap(newArray));
}
}
Then you can set the long[] array directly:
cl_device_partition_property properties = new cl_device_partition_property();
long[] values = { CL.CL_DEVICE_PARTITION_BY_COUNTS, 3, 1,
CL.CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 };
cl_device_partition_property_gateway.set(properties, values);