def test_nowarn_on_managed_array(self):
        @cuda.jit
        def foo(r, x):
            r[0] = x + 1

        N = 10
        ary = cuda.managed_array(N, dtype=np.float32)

        with override_config('CUDA_WARN_ON_IMPLICIT_COPY', 1):
            with warnings.catch_warnings(record=True) as w:
                foo[1, N](ary, N)

        self.assertEqual(len(w), 0)
Exemple #2
0
    def _test_managed_array(self, attach_global=True):
        # Check the managed_array interface on both host and device.

        ary = cuda.managed_array(100, dtype=np.double)
        ary.fill(123.456)
        self.assertTrue(all(ary == 123.456))

        @cuda.jit('void(double[:])')
        def kernel(x):
            i = cuda.grid(1)
            if i < x.shape[0]:
                x[i] = 1.0

        kernel[10, 10](ary)
        cuda.current_context().synchronize()

        self.assertTrue(all(ary == 1.0))
 def test_produce_managed_stream(self):
     s = cuda.stream()
     managed_arr = cuda.managed_array(10, stream=s)
     cai_stream = managed_arr.__cuda_array_interface__['stream']
     self.assertEqual(s.handle.value, cai_stream)
 def test_produce_managed_no_stream(self):
     managed_arr = cuda.managed_array(10)
     self.assertIsNone(managed_arr.__cuda_array_interface__['stream'])