Developer Guide
Developer Guide for Intel® oneAPI Math Kernel Library macOS*
A newer version of this document is available. Customers should click here to go to the newest version.
Visible to Intel only — GUID: GUID-D5E9F1A6-6194-4835-BC16-726CC6AA2F50
Visible to Intel only — GUID: GUID-D5E9F1A6-6194-4835-BC16-726CC6AA2F50
Example of Data Alignment
Needs for best performance with Intel® oneAPI Math Kernel Library or for reproducible results from run to run of Intel® oneAPI Math Kernel Library functions require alignment of data arrays. The following example shows how to align an array on 64-byte boundaries. To do this, usemkl_malloc() in place of system provided memory allocators, as shown in the code example below.
Aligning Addresses on 64-byte Boundaries
// ******* C language *******
...
#include <stdlib.h>
#include <mkl.h>
...
void *darray;
int workspace;
// Set value of alignment
int alignment=64;
...
// Allocate aligned workspace
darray = mkl_malloc( sizeof(double)*workspace, alignment );
...
// call the program using oneMKL
mkl_app( darray );
...
// Free workspace
mkl_free( darray );
! ******* Fortran language *******
...
! Set value of alignment
integer alignment
parameter (alignment=64)
...
! Declare oneMKL routines
#ifdef _IA32
integer mkl_malloc
#else
integer*8 mkl_malloc
#endif
external mkl_malloc, mkl_free, mkl_app
...
double precision darray
pointer (p_wrk,darray(1))
integer workspace
...
! Allocate aligned workspace
p_wrk = mkl_malloc( %val(8*workspace), %val(alignment) )
...
! call the program using oneMKL
call mkl_app( darray )
...
! Free workspace
call mkl_free(p_wrk)