Skip to content
Snippets Groups Projects
Commit 5c3423a6 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixed TNL_ASSERT to work with CUDA 7.5 and older.

parent 3b85a05d
No related branches found
No related tags found
No related merge requests found
...@@ -26,28 +26,42 @@ ...@@ -26,28 +26,42 @@
// __CUDA_ARCH__ is defined by the compiler only for code executed on GPU // __CUDA_ARCH__ is defined by the compiler only for code executed on GPU
#ifdef __CUDA_ARCH__ #ifdef __CUDA_ARCH__
#define TNL_ASSERT( ___tnl__assert_condition, ___tnl__assert_command ) \ #define TNL_ASSERT( ___tnl__assert_condition, ___tnl__assert_command ) \
if( ! ( ___tnl__assert_condition ) ) \ if( ! ( ___tnl__assert_condition ) ) \
{ \ { \
printf( "Assertion '%s' failed !!! \n File: %s \n Line: %d \n Diagnostics: Not supported with CUDA.\n", \ printf( "Assertion '%s' failed !!! \n File: %s \n Line: %d \n Diagnostics: Not supported with CUDA.\n", \
__STRING( ___tnl__assert_condition ), \ __STRING( ___tnl__assert_condition ), \
__FILE__, \ __FILE__, \
__LINE__ ); \ __LINE__ ); \
\ \
} }
#else // __CUDA_ARCH__ #else // __CUDA_ARCH__
#define TNL_ASSERT( ___tnl__assert_condition, ___tnl__assert_command ) \ #if ( __CUDA_API_VERSION >= 8000 )
if( ! ( ___tnl__assert_condition ) ) \ #define TNL_ASSERT( ___tnl__assert_condition, ___tnl__assert_command ) \
{ \ if( ! ( ___tnl__assert_condition ) ) \
std::cerr << "Assertion '" << __STRING( ___tnl__assert_condition ) << "' failed !!!" << std::endl \ { \
<< "File: " << __FILE__ << std::endl \ std::cerr << "Assertion '" << __STRING( ___tnl__assert_condition ) << "' failed !!!" << std::endl \
<< "Function: " << __PRETTY_FUNCTION__ << std::endl \ << "File: " << __FILE__ << std::endl \
<< "Line: " << __LINE__ << std::endl \ << "Function: " << __PRETTY_FUNCTION__ << std::endl \
<< "Diagnostics: "; \ << "Line: " << __LINE__ << std::endl \
___tnl__assert_command; \ << "Diagnostics: "; \
throw EXIT_FAILURE; \ ___tnl__assert_command; \
} throw EXIT_FAILURE; \
}
#else // ( __CUDA_API_VERSION >= 8000 )
#define TNL_ASSERT( ___tnl__assert_condition, ___tnl__assert_command ) \
if( ! ( ___tnl__assert_condition ) ) \
{ \
std::cerr << "Assertion '" << __STRING( ___tnl__assert_condition ) << "' failed !!!" << std::endl \
<< "File: " << __FILE__ << std::endl \
<< "Function: (not known in CUDA 7.5 or older)" << std::endl \
<< "Line: " << __LINE__ << std::endl \
<< "Diagnostics: "; \
___tnl__assert_command; \
throw EXIT_FAILURE; \
}
#endif // ( __CUDA_API_VERSION >= 8000 )
#endif // __CUDA_ARCH__ #endif // __CUDA_ARCH__
#else /* #ifndef NDEBUG */ #else /* #ifndef NDEBUG */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment