CUDA thread

#include <stdio.h>

#include <stdlib.h>

#include <cuda_runtime.h>

#define BLOCK_DIM 512

const int size_x=512;

const int size_y=1;

__global__ static void ThreadDemo1(unsigned int* ret)


  unsigned int xindex=blockDim.x*blockIdx.x+threadIdx.x;

  unsigned int yindex=blockDim.y*blockIdx.y+threadIdx.y;

if(xindex<size_x && yindex<size_y)


	 unsigned int index=xindex+size_x*yindex;





void ThreadDemo1()


  unsigned int* ret=0;

  unsigned int  host_ret={0};

  int i=0;

cudaMalloc((void**) &ret, sizeof(unsigned int)*(size_x*size_y*2));

dim3 grid(size_x / BLOCK_DIM, 1);

  dim3 block(BLOCK_DIM,1,1);


cudaMemcpy(&host_ret, ret, sizeof(unsigned int)*(size_x*size_y*2), cudaMemcpyDeviceToHost);

for(i=0; i<size_x*size_y; i++)






This is a CUDA programme about testing the threads. When I compile it, it says error: unrecognized token error: expected an expression error: unrecognized token error: unrecognized token error: unrecognized token

the line 41 is the line in red.

who can tell me why it is unrecognized? Thanks :blink:

Maybe you’re using the wrong quotation marks, try replacing ¨ with "


Thanks a lot!! :thumbup: