def _call_join_multi(api, ncols, col_left, col_right, ctxt): join_result_ptr = ffi.new("gdf_join_result_type**", None) api(ncols, col_left, col_right, join_result_ptr, ctxt) join_result = join_result_ptr[0] print('join_result', join_result) dataptr = libgdf.gdf_join_result_data(join_result) print(dataptr) datasize = libgdf.gdf_join_result_size(join_result) print(datasize) addr = ctypes.c_uint64(int(ffi.cast("uintptr_t", dataptr))) print(hex(addr.value)) memptr = cuda.driver.MemoryPointer(context=cuda.current_context(), pointer=addr, size=4 * datasize) print(memptr) ary = cuda.devicearray.DeviceNDArray(shape=(datasize, ), strides=(4, ), dtype=np.dtype(np.int32), gpu_data=memptr) joined_idx = ary.reshape(2, datasize // 2).copy_to_host() print(joined_idx) libgdf.gdf_join_result_free(join_result) return joined_idx
def apply_join(col_lhs, col_rhs, how): """Returns a tuple of the left and right joined indices as gpu arrays. """ if (len(col_lhs) != len(col_rhs)): msg = "Unequal #columns in list 'col_lhs' and list 'col_rhs'" raise ValueError(msg) joiner = _join_how_api[how] join_result_ptr = ffi.new("gdf_join_result_type**", None) if (how == 'left'): list_lhs = [] list_rhs = [] for i in range(len(col_lhs)): list_lhs.append(col_lhs[i].cffi_view) list_rhs.append(col_rhs[i].cffi_view) # Call libgdf joiner(len(col_lhs), list_lhs, list_rhs, join_result_ptr) else: joiner(col_lhs[0].cffi_view, col_rhs[0].cffi_view, join_result_ptr) # Extract result join_result = join_result_ptr[0] dataptr = libgdf.gdf_join_result_data(join_result) datasize = libgdf.gdf_join_result_size(join_result) ary = _as_numba_devarray(intaddr=int(ffi.cast("uintptr_t", dataptr)), nelem=datasize, dtype=np.int32) ary = ary.reshape(2, datasize // 2) yield ((ary[0], ary[1]) if datasize > 0 else (ary, ary)) libgdf.gdf_join_result_free(join_result)
def apply_join(col_lhs, col_rhs, how): """Returns a tuple of the left and right joined indices as gpu arrays. """ joiner = _join_how_api[how] join_result_ptr = ffi.new("gdf_join_result_type**", None) # Call libgdf joiner(col_lhs.cffi_view, col_rhs.cffi_view, join_result_ptr) # Extract result join_result = join_result_ptr[0] dataptr = libgdf.gdf_join_result_data(join_result) datasize = libgdf.gdf_join_result_size(join_result) ary = _as_numba_devarray(intaddr=int(ffi.cast("uintptr_t", dataptr)), nelem=datasize, dtype=np.int32) ary = ary.reshape(2, datasize // 2) yield ((ary[0], ary[1]) if datasize > 0 else (ary, ary)) libgdf.gdf_join_result_free(join_result)