簡體   English   中英

Nsight Eclipse Edition Indexer的CUDA 7.5問題

[英]CUDA 7.5 issues with nsight eclipse edition indexer

剛在ubuntu 15.04上安裝了cuda 7.5。 由於某種原因,我的索引器未選擇任何cuda函數。 我不知道為什么。 該代碼可以很好地編譯,但是我發現無法按Ctrl + Space並查看我的選項很煩人。 我試圖包括一些cuda標頭,但這似乎無濟於事。 索引器可用於所有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;
}

我只需要把它放在程序的頂部。 不是很好的解決方案,但它可以工作。 我猜這是新版的nsight,默認情況下cuda沒有eclipse自動包含已經包含的標頭。

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

現在奇怪的是,當我這樣做時,它將禁用以黃色突出顯示設備代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM