Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Aug 10, 2007

Introduction to the BLAS VIs in LabVIEW 8.5

1 ratings | 5.00 out of 5
Print | PDF

Overview

This document discusses the benefits of using the BLAS VIs in LabVIEW. The BLAS VIs are a new feature in LabVIEW 8.5. The document also explains how to use your own BLAS library instead of the VIs that LabVIEW installs. Refer to the LabVIEW 8.5 Upgrade Notes (linked below) for a complete list of new features in LabVIEW 8.5.

What Is BLAS?

Basic Linear Algebra Subroutines (BLAS) are routines that provide standard functions for basic vector and matrix operations. These routines are classified in the following groups:

  • BLAS level 1: vector operations
  • BLAS level 2: matrix-vector operations
  • BLAS level 3: matrix-matrix operations

For example, dgemm is a BLAS level 3 function that calculates the general real matrix-matrix product using the following expression:

where α and β are scalars,

A, B and C are matrices,

and op(A) is A or AT.

BLAS routines are commonly used in the development of linear algebra software, such as LAPACK. Refer to the LAPACK Web site (linked below) for more information about LAPACK. Refer to the BLAS Web site (linked below) for more information about BLAS.

What Are NI BLAS VIs?

The Basic Linear Algebra Subroutines VIs are a new feature in the LabVIEW 8.5 Full and Professional Development Systems. These VIs offer an alternative to the already-existing linear algebra algorithms in LabVIEW by offering an interface to lower-level functionality and optimized algorithms.

Compared to the standard BLAS functions, the BLAS VIs in LabVIEW offer the following advantages:

  • Simplified and concise API for engineering requirements
  • Memory check before calculation to avoid memory violation

Choosing Between BLAS VIs and Linear Algebra VIs

Because the BLAS VIs provide flexible options and high performance, you can use them as the building blocks in complicated and advanced linear algebra algorithms. LabVIEW provides some basic linear algebra VIs, such as the A x B VI, the Dot Product VI, and the Outer Product VI. You can use any of these VIs or the BLAS VIs in your applications. The benefit of using the BLAS VIs comes when combining multiple linear algebra operations. This reduces data copying in LabVIEW and offers a more optimized execution. The following expression shows how you can combine typical linear algebra functions in BLAS VIs:

where α is scalar, A is a matrix, and X and Y are vectors.

With linear algebra VIs, you need five different VIs and functions to perform this calculation, as shown in the following block diagram.

You can replace these five VIs and functions with the the gemv – Generate Matrix-Vector Product VI, as shown in the following block diagram.

Thus, the BLAS VIs allow you to simplify the code on the block diagram. However, there can be disadvantages to using the BLAS VIs. For example, using the BLAS VIs requires LabVIEW to load a new library, lvblas.dll, into memory. On a real-time target, this DLL consumes roughly 270 KB. Therefore, on systems that have limited memory, such as an NI FP-20xx controller, it is advantageous to use only the existing linear algebra VIs, such as the A x B VI and the Dot Product VI.

Using Your Own BLAS Libraries

The BLAS VIs call well-optimized BLAS libraries to ensure you get high performance on a variety of platforms. You also can use the BLAS VIs to call your own BLAS library by following the steps below. Consider the dtrmm function as an example.

  1. Download and unzip the attached blastemplate.zip file.
  2. Rename your BLAS static library as glapack.lib and replace the glapack.lib file in the BLAS\blaslapack\gblaslapack directory with the file you renamed.
  3. Rename your BLAS library header file as cblas.h and replace the cblas.h file in the BLAS\blaslapack\include directory with the file you renamed.
  4. Open BLAS\LVBLAS\build\win32\LVBLAS.sln in Visual Studio 2005.
  5. Build the LVBLAS project to obtain lvblas.dll.

Replace lvblas.dll in the  labview\resource directory with the new DLL.

Related Links

LabVIEW 8.5 Upgrade Notes
LAPACK Web Site
BLAS Web Site
Wikipedia: Basic Linear Algebra Subprograms

Downloads

blastemplate.zip

1 ratings | 5.00 out of 5
Print | PDF

Reader Comments | Submit a comment »

Own BLAS Libraries
I have tried the blastemplate to create my own library and it did not work. Could you tell me precisely how did you create the library you used for that template? My guess is that you library is in C++ and that you compiled it with Visual Studio 2005. Everything which is different than that will not work, so please precise it.
- Regis Dupuy, NUIG. regis.dupuy@nuigalway.ie - Apr 14, 2008

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).