1# Re export
2from .stubs import (threadIdx, blockIdx, blockDim, gridDim, laneid,
3                    warpsize, syncthreads, syncthreads_count, syncwarp,
4                    syncthreads_and, syncthreads_or, shared, local,
5                    const, grid, gridsize, atomic, shfl_sync_intrinsic,
6                    vote_sync_intrinsic, match_any_sync, match_all_sync,
7                    threadfence_block, threadfence_system,
8                    threadfence, selp, popc, brev, clz, ffs, fma)
9from .cudadrv.error import CudaSupportError
10from numba.cuda.cudadrv.driver import (BaseCUDAMemoryManager,
11                                       HostOnlyCUDAMemoryManager,
12                                       GetIpcHandleMixin, MemoryPointer,
13                                       MappedMemory, PinnedMemory, MemoryInfo,
14                                       IpcHandle, set_memory_manager)
15from numba.cuda.cudadrv.runtime import runtime
16from .cudadrv import nvvm
17from numba.cuda import initialize
18from .errors import KernelRuntimeError
19
20from .decorators import jit, declare_device
21from .api import *
22from .api import _auto_device
23
24from .kernels import reduction
25reduce = Reduce = reduction.Reduce
26
27from .intrinsic_wrapper import (all_sync, any_sync, eq_sync, ballot_sync,
28                                shfl_sync, shfl_up_sync, shfl_down_sync,
29                                shfl_xor_sync)
30
31
32def is_available():
33    """Returns a boolean to indicate the availability of a CUDA GPU.
34
35    This will initialize the driver if it hasn't been initialized.
36    """
37    # whilst `driver.is_available` will init the driver itself,
38    # the driver initialization may raise and as a result break
39    # test discovery/orchestration as `cuda.is_available` is often
40    # used as a guard for whether to run a CUDA test, the try/except
41    # below is to handle this case.
42    driver_is_available = False
43    try:
44        driver_is_available = driver.driver.is_available
45    except CudaSupportError:
46        pass
47
48    return driver_is_available and nvvm.is_available()
49
50def cuda_error():
51    """Returns None or an exception if the CUDA driver fails to initialize.
52    """
53    return driver.driver.initialization_error
54
55initialize.initialize_all()
56