インテル® マス・カーネル・ライブラリー 11.2 ユーザーズガイド
インテル® MKL を使用して優れたパフォーマンスを引き出す場合や、インテル® MKL 関数の実行で一貫性のある結果を得る必要がある場合は、データ配列をアライメントする必要があります。次の例は、64 ビット境界でアライメントする方法を示しています。以下のコード例で示されているように、システムが提供するメモリー・アロケーターの代わりに mkl_malloc() を使用します。
// ******* 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 MKL mkl_app( darray ); ... // Free workspace mkl_free( darray );
! ******* Fortran language ******* ... ! Set value of alignment integer alignment parameter (alignment=64) ... ! Declare Intel MKL 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 Intel MKL call mkl_app( darray ) ... ! Free workspace call mkl_free(p_wrk)