BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Python-Like Numerical Computation Library MatX Brings Transforms as Operators and Other Features

Python-Like Numerical Computation Library MatX Brings Transforms as Operators and Other Features

Developed by Nvidia for its own GPUs, MatX is a C++ library that aims to bring near-native performance in numerical computing using a high-level syntax not far from those available in Python scipy or MATLAB. Its latest release brings a number of new features, including the possibility to use transforms as operators, new operators such as upsample, downsample, pwelch, and more.

Transforms can now be used in any operator expression to evaluate them lazily using operator fusion. Operator fusion is a special feature in MatX aimed at improving performance by reducing memory access, which can be orders of magnitude more expensive than register access. Using operator fusion, an expression is not evaluated immediately, rather, it is converted into a C++ type representing it that will be evaluated when its value is needed. In other words, instead of calculating the result of an expression such as:

(A = B * (cos(C) / D)).run();

you can store its value in an intermediate expression:

auto op = (B * (cos(C) / D));

combine it with other expressions and evaluate the result lazily when needed. This feature is achieved by overloading C++ operators. The latest release of MatX extends this possibility to transforms, such as in the expression:

(A = B * fft(C)).run();

where the compiler is able to understand the right side of the multiply operator is and FFT transform and the left side is another expression that can be fused with the former's result at compile time.

It is worth noting that this new syntax for transforms used as operators brings a breaking change with respect to how transforms were used previously. Specifically, whereas you used to write matmul(C, A, B, stream), you should now use (C = matmul(A,B)).run(stream).

Another new feature introduced in MatX 0.6.0 is a new polyphase channelizer operator, which separates an input signal into a set of channels. This is used, for example, to convert a high sample-rate wideband signal into multiple lower sample-rate narrowband signals.

New operators include upsample, used to upsample a signal by stuffing zeroes; downsample, used to downsample a signal by dropping samples; pwelch, used to visualize the spectrum of a signal without preprocessing first.

There is much more to the latest release of MatX than can be covered here. Interested readers should consult the official release note for full details.

About the Author

Rate this Article

Adoption
Style

BT