How to use the numexpr.detect_number_of_cores function in numexpr

To help you get started, weā€™ve selected a few numexpr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sjdv1982 / seamless / seamless / pandeval / core / computation / expressions.py View on Github external
def set_numexpr_threads(n=None):
    # if we are using numexpr, set the threads to n
    # otherwise reset
    if _NUMEXPR_INSTALLED and _USE_NUMEXPR:
        if n is None:
            n = ne.detect_number_of_cores()
        ne.set_num_threads(n)
github IntelPython / BlackScholes_bench / bs_erf_numexpr_crunched.py View on Github external
def black_scholes ( nopt, price, strike, t, rate, vol ):
    mr = -rate
    sig_sig_two = vol * vol * 2

    P = price
    S = strike
    T = t

    call = ne.evaluate("P * (0.5 + 0.5 * erf((log(P / S) - T * mr + 0.25 * T * sig_sig_two) * 1/sqrt(T * sig_sig_two))) - S * exp(T * mr) * (0.5 + 0.5 * erf((log(P / S) - T * mr - 0.25 * T * sig_sig_two) * 1/sqrt(T * sig_sig_two))) ")
    put = ne.evaluate("call - P + S * exp(T * mr) ")

    return call, put

#ne.set_vml_num_threads(ne.detect_number_of_cores())
ne.set_num_threads(ne.detect_number_of_cores())
ne.set_vml_accuracy_mode('high')
base_bs_erf.run("Numexpr-opt", black_scholes)
github pandas-dev / pandas / pandas / core / computation / expressions.py View on Github external
def set_numexpr_threads(n=None):
    # if we are using numexpr, set the threads to n
    # otherwise reset
    if _NUMEXPR_INSTALLED and _USE_NUMEXPR:
        if n is None:
            n = ne.detect_number_of_cores()
        ne.set_num_threads(n)
github ColdGrub1384 / Pyto / site-packages / pandas / core / computation / expressions.py View on Github external
def set_numexpr_threads(n=None):
    # if we are using numexpr, set the threads to n
    # otherwise reset
    if _NUMEXPR_INSTALLED and _USE_NUMEXPR:
        if n is None:
            n = ne.detect_number_of_cores()
        ne.set_num_threads(n)
github IntelPython / BlackScholes_bench / bs_erf_numexpr.py View on Github external
y = ne.evaluate("1/sqrt(z) ")

	w1 = ne.evaluate("(a - b + c) * y ")
	w2 = ne.evaluate("(a - b - c) * y ")

	d1 = ne.evaluate("0.5 + 0.5 * erf(w1) ")
	d2 = ne.evaluate("0.5 + 0.5 * erf(w2) ")

	Se = ne.evaluate("exp(b) * S ")

	call = ne.evaluate("P * d1 - Se * d2 ")
	put = ne.evaluate("call - P + Se ")

	return call, put

ne.set_num_threads(ne.detect_number_of_cores())
ne.set_vml_accuracy_mode('high')
base_bs_erf.run("Numexpr", black_scholes)