Java Jocl与装置裂变

Java Jocl与装置裂变,java,opencl,jocl,Java,Opencl,Jocl,编辑:问题已解决!rzymek的回答很有帮助。 问:对于JOCL,如何使用设备裂变将一些CPU内核从opencl计算中排除?(0.1.9版本的cl_设备_分区_属性的Java端口似乎已损坏) 编辑:我发现这个: clCreateSubDevices(devices[0][1],core , 1, cpuCores, coreIDs); 但java/jocl不接受这一点: cl_device_partition_property core=CL.CL_DEVICE_PARTITION_BY_CO

编辑:问题已解决!rzymek的回答很有帮助。

问:对于JOCL,如何使用设备裂变将一些CPU内核从opencl计算中排除?(0.1.9版本的cl_设备_分区_属性的Java端口似乎已损坏)

编辑:我发现这个:

clCreateSubDevices(devices[0][1],core , 1, cpuCores, coreIDs);
但java/jocl不接受这一点:

cl_device_partition_property core=CL.CL_DEVICE_PARTITION_BY_COUNTS;
错误是:

Type mismatch: cannot convert from int to cl_device_partition_property
只是尝试了null初始化,然后使用变量自己的方法设置属性:

    cl_device_partition_property core = null;
    core.addProperty(CL_DEVICE_PARTITION_BY_COUNTS, platforms[0]);
编辑:现在它给出了

    java.lang.NullPointerException,
错误

它需要是无符号的int(不是cl\u device\u partition\u属性),但java没有

使用构造函数进行新的尝试:

cl_device_partition_property core = new cl_device_partition_property();
错误:

 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]
CL_UNSIGNED_INT32 cannot be resolved to a type
另一种尝试:

    cl_device_partition_property core =  (CL_UNSIGNED_INT32)CL_DEVICE_PARTITION_BY_COUNTS;
错误:

 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]
CL_UNSIGNED_INT32 cannot be resolved to a type
这也不起作用:

   Pointer xyz=Pointer.to(core); // jocl's pointer type.
   clCreateSubDevices(device,xyz, 1, cpuCores, coreIDs);
编辑:问题解决了!谢谢现在可以对我的cpu进行分区:


我认为这是JOCL缺少的一个功能。 我想你可以试试这两种变通方法

假设要设置此属性列表:

{ CL_DEVICE_PARTITION_BY_COUNTS, 3, 1, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 }
(摘自上的财产清单示例)

解决方案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);
说明:addProperty方法只是将id和值附加到长[]数组的末尾,并将其转换为缓冲区:

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));
}
因此,可以创建任何列表,如:

addProperty(item[0], item[1]);
addProperty(item[2], item[3]);
addProperty(item[4], item[5]);
addProperty(item[6], 0);
解决方案2:

org.jcol
包中创建一个类,以访问受限方法
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));
    }
}
然后可以直接设置长[]数组:

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);

我认为这是JOCL缺少的一个特征。 我想你可以试试这两种变通方法

假设要设置此属性列表:

{ CL_DEVICE_PARTITION_BY_COUNTS, 3, 1, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 }
(摘自上的财产清单示例)

解决方案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);
说明:addProperty方法只是将id和值附加到长[]数组的末尾,并将其转换为缓冲区:

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));
}
因此,可以创建任何列表,如:

addProperty(item[0], item[1]);
addProperty(item[2], item[3]);
addProperty(item[4], item[5]);
addProperty(item[6], 0);
解决方案2:

org.jcol
包中创建一个类,以访问受限方法
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));
    }
}
然后可以直接设置长[]数组:

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);

我不完全确定你的问题是什么,问这个问题。你有没有看一下jocl的来源(我想是这一个?),看看在引擎盖下发生了什么?是的,它是新添加的(来自此版本之前的两个版本),只是没有编译或给出致命错误。其他一切都很好。windows-7 64位家庭高级版+eclipse朱诺。有addProperty(id,value.getNativePointer());它没有明确的声明。我不完全确定你的问题是什么,问了这个问题。你有没有看一下jocl的来源(我想是这一个?),看看在引擎盖下发生了什么?是的,它是新添加的(来自此版本之前的两个版本),只是没有编译或给出致命错误。其他一切都很好。windows-7 64位家庭高级版+eclipse朱诺。有addProperty(id,value.getNativePointer());没有明确的声明。总比没有好。将尝试Tomorrow。因此,在属性的末尾会自动添加一个零。解决方案1似乎正在工作。谢谢从现在起,这些Xeon将是高效的。是的,
addProperty
确保最后有一个0。我更喜欢第二种解决方法:)但仍然有30%的时间出现致命错误。启动程序时。如果打开,则运行良好,直到java3d和jmonkey清除opencl上下文或程序。只是划分了我的fx8150:)是的,第二种解决方法似乎更好。总比什么都没有好。将尝试Tomorrow。因此,在属性的末尾会自动添加一个零。解决方案1似乎正在工作。谢谢从现在起,这些Xeon将是高效的。是的,
addProperty
确保最后有一个0。我更喜欢第二种解决方法:)但仍然有30%的时间出现致命错误。启动程序时。如果打开,则运行良好,直到java3d和jmonkey清除opencl上下文或程序。刚刚划分了我的fx8150:)是的,第二种解决方法似乎更好。