pattern

Date:

01-09-2012

NAME

nopattern, NOPATTERN, PATTERN - In C/C++, disables pattern matching for the loop immediately following the directive. In Fortran, disables or resumes pattern matching within a program.

SYNOPSIS

#pragma _CRI nopattern
!DIR$ PATTERN
!DIR$ NOPATTERN

IMPLEMENTATION

Cray Linux Environment (CLE)

DESCRIPTION: C/C++

Scope: Local

The nopattern directive disables pattern matching for the loop immediately following the directive.

By default, the compiler detects coding patterns in source code sequences and replaces these sequences with calls to optimized library functions. In most cases, this replacement improves performance. There are cases, however, in which this substitution degrades performance. This can occur, for example, in loops with very low trip counts. In such a case, you can use the nopattern directive to disable pattern matching and cause the compiler to generate inline code.

DESCRIPTION: Fortan

The NOPATTERN directive disables pattern matching and causes the compiler to generate inline code. The !DIR$ NOPATTERN directive is used to resume pattern matching within the program.

By default, the compiler detects coding patterns in source code sequences and replaces these sequences with calls to optimized library routines. In most cases, this replacement improves performance. There are cases, however, in which this substitution degrades performance. This can occur, for example, in loops with very low trip counts.

When the NOPATTERN directive is encountered, pattern matching is suspended for the remainder of the program unit or until a PATTERN directive is encountered.

When the -O nopattern command line option is in effect, the NOPATTERN and PATTERN compiler directives are ignored.

EXAMPLES

Example 1: nopattern directive

In the following C/C++ example, placing the nopattern directive in front of the outer loop of a nested loop turns off pattern matching for the matrix multiply that takes place inside the inner loop:

double a[100][100], b[100][100], c[100][100];

void nopat(int n)
{
  int i, j, k;

#pragma _CRI nopattern
  for (i=0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      for (k = 0; k < n; ++k) {
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }
}

Example 2: NOPATTERN directive

In this Fortran example, the compiler would detect that the following loop is a matrix multiply and replace it with a call to a matrix multiply library routine. By preceding the loop with a NOPATTERN directive, however, pattern matching is inhibited and no replacement is done.

!DIR$ NOPATTERN
                             DO k= 1,n
                                     DO i= 1,n
                                             DO j= 1,m
                                                     A(i,j) = A(i,j) + B(i,k) * C(k,j)
                                             END DO
                                     END DO
                             END DO

SEE ALSO

intro_directives(1)