当前位置: 首页>>代码示例>>Java>>正文


Java Pointer.address方法代码示例

本文整理汇总了Java中org.bytedeco.javacpp.Pointer.address方法的典型用法代码示例。如果您正苦于以下问题:Java Pointer.address方法的具体用法?Java Pointer.address怎么用?Java Pointer.address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bytedeco.javacpp.Pointer的用法示例。


在下文中一共展示了Pointer.address方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: memcpyAsync

import org.bytedeco.javacpp.Pointer; //导入方法依赖的package包/类
/**
 * Asynchronous version of memcpy
 *
 * PLEASE NOTE: This is device-dependent method, if it's not supported in your environment, blocking call will be used instead.
 *
 * @param dstBuffer
 * @param srcPointer
 * @param length
 * @param dstOffset
 */
@Override
public void memcpyAsync(DataBuffer dstBuffer, Pointer srcPointer, long length, long dstOffset) {
    AllocationPoint point = ((BaseCudaDataBuffer) dstBuffer).getAllocationPoint();
    // we update host memory regardless.
    //Pointer dP = new Pointer((point.getAllocationStatus() == AllocationStatus.DEVICE ? point.getPointers().getDevicePointer().address() : point.getPointers().getHostPointer().address()) + dstOffset);
    Pointer dP = new CudaPointer((point.getPointers().getHostPointer().address()) + dstOffset);
    //        Pointer sP = new Pointer(srcPointer.getNativePointer());
    //log.info("Location: " + point.getAllocationStatus());
    //        if (length > 4)
    //log.info("memcpyAsync:  ["+ srcPointer.getNativePointer()+"] -> ["+ dP.getNativePointer()+"], length: [" + length+ "], offset: ["+ dstOffset+"], dstBufferOffset: ["+(dstBuffer.getElementSize() * dstBuffer.offset()) + "/" + dstBuffer.offset() +"]");

    CudaContext tContext = null;

    if (dstBuffer.isConstant()) {

        org.bytedeco.javacpp.Pointer dstPointer =
                        new CudaPointer(point.getPointers().getHostPointer().address() + dstOffset, 0L);
        org.bytedeco.javacpp.Pointer srcPointerJ = new CudaPointer(srcPointer, length);

        //   log.info("JCPP Memcpy: [{}] -> [{}], length: [{}]", srcPointerJ.address(), dstPointer.address(), length);

        org.bytedeco.javacpp.Pointer.memcpy(dstPointer, srcPointerJ, length);

        point.tickHostRead();
    } else {
        //log.info("Memcpy pointers: [{}] -> [{}]", srcPointer.address(),  dP.address());

        CudaContext context = flowController.prepareAction(point);
        tContext = context;
        if (nativeOps.memcpyAsync(dP, srcPointer, length, CudaConstants.cudaMemcpyHostToHost,
                        context.getSpecialStream()) == 0)
            throw new IllegalStateException(
                            "MemcpyAsync H2H failed: [" + srcPointer.address() + "] -> [" + dP.address() + "]");

        flowController.commitTransfer(tContext.getSpecialStream());

        if (point.getAllocationStatus() == AllocationStatus.HOST)
            flowController.registerAction(context, point);
    }

    // if we're copying something into host memory, but we're on device - we need to provide exact copy to device as well
    if (point.getAllocationStatus() == AllocationStatus.DEVICE) {
        // TODO: this sounds wrong, and probably memcpy whould check initial direction, like relocate did before
        Pointer rDP = new CudaPointer(point.getPointers().getDevicePointer().address() + dstOffset);

        if (tContext == null)
            tContext = flowController.prepareAction(point);
        //log.info("MemcpyAsync to device... [{}] -> [{}]", dP.getNativePointer(), rDP.getNativePointer());

        if (nativeOps.memcpyAsync(rDP, dP, length, CudaConstants.cudaMemcpyHostToDevice,
                        tContext.getSpecialStream()) == 0)
            throw new IllegalStateException(
                            "MemcpyAsync H2D failed: [" + dP.address() + "] -> [" + rDP.address() + "]");

        flowController.commitTransfer(tContext.getSpecialStream());

        flowController.registerAction(tContext, point);


    }
    point.tickDeviceWrite();
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:73,代码来源:CudaZeroHandler.java

示例2: allocate

import org.bytedeco.javacpp.Pointer; //导入方法依赖的package包/类
/**
 * This method returns
 * PLEASE NOTE: Cache options depend on specific implementations
 *
 * @param bytes
 * @param kind
 * @param initialize
 */
@Override
public Pointer allocate(long bytes, MemoryKind kind, boolean initialize) {
    Pointer ptr = NativeOpsHolder.getInstance().getDeviceNativeOps().mallocHost(bytes, 0);

    if (ptr == null || ptr.address() == 0L)
        throw new ND4JIllegalStateException("Failed to allocate [" + bytes + "] bytes");

    //log.info("Allocating {} bytes at MemoryManager", bytes);


    if (initialize)
        Pointer.memset(ptr, 0, bytes);

    return ptr;
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:24,代码来源:CpuMemoryManager.java

示例3: LongPointerWrapper

import org.bytedeco.javacpp.Pointer; //导入方法依赖的package包/类
public LongPointerWrapper(Pointer pointer) {
    this.address = pointer.address();
    this.capacity = pointer.capacity();
    this.limit = pointer.limit();
    this.position = pointer.position();
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:7,代码来源:LongPointerWrapper.java


注:本文中的org.bytedeco.javacpp.Pointer.address方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。