I use a bit of #pragma nowarn to stop the compiler giving me warnings about subscripts being out of range in a templated kernel (the subscripts can never be out of range but the compiler isn’t recognising that).
Today I found a bug in the kernel which was fixed by removing the #pragma nowarn commands. Rather unexpectedly this preprocessor which I was expecting just to remove annoying warnings seemed to be changing the program execution.
Without a code example that reproduces the problem, no one can even try to fix your problem…
You don’t mention what warning message (Edit: sorry, it’s the first thing you say! External Media, why it’s incorrect, how you produce it… what do you seriously expect?
I don’t have CUDA available right now but the code is something like:
template<int length> kernel(...) {
double cache[length];
// Do some clever stuff that fills the cache
switch (length) {
case 1:
a = cache[0]; break;
case 2:
a = cache[0] + cache[1]; break; // Gives a warning when compiled with length = 1. To supress the warning (subscript out of range) we can prepend the line with #pragma nowarn, but this appears to effect the program execution.
}
}
#pragma Preprocessor Directives Issues special commands to the compiler. The pragma directive is used to access compiler-specific preprocessor extensions. A common use of #pragma is the #pragma once directive, which asks the compiler to include a header file only a single time, no matter how many times it has been imported. #pragma once
// header file code