Possible bug discovered in CUDA 5.5 RC helper_timer.h

Am attempting to compile on a Windows 7 64 bit machine setting my .cu files to x64 as the target platform. The preprocessor logic inside of this header file does not recognize x64 as a target leading it down the compile path for a Linux and MacOS system. (It chokes on trying to find sys/time.h on line 223 for StopWatch class. Not certain if this issue is rampant or not, haven’t tried looking through other header files.

I did not find out this file in my source tree.
Could you tell me the path of the file?

Hi … its in the SDK in the same branch where the example code is found. Checking on my LINUX machine its at $(SDK_PATH)/C/common/inc … In Windows (where I found the problem) … it gets installed to C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.5\common\inc

I saw there’s “#ifdef WIN32” in line 58. I don’t know if this macro has been defined.

Could you tell us how do you compile the code?

Yes… that is my point. If I compile it as an x64 project in MS2012, it totally bypassed the Win32 branch … thus missing the include on <windows.h>, the StopWatchWin class declarations and ended up in the Linux and Mac OS branch further down in the code (line 219) #else. If I switch to Win32 compilation settings in MSVS … all is right with the world. Haven’t looked at it enough to determine if just adding the x64 windows macro (something like _x86_64 ??) is safe and would suffice or if you needed a completely new branch for 64 bit code.

From MSDN Predefined Macros | Microsoft Docs
we saw this:

_WIN32
Defined for applications for Win32 and Win64. Always defined.
_WIN64
Defined for applications for Win64.

I also tested the macro in vs 2012, by adding these lines to the source code

#ifdef WIN32
#else
#error
#endif

and it passed the X64 build.

could you show us a piece of the source code, and how do you compile it?

Hi Joseph … do you include <windows.h> in your file? I did find elsewhere in my project that in translating some of the code from Linux to Windows, that I’d inadvertantly left out that #include. which may have been the cause. As I’ve revereted my project back to MSVS2010 and have that As the windows.h on my system is from 2010, I can’t confirm if the #ifndef WIN32 is forced (via its include of WinDef.h) even for a 64 bit compile … if you have it on your test system you should be able to confirm that macro is defined as the MSDN pages suggest.

If I’m feeling adventuresome this weekend, I might try putting 2012 back on and checking it. Otherwise, its likely the cause of my compile issue was the lack of the #include <windows.h>.

Thx!!

Adding include <windows.h> in helper_timer.h fixed this issue for me! I had the same problem using helper_cuda.h on a windows 64 bit machine.