mecode4food
mecode4food

Reputation: 320

CUDA does not seem to compile

I am currently running the CUDA 5.0 Toolkit on my Visual Studio 2012 Express.

I attempted to run the following code

I have searched high and low for methods of compiling .cu on Visual Studio but to no avail

Code I have attempted to compile:

    //CUDA.cu
    #include <iostream>
    #include <cuda.h>
    #include <cuda_runtime.h>
    #include <device_launch_parameters.h>

    using namespace std;

    __global__ void Add(int* a, int* b)
    {
    a[0] += b[0];
    }

int main()
{
    int a = 5, b = 9;
    int *d_a, *d_b;

    cudaMalloc(&d_a, sizeof(int));
    cudaMalloc(&d_b, sizeof(int));

    cudaMemcpy(d_a, &a, sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy(d_b, &b, sizeof(int), cudaMemcpyHostToDevice);

    Add<<< 1 , 1 >>>(d_a, d_b);

    cudaMemcpy(&a, d_a, sizeof(int) , cudaMemcpyDeviceToHost);

    cout << a << endl;

    return 0;
}

The compiler shows an error in the line

Add<<< 1 , 1 >>>(d_a, d_b);

Where it says "Error:expected an expression"

Any attempts to compile this code results in a success. but no .exe is to be found hence I cannot debug whatsoever.

Unable to start program 'C:\Users\...\CUDATest3.exe'
The system cannot find the file specified

Any help whatsoever is VERY MUCH appreciated. Thanks

CK

Upvotes: 0

Views: 261

Answers (1)

mecode4food
mecode4food

Reputation: 320

Although I would love to understand as to WHY in my computer CUDA decided that VS is a deplorable program to be married to, I have taken a shortcut by handcuffing both of said program by means of copying from the templates provided by the CUDA installation toolkit. (The CUDA samples.)

Apparently those samples have everything already set up and ready to go; all you need to do is edit the code from inside the solution itself. For some reason the code would not work if I had written all of the code from square one.

I still have no idea as to why I am unable to get it to run from scratch but I guess

editing the sample templates would give a much satisfactory result

if one does not have the time for it.

Upvotes: 1

Related Questions