Book Image

DART Cookbook

By : Ivo Balbaert
Book Image

DART Cookbook

By: Ivo Balbaert

Overview of this book

Table of Contents (18 chapters)
Dart Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using SIMD for enhanced performance


A lot of modern CPUs and GPUs provide Single Instruction Multiple Data (SIMD) support. Four 32-bit data values (integers or floats) can be processed in parallel with the help of 128-bit special registers. This provides a potential speedup of 400 percent for image processing, 3D graphics, audio processing, and other numeric computation algorithms. Also, machine-learning algorithms (such as for automatic speech recognition) that use a Gauss Mixture Model (GMM) benefit from SIMD.

How to do it…

Dart lets you work with this feature by using the special SIMD x types from the typed_data library. It offers the following four types:

  • Int32x4, which represents four 32-bit integer values

  • Float32x4, which represents four single-precision floating point values

  • List structures to contain the 32-bit integer values, such as Int32x4List

  • Float32x4List, list structure to contain the 32-bit floating point values

Let's see some examples of SIMD operations in simd.dart; the different...