30

これが私のコードです:

int threadNum = BLOCKDIM/8;
dim3 dimBlock(threadNum,threadNum);
int blocks1 = nWidth/threadNum + (nWidth%threadNum == 0 ? 0 : 1);
int blocks2 = nHeight/threadNum + (nHeight%threadNum == 0 ? 0 : 1);
dim3 dimGrid;
dimGrid.x = blocks1;
dimGrid.y = blocks2;

//  dim3 numThreads2(BLOCKDIM);
//  dim3 numBlocks2(numPixels/BLOCKDIM + (numPixels%BLOCKDIM == 0 ? 0 : 1) );
perform_scaling<<<dimGrid,dimBlock>>>(imageDevice,imageDevice_new,min,max,nWidth, nHeight);
cudaError_t err = cudaGetLastError();
cudasafe(err,"Kernel2");

これは私の 2 番目のカーネルの実行であり、データの使用に関して完全に独立しています。BLOCKDIMis 512 、nWidth and nHeightare 512 toocudasafeで、エラーコードの対応する文字列メッセージを単に出力します。コードのこのセクションでは、カーネル呼び出しの直後に構成エラーが発生します。

このエラーの原因は何ですか?

4

2 に答える 2

1

前の回答に追加するために、コードで許可されている最大スレッドも見つけることができるため、使用するスレッドの数をハードコーディングせずに他のデバイスで実行できます。

struct cudaDeviceProp properties;
cudaGetDeviceProperties(&properties, device);
cout<<"using "<<properties.multiProcessorCount<<" multiprocessors"<<endl;
cout<<"max threads per processor: "<<properties.maxThreadsPerMultiProcessor<<endl;
于 2015-10-12T11:11:02.330 に答える