1from numba.cuda.cudadrv import devices, driver 2from numba.core.registry import cpu_target 3 4 5def _calc_array_sizeof(ndim): 6 """ 7 Use the ABI size in the CPU target 8 """ 9 ctx = cpu_target.target_context 10 return ctx.calc_array_sizeof(ndim) 11 12 13def ndarray_device_allocate_data(ary): 14 """ 15 Allocate gpu data buffer 16 """ 17 datasize = driver.host_memory_size(ary) 18 # allocate 19 gpu_data = devices.get_context().memalloc(datasize) 20 return gpu_data 21