Package jcuda

Examples of jcuda.Pointer


   */
  public static DenseDoubleMatrix multiply(Pointer a, Pointer b,
      MatrixDimension dim) {

    // Prepare the pointer for the result in DEVICE memory
    Pointer deviceResultPointer = new Pointer();
    int resMatrixSize = dim.getM() * dim.getN();
    int transA = dim.isTransposeA() ? cublasOperation.CUBLAS_OP_T
        : cublasOperation.CUBLAS_OP_N;
    int transB = dim.isTransposeB() ? cublasOperation.CUBLAS_OP_T
        : cublasOperation.CUBLAS_OP_N;

    if (CUBLAS2_AVAILABLE) {
      JCuda.cudaMalloc(deviceResultPointer, Sizeof.DOUBLE * resMatrixSize);
      Pointer alpha = Pointer.to(new double[] { 1.0d });
      Pointer beta = Pointer.to(new double[] { 0.0d });
      JCublas2.cublasDgemm(handle, transA, transB, dim.getM(), dim.getN(),
          dim.getK(), alpha, a, dim.getLdA(), b, dim.getLdB(), beta,
          deviceResultPointer, dim.getLdC());
      freePointer(alpha);
      freePointer(beta);
View Full Code Here


   * Multiplies matrix a with matrix b and returns a new matrix. You can add
   * transpose flags for both matrices.
   */
  public static DenseDoubleMatrix multiply(DenseDoubleMatrix a,
      DenseDoubleMatrix b, boolean transposeA, boolean transposeB) {
    Pointer matrixPointerA = memcpyMatrix(a);
    Pointer matrixPointerB = memcpyMatrix(b);
    DenseDoubleMatrix matrix = multiply(matrixPointerA, matrixPointerB,
        new MatrixDimension(a, b, transposeA, transposeB));
    freePointer(matrixPointerA);
    freePointer(matrixPointerB);
    return matrix;
View Full Code Here

   * @return a pointer to this matrix.
   */
  public static Pointer memcpyMatrix(DenseDoubleMatrix a) {
    int matrixSizeA = a.getColumnCount() * a.getRowCount();
    double[] matrix = a.getColumnMajorMatrix();
    Pointer deviceMatrixA = new Pointer();
    JCuda.cudaMalloc(deviceMatrixA, matrixSizeA * Sizeof.DOUBLE);
    if (CUBLAS2_AVAILABLE) {
      JCublas2.cublasSetMatrix(a.getRowCount(), a.getColumnCount(),
          Sizeof.DOUBLE, Pointer.to(matrix), a.getRowCount(), deviceMatrixA,
          a.getRowCount());
View Full Code Here

   * @param columns the number of columns
   * @return a new matrix with the results from device.
   */
  public static DenseDoubleMatrix getMatrix(Pointer src, int rows, int columns) {
    double[] raw = new double[rows * columns];
    Pointer dst = Pointer.to(raw);
    if (CUBLAS2_AVAILABLE) {
      JCublas2.cublasGetMatrix(rows, columns, Sizeof.DOUBLE, src, rows, dst,
          rows);
    } else {
      JCublas.cublasGetMatrix(rows, columns, Sizeof.DOUBLE, src, rows, dst,
View Full Code Here

TOP

Related Classes of jcuda.Pointer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.