need help with gpu code

Im trying to use mutex in my code with no luck. Matlab says that kernel reaches timeout.
kernel:
__global__ void getGrid( int* mask,
int* mutex ) {
unsigned int idx = blockIdx.x * blockDim.x + threadIdx.x;
while( idx < 100 ){
while( atomicCAS( mutex, 0, 1 ) != 0 );
mask[ idx ] = idx;
atomicExch( mutex, 0 );
//*mutex = 0;
//while( atomicCAS( mutex, idx, idx + 1 ) != idx );
idx += blockDim.x * gridDim.x;
}
}
script:
mutex = parallel.gpu.GPUArray.zeros('int32');
kern0 = parallel.gpu.CUDAKernel('testkern.ptx', 'testkern.cu');
kern0.ThreadBlockSize = [256 1 1];
kern0.GridSize = [7*20 1];
mask = parallel.gpu.GPUArray.zeros(int32(256*7*20),int32(1),'int32');
tic
[mask mutex] = feval(kern0, mask, mutex);
toc
Commented atomicCAS works properly, but first one don't. Any mistakes or.. ?

3 件のコメント

Walter Roberson
Walter Roberson 2012 年 2 月 4 日
Are you running the card in "service mode", or is it shared for graphics? Service mode is available on Telsa, but not GT / GTX (I do not know about Quadro.)
m4 Chrennikov
m4 Chrennikov 2012 年 2 月 4 日
It is shared for graphics but this is not the cause.
Konrad Malkowski
Konrad Malkowski 2012 年 2 月 15 日
Does this work outside of MATLAB?

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGPU Computing についてさらに検索

タグ

質問済み:

2012 年 2 月 4 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by