2

新しいインテル Xeon Phi コプロセッサーで MKL の自動オフロードを使用して、?GEMM、?TRMM、?TRSM のパフォーマンスをテストしていますが、DTRMM と DTRSM で問題が発生しています。1024 から 10240 までのステップで行列サイズのパフォーマンスをテストするコードがあり、パフォーマンスは N=M=K=8192 のどこかで大幅に低下するようです。ステップ サイズ 2 を使用して正確にどこをテストしようとすると、スクリプトがハングしていました。次に、512 のステップ サイズをチェックしました。これは正常に動作し、256 も同様に動作しますが、256 未満のものはすべて失速します。この問題に関する既知の問題は見つかりません。?GEMM の単精度および倍精度と同様に、すべての単精度バージョンが機能します。これが私のコードです:

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <stdint.h>
#include <time.h>
#include "mkl.h"

#define DBG 0

int main(int argc, char **argv)
{
   char transa = 'N', side = 'L', uplo = 'L', diag = 'U';
   MKL_INT N, NP; // N = M, N, K, lda, ldb, ldc
   double alpha = 1.0; // Scaling factors 
   double *A, *B; // Matrices 
   int matrix_bytes; // Matrix size in bytes 
   int matrix_elements; // Matrix size in elements
   int i, j; // Counters
   int msec;
   clock_t start, diff;

   N = atoi(argv[1]);

   start = clock();

   matrix_elements = N * N;
   matrix_bytes = sizeof(double) * matrix_elements;

   // Allocate the matrices
   A = malloc(matrix_bytes);
   if (A == NULL)
   {
      printf("Could not allocate matrix A\n");
      return -1;
   }

   B = malloc(matrix_bytes);
   if (B == NULL)
   {
      printf("Could not allocate matrix B\n");
      return -1;
   }

   for (i = 0; i < matrix_elements; i++)
   {
      A[i] = 0.0;
      B[i] = 0.0;
   }

   // Initialize the matrices
   for (i = 0; i < N; i++)
      for (j = 0; j <= i; j++)
      {
         A[i+N*j] = 1.0;
         B[i+N*j] = 2.0;
      }

   // DTRMM call
   dtrmm(&side, &uplo, &transa, &diag, &N, &N, &alpha, A, &N, B, &N);

   diff = clock() - start;
   msec = diff * 1000 / CLOCKS_PER_SEC;
   printf("%f\n", (float)msec * 10e-4);

   if (DBG == 1)
   {
      printf("\nMatrix dimension is set to %d \n\n", (int)N);

      // Display the result
      printf("\nResulting matrix B:\n");
      if (N > 10)
      {
         printf("NOTE: B is too large, print only upper-left 10x10 block...\n");
         NP = 10;
      }
      else
         NP = N;

      printf("\n");
      for (i = 0; i < NP; i++)
      {
         for (j = 0; j < NP; j++)
            printf("%7.3f ", B[i + j * N]);
         printf("\n");
      }
   }

   // Free the matrix memory
   free(A);
   free(B);

   return 0;
}

どんな助けや洞察も大歓迎です。

4

2 に答える 2

2

この現象は、他の質問や、Intel のソフトウェア最適化マニュアルおよび Agner Fog のメモでも広く議論されています。

通常、メモリ階層で完全なエビクションの嵐が発生し、突然 (ほぼ)すべてのアクセスでキャッシュや TLB が失われます (特定のデータ アクセス パターンを調べるか、 PMC; mystical が最初にあなたに到達しない限り、後でホワイトボードの近くにいるときに計算を行うことができます)。

また、私の回答または Mystical の回答を検索して、以前の回答を見つけることもできます。

于 2013-02-20T16:37:08.393 に答える
0

問題は、Intel の icc コンパイラの古いバージョン (ベータ 10 の更新、おそらく..) でした。ゴールドの更新は魅力のように機能します。

于 2013-02-25T13:46:36.583 に答える