本文介绍了无法找到异常源:内存位置中的cudaError_enum的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试确定Microsoft C ++异常的来源:

I am trying to identify the source of an Microsoft C++ exception:

我的构建环境是:


  • IDE:Microsoft Visual C ++ 2010 Express

  • NVIDIA驱动程序:301.27

  • CUDA:NVIDIA CUDA工具包v4 .2(32位)

  • SDK:NVIDIA GPU Computing SDK 4.2(32位)

  • IDE: Microsoft Visual C++ 2010 Express
  • NVIDIA Driver: 301.27
  • CUDA: NVIDIA CUDA Toolkit v4.2 (32-bit)
  • SDK: NVIDIA GPU Computing SDK 4.2 (32-bit)

问题范围:我正在尝试将CUFFT包装在C ++类后面。这样,我可以隐藏从一种数据类型到cufftComplex的转换,FFT的执行以及调用代码的内存传输。

Problem scope: I am trying to wrap the CUFFT behind a C++ class. This way I can hide the translation from one data type to the cufftComplex, execution of the FFT and memory transfers from the calling code.

类头 >:

#ifndef SIGNAL_PROCESSING_FFT_HPP
#define SIGNAL_PROCESSING_FFT_HPP

#include "signal_processing\types.hpp"

#include <boost/cstdint.hpp>

#include <cufft.h>

#include <vector>

namespace signal_processing {

    class FFT {
    public:

        FFT ( boost::uint32_t size );

        virtual ~FFT();

        void forward ( ComplexVectorT const& input, ComplexVectorT& output );

        void reverse ( ComplexVectorT const& input, ComplexVectorT& output );

    private:

        cufftComplex* m_device_data;

        cufftComplex* m_host_data;

        cufftHandle m_plan;

        boost::uint32_t m_size;
    };

}

#endif // SIGNAL_PROCESSING_FFT_HPP

FFT构造函数:

FFT::FFT ( boost::uint32_t size )
        : m_size ( size )
    {
            CudaSafeCall ( cudaMalloc((void**)&m_device_data, sizeof(cufftComplex) * m_size ) );
            m_host_data = (cufftComplex*) malloc ( m_size * sizeof(cufftComplex) );
            CufftSafeCall ( cufftPlan1d ( &m_plan, m_size, CUFFT_C2C, 1 ) );
    }

第一行中的FFT构造函数中抛出Microsoft C ++异常对cudaMalloc的调用。仅当我在Visual Studio调试器中使用FFT类运行代码时,才会出现此错误。

The Microsoft C++ exception is being thrown in the FFT constructor at the first line where the call to cudaMalloc. This error only seems to occur if I run the code using the FFT class with the Visual Studio debugger.

CudaSafeCall定义

#define CudaSafeCall(err) __cudaSafeCall ( err, __FILE__, __LINE__ )

__ cudaSafeCall定义

inline void __cudaSafeCall ( cudaError err, const char* file, const int line )
{
#ifdef CUDA_ERROR_CHECK
        if ( cudaSuccess != err )
        {
            std::cerr << boost::format ( "cudaSafeCall() failed at %1$s:%2$i : %3$s\n" )
                % file
                % line
                % cudaGetErrorString ( err );
            exit(-1);
        }
#endif
        return;
}


推荐答案

您正在进行的观察与在CUDA库中正确捕获和处理的异常有关。在某些情况下,它是CUDA GPU操作的正常部分。我相信您的应用在这种情况下不会返回API错误。如果您不在可以报告此问题的VS环境中,则根本不会观察到此情况。

The observation you are making has to do with an exception that is caught and handled properly within the CUDA libraries. It is, in some cases, a normal part of CUDA GPU operation. I believe your application is returning no API errors in this case. If you were not within the VS environment that can report this, you would not observe this at all.

在CUDA下,这被视为正常行为。我相信在CUDA 5.5中有一些消除它的尝试。您可能想尝试一下,尽管无论哪种方式都不认为是问题。

This is considered normal behavior under CUDA. I believe there were some attempts to eliminate it in CUDA 5.5. You might wish to try that, although it's not considered an issue either way.

这篇关于无法找到异常源:内存位置中的cudaError_enum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 15:24