本文整理汇总了Java中com.jogamp.opencl.CLMemory.Mem类的典型用法代码示例。如果您正苦于以下问题:Java Mem类的具体用法?Java Mem怎么用?Java Mem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Mem类属于com.jogamp.opencl.CLMemory包,在下文中一共展示了Mem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSamplingPoints
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
public CLBuffer<FloatBuffer> generateSamplingPoints(int elementCountV,
int elementCountU) {
// prepare sampling points
CLBuffer<FloatBuffer> samplingPoints = context.createFloatBuffer(
elementCountU * elementCountV * 2, Mem.READ_ONLY);
for (int j = 0; j < elementCountV; j++) {
for (int i = 0; i < elementCountU; i++) {
samplingPoints.getBuffer().put(i * (1.0f / elementCountU));
samplingPoints.getBuffer().put(j * (1.0f / elementCountV));
}
}
samplingPoints.getBuffer().rewind();
CLCommandQueue clc = device.createCommandQueue();
clc.putWriteBuffer(samplingPoints, true).finish();
clc.release();
return samplingPoints;
}
示例2: initProjectionMatrix
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
private synchronized void initProjectionMatrix(int projectionNumber){
// load projection Matrix for current Projection.
SimpleMatrix pMat = getGeometry().getProjectionMatrix(projectionNumber).computeP();
float [] pMatFloat = new float[pMat.getCols() * pMat.getRows()];
for (int j = 0; j< pMat.getRows(); j++) {
for (int i = 0; i< pMat.getCols(); i++) {
pMatFloat[(j * pMat.getCols()) + i] = (float) pMat.getElement(j, i);
}
}
// Obtain the global pointer to the view matrix from
// the module
if (projectionMatrix == null)
projectionMatrix = context.createFloatBuffer(pMatFloat.length, Mem.READ_ONLY);
projectionMatrix.getBuffer().put(pMatFloat);
projectionMatrix.getBuffer().rewind();
commandQueue.putWriteBuffer(projectionMatrix, true).finish();
}
示例3: initProjectionMatrix
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
private synchronized void initProjectionMatrix(int projectionNumber){
// load projection Matrix for current Projection.
SimpleMatrix pMat = getGeometry().getProjectionMatrix(projectionNumber).computeP();
float [] pMatFloat = new float[pMat.getCols() * pMat.getRows()];
for (int j = 0; j< pMat.getRows(); j++) {
for (int i = 0; i< pMat.getCols(); i++) {
pMatFloat[(j * pMat.getCols()) + i] = (float) pMat.getElement(j, i);
}
}
// Obtain the global pointer to the view matrix from
// the module
if (projectionMatrix == null)
projectionMatrix = context.createFloatBuffer(pMatFloat.length, Mem.READ_ONLY);
projectionMatrix.getBuffer().put(pMatFloat);
projectionMatrix.getBuffer().rewind();
commandQueue.putWriteBuffer(projectionMatrix, true).finish();
}
示例4: backprojectPixelDrivenCL
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
public void backprojectPixelDrivenCL(OpenCLGrid3D volume, OpenCLGrid2D[] sino) {
for(int p = 0; p < maxProjs; p++) {
CLImage2d<FloatBuffer> sinoGrid = context.createImage2d(sino[p].getDelegate().getCLBuffer().getBuffer(), sino[p].getSize()[0], sino[p].getSize()[1],format,Mem.READ_ONLY);
kernel.putArg(sinoGrid)
.putArg(volume.getDelegate().getCLBuffer())
.putArg(projMatrices)
.putArg(p)
.putArg(imgSizeX).putArg(imgSizeY).putArg(imgSizeZ)
.putArg((float)originX).putArg((float)originY).putArg((float)originZ)
.putArg((float)spacingX).putArg((float)spacingY).putArg((float)spacingZ)
.putArg(normalizer);
queue
.putCopyBufferToImage(sino[p].getDelegate().getCLBuffer(), sinoGrid).finish()
.put2DRangeKernel(kernel, 0, 0, globalWorkSizeX, globalWorkSizeY,localWorkSize, localWorkSize)
.finish();
kernel.rewind();
sinoGrid.release();
}
volume.getDelegate().notifyDeviceChange();
}
示例5: initProjectionMatrix
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
protected synchronized void initProjectionMatrix(int projectionNumber){
// load projection Matrix for current Projection.
if (getGeometry().getProjectionMatrix(projectionNumber)== null) {
CONRAD.log("No geometry found for projection " +projectionNumber + ". Skipping.");
return;
}
SimpleMatrix pMat = getGeometry().getProjectionMatrix(projectionNumber).computeP();
float [] pMatFloat = new float[pMat.getCols() * pMat.getRows()];
for (int j = 0; j< pMat.getRows(); j++) {
for (int i = 0; i< pMat.getCols(); i++) {
pMatFloat[(j * pMat.getCols()) + i] = (float) pMat.getElement(j, i);
}
}
// Obtain the global pointer to the view matrix from
// the module
if (projectionMatrix == null)
projectionMatrix = context.createFloatBuffer(pMatFloat.length, Mem.READ_ONLY);
projectionMatrix.getBuffer().put(pMatFloat);
projectionMatrix.getBuffer().rewind();
commandQueue.putWriteBuffer(projectionMatrix, true).finish();
//System.out.println("Uploading matrix " + projectionNumber);
}
示例6: runBinaryGridKernel
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
public CLBuffer<FloatBuffer> runBinaryGridKernel(String name, CLDevice device, CLBuffer<FloatBuffer> clmemA, CLBuffer<FloatBuffer> clmemB, int elementCount) {
CLProgram program = getProgram(device);
CLKernel kernel = getKernel(name, program);
int localWork = 32;
int localWorkSize = Math.min(device.getMaxWorkGroupSize(), 128);
int globalWorkSize = OpenCLUtil.roundUp(localWorkSize, elementCount/localWork);
localWork = (elementCount / globalWorkSize)+1;
CLBuffer<FloatBuffer> clmemResult = device.getContext().createFloatBuffer(globalWorkSize*2, Mem.WRITE_ONLY);
CLCommandQueue queue = device.createCommandQueue();
kernel.putArg(clmemA).putArg(clmemB).putArg(clmemResult).putArg(elementCount);
queue.put1DRangeKernel(kernel, 0, globalWorkSize, localWorkSize).finish();
queue.putReadBuffer(clmemResult, true);
queue.release();
kernel.rewind();
return clmemResult;
}
示例7: runUnaryKernel
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
public CLBuffer<FloatBuffer> runUnaryKernel(String name, CLDevice device,
CLBuffer<FloatBuffer> clmem, int elementCount){
CLProgram program = getProgram(device);
CLKernel kernel = getKernel(name, program);
int localWork = 32;
int localWorkSize = Math.min(device.getMaxWorkGroupSize(), 128);
int globalWorkSize = OpenCLUtil.roundUp(localWorkSize, elementCount/localWork);
localWork = (elementCount / globalWorkSize)+1;
CLBuffer<FloatBuffer> clmemResult = device.getContext().createFloatBuffer(globalWorkSize*2, Mem.WRITE_ONLY);
CLCommandQueue queue = device.createCommandQueue();
kernel.putArg(clmem).putArg(clmemResult).putArg(elementCount);
queue.put1DRangeKernel(kernel, 0, globalWorkSize, localWorkSize).finish();
queue.putReadBuffer(clmemResult, true);
queue.release();
kernel.rewind();
return clmemResult;
}
示例8: runBinaryGridScalarKernel
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
public void runBinaryGridScalarKernel(String name, CLDevice device, CLBuffer<FloatBuffer> clmem, T value, int elementCount){
float[] argument = value.getAsFloatArray();
CLBuffer<FloatBuffer> argBuffer = device.getContext().createFloatBuffer(argument.length, Mem.READ_ONLY);
argBuffer.getBuffer().put(argument);
argBuffer.getBuffer().rewind();
CLProgram program = getProgram(device);
CLKernel kernel = getKernel(name, program);
CLCommandQueue queue = device.createCommandQueue();
kernel.putArgs(clmem).putArg(argBuffer).putArg(elementCount);
int localWorkSize = Math.min(device.getMaxWorkGroupSize(), 128);
int globalWorkSize = OpenCLUtil.roundUp(localWorkSize, elementCount);
queue.putWriteBuffer(argBuffer, true).put1DRangeKernel(kernel, 0, globalWorkSize, localWorkSize).finish();
queue.release();
kernel.rewind();
}
示例9: dotProduct
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
@Override
public T dotProduct(final GenericGrid<T> gridA, final GenericGrid<T> gridB) {
if (debug) System.out.println("Bei OpenCL dotProduct");
// not possible to have a grid that is not implementing OpenCLGenericGridInterface<T>
OpenCLGenericGridInterface<T> clGridA = (OpenCLGenericGridInterface<T>)gridA;
OpenCLGenericGridInterface<T> clGridB = (OpenCLGenericGridInterface<T>)gridB;
clGridA.getDelegate().prepareForDeviceOperation();
clGridB.getDelegate().prepareForDeviceOperation();
// TODO check if both live on the same device.
CLDevice device = clGridA.getDelegate().getCLDevice();
CLBuffer<FloatBuffer> clmemA = clGridA.getDelegate().getCLBuffer();
CLBuffer<FloatBuffer> dummy = clGridA.getDelegate().getCLContext().createFloatBuffer(clmemA.getCLCapacity(),Mem.READ_WRITE);
clGridA.getDelegate().getCLDevice().createCommandQueue().putWriteBuffer(dummy, true).release();
runBinaryGridKernelNoReturn("copy", device, dummy, clmemA, gridA.getNumberOfElements());
CLBuffer<FloatBuffer> clmemB = clGridB.getDelegate().getCLBuffer();
runBinaryGridKernelNoReturn("multiplyBy", device, dummy, clmemB, gridA.getNumberOfElements());
CLBuffer<FloatBuffer> clRes = runUnaryKernel("sum", device, dummy, gridA.getNumberOfElements());
return getSum(clRes);
}
示例10: convert2DArrayTo3D
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
/**
* convert grid2d[] to grid3d
*/
public void convert2DArrayTo3D(NumericGrid gridRes,final NumericGrid[] grid) {
// not possible to have a grid that is not implementing OpenCLGridInterface
OpenCLGridInterface clGridA[] = new OpenCLGridInterface[grid.length];
CLBuffer<FloatBuffer> clmemA = OpenCLUtil.getStaticContext().createFloatBuffer(gridRes.getSize()[0]*gridRes.getSize()[1]*gridRes.getSize()[2], Mem.READ_WRITE);
CLCommandQueue queueHelp = OpenCLUtil.getStaticContext().getMaxFlopsDevice().createCommandQueue();
System.out.println();
for(int i = 0; i < grid.length;i++){
clGridA[i] = (OpenCLGridInterface)grid[i];
clGridA[i].getDelegate().prepareForDeviceOperation();
queueHelp.putCopyBuffer(clGridA[i].getDelegate().getCLBuffer(), clmemA,0,i*(int)clGridA[i].getDelegate().getCLBuffer().getCLSize(),clGridA[i].getDelegate().getCLBuffer().getCLSize(),null).finish();
clGridA[i].getDelegate().notifyDeviceChange();
}
OpenCLGridInterface clGridRes = (OpenCLGridInterface)gridRes;
clGridRes.getDelegate().prepareForDeviceOperation();
queueHelp.putCopyBuffer(clmemA, clGridRes.getDelegate().getCLBuffer()).finish();
clGridRes.getDelegate().notifyDeviceChange();
}
示例11: generateTimeSamplingPoints
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
public static CLBuffer<FloatBuffer> generateTimeSamplingPoints(float tIndex, int elementCountU, int elementCountV, CLContext context, CLDevice device){
// prepare sampling points
CLBuffer<FloatBuffer> samplingPoints = context.createFloatBuffer(elementCountU * elementCountV*3, Mem.READ_ONLY);
for (int j = 0; j < elementCountV; j++){
for (int i = 0; i < elementCountU; i++){
samplingPoints.getBuffer().put(i*(1.0f / elementCountU));
samplingPoints.getBuffer().put(j*(1.0f / elementCountV));
samplingPoints.getBuffer().put(tIndex);
//System.out.println(i*(1.0f / elementCountU) + " " +j*(1.0f / elementCountV)+ " "+t*(1.0f / elementCountT) );
}
}
samplingPoints.getBuffer().rewind();
CLCommandQueue clc = device.createCommandQueue();
clc.putWriteBuffer(samplingPoints, true).finish();
clc.release();
return samplingPoints;
}
示例12: initProjectionMatrix
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
protected synchronized void initProjectionMatrix(int projectionNumber){
// load projection Matrix for current Projection.
if (getGeometry().getProjectionMatrix(projectionNumber)== null) {
CONRAD.log("No geometry found for projection " +projectionNumber + ". Skipping.");
return;
}
SimpleMatrix pMat = getGeometry().getProjectionMatrix(projectionNumber).computeP();
float [] pMatFloat = new float[pMat.getCols() * pMat.getRows()];
for (int j = 0; j< pMat.getRows(); j++) {
for (int i = 0; i< pMat.getCols(); i++) {
pMatFloat[(j * pMat.getCols()) + i] = (float) pMat.getElement(j, i);
}
}
// Obtain the global pointer to the view matrix from
// the module
if (projectionMatrix == null)
projectionMatrix = context.createFloatBuffer(pMatFloat.length, Mem.READ_ONLY);
projectionMatrix.getBuffer().put(pMatFloat);
projectionMatrix.getBuffer().rewind();
commandQueue.putWriteBuffer(projectionMatrix, true);
//System.out.println("Uploading matrix " + projectionNumber);
}
示例13: initProjectionData
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
protected synchronized void initProjectionData(Grid2D projection){
initialize(projection);
if (projection != null){
if (projectionArray == null) {
// Create the array that will contain the projection data.
projectionArray = context.createFloatBuffer(projection.getWidth()*projection.getHeight(), Mem.READ_ONLY);
}
// Copy the projection data to the array
projectionArray.getBuffer().put(projection.getBuffer());
projectionArray.getBuffer().rewind();
if(projectionTex != null && !projectionTex.isReleased()){
projectionTex.release();
}
// set the texture
CLImageFormat format = new CLImageFormat(ChannelOrder.INTENSITY, ChannelType.FLOAT);
projectionTex = context.createImage2d(projectionArray.getBuffer(), projection.getWidth(), projection.getHeight(), format, Mem.READ_ONLY);
//projectionArray.release();
} else {
CONRAD.log("Projection was null!!");
}
}
示例14: initVolumeBuffer
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
void initVolumeBuffer(){
hvolumeBuffer = glCtx.createIntBuffer(h_volume.length, Mem.READ_ONLY);
for (int i = 0; i < h_volume.length; i++) {
hvolumeBuffer.getBuffer().put(i, (int)h_volume[i]);
}
hvolumeBuffer.getBuffer().rewind();
CLImageFormat format = new CLImageFormat(ChannelOrder.RGBA, ChannelType.UNORM_INT8);
tex = glCtx.createImage3d(hvolumeBuffer.getBuffer(), volumeSize[0], volumeSize[1], volumeSize[2], format, Mem.READ_ONLY, Mem.ALLOCATE_BUFFER);
hvolumeBuffer.release();
try {
commandQueue.putWriteImage(tex, true)
.finish();
} catch (Exception e) {
e.printStackTrace();
unload();
}
hvolumeBuffer = null;
}
示例15: initCL
import com.jogamp.opencl.CLMemory.Mem; //导入依赖的package包/类
/**
* Initialize CUDA and the 3D texture with the current volume data.
*/
void initCL()
{
initVolumeBuffer();
transferFctBuffer = glCtx.createFloatBuffer(transferFunc.length, Mem.READ_ONLY);
transferFctBuffer.getBuffer().put(transferFunc);
transferFctBuffer.getBuffer().rewind();
CLImageFormat formatTransFct = new CLImageFormat(ChannelOrder.RGBA, ChannelType.FLOAT);
transferTex = glCtx.createImage2d(transferFctBuffer.getBuffer(), transferFunc.length/4, 1, formatTransFct, Mem.READ_ONLY, Mem.ALLOCATE_BUFFER);
transferFctBuffer.release();
try {
commandQueue.putWriteImage(transferTex, true)
.finish();
} catch (Exception e) {
e.printStackTrace();
unload();
}
invViewMatrix = glCtx.createFloatBuffer(12, Mem.READ_ONLY);
}