int canMapHostMemory Possible values?

The field “canMapHostMemory” is an integer in cudaDeviceProps structure…

So, what number means “yes” and what number means “no” ??

Had been a boolean - there would be no confusions

Thanks!

uhhh… in C, one number evaluates to false, and every other number evaluates to true…

(bools are C++ constructs anyway)

Ah, Is it?

I return “0” in my “C” functions to signal success and “-1” to return failure. Will that work?

Btw, I did not write the NVIDIA driver and I have no clue what it returns unless it is “documented”.

int condition = 0;

if (condition)

{

  char* segfault = 0;

  segfault[50] = 'p';

  return;

}

This code will not segfault. Does that answer your question?

Of course, I do understand.

You continue to treat me like an ignorant C kid – which sounds very funny.

My point is:

I have no idea what the driver puts in there unless it is “documented”. I can assume that a zero means not supported and non-zero means supported. But that is just an assumption. I dont find a documentation.

If it had been a boolean – it does NOT need a documentation.

Thats my POINT.

There are no booleans in C–they were introduced in C++ (and C99 as well, but so what–you can’t reliably use C99 with MSVC). In C, logical operations that resolve to false actually become 0, and logical operations that resolve to true become some number (it might be specified in the spec as 1, I’m not sure). Considering our intent is usually to be as obvious as possible, if we want you to be able to do something like if (properties.canMapHostMemory) and have things behave in a sensible manner there’s only one way to do it.

This is also explicitly documented in the reference manual.

The reference manual has it. I was checking the PG and the HTML documentation all the while. Thanks!

Explicit documentation always helps.

btw,

The host compiler by default is C++ with 2.2, right?

So, bool should get along well. no?