Other functionality#
Metadata (“tags”) for Arrays and Array Axes#
ArrayContext
-generating fixture for pytest
#
- class arraycontext.PytestPyOpenCLArrayContextFactory(device)[source]#
- __init__(device)[source]#
- Parameters:
device – a
pyopencl.Device
.
- __call__() ArrayContext [source]#
Call self as a function.
- arraycontext.pytest_generate_tests_for_array_contexts(factories: Sequence[str | Type[PytestArrayContextFactory]], *, factory_arg_name: str = 'actx_factory') Callable[[Any], None] [source]#
Parametrize tests for pytest to use an
ArrayContext
.Using this function in
pytest
test scripts allows you to use the argument factory_arg_name, which is a callable that returns aArrayContext
. All test functions will automatically be run once for each implemented array context. To select specific array context implementations explicitly define, for example,pytest_generate_tests = pytest_generate_tests_for_array_context([ "pyopencl", ])
to use the
pyopencl
-based array context. Forpyopencl
-based contextspyopencl.tools.pytest_generate_tests_for_pyopencl()
is used as a backend, which allows specifying thePYOPENCL_TEST
environment variable for device selection.The environment variable
ARRAYCONTEXT_TEST
can also be used to overwrite any chosen implementations through factories. This is a comma-separated list of known array contexts.Current supported implementations include:
"pyopencl"
, which creates aPyOpenCLArrayContext
withforce_device_scalars=True
."pyopencl-deprecated"
, which creates aPyOpenCLArrayContext
withforce_device_scalars=False
."pytato-pyopencl"
, which creates aPytatoPyOpenCLArrayContext
.
- Parameters:
factories – a list of identifiers or
PytestPyOpenCLArrayContextFactory
classes (not instances) for which to generate test fixtures.
- arraycontext.pytest_generate_tests_for_pyopencl_array_context(metafunc) None [source]#
Parametrize tests for pytest to use a
PyOpenCLArrayContext
.Performs device enumeration analogously to
pyopencl.tools.pytest_generate_tests_for_pyopencl()
.Using the line:
from arraycontext import ( pytest_generate_tests_for_pyopencl_array_context as pytest_generate_tests)
in your pytest test scripts allows you to use the argument
actx_factory
, in your test functions, and they will automatically be run once for each OpenCL device/platform in the system, as appropriate, with an argument-less function that returns anArrayContext
when called.It also allows you to specify the
PYOPENCL_TEST
environment variable for device selection.
Program creation for loopy
#
- arraycontext.make_loopy_program(domains, statements, kernel_data=None, name='mm_actx_kernel', tags=None)[source]#
Return a
loopy.LoopKernel
suitable for use withArrayContext.call_loopy()
.