Pregunta

OK, I've switched over from Python to C++ in VS2012 in an effort to get this project rolling once more. I've run into a lot of roadblocks and headaches getting to know the ins and outs of this. Here's my latest, most frustrating one and the compile error that goes with it.

1>  C:\Users\Karsten Chu\New Google Drive\Research\Visual Studio 2012\Projects\Dynamic Parallelism Test\Dynamic Parallelism Test>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\bin\nvcc.exe" -dlink -o "x64\Debug\Dynamic Parallelism Test.device-link.obj" -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd  " -L"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\lib\x64" cuda.lib cudart.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib -lcudadevrt  -gencode=arch=compute_35,code=sm_35 -G --machine 64 "x64\Debug\CUDA Test 2.cu.obj" "x64\Debug\CUDA Test.cu.obj" 
1>Dynamic Parallelism Test.device-link.obj : error LNK2001: unresolved external symbol __fatbinwrap_54_tmpxft_00000634_00000000_8_cuda_device_runtime_cpp1_ii_5f6993ef
1>C:\Users\Karsten Chu\New Google Drive\Research\Visual Studio 2012\Projects\Dynamic Parallelism Test\x64\Debug\Dynamic Parallelism Test.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

And my code.

#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <stdio.h>
#include <iostream>
using namespace std;

__global__ void rkf5(double*, int*);
__global__ void k1(double*);

int main2(int argc, char** argv)
{
    const int max_length = 5;
    double concs[max_length];
    for (int i=0; i<max_length; i++)
    {
        concs[i]=0;
        //std::cout<<concs[i];
    }

    double *d_concs;
    int *d_max_length;
    size_t size_concs = sizeof(concs);
    size_t size_max_length = sizeof(max_length);
    cudaMalloc((void**)&d_concs, size_concs);
    cudaMemcpy(d_concs, concs, size_concs, cudaMemcpyHostToDevice);
    cudaMalloc((void**)&d_max_length, size_max_length);
    cudaMemcpy(d_concs, concs, size_concs, cudaMemcpyHostToDevice);
    rkf5<<<1,max_length>>>(d_concs, d_max_length);
    cudaMemcpy(concs, d_concs, size_concs, cudaMemcpyDeviceToHost);

    for (int i=0; i<max_length; i++)
    {
        std::cout<<concs[i];
    }
    return 0;
}

__global__ void rkf5(double* concs, int* max_length)
{
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    concs[idx]=idx;
    //dim3 threads = dim3(max_length);
    k1<<< 1, *max_length >>>(concs);
}
__global__ void k1(double* concs)
{
    int idx = blockIdx.x * blockDim.x + threadIdx.x;
    concs[idx]=0;
}

Please help me out here, I've spent so much time Googling this problem and every lead I find has no solution posted.

¿Fue útil?

Solución

Your command line for compiling and linking:

nvcc.exe -dlink -o "x64\Debug\Dynamic Parallelism Test.device-link.obj" 
-Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd  " 
-L"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\lib\x64" 
cuda.lib cudart.lib kernel32.lib user32.lib gdi32.lib winspool.lib  
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib 
odbc32.lib odbccp32.lib -lcudadevrt -gencode=arch=compute_35,code=sm_35 -G 
--machine 64 "x64\Debug\CUDA Test 2.cu.obj" "x64\Debug\CUDA Test.cu.obj"

You are trying to link against cudadevrt linux style (-lcudadevrt). This will not work on windows, the invoked linker is form VS. Add cudadevrt.lib to your linker input like cudart.lib.

Otros consejos

I have successfully compiled and run your code by:

  1. using the procedure in Using CUDA dynamic parallelism in Visual Studio 2010;
  2. changing main2 to main;

The program outputs 0123 :-)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top