Java Code Examples for jcuda.jcublas.JCublas2#cublasSetMatrix()

The following examples show how to use jcuda.jcublas.JCublas2#cublasSetMatrix() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CublasUtil.java    From murphy with Apache License 2.0 5 votes vote down vote up
public static Matrix build(float[][] mat) {
	Matrix result = new Matrix(mat.length, mat[0].length);
	float[] data_h = toColMajor(mat);
	JCublas2.cublasSetMatrix(result.rows, result.cols, Sizeof.FLOAT, Pointer.to(data_h), result.rows, result.data_d, result.rows);
	if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
	return result;
}
 
Example 2
Source File: CublasUtil.java    From murphy with Apache License 2.0 4 votes vote down vote up
public static Matrix build(int rows, int cols, float[] data_h) {
	Matrix result = new Matrix(rows, cols);
	JCublas2.cublasSetMatrix(result.rows, result.cols, Sizeof.FLOAT, Pointer.to(data_h), result.rows, result.data_d, result.rows);
	if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
	return result;
}
 
Example 3
Source File: CublasUtil.java    From murphy with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 4
Source File: CublasUtil.java    From murphy with Apache License 2.0 4 votes vote down vote up
public Matrix setSubmatrix(int r, int c, Matrix that, int r0, int r1, int c0, int c1) {
	JCublas2.cublasSetMatrix(r1-r0, c1-c0, Sizeof.FLOAT, that.data_d.withByteOffset((c0*that.rows+r0)*Sizeof.FLOAT), that.rows, this.data_d.withByteOffset((c*this.rows+r)*Sizeof.FLOAT), this.rows);
	if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
	return this;
}
 
Example 5
Source File: CublasUtil.java    From murphy with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 6
Source File: CublasUtil.java    From murphy with Apache License 2.0 4 votes vote down vote up
public Matrix setSubmatrix(float[][] mat, int r, int c) {
	float[] data_h = toColMajor(mat);
	JCublas2.cublasSetMatrix(mat.length, mat[0].length, Sizeof.FLOAT, Pointer.to(data_h), mat.length, this.data_d.withByteOffset((c*this.rows+r)*Sizeof.FLOAT), this.rows);
	if (DEBUG_SYNC) JCudaDriver.cuCtxSynchronize();
	return this;
}