Search in sources :

Example 21 with CublasPointer

use of org.nd4j.linalg.jcublas.CublasPointer in project nd4j by deeplearning4j.

the class JcublasLevel1 method ddot.

@Override
protected double ddot(int N, INDArray X, int incX, INDArray Y, int incY) {
    if (Nd4j.dataType() != DataBuffer.Type.DOUBLE)
        logger.warn("DOUBLE dot called");
    Nd4j.getExecutioner().push();
    double ret;
    CudaContext ctx = allocator.getFlowController().prepareAction(null, X, Y);
    CublasPointer xCPointer = new CublasPointer(X, ctx);
    CublasPointer yCPointer = new CublasPointer(Y, ctx);
    cublasHandle_t handle = ctx.getHandle();
    synchronized (handle) {
        cublasSetStream_v2(new cublasContext(handle), new CUstream_st(ctx.getOldStream()));
        DoublePointer resultPointer = new DoublePointer(0.0);
        cublasDdot_v2(new cublasContext(handle), N, (DoublePointer) xCPointer.getDevicePointer(), incX, (DoublePointer) yCPointer.getDevicePointer(), incY, resultPointer);
        ret = resultPointer.get();
    }
    allocator.registerAction(ctx, null, X, Y);
    return ret;
}
Also used : CUstream_st(org.bytedeco.javacpp.cuda.CUstream_st) org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t(org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t) CudaContext(org.nd4j.linalg.jcublas.context.CudaContext) DoublePointer(org.bytedeco.javacpp.DoublePointer) CublasPointer(org.nd4j.linalg.jcublas.CublasPointer)

Example 22 with CublasPointer

use of org.nd4j.linalg.jcublas.CublasPointer in project nd4j by deeplearning4j.

the class JcublasLevel1 method snrm2.

@Override
protected float snrm2(int N, INDArray X, int incX) {
    if (Nd4j.dataType() != DataBuffer.Type.FLOAT)
        logger.warn("FLOAT nrm2 called");
    Nd4j.getExecutioner().push();
    CudaContext ctx = allocator.getFlowController().prepareAction(null, X);
    float ret;
    CublasPointer cAPointer = new CublasPointer(X, ctx);
    cublasHandle_t handle = ctx.getHandle();
    synchronized (handle) {
        cublasSetStream_v2(new cublasContext(handle), new CUstream_st(ctx.getOldStream()));
        FloatPointer resultPointer = new FloatPointer(0.0f);
        cublasSnrm2_v2(new cublasContext(handle), N, (FloatPointer) cAPointer.getDevicePointer(), incX, resultPointer);
        ret = resultPointer.get();
    }
    allocator.registerAction(ctx, null, X);
    return ret;
}
Also used : CUstream_st(org.bytedeco.javacpp.cuda.CUstream_st) org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t(org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t) FloatPointer(org.bytedeco.javacpp.FloatPointer) CudaContext(org.nd4j.linalg.jcublas.context.CudaContext) CublasPointer(org.nd4j.linalg.jcublas.CublasPointer)

Example 23 with CublasPointer

use of org.nd4j.linalg.jcublas.CublasPointer in project nd4j by deeplearning4j.

the class JcublasLevel3 method dtrsm.

@Override
protected void dtrsm(char Order, char Side, char Uplo, char TransA, char Diag, int M, int N, double alpha, INDArray A, int lda, INDArray B, int ldb) {
    if (Nd4j.dataType() != DataBuffer.Type.DOUBLE)
        logger.warn("DOUBLE trsm called");
    Nd4j.getExecutioner().push();
    CudaContext ctx = allocator.getFlowController().prepareAction(B, A);
    CublasPointer aPointer = new CublasPointer(A, ctx);
    CublasPointer bPointer = new CublasPointer(B, ctx);
    cublasHandle_t handle = ctx.getHandle();
    synchronized (handle) {
        cublasSetStream_v2(new cublasContext(handle), new CUstream_st(ctx.getOldStream()));
        cublasDtrsm_v2(new cublasContext(handle), convertSideMode(Side), convertUplo(Uplo), convertTranspose(TransA), convertDiag(Diag), M, N, new DoublePointer(alpha), (DoublePointer) aPointer.getDevicePointer(), lda, (DoublePointer) bPointer.getDevicePointer(), ldb);
    }
    allocator.registerAction(ctx, B, A);
    OpExecutionerUtil.checkForAny(B);
}
Also used : org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t(org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t) CudaContext(org.nd4j.linalg.jcublas.context.CudaContext) DoublePointer(org.bytedeco.javacpp.DoublePointer) CublasPointer(org.nd4j.linalg.jcublas.CublasPointer)

Example 24 with CublasPointer

use of org.nd4j.linalg.jcublas.CublasPointer in project nd4j by deeplearning4j.

