本文整理汇总了Python中pycuda.characterize.has_double_support函数的典型用法代码示例。如果您正苦于以下问题:Python has_double_support函数的具体用法?Python has_double_support怎么用?Python has_double_support使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_double_support函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: do_generate
def do_generate(out_type):
result = True
if "double" in out_type:
result = result and has_double_support()
if "2" in out_type:
result = result and self.has_box_muller
return result
开发者ID:hannes-brt,项目名称:pycuda,代码行数:7,代码来源:curandom.py
示例2: test_subset_minmax
def test_subset_minmax(self):
from pycuda.curandom import rand as curand
l_a = 200000
gran = 5
l_m = l_a - l_a // gran + 1
if has_double_support():
dtypes = [np.float64, np.float32, np.int32]
else:
dtypes = [np.float32, np.int32]
for dtype in dtypes:
a_gpu = curand((l_a,), dtype)
a = a_gpu.get()
meaningful_indices_gpu = gpuarray.zeros(l_m, dtype=np.int32)
meaningful_indices = meaningful_indices_gpu.get()
j = 0
for i in range(len(meaningful_indices)):
meaningful_indices[i] = j
j = j + 1
if j % gran == 0:
j = j + 1
meaningful_indices_gpu = gpuarray.to_gpu(meaningful_indices)
b = a[meaningful_indices]
min_a = np.min(b)
min_a_gpu = gpuarray.subset_min(meaningful_indices_gpu, a_gpu).get()
assert min_a_gpu == min_a
开发者ID:rutsky,项目名称:pycuda,代码行数:32,代码来源:test_gpuarray.py
示例3: test_curand_wrappers
def test_curand_wrappers(self):
from pycuda.curandom import get_curand_version
if get_curand_version() is None:
from pytest import skip
skip("curand not installed")
from pycuda.curandom import (
XORWOWRandomNumberGenerator,
Sobol32RandomNumberGenerator)
if has_double_support():
dtypes = [np.float32, np.float64]
else:
dtypes = [np.float32]
for gen_type in [
XORWOWRandomNumberGenerator,
#Sobol32RandomNumberGenerator
]:
gen = gen_type()
for dtype in dtypes:
gen.gen_normal(10000, dtype)
# test non-Box-Muller version, if available
gen.gen_normal(10001, dtype)
x = gen.gen_uniform(10000, dtype)
x_host = x.get()
assert (-1 <= x_host).all()
assert (x_host <= 1).all()
gen.gen_uniform(10000, np.uint32)
开发者ID:bryancatanzaro,项目名称:catanzaro.pycuda,代码行数:33,代码来源:test_gpuarray.py
示例4: test_curand_wrappers
def test_curand_wrappers(self):
from pycuda.curandom import get_curand_version
if get_curand_version() is None:
from pytest import skip
skip("curand not installed")
generator_types = []
if get_curand_version() >= (3, 2, 0):
from pycuda.curandom import XORWOWRandomNumberGenerator, Sobol32RandomNumberGenerator
generator_types.extend([XORWOWRandomNumberGenerator, Sobol32RandomNumberGenerator])
if get_curand_version() >= (4, 0, 0):
from pycuda.curandom import (
ScrambledSobol32RandomNumberGenerator,
Sobol64RandomNumberGenerator,
ScrambledSobol64RandomNumberGenerator,
)
generator_types.extend(
[
ScrambledSobol32RandomNumberGenerator,
Sobol64RandomNumberGenerator,
ScrambledSobol64RandomNumberGenerator,
]
)
if get_curand_version() >= (4, 1, 0):
from pycuda.curandom import MRG32k3aRandomNumberGenerator
generator_types.extend([MRG32k3aRandomNumberGenerator])
if has_double_support():
dtypes = [np.float32, np.float64]
else:
dtypes = [np.float32]
for gen_type in generator_types:
gen = gen_type()
for dtype in dtypes:
gen.gen_normal(10000, dtype)
# test non-Box-Muller version, if available
gen.gen_normal(10001, dtype)
if get_curand_version() >= (4, 0, 0):
gen.gen_log_normal(10000, dtype, 10.0, 3.0)
# test non-Box-Muller version, if available
gen.gen_log_normal(10001, dtype, 10.0, 3.0)
x = gen.gen_uniform(10000, dtype)
x_host = x.get()
assert (-1 <= x_host).all()
assert (x_host <= 1).all()
gen.gen_uniform(10000, np.uint32)
if get_curand_version() >= (5, 0, 0):
gen.gen_poisson(10000, np.uint32, 13.0)
开发者ID:fjarri,项目名称:pycuda,代码行数:58,代码来源:test_gpuarray.py
示例5: test_random
def test_random(self):
from pycuda.curandom import rand as curand
if has_double_support():
dtypes = [np.float32, np.float64]
else:
dtypes = [np.float32]
for dtype in dtypes:
a = curand((10, 100), dtype=dtype).get()
assert (0 <= a).all()
assert (a < 1).all()
开发者ID:rutsky,项目名称:pycuda,代码行数:13,代码来源:test_gpuarray.py
示例6: test_minmax
def test_minmax(self):
from pycuda.curandom import rand as curand
if has_double_support():
dtypes = [np.float64, np.float32, np.int32]
else:
dtypes = [np.float32, np.int32]
for what in ["min", "max"]:
for dtype in dtypes:
a_gpu = curand((200000,), dtype)
a = a_gpu.get()
op_a = getattr(np, what)(a)
op_a_gpu = getattr(gpuarray, what)(a_gpu).get()
assert op_a_gpu == op_a, (op_a_gpu, op_a, dtype, what)
开发者ID:rutsky,项目名称:pycuda,代码行数:17,代码来源:test_gpuarray.py
示例7: test_complex_bits
def test_complex_bits(self):
from pycuda.curandom import rand as curand
if has_double_support():
dtypes = [np.complex64, np.complex128]
else:
dtypes = [np.complex64]
n = 20
for tp in dtypes:
dtype = np.dtype(tp)
from pytools import match_precision
real_dtype = match_precision(np.dtype(np.float64), dtype)
z = (curand((n,), real_dtype).astype(dtype)
+ 1j*curand((n,), real_dtype).astype(dtype))
assert la.norm(z.get().real - z.real.get()) == 0
assert la.norm(z.get().imag - z.imag.get()) == 0
assert la.norm(z.get().conj() - z.conj().get()) == 0
开发者ID:rutsky,项目名称:pycuda,代码行数:20,代码来源:test_gpuarray.py
示例8: test_astype
def test_astype(self):
from pycuda.curandom import rand as curand
if not has_double_support():
return
a_gpu = curand((2000,), dtype=np.float32)
a = a_gpu.get().astype(np.float64)
a2 = a_gpu.astype(np.float64).get()
assert a2.dtype == np.float64
assert la.norm(a - a2) == 0, (a, a2)
a_gpu = curand((2000,), dtype=np.float64)
a = a_gpu.get().astype(np.float32)
a2 = a_gpu.astype(np.float32).get()
assert a2.dtype == np.float32
assert la.norm(a - a2)/la.norm(a) < 1e-7
开发者ID:rutsky,项目名称:pycuda,代码行数:21,代码来源:test_gpuarray.py
示例9: test_complex_bits
def test_complex_bits(self):
from pycuda.curandom import rand as curand
if has_double_support():
dtypes = [np.complex64, np.complex128]
else:
dtypes = [np.complex64]
n = 20
for tp in dtypes:
dtype = np.dtype(tp)
from pytools import match_precision
real_dtype = match_precision(np.dtype(np.float64), dtype)
z = (curand((n,), real_dtype).astype(dtype)
+ 1j*curand((n,), real_dtype).astype(dtype))
assert la.norm(z.get().real - z.real.get()) == 0
assert la.norm(z.get().imag - z.imag.get()) == 0
assert la.norm(z.get().conj() - z.conj().get()) == 0
# verify contiguity is preserved
for order in ["C", "F"]:
# test both zero and non-zero value code paths
z_real = gpuarray.zeros(z.shape, dtype=real_dtype,
order=order)
z2 = z.reshape(z.shape, order=order)
for zdata in [z_real, z2]:
if order == "C":
assert zdata.flags.c_contiguous == True
assert zdata.real.flags.c_contiguous == True
assert zdata.imag.flags.c_contiguous == True
assert zdata.conj().flags.c_contiguous == True
elif order == "F":
assert zdata.flags.f_contiguous == True
assert zdata.real.flags.f_contiguous == True
assert zdata.imag.flags.f_contiguous == True
assert zdata.conj().flags.f_contiguous == True
开发者ID:grlee77,项目名称:pycuda,代码行数:38,代码来源:test_gpuarray.py
示例10: _get_common_dtype
def _get_common_dtype(obj1, obj2):
return _get_common_dtype_base(obj1, obj2, has_double_support())
开发者ID:Benli11,项目名称:pycuda,代码行数:2,代码来源:gpuarray.py
注:本文中的pycuda.characterize.has_double_support函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论