コード例 #1
0
def check_availability(name):
    if name not in _available_cuda_version:
        msg = 'No available version information specified for {}'.name
        raise ValueError(msg)
    version_added, version_removed = _available_cuda_version[name]
    cuda_version = runtime.runtimeGetVersion()
    if version_added is not None and cuda_version < version_added:
        return False
    if version_removed is not None and cuda_version >= version_removed:
        return False
    return True
コード例 #2
0
 def call(self, env, array, index, value, value2=None):
     name = self._name
     op = self._op
     array = Data.init(array, env)
     if not isinstance(array.ctype, (_cuda_types.CArray, _cuda_types.Ptr)):
         raise TypeError('The first argument must be of array type.')
     target = _compile._indexing(array, index, env)
     ctype = target.ctype
     if ctype.dtype.name not in self._dtypes:
         raise TypeError(f'`{name}` does not support {ctype.dtype} input.')
     # On HIP, 'e' is not supported and we will never reach here
     if (op == 'Add' and ctype.dtype.char == 'e'
             and runtime.runtimeGetVersion() < 10000):
         raise RuntimeError(
             'float16 atomic operation is not supported before CUDA 10.0.')
     value = _compile._astype_scalar(value, ctype, 'same_kind', env)
     value = Data.init(value, env)
     if op == 'CAS':
         assert value2 is not None
         # On HIP, 'H' is not supported and we will never reach here
         if ctype.dtype.char == 'H':
             if runtime.runtimeGetVersion() < 10010:
                 raise RuntimeError(
                     'uint16 atomic operation is not supported before '
                     'CUDA 10.1')
             if int(device.get_compute_capability()) < 70:
                 raise RuntimeError(
                     'uint16 atomic operation is not supported before '
                     'sm_70')
         value2 = _compile._astype_scalar(value2, ctype, 'same_kind', env)
         value2 = Data.init(value2, env)
         code = f'{name}(&{target.code}, {value.code}, {value2.code})'
     else:
         assert value2 is None
         code = f'{name}(&{target.code}, {value.code})'
     return Data(code, ctype)
コード例 #3
0
 def call(self, env, array, index, value):
     array = Data.init(array, env)
     if not isinstance(array.ctype, (_cuda_types.CArray, _cuda_types.Ptr)):
         raise TypeError('The first argument must be of array type.')
     target = _compile._indexing(array, index, env)
     ctype = target.ctype
     value = _compile._astype_scalar(value, ctype, 'same_kind', env)
     name = self._name
     value = Data.init(value, env)
     if ctype.dtype.char not in self._dtypes:
         raise TypeError(f'`{name}` does not support {ctype.dtype} input.')
     if ctype.dtype.char == 'e' and runtime.runtimeGetVersion() < 10000:
         raise RuntimeError(
             'float16 atomic operation is not supported this CUDA version.')
     return Data(f'{name}(&{target.code}, {value.code})', ctype)
コード例 #4
0
def check_availability(name):
    if name not in _available_cuda_version:
        msg = 'No available version information specified for {}'.format(name)
        raise ValueError(msg)
    version_added, version_removed = _available_cuda_version[name]
    cuda_version = _runtime.runtimeGetVersion()
    if version_added is not None and cuda_version < version_added:
        return False
    if version_removed is not None and cuda_version >= version_removed:
        return False
    if name in _available_compute_capability:
        compute_capability = int(_device.get_compute_capability())
        if compute_capability < _available_compute_capability[name]:
            return False
    return True
コード例 #5
0
ファイル: compiler.py プロジェクト: takagi/cupy
def _get_arch_for_options_for_nvrtc(arch=None):
    # NVRTC in CUDA 11.3+ generates PTX that cannot be run an earlier driver
    # version than the one included in the used CUDA version, as
    # documented in:
    # https://docs.nvidia.com/cuda/archive/11.3.0/nvrtc/index.html#versioning
    # Here we use `-arch=sm_*` instead of `-arch=compute_*` to directly
    # generate cubin (SASS) instead of PTX. See #5097 for details.
    if arch is None:
        arch = _get_arch()
    if driver._is_cuda_python():
        version = runtime.runtimeGetVersion()
    else:
        version = _cuda_hip_version
    if (not _use_ptx and version >= 11010
            and arch <= _get_max_compute_capability()):
        return f'-arch=sm_{arch}', 'cubin'
    return f'-arch=compute_{arch}', 'ptx'
コード例 #6
0
ファイル: cusolver.py プロジェクト: srijan-deepsource/cupy
def check_availability(name):
    if not _runtime.is_hip:
        available_version = _available_cuda_version
        version = _runtime.runtimeGetVersion()
    else:
        available_version = _available_hip_version
        # TODO(leofang): use HIP_VERSION instead?
        version = _cusolver._getVersion()
        version = version[0] * 100 + version[1]
    if name not in available_version:
        msg = 'No available version information specified for {}'.format(name)
        raise ValueError(msg)
    version_added, version_removed = available_version[name]
    if version_added is not None and version < version_added:
        return False
    if version_removed is not None and version >= version_removed:
        return False
    # CUDA specific stuff
    if name in _available_compute_capability:
        compute_capability = int(_device.get_compute_capability())
        if compute_capability < _available_compute_capability[name]:
            return False
    return True
コード例 #7
0
def default_rng(seed=None):  # NOQA  avoid redefinition of seed
    """Construct a new Generator with the default BitGenerator (XORWOW).

    Args:
        seed (None, int, array_like[ints], numpy.random.SeedSequence, cupy.random.BitGenerator, cupy.random.Generator, optional):
            A seed to initialize the :class:`cupy.random.BitGenerator`. If an
            ``int`` or ``array_like[ints]`` or None is passed, then it will be
            passed to :class:`numpy.random.SeedSequence` to detive the initial
            :class:`BitGenerator` state. One may also pass in a `SeedSequence
            instance. Adiditionally, when passed :class:`BitGenerator`, it will
            be wrapped by :class:`Generator`. If passed a :class:`Generator`,
            it will be returned unaltered.

    Returns:
        Generator: The initialized generator object.
    """  # NOQA, list of types need to be in one line for sphinx
    if runtime.is_hip and int(str(runtime.runtimeGetVersion())[:3]) < 403:
        raise RuntimeError('Generator API not supported in ROCm<4.3,'
                           ' please use the legacy one or update ROCm.')
    if isinstance(seed, BitGenerator):
        return Generator(seed)
    elif isinstance(seed, Generator):
        return seed
    return Generator(XORWOW(seed))