Developer Reference for Intel® oneAPI Math Kernel Library for C

ID 766684
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Usage Examples for CNR Support Functions

The following examples illustrate usage of support functions for conditional numerical reproducibility.

Setting Automatically Detected CNR Branch

#include <mkl.h>
int main(void) {
   int my_cbwr_branch;
   /* Find the available MKL_CBWR_BRANCH automatically */
   my_cbwr_branch = mkl_cbwr_get_auto_branch();
   /* User code without Intel MKL calls */
   /* Piece of the code where CNR of Intel MKL is needed */
   /* The performance of Intel MKL functions might be reduced for CNR mode */
   if (mkl_cbwr_set(my_cbwr_branch)!=MKL_CBWR_SUCCESS) {
      printf("Error in setting MKL_CBWR_BRANCH! Aborting…\n");
      return;
   }
   /* CNR calls to Intel MKL + any other code */
}

Use of the mkl_cbwr_get Function

#include <mkl.h>
int main(void) {
   int my_cbwr_branch;
   /* Piece of the code where CNR of Intel MKL is analyzed */
   my_cbwr_branch = mkl_cbwr_get(MKL_CBWR_BRANCH);
   switch (my_cbwr_branch) {
      case MKL_CBWR_AUTO:
	      	/* actions in case of automatic mode */
      		break;
      case MKL_CBWR_SSSE3:
      		/* actions for SSSE3 code */
      		break;
     	default:
	      	/* all other cases */
   }
   /* User code */
}

Product and Performance Information

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.

Notice revision #20201201