MCPcopy Create free account
hub / github.com/apache/arrow / test_pyarrow_jit

Function test_pyarrow_jit

python/pyarrow/tests/test_cuda_numba_interop.py:219–238  ·  view source on GitHub ↗
(c, dtype)

Source from the content-addressed store, hash-verified

217 ids=context_choice_ids)
218@pytest.mark.parametrize("dtype", dtypes, ids=dtypes)
219def test_pyarrow_jit(c, dtype):
220 ctx, nb_ctx = context_choices[c]
221
222 @nb_cuda.jit
223 def increment_by_one(an_array):
224 pos = nb_cuda.grid(1)
225 if pos < an_array.size:
226 an_array[pos] += 1
227
228 # applying numba.cuda kernel to memory hold by CudaBuffer
229 size = 10
230 arr, cbuf = make_random_buffer(size, target='device', dtype=dtype, ctx=ctx)
231 threadsperblock = 32
232 blockspergrid = (arr.size + (threadsperblock - 1)) // threadsperblock
233 mem = cbuf.to_numba()
234 darr = DeviceNDArray(arr.shape, arr.strides, arr.dtype, gpu_data=mem)
235 increment_by_one[blockspergrid, threadsperblock](darr)
236 cbuf.context.synchronize()
237 arr1 = np.frombuffer(cbuf.copy_to_host(), dtype=arr.dtype)
238 np.testing.assert_equal(arr1, arr + 1)

Callers

nothing calls this directly

Calls 1

make_random_bufferFunction · 0.70

Tested by

no test coverage detected