 }
 #define SAFE_CALL(call,msg) _safe_cuda_call((call),(msg),__FILE__,__LINE__)
 
+#ifndef cublasSafeCall
+#define cublasSafeCall(err) __cublasSafeCall(err, __FILE__, __LINE__)
+#endif
+inline void __cublasSafeCall(cublasStatus_t err, const char *file, const int line)
+{
+if( CUBLAS_STATUS_SUCCESS != err) {
+fprintf(stderr, "CUBLAS error in file '%s', line %d\n \nerror %d \nterminating!\n",__FILE__, __LINE__,err);
+cudaDeviceReset(); assert(0);
+}
+}
 // Apply global contrast normalization to
 // each input image.
 // For each channel in each image, the mean and stddev has

	// of values seen). n is number of values corresponding
	// to each M1 and M2 value.
	mean_stddev_reduction_kernel1<<<grid,block,0,sa.getStream(stream)>>>(dPssIn, d_M1, d_M2, d_n);

	// Second reduction generates mean and stddev values
	// 12x12 fit in a single block so there's no

#include <opencv2/gpu/stream_accessor.hpp>
#include <cuda_runtime.h>
#include <cuda_runtime_api.h>
#include <cublas_v2.h>

using std::cout;
using std::endl;
