3

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

First-chance exception at 0x770ab9bc in test_fft.exe: Microsoft C++ exception: cudaError_enum at memory location 0x016cf234...

My build environment is:

  • 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)

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.

Class header:

#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 constructor:

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 ) );
    }

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.


References

CudaSafeCall definition

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

__cudaSafeCall definition

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;
}
Stephen
  • 71
  • 1
  • 4
  • The debugger catches exceptions that may be thrown by components during normal operations. So, there might be a component in place that expects those exceptions and will catch them before they ever reach your code. Is this exception actually causing a problem in your code? – Roger Dahl Jun 08 '12 at 18:57

1 Answers1

2

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.

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.

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257