Class: SGC::CU::CUDevicePtr

Inherits:
Object
  • Object
show all
Defined in:
lib/cuda/driver/deviceptr.rb

Instance Method Summary collapse

Instance Method Details

#freeObject

Free the allocated device memory that this pointer pointing to.



35
36
37
38
39
40
# File 'lib/cuda/driver/deviceptr.rb', line 35

def free
    status = API::cuMemFree(API::read_cudeviceptr(@pdevptr))
    Pvt::handle_error(status, "Failed to free device memory.")
    API::write_cudeviceptr(@pdevptr, 0)
    nil
end

#offset(index) ⇒ CUDevicePtr

Returns A pointer pointing to the memory location index (bytes) from this pointer address.

Parameters:

  • index (Integer)

    Number of bytes to offset from this pointer address.

Returns:

  • (CUDevicePtr)

    A pointer pointing to the memory location index (bytes) from this pointer address.



46
47
48
49
50
51
# File 'lib/cuda/driver/deviceptr.rb', line 46

def offset(index)
    p = FFI::MemoryPointer.new(:CUDevicePtr)
    addr = API::read_cudeviceptr(@pdevptr).to_i + index
    API::write_cudeviceptr(p, addr)
    CUDevicePtr.send(:new, p)
end