Exemple #1
0
def test_managed_memory():
    cp.cuda.set_allocator(cp.cuda.malloc_managed)

    gpu_arr = cp.ones((10, 10, 10))
    cpu_view = gt_storage_utils.cpu_view(gpu_arr)

    gpu_arr[0, 0, 0] = 123
    cp.cuda.runtime.deviceSynchronize()
    assert cpu_view[0, 0, 0] == 123
    cpu_view[1, 1, 1] = 321
    assert gpu_arr[1, 1, 1] == 321
Exemple #2
0
def test_managed_memory():
    cp.cuda.set_allocator(cp.cuda.malloc_managed)
    gpu_arr = cp.empty((5, 5, 5))

    gpu_arr = cp.ones((10, 10, 10))
    cpu_view = gt_storage_utils.cpu_view(gpu_arr)

    gpu_arr[0, 0, 0] = 123
    assert cpu_view[0, 0, 0] == 123
    cpu_view[1, 1, 1] = 321
    assert gpu_arr[1, 1, 1] == 321
Exemple #3
0
def test_view_casting():
    cp.cuda.set_allocator(cp.cuda.malloc_managed)
    gpu_arr = cp.empty((5, 5, 5))

    gpu_arr = cp.ones((10, 10, 10))
    cpu_view = gt_storage_utils.cpu_view(gpu_arr)
    assert cpu_view.ctypes.data == gpu_arr.data.ptr
    assert cpu_view.strides == gpu_arr.strides
    assert cpu_view.shape == gpu_arr.shape

    gpu_view = gt_storage_utils.gpu_view(cpu_view)
    assert gpu_view.data.ptr == cpu_view.ctypes.data
    assert gpu_view.strides == cpu_view.strides
    assert gpu_view.shape == cpu_view.shape