find the fpe

some macros & code snippets for seeking and destroying fpes in your CUDA code

#ifndef _FPE_DEBUG_INFO_
#define _FPE_DEBUG_INFO_ printf("fpe detected in %s around %d, dump follows :\n",__FILE__,__LINE__);
#endif

#define fpe(x) (isnan(x) || isinf(x))

#ifdef _VERBOSE_DEBUG_
	if (fpe(my_variable)){
   		_FPE_DEBUG_INFO_
      	        printf("my_variable : %f threadIdx %i\n",my_variable,threadIdx.x);
	        asm(“trap;”);

  	}
#endif
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s