简体   繁体   English

Nsight Eclipse Edition Indexer的CUDA 7.5问题

[英]CUDA 7.5 issues with nsight eclipse edition indexer

just installed cuda 7.5 on ubuntu 15.04. 刚在ubuntu 15.04上安装了cuda 7.5。 For some reason my indexer is not picking up any of the cuda functions. 由于某种原因,我的索引器未选择任何cuda函数。 I am not sure why. 我不知道为什么。 The code compiles fine but I find it annoying not being able to hit Ctrl+Space and see my options. 该代码可以很好地编译,但是我发现无法按Ctrl + Space并查看我的选项很烦人。 I tried to include some of the cuda headers but this does not seem to help. 我试图包括一些cuda标头,但这似乎无济于事。 The indexer works for all of the stl functions but none of the function that start with cuda... show up in the auto complete. 索引器可用于所有stl函数,但不适用于以cuda开头的函数。

#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_device_runtime_api.h>

inline void cuda_error(cudaError_t code, const char* lbl)
{
    if(code != cudaSuccess)
    {
        std::cerr << lbl << " : " << cudaGetErrorString(code) << std::endl;
        exit(1);
    }
}

struct City
{
    int n;
    float x, y;

    City(int n_ = 0, float x_ = 0, float y_ = 0) : n(n_), x(x_), y(y_) { }

    __host__ __device__ float fast_distance(const City& other)
    {
        float dx = other.x - x;
        float dy = other.y - y;
        return dx * dx + dy * dy;
    }
    __host__ __device__ float distance(const City& other)
    {
        float dx = other.x - x;
        float dy = other.y - y;
        return sqrtf(dx * dx + dy * dy);
    }
};

int main()
{
    using namespace std;

    ifstream fin("input.txt");
    vector<City> citites;
    City c;
    while(fin >> c.n >> c.x >> c.y)
        citites.push_back(c);

    City* cities_d;
    //if I start typing cuda and hit ctrl + space there are no option displayed
    cudaMalloc(&cities_d, sizeof(City) * citites.size());
    cudaMemcpy(cities_d, citites.data(), citites.size() * sizeof(City), cudaMemcpyHostToDevice);

    return 0;
}

I just had to put this at the top of my program. 我只需要把它放在程序的顶部。 Not that great of a solution but it works. 不是很好的解决方案,但它可以工作。 I guess this new version of nsight does not have eclipse automatically include the already included headers by default with cuda. 我猜这是新版的nsight,默认情况下cuda没有eclipse自动包含已经包含的标头。

#ifdef __CDT_PARSER__
#undef __CUDA_RUNTIME_H__
#include <cuda_runtime.h>
#endif

Whats strange now is that when I do this it disables the highlighting of device code in yellow. 现在奇怪的是,当我这样做时,它将禁用以黄色突出显示设备代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM