本文整理汇总了Python中pycuda._pvt_struct.pack函数的典型用法代码示例。如果您正苦于以下问题:Python pack函数的具体用法?Python pack怎么用?Python pack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pack函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: function_prepared_async_call_pre_v4
def function_prepared_async_call_pre_v4(func, grid, block, stream, *args, **kwargs):
if isinstance(block, tuple):
func._set_block_shape(*block)
else:
from warnings import warn
warn("Not passing the block size to prepared_async_call is deprecated as of "
"version 2011.1.", DeprecationWarning, stacklevel=2)
args = (stream,) + args
stream = block
shared_size = kwargs.pop("shared_size", None)
if shared_size is not None:
func._set_shared_size(shared_size)
if kwargs:
raise TypeError("unknown keyword arguments: "
+ ", ".join(kwargs.iterkeys()))
from pycuda._pvt_struct import pack
func._param_setv(0, pack(func.arg_format, *args))
for texref in func.texrefs:
func.param_set_texref(texref)
if stream is None:
func._launch_grid(*grid)
else:
grid_x, grid_y = grid
func._launch_grid_async(grid_x, grid_y, stream)
开发者ID:abergeron,项目名称:pycuda,代码行数:29,代码来源:driver.py
示例2: _build_arg_buf
def _build_arg_buf(args):
handlers = []
arg_data = []
format = ""
for i, arg in enumerate(args):
if isinstance(arg, np.number):
arg_data.append(arg)
format += arg.dtype.char
elif isinstance(arg, (DeviceAllocation, PooledDeviceAllocation)):
arg_data.append(int(arg))
format += "P"
elif isinstance(arg, ArgumentHandler):
handlers.append(arg)
arg_data.append(int(arg.get_device_alloc()))
format += "P"
elif isinstance(arg, np.ndarray):
arg_data.append(arg)
format += "%ds" % arg.nbytes
else:
try:
gpudata = np.intp(arg.gpudata)
except AttributeError:
raise TypeError("invalid type on parameter #%d (0-based)" % i)
else:
# for gpuarrays
arg_data.append(int(gpudata))
format += "P"
from pycuda._pvt_struct import pack
return handlers, pack(format, *arg_data)
开发者ID:abergeron,项目名称:pycuda,代码行数:31,代码来源:driver.py
示例3: function_prepared_timed_call_pre_v4
def function_prepared_timed_call_pre_v4(func, grid, block, *args, **kwargs):
if isinstance(block, tuple):
func._set_block_shape(*block)
else:
from warnings import warn
warn("Not passing the block size to prepared_timed_call is deprecated as of "
"version 2011.1.", DeprecationWarning, stacklevel=2)
args = (block,) + args
shared_size = kwargs.pop("shared_size", None)
if shared_size is not None:
func._set_shared_size(shared_size)
if kwargs:
raise TypeError("unknown keyword arguments: "
+ ", ".join(kwargs.iterkeys()))
from pycuda._pvt_struct import pack
func._param_setv(0, pack(func.arg_format, *args))
for texref in func.texrefs:
func.param_set_texref(texref)
start = Event()
end = Event()
start.record()
func._launch_grid(*grid)
end.record()
def get_call_time():
end.synchronize()
return end.time_since(start)*1e-3
return get_call_time
开发者ID:abergeron,项目名称:pycuda,代码行数:35,代码来源:driver.py
示例4: function_prepared_async_call
def function_prepared_async_call(func, grid, block, stream, *args, **kwargs):
if isinstance(block, tuple):
func._set_block_shape(*block)
else:
from warnings import warn
warn(
"Not passing the block size to prepared_async_call is deprecated as of " "version 2011.1.",
DeprecationWarning,
stacklevel=2,
)
args = (stream,) + args
stream = block
shared_size = kwargs.pop("shared_size", 0)
if kwargs:
raise TypeError("unknown keyword arguments: " + ", ".join(kwargs.iterkeys()))
from pycuda._pvt_struct import pack
arg_buf = pack(func.arg_format, *args)
for texref in func.texrefs:
func.param_set_texref(texref)
func._launch_kernel(grid, block, arg_buf, shared_size, stream)
开发者ID:leifdenby,项目名称:pycuda,代码行数:27,代码来源:driver.py
示例5: function_prepared_timed_call
def function_prepared_timed_call(func, grid, block, *args, **kwargs):
if isinstance(block, tuple):
func._set_block_shape(*block)
else:
from warnings import warn
warn("Not passing the block size to prepared_timed_call is deprecated as of "
"version 2011.1.", DeprecationWarning, stacklevel=2)
args = (block,) + args
from pycuda._pvt_struct import pack
func._param_setv(0, pack(func.arg_format, *args))
for texref in func.texrefs:
func.param_set_texref(texref)
start = Event()
end = Event()
start.record()
func._launch_grid(*grid)
end.record()
def get_call_time():
end.synchronize()
return end.time_since(start)*1e-3
return get_call_time
开发者ID:bryancatanzaro,项目名称:catanzaro.pycuda,代码行数:27,代码来源:driver.py
示例6: function_prepared_async_call
def function_prepared_async_call(func, grid, block, stream, *args, **kwargs):
if isinstance(block, tuple):
func._set_block_shape(*block)
else:
from warnings import warn
warn(
"Not passing the block size to prepared_async_call is deprecated as of " "version 2011.1.",
DeprecationWarning,
stacklevel=2,
)
args = (stream,) + args
stream = block
from pycuda._pvt_struct import pack
func._param_setv(0, pack(func.arg_format, *args))
for texref in func.texrefs:
func.param_set_texref(texref)
if stream is None:
func._launch_grid(*grid)
else:
grid_x, grid_y = grid
func._launch_grid_async(grid_x, grid_y, stream)
开发者ID:andrewcron,项目名称:pycuda,代码行数:26,代码来源:driver.py
示例7: function_prepared_call
def function_prepared_call(func, grid, *args):
from pycuda._pvt_struct import pack
func.param_setv(0, pack(func.arg_format, *args))
for texref in func.texrefs:
func.param_set_texref(texref)
func.launch_grid(*grid)
开发者ID:spatel81,项目名称:pycuda,代码行数:8,代码来源:driver.py
示例8: function_prepared_async_call
def function_prepared_async_call(func, grid, stream, *args):
from pycuda._pvt_struct import pack
func.param_setv(0, pack(func.arg_format, *args))
for texref in func.texrefs:
func.param_set_texref(texref)
if stream is None:
func.launch_grid(*grid)
else:
grid_x, grid_y = grid
func.launch_grid_async(grid_x, grid_y, stream)
开发者ID:spatel81,项目名称:pycuda,代码行数:12,代码来源:driver.py
示例9: function_prepared_timed_call
def function_prepared_timed_call(func, grid, *args):
from pycuda._pvt_struct import pack
func.param_setv(0, pack(func.arg_format, *args))
for texref in func.texrefs:
func.param_set_texref(texref)
start = Event()
end = Event()
start.record()
func.launch_grid(*grid)
end.record()
def get_call_time():
end.synchronize()
return end.time_since(start)*1e-3
return get_call_time
开发者ID:spatel81,项目名称:pycuda,代码行数:19,代码来源:driver.py
示例10: function_param_set
def function_param_set(func, *args):
try:
import numpy
except ImportError:
numpy = None
handlers = []
arg_data = []
format = ""
for i, arg in enumerate(args):
if numpy is not None and isinstance(arg, numpy.number):
arg_data.append(arg)
format += arg.dtype.char
elif isinstance(arg, (DeviceAllocation, PooledDeviceAllocation)):
arg_data.append(int(arg))
format += "P"
elif isinstance(arg, ArgumentHandler):
handlers.append(arg)
arg_data.append(int(arg.get_device_alloc()))
format += "P"
elif isinstance(arg, buffer):
arg_data.append(arg)
format += "s"
else:
try:
gpudata = arg.gpudata
except AttributeError:
raise TypeError("invalid type on parameter #%d (0-based)" % i)
else:
# for gpuarrays
arg_data.append(int(gpudata))
format += "P"
from pycuda._pvt_struct import pack
buf = pack(format, *arg_data)
func.param_setv(0, buf)
func.param_set_size(len(buf))
return handlers
开发者ID:minrk,项目名称:PyCUDA,代码行数:42,代码来源:driver.py
示例11: function_prepared_timed_call
def function_prepared_timed_call(func, grid, block, *args, **kwargs):
shared_size = kwargs.pop("shared_size", 0)
if kwargs:
raise TypeError("unknown keyword arguments: "
+ ", ".join(kwargs.iterkeys()))
from pycuda._pvt_struct import pack
arg_buf = pack(func.arg_format, *args)
for texref in func.texrefs:
func.param_set_texref(texref)
start = Event()
end = Event()
start.record()
func._launch_kernel(grid, block, arg_buf, shared_size, None)
end.record()
def get_call_time():
end.synchronize()
return end.time_since(start)*1e-3
return get_call_time
开发者ID:abergeron,项目名称:pycuda,代码行数:24,代码来源:driver.py
注:本文中的pycuda._pvt_struct.pack函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论