Parallel

Programming Intel's Xeon Phi: A Jumpstart Introduction

Reaching one teraflop on Intel's new 60-core coprocessor requires a little know-how

Scaling Behavior According to Matrix Size

The source code for matrix.c (Listing Five) can be compiled without modification by the Intel compiler to run in the following modes:

Native: The entire application runs on the Intel Xeon Phi.

Offload: The host processor runs the application and offloads compute intensive codeand associated data to the device as specified by the programmer via pragmas in the source code.

Host: Run the code as a traditional OpenMP application on the host.

Regression testing and verification of results is an essential part of any programming project, and so to validate the correctness of the tutorial matrix multiplication (Listing One), the doCheck() method has been added to call the highly optimized, known-to-be-correctly working Intel MKL (Math Kernel Library) sgemm() matrix multiplication routine.

Unfortunately, it is not possible to perform a bit-wise comparison between the matrices calculated by doMult() and sgemm(). Floating-point arithmetic is only approximate, which means that even slight variations in the order in which the arithmetic operations are performed (say when compiling with different optimization flags or as a result of running on different devices) can cause applications compiled from the same source code to produce slightly different numerical results. For this reason, the nrmsdError() calculates a Normalized Root–Mean-Squared Deviation (NRMSD) as a measure of similarity. The NRMSD value will be small when the matrices are similar.

The doCheck() method also returns the average runtime of the MKL sgemm(). Just like our example code, the the MKL library can run in three modes: natively on the coprocessor, in offload mode, and on the host processor. The MKL runtime reported by doCheck() provides that ability to observe how fast highly-optimized code can run a coprocessor and compare performance against a similarly highly optimized code running on the host processor.

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task.
However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Video

This month's Dr. Dobb's Journal

This month,
Dr. Dobb's Journal is devoted to mobile programming. We introduce you to Apple's new Swift programming language, discuss the perils of being the third-most-popular mobile platform, revisit SQLite on Android
, and much more!