J'écris un noyau CUDA pour Histogram sur une image, mais je n'avais aucune idée comment retourner un tableau depuis le noyau, et le tableau va changer quand un autre thread le lira. Une solution possible pour cela?comment créer un noyau d'histogramme CUDA?
__global__ void Hist(
TColor *dst, //input image
int imageW,
int imageH,
int*data
){
const int ix = blockDim.x * blockIdx.x + threadIdx.x;
const int iy = blockDim.y * blockIdx.y + threadIdx.y;
if(ix < imageW && iy < imageH)
{
int pixel = get_red(dst[imageW * (iy) + (ix)]);
//this assign specific RED value of image to pixel
data[pixel] ++; // ?? problem statement ...
}
}
@para d_dst: l'image d'entrée TColor est égale à float4.
données @para: le tableau pour la taille de l'histogramme [255]
extern "C" void
cuda_Hist(TColor *d_dst, int imageW, int imageH,int* data)
{
dim3 threads(BLOCKDIM_X, BLOCKDIM_Y);
dim3 grid(iDivUp(imageW, BLOCKDIM_X), iDivUp(imageH, BLOCKDIM_Y));
Hist<<<grid, threads>>>(d_dst, imageW, imageH, data);
}
Cependant, Ma tâche consiste à utiliser CUDA pour appliquer un histogramme. Et je ne peux pas le finir. Les données ne peuvent pas atteindre – kitw