1

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:

enter image description here

huseyin tugrul buyukisik
  • 11,469
  • 4
  • 45
  • 97

1 Answers1

1

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);
rzymek
  • 9,064
  • 2
  • 45
  • 59
  • Better than nothing. Will try tomorow. – huseyin tugrul buyukisik May 22 '13 at 13:50
  • So a zero is automatically added in the end to properties. – huseyin tugrul buyukisik May 22 '13 at 14:51
  • Workaround 1 seems to be working. Thanks. Those xeons will be efficient from now. – huseyin tugrul buyukisik May 22 '13 at 15:08
  • Yes, `addProperty` ensures there's a 0 at the end. I like the second workaround better :) – rzymek May 22 '13 at 15:20
  • But still I am getting fatal error %30 of the time. When initiating the program. If it opens, runs good until java3d and jmonkey purges the opencl contexts or programs. Just partitioned my fx8150 :) and yes second workaround seeming better. – huseyin tugrul buyukisik May 22 '13 at 15:32
  • If you can solve the problem with java3d-opencl-jmonkey compatibility, there another question. { CL_DEVICE_PARTITION_EQUALLY, 1, 0 } makes more general partitioning suitable for any number of cores, does it? Does it impact performance ? Occupancy can be a problem? – huseyin tugrul buyukisik May 22 '13 at 15:42
  • I am not using any sound file or command but jmonkey is using its own will. # 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 [atiadlxx.dll+0x41b20] ADL_Audio_CurrentSampleRate_Get+0x5a40 # # 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\bin\hs_err_pid1560.log # # The crash happened outside the Java Virtual Machine in native code. – huseyin tugrul buyukisik May 22 '13 at 18:06