def set_pnumpy_thread_count(num_threads: Optional[int]) -> None: """ Set the number of worker threads used by pnumpy; if set to zero/None, disables threading. """ pnumpy.initialize() if num_threads is not None and num_threads > 0: pnumpy.thread_enable() pnumpy.thread_setworkers(num_threads) else: pnumpy.thread_disable()
import numpy as np import pnumpy pnumpy.initialize() ######## import random # Various pre-crafted datasets/variables for testing # !!! Must not be changed -- only appended !!! # while testing numpy we better not rely on numpy to produce random # sequences random.seed(1) # but will seed it nevertheless np.random.seed(1) # Size of square 2d arrays to use in benchmarks nxy = 1024 # a set of interesting types to test TYPES1 = [ 'int16', 'float16', 'int32', 'float32', 'int64', 'float64', 'complex64', 'longfloat', 'complex128', ]
def initialize_pnumpy(): if HAVE_PNUMPY: from numpy.core._multiarray_umath import __cpu_features__ as cpu if not cpu['AVX2']: pytest.skip('pnumpy.initialize requires AVX2') pnumpy.initialize()