the class JcublasLevel3 method dsyr2k.

@Override
protected void dsyr2k(char Order, char Uplo, char Trans, int N, int K, double alpha, INDArray A, int lda, INDArray B, int ldb, double beta, INDArray C, int ldc) {
    if (Nd4j.dataType() != DataBuffer.Type.DOUBLE)
        logger.warn("DOUBLE syr2k called");
    Nd4j.getExecutioner().push();
    CudaContext ctx = allocator.getFlowController().prepareAction(C, A, B);
    CublasPointer aPointer = new CublasPointer(A, ctx);
    CublasPointer bPointer = new CublasPointer(B, ctx);
    CublasPointer cPointer = new CublasPointer(C, ctx);
    cublasHandle_t handle = ctx.getHandle();
    synchronized (handle) {
        cublasSetStream_v2(new cublasContext(handle), new CUstream_st(ctx.getOldStream()));
        cublasDsyr2k_v2(new cublasContext(handle), convertUplo(Uplo), Trans, N, K, new DoublePointer(alpha), (DoublePointer) aPointer.getDevicePointer(), lda, (DoublePointer) bPointer.getDevicePointer(), ldb, new DoublePointer(beta), (DoublePointer) cPointer.getDevicePointer(), ldc);
    }
    allocator.registerAction(ctx, C, A, B);
    OpExecutionerUtil.checkForAny(C);
}
Also used : org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t(org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t) CudaContext(org.nd4j.linalg.jcublas.context.CudaContext) DoublePointer(org.bytedeco.javacpp.DoublePointer) CublasPointer(org.nd4j.linalg.jcublas.CublasPointer)

Example 25 with CublasPointer

use of org.nd4j.linalg.jcublas.CublasPointer in project nd4j by deeplearning4j.

the class JcublasLevel3 method dtrmm.

@Override
protected void dtrmm(char Order, char Side, char Uplo, char TransA, char Diag, int M, int N, double alpha, INDArray A, int lda, INDArray B, int ldb) {
    if (Nd4j.dataType() != DataBuffer.Type.DOUBLE)
        logger.warn("DOUBLE trmm called");
    Nd4j.getExecutioner().push();
    CudaContext ctx = allocator.getFlowController().prepareAction(B, A);
    CublasPointer aPointer = new CublasPointer(A, ctx);
    CublasPointer bPointer = new CublasPointer(B, ctx);
    cublasHandle_t handle = ctx.getHandle();
    synchronized (handle) {
        cublasSetStream_v2(new cublasContext(handle), new CUstream_st(ctx.getOldStream()));
        cublasDtrmm_v2(new cublasContext(handle), convertSideMode(Side), convertUplo(Uplo), convertTranspose(TransA), convertDiag(Diag), M, N, new DoublePointer(alpha), (DoublePointer) aPointer.getDevicePointer(), lda, (DoublePointer) bPointer.getDevicePointer(), ldb, (DoublePointer) bPointer.getDevicePointer(), ldb);
    }
    allocator.registerAction(ctx, B, A);
    OpExecutionerUtil.checkForAny(B);
}
Also used : org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t(org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t) CudaContext(org.nd4j.linalg.jcublas.context.CudaContext) DoublePointer(org.bytedeco.javacpp.DoublePointer) CublasPointer(org.nd4j.linalg.jcublas.CublasPointer)

Aggregations

CublasPointer (org.nd4j.linalg.jcublas.CublasPointer)36 CudaContext (org.nd4j.linalg.jcublas.context.CudaContext)35 org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t (org.nd4j.jita.allocator.pointers.cuda.cublasHandle_t)25 CUstream_st (org.bytedeco.javacpp.cuda.CUstream_st)24 DoublePointer (org.bytedeco.javacpp.DoublePointer)20 FloatPointer (org.bytedeco.javacpp.FloatPointer)19 IntPointer (org.bytedeco.javacpp.IntPointer)12 INDArray (org.nd4j.linalg.api.ndarray.INDArray)11 Pointer (org.bytedeco.javacpp.Pointer)10 CudaPointer (org.nd4j.jita.allocator.pointers.CudaPointer)10 org.nd4j.jita.allocator.pointers.cuda.cusolverDnHandle_t (org.nd4j.jita.allocator.pointers.cuda.cusolverDnHandle_t)10 DataBuffer (org.nd4j.linalg.api.buffer.DataBuffer)10 GridExecutioner (org.nd4j.linalg.api.ops.executioner.GridExecutioner)10 BlasException (org.nd4j.linalg.api.blas.BlasException)8 INDArrayIndex (org.nd4j.linalg.indexing.INDArrayIndex)4 ShortPointer (org.bytedeco.javacpp.ShortPointer)1 JCudaBuffer (org.nd4j.linalg.jcublas.buffer.JCudaBuffer)1