Aligning Data for Consistent Results

Routines in Intel MKL may return different results from run-to-run on the same system. This is usually due to a change in the order in which floating-point operations are performed. The two most influential factors are array alignment and parallelism. Array alignment can determine how internal loops order floating-point operations. Non-deterministic parallelism may change the order in which computational tasks are executed. While these results may differ, they should still fall within acceptable computational error bounds. To better assure identical results from run-to-run, do the following:

To align input arrays on 16-byte boundaries, use mkl_malloc() in place of system provided memory allocators, as shown in the code example below. Sequential mode of Intel MKL removes the influence of non-deterministic parallelism.

Aligning Addresses on 16-byte Boundaries

            
            // ******* C language *******
            ...
            #include <stdlib.h>
            ...
            void *darray;
            int workspace;
            ...
            // Allocate workspace aligned on 16-byte boundary
            darray = mkl_malloc( sizeof(double)*workspace, 16 );
            ...
            // call the program using MKL
            mkl_app( darray );
            ...
            // Free workspace
            mkl_free( darray );
            

    
            ! ******* Fortran language *******
            ...
            double precision darray
            pointer (p_wrk,darray(1))
            integer workspace
            ...
            ! Allocate workspace aligned on 16-byte boundary
            p_wrk = mkl_malloc( 8*workspace, 16 )
            ...
            ! call the program using MKL
            call mkl_app( darray )
            ...
            ! Free workspace
            call mkl_free(p_wrk)
            

Submit feedback on this help topic