Boost C++ Libraries: Ticket #4431: stdint.h not available in CUDA nvcc + visual studio https://svn.boost.org/trac10/ticket/4431 <p> The "boost/config/compiler/nvcc.hpp" contains "#define BOOST_HAS_STDINT_H", but it looks like stdint.h availability for CUDA nvcc is platform-dependent; it is unavailable if nvcc is used with visual studio (in my case it is vc9). Thus this fails to compile with nvcc: </p> <p> #include "boost/cstdint.hpp" </p> <p> Also, AFAIK, nvcc passes all code that is not CUDA-related to the native compiler that is g++ on linux and cl on windows. So, it may sound silly, but commenting out anything and including "boost/config/compiler/visualc.hpp" in nvcc.hpp helps with several other compile errors, of course for msvc only. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4431 Trac 1.4.3 John Maddock Thu, 15 Jul 2010 10:31:21 GMT cc set https://svn.boost.org/trac10/ticket/4431#comment:1 https://svn.boost.org/trac10/ticket/4431#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">joel.falcou@…</span> added </li> </ul> <p> Sergey, </p> <p> I'm not able to run the nvcc compiler here, so I'm totally dependent upon others supplying the correct patches. The current nvcc config is the one supplied by Joel Falcoe here: <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/3919"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/3919</a>. I'm adding him as a CC to this ticket - perhaps you can work out a better configuration option between you - I'm fairly sure he enabled BOOST_HAS_STDINT_H for a reason? </p> <p> Cheers, John Maddock. </p> Ticket Joel Falcou Thu, 15 Jul 2010 11:24:13 GMT <link>https://svn.boost.org/trac10/ticket/4431#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4431#comment:2</guid> <description> <p> I can test the following ticket tomorrow no problem. </p> <p> I think the fact is that the original patch was generated using a unix based nvcc with the config script. Now I think Sergey is right and the nvcc.hpp file should be rewritten by just adding the NVCC macro AND forward to the current underlying compiler </p> <p> I will give a shot to that </p> </description> <category>Ticket</category> </item> <item> <dc:creator>sprevrha</dc:creator> <pubDate>Mon, 11 Oct 2010 17:43:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4431#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4431#comment:3</guid> <description> <p> I followed the advice and commented out everything and included the msvc config. Now I am getting </p> <p> \boost\include\boost-1_43\boost/test/utils/basic_cstring/basic_cstring.hpp(60): error: enumeration value is out of "int" range </p> <p> when I do a empty boost test in a .cu file. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 12 Oct 2010 07:46:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4431#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4431#comment:4</guid> <description> <p> If you look at the line of code in question, you'll see a possible workaround there already. </p> <p> If you get something that works, please report a separate bug to Boost.Test. </p> <p> In the mean time, what config are you using - if there's a patch available I can apply to Trunk. </p> <p> Thanks, John. </p> </description> <category>Ticket</category> </item> <item> <author>sven.prevrhal@…</author> <pubDate>Mon, 20 Dec 2010 17:54:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4431#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4431#comment:5</guid> <description> <p> John - At this point, I am using MSVC 9.0 on Win 7 64-bit, compiling for 64-bit with CUDA 3.2 using nvcc with the -m64 switch. </p> <p> Getting this to work has failed, at least for me. If I switch in basic_cstring </p> <pre class="wiki">#if !BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) enum npos_type { npos = static_cast&lt;size_type&gt;(-1) }; #else // IBM/VisualAge version 6 is not able to handle enums larger than 4 bytes. // But size_type is 8 bytes in 64bit mode. static const size_type npos = -1 ; #endif </pre><p> to the #else clause, the cuda compiler dies: </p> <pre class="wiki">1&gt;"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\\bin\nvcc.exe" -m64 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -D_DEBUG -D_WIN32 -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\\include" -I"./" -I"../../common/inc" -I"../../../shared/inc" -I""D:\projects\quattro\src\recon\src\\..\include\TEST_librecon"" -I""D:\projects\quattro\src\recon\src\\..\include"" -I""c:\packages\boost\include\boost-1_43"" -I""c:\packages\boost\include"" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MDd " -maxrregcount=32 -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --compile -o "x64\Debug\sorting.cu.obj" "d:\projects\quattro\src\recon\src\TEST_librecon\sorting.cu" 1&gt;sorting.cu 1&gt;c:\packages\boost\include\boost-1_43\boost/test/utils/basic_cstring/basic_cstring.hpp(59): warning: integer conversion resulted in a change of sign 1&gt;nvcc error : 'cudafe' died with status 0xC0000005 (ACCESS_VIOLATION) 1&gt;Compiling... </pre><p> I am not experienced enough to work up a patch for this. I can't even tell if that's a bug with nvcc (since people report boost to work with gcc, but have they tested boost unit testing?) or whether the boost macros are just wrong for the nvcc on MSVC case. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 20 Dec 2010 18:21:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4431#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4431#comment:6</guid> <description> <p> That looks like an nvcc bug given that the compiler is segfaulting. </p> <p> Sorry, I don't really know what to suggest here, how is the rest of Boost doing with your current nvcc config? </p> <p> John. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel Falcou</dc:creator> <pubDate>Thu, 30 Dec 2010 16:30:55 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/4431#comment:7 https://svn.boost.org/trac10/ticket/4431#comment:7 <ul> <li><strong>owner</strong> changed from <span class="trac-author">John Maddock</span> to <span class="trac-author">Joel Falcou</span> </li> </ul> Ticket sven.prevrhal@… Mon, 17 Jan 2011 19:40:21 GMT component changed https://svn.boost.org/trac10/ticket/4431#comment:8 https://svn.boost.org/trac10/ticket/4431#comment:8 <ul> <li><strong>component</strong> <span class="trac-field-old">config</span> → <span class="trac-field-new">concept_check</span> </li> </ul> <p> I found a compliant stdint.h for my MSVC 9.0 compiler at <a class="ext-link" href="http://msinttypes.googlecode.com/.svn/trunk/stdint.h"><span class="icon">​</span>http://msinttypes.googlecode.com/.svn/trunk/stdint.h</a> , put this in the path, still didn't work, nvcc complaining about enumeration value is out of "int" range in the boost generic traits header. What worked was to undefine BOOST_NO_INCLASS_MEMBER_INITIALIZATION in config/compiler/nvcc.hpp (read some similar issue with this resolution in a different ticket). As a patch, I am proposing to wrap #define BOOST_NO_INCLASS_MEMBER_INITIALIZATION - </p> <p> #ifndef _MSC_VER #define BOOST_NO_INCLASS_MEMBER_INITIALIZATION #endif </p> <p> if it's indeed only a Windows problem. Sven </p> Ticket anonymous Tue, 18 Jan 2011 09:12:59 GMT <link>https://svn.boost.org/trac10/ticket/4431#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4431#comment:9</guid> <description> <p> I'm not sure that's the correct fix - as I understand it nvcc supports inline initializarion perfectly well - the bug is elsewhere (assigning a too large value to an enum). What/where was the actual error? </p> <p> Thanks, John. </p> </description> <category>Ticket</category> </item> <item> <author>sven.prevrhal@…</author> <pubDate>Tue, 18 Jan 2011 17:27:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4431#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4431#comment:10</guid> <description> <p> You're right...The actual error without, but with a stdint.h in place is/was </p> <p> c:\packages\boost\include\boost-1_45\boost/integer_traits.hpp(56): error: enumeration value is out of "int" range 1&gt; detected during instantiation of class "boost::detail::integer_traits_base&lt;T, min_val, max_val&gt; [with T=boost::long_long_type, min_val=-9223372036854775808LL, max_val=9223372036854775807LL]" </p> <p> and occured, as far as I can tell during #include &lt;boost/random.hpp&gt; in a nvcc-compiled cuda file. I use nvcc flags -m64 -ccbin -use_fast_math -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MD " -maxrregcount=32 -gencode=arch=compute_13,code=\"sm_13,compute_13\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --compile -o "x64\<a class="missing wiki">ReleaseLib</a>\projection.cu.obj" "d:\projects\quattro\src\recon\src\CUDAProjector\projection.cu" </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 18 Jan 2011 18:11:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4431#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4431#comment:11</guid> <description> <p> Hold on though, if I am not mistaken #define'ing BOOST_NO_INCLASS_MEMBER_INITIALIZATION _dis_allows initialization inlining, so therefore having the #define in nvcc.hpp is wrong, and putting it inside a #ifdef _MSC_VER prevents it for nvcc on Windows, so in fact allows inline initialization. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 18 Jan 2011 18:29:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4431#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4431#comment:12</guid> <description> <blockquote class="citation"> <p> Hold on though, if I am not mistaken #define'ing BOOST_NO_INCLASS_MEMBER_INITIALIZATION _dis_allows initialization inlining, so therefore having the #define in nvcc.hpp is wrong, and putting it inside a #ifdef _MSC_VER prevents it for nvcc on Windows, so in fact allows inline initialization. </p> </blockquote> <p> It would have to be inside an #ifndef _MSC_VER block? But I see this comment in the header file: </p> <p> <em> NVCC Basically behaves like some flavor of MSVC6 + some specific quirks </em></p> <p> Which suggests inline initialization is *not* supported? </p> <p> Confused yours, John. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sun, 30 Jan 2011 12:47:53 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4431#comment:13 https://svn.boost.org/trac10/ticket/4431#comment:13 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/68566" title="Change nvcc config to use underlying compiler config. Fixes #4431.">[68566]</a>) Change nvcc config to use underlying compiler config. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4431" title="#4431: Bugs: stdint.h not available in CUDA nvcc + visual studio (closed: fixed)">#4431</a>. </p> Ticket