Repository: numba/numba

Issue:
CUDA: Managed alloc test fail on Jetson AGX Xavier
Message from test suite:

```
======================================================================
ERROR: test_managed_alloc_driver_host_attach (numba.cuda.tests.cudadrv.test_managed_alloc.TestManagedAlloc)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gmarkall/numbadev/numba/numba/cuda/tests/cudadrv/test_managed_alloc.py", line 67, in test_managed_alloc_driver_host_attach
    self._test_managed_alloc_driver(0.01, attach_global=False)
  File "/home/gmarkall/numbadev/numba/numba/cuda/tests/cudadrv/test_managed_alloc.py", line 84, in _test_managed_alloc_driver
    device_memset(mem, magic, n_bytes)
  File "/home/gmarkall/numbadev/numba/numba/cuda/cudadrv/driver.py", line 2469, in device_memset
    fn(device_pointer(dst), val, size, *varargs)
  File "/home/gmarkall/numbadev/numba/numba/cuda/cudadrv/driver.py", line 302, in safe_cuda_api_call
    self._check_error(fname, retcode)
  File "/home/gmarkall/numbadev/numba/numba/cuda/cudadrv/driver.py", line 342, in _check_error
    raise CudaAPIError(retcode, msg)
numba.cuda.cudadrv.driver.CudaAPIError: [1] Call to cuMemsetD8 results in CUDA_ERROR_INVALID_VALUE
```

During the test run, the following is also emitted:

```
test_managed_alloc_driver_host_attach (numba.cuda.tests.cudadrv.test_managed_alloc.TestManagedAlloc) ... ERROR
test_managed_alloc_driver_oversubscribe (numba.cuda.tests.cudadrv.test_managed_alloc.TestManagedAlloc) ... skipped ''
test_managed_alloc_driver_undersubscribe (numba.cuda.tests.cudadrv.test_managed_alloc.TestManagedAlloc) ... NvMapReserveOp 0x80000001 failed [22]
NvMapReserveOp 0x80000000 failed [22]
```


Discussion:

Resolving patch:
diff --git a/numba/cuda/api.py b/numba/cuda/api.py
--- a/numba/cuda/api.py
+++ b/numba/cuda/api.py
@@ -146,8 +146,8 @@ def managed_array(shape, dtype=np.float_, strides=None, order='C', stream=0,
     Allocate a np.ndarray with a buffer that is managed.
     Similar to np.empty().
 
-    Managed memory is supported on Linux, and is considered experimental on
-    Windows.
+    Managed memory is supported on Linux / x86 and PowerPC, and is considered
+    experimental on Windows and Linux / AArch64.
 
     :param attach_global: A flag indicating whether to attach globally. Global
                           attachment implies that the memory is accessible from


Test patch:
diff --git a/numba/cuda/testing.py b/numba/cuda/testing.py
--- a/numba/cuda/testing.py
+++ b/numba/cuda/testing.py
@@ -1,5 +1,6 @@
 import contextlib
 import os
+import platform
 import shutil
 import sys
 
@@ -99,6 +100,12 @@ def skip_with_nvdisasm(reason):
     return unittest.skipIf(nvdisasm_path is not None, reason)
 
 
+def skip_on_arm(reason):
+    cpu = platform.processor()
+    is_arm = cpu.startswith('arm') or cpu.startswith('aarch')
+    return unittest.skipIf(is_arm, reason)
+
+
 def cc_X_or_above(major, minor):
     if not config.ENABLE_CUDASIM:
         cc = devices.get_context().device.compute_capability
diff --git a/numba/cuda/tests/cudadrv/test_managed_alloc.py b/numba/cuda/tests/cudadrv/test_managed_alloc.py
--- a/numba/cuda/tests/cudadrv/test_managed_alloc.py
+++ b/numba/cuda/tests/cudadrv/test_managed_alloc.py
@@ -3,12 +3,13 @@
 from numba.cuda.cudadrv.driver import device_memset, driver
 from numba import cuda
 from numba.cuda.testing import unittest, ContextResettingTestCase
-from numba.cuda.testing import skip_on_cudasim
+from numba.cuda.testing import skip_on_cudasim, skip_on_arm
 from numba.tests.support import linux_only
 
 
 @skip_on_cudasim('CUDA Driver API unsupported in the simulator')
 @linux_only
+@skip_on_arm('Managed Alloc support is experimental/untested on ARM')
 class TestManagedAlloc(ContextResettingTestCase):
 
     def get_total_gpu_memory(self):