相关疑难解决方法(0)

CUDA流销毁和CudaDeviceReset

我使用CUDA流实现了以下类

class CudaStreams
{
    private:
        int             nStreams_;
        cudaStream_t*   streams_;
        cudaStream_t    active_stream_;

    public:

        // default constructor
        CudaStreams() { }

        // streams initialization
        void InitStreams(const int nStreams = 1) {
            nStreams_ = nStreams;
            // allocate and initialize an array of stream handles
            streams_ = (cudaStream_t*) malloc(nStreams_*sizeof(cudaStream_t));
            for(int i = 0; i < nStreams_; i++) CudaSafeCall(cudaStreamCreate(&(streams_[i]))); 

            active_stream_ = streams_[0];}

        // default destructor
        ~CudaStreams() {     
            for(int i = 0; i<nStreams_; i++) CudaSafeCall(cudaStreamDestroy(streams_[i])); }

}; 
Run Code Online (Sandbox Code Playgroud)

如果我现在运行这个简单的代码

void main( int argc, char** argv) 
{
    streams.InitStreams(1);
    streams.~CudaStreams(); …
Run Code Online (Sandbox Code Playgroud)

c++ cuda gpgpu class nvidia

1
推荐指数
1
解决办法
2070
查看次数

标签 统计

c++ ×1

class ×1

cuda ×1

gpgpu ×1

nvidia ×1