Sign up for our newsletter and get the latest HPC news and analysis.
Send me information from insideHPC:


Parallelism in Python: Directing Vectorization with NumExpr

Sponsored Post

According to a new edition of Parallel Universe Magazine, from Intel, Python has several pathways to vectorization. These range from just-intime (JIT) compilation with Numba 1 to C-like code with Cython .

parallelism

Download the full magazine.

According to a chapter dedicated to the topic in the publication, one way of achieving Python parallelism is through NumExpr, “in which a symbolic evaluator transforms numerical Python expressions into high-performance, vectorized code.”

The report explores how NumExpr achieves this by vectorizing in chunks of elements — instead of compiling everything at once.

This creates accelerated object kernels that are usable from Python code. The chapter explores in detail how to refactor Python code to take advantage of NumExpr’s capabilities. The author, Fabio Baruffa, Technical Consulting Engineer at Intel, highlights how to boost performance for computing with arrays and numerical expressions.

The flexibility of Python, with its easy syntax, allows developers to rapidly prototype numerical computations with the help of libraries like NumPy and SciPy.

To make use of the NumExpr package, the report explains, users need to pass the computational string to the evaluate function. Then it’s compiled into an object, leaving the entire computation at low-level code before completion.

As far controlling the NumExpr evaluator goes, since NumExpr uses the Intel VML library internally, it computes the mathematical functions only for the types the library allows.

“Using NumExpr as alternative to NumPy can give significant performance benefits for computing with arrays and numerical expressions, thanks to the Intel VML performance library. The syntax is very similar to NumPy and, with a couple of easy function calls, you can transition your code to NumExpr,” Baruffa concludes.

The chapter on parallelism in Python in the recent magazine issue explores in detail the following topics:

  • Parallelization of Numerical Expressions
  • Refactoring Common NumPy Calls for NumExpr
  • Controlling the NumExpr Evaluator

Download the new issue of Parallel Universe Magazine for more on the latest in HPC from Intel. 

Leave a Comment

*

Resource Links: