本文整理汇总了Java中jcuda.driver.JCudaDriver.cuParamSetSize方法的典型用法代码示例。如果您正苦于以下问题:Java JCudaDriver.cuParamSetSize方法的具体用法?Java JCudaDriver.cuParamSetSize怎么用?Java JCudaDriver.cuParamSetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jcuda.driver.JCudaDriver
的用法示例。
在下文中一共展示了JCudaDriver.cuParamSetSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: projectSingleProjection
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
private synchronized void projectSingleProjection(int projectionNumber, int dimz){
// load projection matrix
initProjectionMatrix(projectionNumber);
// load projection
Grid2D projection = (Grid2D)projections.get(projectionNumber).clone();
// Correct for constant part of distance weighting + For angular sampling
double D = getGeometry().getSourceToDetectorDistance();
NumericPointwiseOperators.multiplyBy(projection, (float)(D*D * 2* Math.PI / getGeometry().getNumProjectionMatrices()));
initProjectionData(projection);
if (!largeVolumeMode) {
projections.remove(projectionNumber);
}
// backproject for each slice
// CUDA Grids are only two dimensional!
int [] zed = new int[1];
int reconDimensionZ = dimz;
double voxelSpacingX = getGeometry().getVoxelSpacingX();
double voxelSpacingY = getGeometry().getVoxelSpacingY();
double voxelSpacingZ = getGeometry().getVoxelSpacingZ();
zed[0] = reconDimensionZ;
Pointer dOut = Pointer.to(volumePointer);
Pointer pWidth = Pointer.to(new int[]{(int) lineOffset});
Pointer pZOffset = Pointer.to(zed);
float [] vsx = new float[]{(float) voxelSpacingX};
Pointer pvsx = Pointer.to(vsx);
Pointer pvsy = Pointer.to(new float[]{(float) voxelSpacingY});
Pointer pvsz = Pointer.to(new float[]{(float) voxelSpacingZ});
Pointer pox = Pointer.to(new float[]{(float) offsetX});
Pointer poy = Pointer.to(new float[]{(float) offsetY});
Pointer poz = Pointer.to(new float[]{(float) offsetZ});
int offset = 0;
//System.out.println(dimz + " " + zed[0] + " " + offsetZ + " " + voxelSpacingZ);
offset = CUDAUtil.align(offset, Sizeof.POINTER);
JCudaDriver.cuParamSetv(function, offset, dOut, Sizeof.POINTER);
offset += Sizeof.POINTER;
offset = CUDAUtil.align(offset, Sizeof.INT);
JCudaDriver.cuParamSetv(function, offset, pWidth, Sizeof.INT);
offset += Sizeof.INT;
offset = CUDAUtil.align(offset, Sizeof.INT);
JCudaDriver.cuParamSetv(function, offset, pZOffset, Sizeof.INT);
offset += Sizeof.INT;
offset = CUDAUtil.align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, pvsx, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
offset = CUDAUtil.align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, pvsy, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
offset = CUDAUtil.align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, pvsz, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
offset = CUDAUtil.align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, pox, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
offset = CUDAUtil.align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, poy, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
offset = CUDAUtil.align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, poz, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
JCudaDriver.cuParamSetSize(function, offset);
// Call the CUDA kernel, writing the results into the volume which is pointed at
JCudaDriver.cuFuncSetBlockShape(function, bpBlockSize[0], bpBlockSize[1], 1);
JCudaDriver.cuLaunchGrid(function, gridSize.x, gridSize.y);
JCudaDriver.cuCtxSynchronize();
}
示例2: project
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
/**
* loads the actual CUDA kernel and performs the projection
* @param projectionNumber the projection number.
* @return
*/
private ImageProcessor project(int projectionNumber){
init();
prepareProjection(projectionNumber);
Pointer dOut = Pointer.to(gProjection);
Pointer pStride = Pointer.to(new int[]{width});
Pointer pstepsize = Pointer.to(new float[]{(float) 1});
int offset = 0;
offset = CUDAUtil.align(offset, Sizeof.POINTER);
JCudaDriver.cuParamSetv(function, offset, dOut, Sizeof.POINTER);
offset += Sizeof.POINTER;
offset = CUDAUtil.align(offset, Sizeof.INT);
JCudaDriver.cuParamSetv(function, offset, pStride, Sizeof.INT);
offset += Sizeof.INT;
offset = CUDAUtil.align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, pstepsize, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
JCudaDriver.cuParamSetSize(function, offset);
dim3 gridSize = new dim3(
CUDAUtil.iDivUp(width, bpBlockSize[0]),
CUDAUtil.iDivUp(height, bpBlockSize[0]),
1);
//System.out.println("Grid: " + gridSize);
JCudaDriver.cuFuncSetBlockShape(function, bpBlockSize[0], bpBlockSize[1], 1);
JCudaDriver.cuLaunchGrid(function, gridSize.x, gridSize.y);
JCudaDriver.cuCtxSynchronize();
JCudaDriver.cuMemcpyDtoH(Pointer.to(projection), gProjection, width * height * Sizeof.FLOAT);
FloatProcessor fl = new FloatProcessor(width, height, projection, null);
// TODO: Normalization is never considered in the backprojectors,
// thus, iteratively applying forward and backward projections
// would yield to a scaling issue!
// conversion from [g*mm/cm^3] = [g*0.1cm/cm^3] to [g/cm^2]
// fl.multiply(1.0 / 10);
if (geometry instanceof ProjectionTableFileTrajectory){
fl.flipVertical();
}
return fl;
}
示例3: callCUDAFunction
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
private void callCUDAFunction(CUfunction function, ArrayList<Object> arguments){
int offset = 0;
if (debug) System.out.println("Working on Parameter set.");
// send the parameters to the function
for (int i = 0; i < arguments.size(); i++) {
if (debug) System.out.print("Parameter " + i);
Object argument = arguments.get(i);
if (argument instanceof CUdeviceptr) {
if (debug) System.out.println(" is CUdeviceptr");
Pointer pointer = Pointer.to((Pointer) argument);
offset = CUDAUtil.align(offset, Sizeof.POINTER);
JCudaDriver.cuParamSetv(function, offset, pointer, Sizeof.POINTER);
offset += Sizeof.POINTER;
}
if (argument instanceof Integer) {
if (debug) System.out.println(" is Integer");
int [] integer = {((Integer) argument).intValue()};
Pointer intPointer = Pointer.to(integer);
offset = CUDAUtil.align(offset, Sizeof.INT);
JCudaDriver.cuParamSetv(function, offset, intPointer, Sizeof.INT);
offset += Sizeof.INT;
}
if (argument instanceof Float){
if (debug) System.out.println(" is Float");
float [] array = {((Float) argument).floatValue()};
Pointer floatPointer = Pointer.to(array);
offset = CUDAUtil.align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, floatPointer, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
}
}
// set parameter space
JCudaDriver.cuParamSetSize(function, offset);
if (debug) System.out.println("Parameters set.");
// Call the CUDA kernel, writing the results into the volume which is pointed at
if (debug) System.out.println("Setting blocks.");
JCudaDriver.cuFuncSetBlockShape(function, CUDAUtil.gridBlockSize[0], CUDAUtil.gridBlockSize[1], 1);
if (debug) System.out.println("Staring grid: " + gridSize.x + "x"+ gridSize.y);
int revan = JCudaDriver.cuLaunchGrid(function, gridSize.x, gridSize.y);
if (debug) System.out.println("Exit code launch: "+revan);
revan = JCudaDriver.cuCtxSynchronize();
if (debug) System.out.println("Exit code sync: "+revan);
}
示例4: render
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
protected void render()
{
if (multiFrameMode) {
// Map the PBO to get a CUDA device pointer
CUdeviceptr d_output = new CUdeviceptr();
JCudaDriver.cuGLMapBufferObject(d_output, new int[1], pbo);
JCudaDriver.cuMemsetD32(d_output, 0, width * height);
// Set up the execution parameters for the kernel:
// - One pointer for the output that is mapped to the PBO
// - Two ints for the width and height of the image to render
// - Four floats for the visualization parameters of the renderer
Pointer dOut = Pointer.to(d_output);
Pointer pWidth = Pointer.to(new int[]{width});
Pointer pHeight = Pointer.to(new int[]{height});
Pointer pDensity = Pointer.to(new float[]{density});
Pointer pBrightness = Pointer.to(new float[]{brightness});
Pointer pTransferOffset = Pointer.to(new float[]{transferOffset});
Pointer pTransferScale = Pointer.to(new float[]{transferScale});
Pointer pTime = Pointer.to(new int[]{time});
int offset = 0;
offset = align(offset, Sizeof.POINTER);
JCudaDriver.cuParamSetv(function, offset, dOut, Sizeof.POINTER);
offset += Sizeof.POINTER;
offset = align(offset, Sizeof.INT);
JCudaDriver.cuParamSetv(function, offset, pWidth, Sizeof.INT);
offset += Sizeof.INT;
offset = align(offset, Sizeof.INT);
JCudaDriver.cuParamSetv(function, offset, pHeight, Sizeof.INT);
offset += Sizeof.INT;
offset = align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, pDensity, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
offset = align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, pBrightness, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
offset = align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, pTransferOffset, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
offset = align(offset, Sizeof.FLOAT);
JCudaDriver.cuParamSetv(function, offset, pTransferScale, Sizeof.FLOAT);
offset += Sizeof.FLOAT;
offset = align(offset, Sizeof.INT);
JCudaDriver.cuParamSetv(function, offset, pTime, Sizeof.INT);
offset += Sizeof.INT;
JCudaDriver.cuParamSetSize(function, offset);
// Call the CUDA kernel, writing the results into the PBO
JCudaDriver.cuFuncSetBlockShape(function, blockSize.x, blockSize.y, 1);
JCudaDriver.cuLaunchGrid(function, gridSize.x, gridSize.y);
JCudaDriver.cuCtxSynchronize();
JCudaDriver.cuGLUnmapBufferObject(pbo);
} else {
super.render();
}
}