cudaAssert() from device code?

I’d like to have a macro for killing off a kernel if I can tell that something’s wrong. If I could have an assertion failure trigger a ULF (or better, some rarely-used error code), that’d be great.

You’d think it would be easy to trigger a ULF :)

#define DO_ULF() { int *y = NULL; int x = *y; }

#ifndef NDEBUG

#define cudaAssert(x) if (!(x)) { DO_ULF(); }


#define cudaAssert(x) {}

#endif /* NDEBUG */

So I think this doesn’t work because NULL doesn’t really point to GMEM, or something? Does anyone already have something like this? Suggestions?