2013-06-13 37 views
0

我測試上的GTX 690 GPU與4GB RAM在Windows 7 64以下時,Visual C++ 10:多GPU性能劣化增加

我已經寫了接收2個向量,並增加了一個函數成第三個向量。該任務被打破了2個GPU設備。我逐漸將矢量大小增加到基準GPU性能。所需時間相對於矢量大小線性增加到某個點,然後突然跳起來。當我禁用每個GPU內核時,所需的時間與可用內存的末端保持線性關係。我附上了一張顯示所需時間與分配內存的圖表。

你可以看到速度線圖中的位置:Speed Comparison Diagram!

你能告訴我什麼是錯?

最好成績, 拉敏

這是我的代碼:

unsigned BenchMark(unsigned VectorSize) 
{ 
    unsigned *  D[ 2 ][ 3 ] ; 

    for (int i = 0 ; i < 2 ; i++) 
    { 
     cudaSetDevice(i) ; 

     for (int j = 0 ; j < 3 ; j++) 
      cudaMalloc(& D[ i ][ j ] , VectorSize * sizeof(unsigned)) ; 
    } 

    unsigned uStartTime = clock() ; 

    // TEST 
    for (int i = 0 ; i < 2 ; i++) 
    { 
     cudaSetDevice(i) ; 

     AddKernel<<<VectorSize/256,256>>>(
      D[ i ][ 0 ] , 
      D[ i ][ 1 ] , 
      D[ i ][ 2 ] , 
       VectorSize) ; 
    } 

    cudaDeviceSynchronize() ; 
    cudaSetDevice(0) ; 
    cudaDeviceSynchronize() ; 

    unsigned uEndTime = clock() ; 

    for (int i = 0 ; i < 2 ; i++) 
    { 
     cudaSetDevice(i) ; 

     for (int j = 0 ; j < 3 ; j++) 
      cudaFree(D[ i ][ j ]) ; 
    } 

    return uEndTime - uStartTime ; 
} 

__global__ void AddKernel(
        const Npp32u * __restrict__ pSource1 , 
        const Npp32u * __restrict__ pSource2 , 
         Npp32u * __restrict__ pDestination , 
         unsigned   uLength) 
{ 
    unsigned x = blockIdx.x * blockDim.x + threadIdx.x ; 

    if (x < uLength) 
     pDestination[ x ] = pSource1[ x ] + pSource2[ x ] ; 
} 
+0

視覺分析器可能會給你一些線索。 –

+0

您是否檢查過CUDA API調用之一是否發生錯誤?也許一個cudaSetDevice調用失敗。比使用UVA和對等訪問功能在內的錯誤設備上調用內核會讀取和寫入其他設備的內存,從而導致極高的性​​能影響。 –

+0

親愛的克羅諾斯,我檢查了錯誤,它確實是在不同的內核上完成的。在大向量上,所需的內存量不能分配到一個內核上。 –

回答

1

我找到了答案。問題發生在SLI活躍時,我禁用了它,現在它運行正常。