本文整理汇总了Java中jcuda.driver.JCudaDriver.cuCtxSynchronize方法的典型用法代码示例。如果您正苦于以下问题:Java JCudaDriver.cuCtxSynchronize方法的具体用法?Java JCudaDriver.cuCtxSynchronize怎么用?Java JCudaDriver.cuCtxSynchronize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jcuda.driver.JCudaDriver
的用法示例。
在下文中一共展示了JCudaDriver.cuCtxSynchronize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: freeAll
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public static void freeAll(boolean freeDontFree) {
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
LinkedList<Matrix> remainingAllocated = new LinkedList<Matrix>();
while (!allocated.isEmpty()) {
Matrix mat = allocated.poll();
if (freeDontFree || !mat.dontFree) {
mat.free();
} else {
remainingAllocated.add(mat);
}
}
allocated = remainingAllocated;
}
示例2: freeAllBut
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public static void freeAllBut(Collection<Matrix> keep) {
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
LinkedList<Matrix> remainingAllocated = new LinkedList<Matrix>();
while (!allocated.isEmpty()) {
Matrix mat = allocated.poll();
if (!keep.contains(mat) && !mat.dontFree) {
mat.free();
} else {
remainingAllocated.add(mat);
}
}
allocated = remainingAllocated;
}
示例3: toArray
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public float[] toArray() {
float[] data_h = new float[rows*cols];
// JCublas2.cublasGetVector(data_h.length, Sizeof.FLOAT, data_d, 1, Pointer.to(data_h), 1);
JCublas2.cublasGetMatrix(rows, cols, Sizeof.FLOAT, data_d, rows, Pointer.to(data_h), rows);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
return data_h;
}
示例4: pow
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
private static void pow(Matrix A, Matrix B, float val) {
int n = A.rows*A.cols;
CUfunction function = new CUfunction();
cuModuleGetFunction(function, helperModule, "vectorPow");
Pointer kernelParameters = Pointer.to(Pointer.to(A.data_d), Pointer.to(B.data_d), Pointer.to(new float[] {val}), Pointer.to(new int[] {n}));
int blockSize = Math.min(n, BLOCK_SIZE);
int gridSizeX = (int) Math.ceil((double) n / blockSize);
cuLaunchKernel(function,
gridSizeX, 1, 1, // Grid dimension
blockSize, 1, 1, // Block dimension
0, null, // Shared memory size and stream
kernelParameters, null // Kernel- and extra parameters
);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
}
示例5: min
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
private static void min(Matrix A, Matrix B, float val) {
int n = A.rows*A.cols;
CUfunction function = new CUfunction();
cuModuleGetFunction(function, helperModule, "vectorMin");
Pointer kernelParameters = Pointer.to(Pointer.to(A.data_d), Pointer.to(B.data_d), Pointer.to(new float[] {val}), Pointer.to(new int[] {n}));
int blockSize = Math.min(n, BLOCK_SIZE);
int gridSizeX = (int) Math.ceil((double) n / blockSize);
cuLaunchKernel(function,
gridSizeX, 1, 1, // Grid dimension
blockSize, 1, 1, // Block dimension
0, null, // Shared memory size and stream
kernelParameters, null // Kernel- and extra parameters
);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
}
示例6: exp
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
private static void exp(Matrix A, Matrix B) {
int n = A.rows*A.cols;
CUfunction function = new CUfunction();
cuModuleGetFunction(function, helperModule, "vectorExp");
Pointer kernelParameters = Pointer.to(Pointer.to(A.data_d), Pointer.to(B.data_d), Pointer.to(new int[] {n}));
int blockSize = Math.min(n, BLOCK_SIZE);
int gridSizeX = (int) Math.ceil((double) n / blockSize);
cuLaunchKernel(function,
gridSizeX, 1, 1, // Grid dimension
blockSize, 1, 1, // Block dimension
0, null, // Shared memory size and stream
kernelParameters, null // Kernel- and extra parameters
);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
}
示例7: div
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
private static void div(Matrix A, Matrix B, Matrix C) {
int n = A.rows*A.cols;
CUfunction function = new CUfunction();
cuModuleGetFunction(function, helperModule, "vectorDiv");
Pointer kernelParameters = Pointer.to(Pointer.to(A.data_d), Pointer.to(B.data_d), Pointer.to(C.data_d), Pointer.to(new int[] {n}));
int blockSize = Math.min(n, BLOCK_SIZE);
int gridSizeX = (int) Math.ceil((double) n / blockSize);
cuLaunchKernel(function,
gridSizeX, 1, 1, // Grid dimension
blockSize, 1, 1, // Block dimension
0, null, // Shared memory size and stream
kernelParameters, null // Kernel- and extra parameters
);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
}
示例8: norm2
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public float norm2() {
float[] result = new float[1];
JCublas2.cublasSnrm2(cublasHandle, rows*cols, data_d, 1, Pointer.to(result));
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
return result[0];
}
示例9: ger
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
private static void ger(float alpha, Matrix x, Matrix y, Matrix A) {
JCublas2.cublasSger(cublasHandle, A.rows, A.cols, Pointer.to(new float[] {alpha}), x.data_d, 1, y.data_d, 1, A.data_d, A.rows);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
}
示例10: sqr
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public Matrix sqr() {
Matrix result = new Matrix(rows, cols);
sqr(this, result);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
return result;
}
示例11: copySubmatrix
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public Matrix copySubmatrix(int r0, int r1, int c0, int c1) {
Matrix result = new Matrix(r1-r0, c1-c0);
JCublas2.cublasSetMatrix(result.rows, result.cols, Sizeof.FLOAT, this.data_d.withByteOffset((c0*this.rows+r0)*Sizeof.FLOAT), this.rows, result.data_d, result.rows);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
return result;
}
示例12: 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;
}
示例13: setSubmatrix
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public Matrix setSubmatrix(Matrix that, int r, int c) {
JCublas2.cublasSetMatrix(that.rows, that.cols, Sizeof.FLOAT, that.data_d, that.rows, this.data_d.withByteOffset((c*this.rows+r)*Sizeof.FLOAT), this.rows);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
return this;
}
示例14: muli
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public Matrix muli(float alpha) {
JCublas2.cublasSscal(cublasHandle, rows*cols, Pointer.to(new float[] {alpha}), data_d, 1);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
return this;
}
示例15: zeroi
import jcuda.driver.JCudaDriver; //导入方法依赖的package包/类
public Matrix zeroi() {
JCublas2.cublasSgeam(cublasHandle, cublasOperation.CUBLAS_OP_N, cublasOperation.CUBLAS_OP_N, rows, cols, Pointer.to(new float[] {0.0f}), new Pointer(), rows, Pointer.to(new float[] {0.0f}), new Pointer(), rows, data_d, rows);
if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
return this;
}