Hey guys, I just installed CUDA 6.0 on my Windows 8.1.
I have a GeForce GT 630M, and I am using Visual Studio Professional 2012.
This is the code I am trying to compile, but is doesn’t recognize the main part “<<<”.
It gives me “Error: expected an expression”. My file has extension .cu.
Any idea of how to fix the intellisense issue?
Thanks
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
__global__ void AddInts(int* a, int *b, int *c, int count){
int id = blockIdx.x * blockDim.x + threadIdx.x;
if(id < count) c[id] = a[id] + b[id];
}
int main(){
srand(time(NULL));
int count = 100;
int *h_a = (int *)malloc(count * sizeof(int));
int *h_b = (int *)malloc(count * sizeof(int));
int *h_c = (int *)malloc(count * sizeof(int));
for(int i = 0; i < count; i++){
h_a[i] = rand() % 1000;
h_b[i] = rand() % 1000;
}
int *d_a, *d_b, *d_c;
cudaMalloc(&d_a, sizeof(int) * count);
cudaMalloc(&d_b, sizeof(int) * count);
cudaMalloc(&d_c, sizeof(int) * count);
cudaMemcpy(d_a, h_a, sizeof(int) * count, cudaMemcpyHostToDevice);
cudaMemcpy(d_b, h_b, sizeof(int) * count, cudaMemcpyHostToDevice);
AddInts<<<dim3(1024,1024,64), 1024>>>(d_a, d_b, d_c, count);
cudaMemcpy(h_c, d_c, sizeof(int) * count, cudaMemcpyDeviceToHost);
printf("Sum of two vectors\n\n");
for(int i = 0; i < count; i++) printf("%3d + %3d = %d\n",h_a[i], h_b[i], h_c[i]);
free(h_a); free(h_b); free(h_c);
cudaFree(d_a); cudaFree(d_b); cudaFree(d_c);
system("pause");
return 0;
}