Errors encountered when starting the kernel function in CUDA 5.5

I installed CUDA5.5. The development environment uses Visual Studio 2010 Professional. And I tried to run the source code as follows. However, the red line was allotted to the "<<for some reason in Visual Studio. The expression" Error "is displayed. Required" and. If someone the same phenomenon occurs, please tell me how to solve.

Development environment --------------------------------------------- --- --------------------------

         OS:Windows7 64bit
         Visual Studio 2010 Professional SP1
         CUDA 5.5

Phenomenon ---------------------------------------------- --- ----------------------------------------

↓ The underlined red part "<<of the source code you will see the following. However, the third underscore appears only" <". It seems that:" expression Required. Error "and move the mouse to the location of the red line.

Source --------------------------------------------- --- ---------------------------

#include <cuda_runtime.h>
#include <stdio.h> 
#include <math.h> 
#include <cuda.h> 

#define N 256


__global__ void matrix_vector_multi_gpu_1_1(float *A_d, float *B_d, float *C_d){
    int i,j;

    for(j=0;j<N;j++){
        A_d[j]=0.0F;
        for(i=0;i<N;i++){
            A_d[j]=A_d[j]+B_d[j*N+i]*C_d[i];
        }
    }
  }

int main(){
    int i,j;
    float A[N], B[N*N], C[N];
    float *A_d, *B_d, *C_d;

    dim3 blocks(1,1,1);
    dim3 threads(1,1,1);

    for(j=0;j<N;j++){
        for(i=0;i<N;i++){
            B[j*N+i]=((float)j)/256.0;
        }
    }

    for(j=0;j<N;j++){
        C[j]=1.0F;
    }

    cudaMalloc((void**)&A_d, N*sizeof(float));
    cudaMalloc((void**)&B_d, N*N*sizeof(float));
    cudaMalloc((void**)&C_d, N*sizeof(float));

    cudaMemcpy(A_d,A,N*sizeof(float),cudaMemcpyHostToDevice);
    cudaMemcpy(B_d,B,N*N*sizeof(float),cudaMemcpyHostToDevice);
    cudaMemcpy(C_d,C,N*sizeof(float),cudaMemcpyHostToDevice);

    matrix_vector_multi_gpu_1_1<<<blocks,threads>>>(A_d,B_d,C_d);

    cudaMemcpy(A,A_d,N*sizeof(float),cudaMemcpyDeviceToDevice);

    for(j=0;j<N;j++){
        printf("A[ %d ]=%f \n",j,A[j]);
    }
    getchar();
    cudaFree(A_d);
    cudaFree(B_d);
    cudaFree(C_d);
    return 0;
}

Place of occurrence

0
source share
2 answers

You should at least change

cudaMemcpy(A,A_d,N*sizeof(float),cudaMemcpyDeviceToDevice);

to

cudaMemcpy(A,A_d,N*sizeof(float),cudaMemcpyDeviceToHost);

Some suggestions

  • Run some sample CUDA code to make sure you have configured CUDA correctly.
  • Verify that the source file has an external name .cu

cudaMemcpyDeviceToDevice . . , .

+1

, Intellisense. Intellisense Visual Studio 2010 CUDA

Intellisense Visual Studio 2010 CUDA

+1

All Articles