相关疑难解决方法(0)

How do I start a new CUDA project in Visual Studio 2008?

This is an incredibly basic question, but how do I start a new CUDA project in Visual Studio 2008? I have found tons and tons of documentation about CUDA related matters, but nothing about how to start a new project. I am working with Windows 7 x64 Visual Studio 2008 C++. I would really like to find some sort of really really basic Hello World app to just get a basic program compiling and running.

Edit:

I tried your steps …

c++ cuda visual-studio

27
推荐指数
1
解决办法
4万
查看次数

如何将CUDA代码分成多个文件

我正在尝试将CUDA程序分成两个独立的.cu文件,以便更接近于在C++中编写真正的应用程序.我有一个简单的小程序:

在主机和设备上分配内存.
将主机阵列初始化为一系列数字.将主机阵列复制到设备阵列使用设备内核查找阵列中所有元素的平方将设备阵列复制回主机阵列打印结果

如果我把它全部放在一个.cu文件中并运行它,这很有效.当我将它分成两个单独的文件时,我开始得到链接错误.像我最近的所有问题一样,我知道这很小,但它是什么?

KernelSupport.cu

#ifndef _KERNEL_SUPPORT_
#define _KERNEL_SUPPORT_

#include <iostream>
#include <MyKernel.cu>

int main( int argc, char** argv) 
{
    int* hostArray;
    int* deviceArray;
    const int arrayLength = 16;
    const unsigned int memSize = sizeof(int) * arrayLength;

    hostArray = (int*)malloc(memSize);
    cudaMalloc((void**) &deviceArray, memSize);

    std::cout << "Before device\n";
    for(int i=0;i<arrayLength;i++)
    {
        hostArray[i] = i+1;
        std::cout << hostArray[i] << "\n";
    }
    std::cout << "\n";

    cudaMemcpy(deviceArray, hostArray, memSize, cudaMemcpyHostToDevice);
    TestDevice <<< 4, 4 >>> (deviceArray);
    cudaMemcpy(hostArray, deviceArray, memSize, cudaMemcpyDeviceToHost);

    std::cout << "After device\n"; …
Run Code Online (Sandbox Code Playgroud)

c c++ cuda visual-studio-2008

13
推荐指数
1
解决办法
3万
查看次数

标签 统计

c++ ×2

cuda ×2

c ×1

visual-studio ×1

visual-studio-2008 ×1