Coder Social home page Coder Social logo

Comments (9)

jzmaddock avatar jzmaddock commented on July 28, 2024

I think we do need to include nvcc.hpp to set up the device/host macros, but disable the nvcc specific macros when clang is being used. There are actually 3 use cases:

  1. Clang is doing everything.
  2. NVCC is calling clang as the host compiler and/or preprocessor.
  3. It really is NVCC.

I assume that (2) still need the workarounds (in which case Boost.Optional may still be broken if it's behaving differently for clang), but I don't have a CUDO setup here to test on any more.

If we encase the block:

// A bug in version 7.0 of CUDA prevents use of variadic templates in some occasions
// https://svn.boost.org/trac/boost/ticket/11897
// This is fixed in 7.5. As the following version macro was introduced in 7.5 an existance
// check is enough to detect versions < 7.5
#if BOOST_CUDA_VERSION < 7050000
#   define BOOST_NO_CXX11_VARIADIC_TEMPLATES
#endif
// The same bug is back again in 8.0:
#if (BOOST_CUDA_VERSION > 8000000) && (BOOST_CUDA_VERSION < 8010000)
#   define BOOST_NO_CXX11_VARIADIC_TEMPLATES
#endif
// CUDA (8.0) has no constexpr support in msvc mode:
#if defined(_MSC_VER) && (BOOST_CUDA_VERSION < 9000000)
#  define BOOST_NO_CXX11_CONSTEXPR
#endif

In a

# !defined(__clang__) || defined(__NVCC__)

block, does that fix things for you?

from config.

psalz avatar psalz commented on July 28, 2024

Yes, that would indeed fix it!

(Note: Coming back to this I initially had some trouble to replicate the bug with the snippet I provided above, as variadic templates require compilation with std=c++11 or newer - which I forgot).

from config.

bernhardmgruber avatar bernhardmgruber commented on July 28, 2024

I just ran into this as well, because BOOST_METAPARSE_STRING fails to compile with clang in CUDA mode: https://cuda.godbolt.org/z/nzsGEGTn9
The reason is again because BOOST_NO_CXX11_VARIADIC_TEMPLATES is wrongly defined by Boost.Config.

from config.

bernhardmgruber avatar bernhardmgruber commented on July 28, 2024

@jzmaddock If I apply the above mentioned fix then I get compilation errors: boost/type_traits/is_base_and_derived.hpp:142:25: error: invalid application of 'sizeof' to an incomplete type 'boost::in_place_factory_base' BOOST_STATIC_ASSERT(sizeof(B) != 0);. This might be more involved to fix.

from config.

jzmaddock avatar jzmaddock commented on July 28, 2024

What compile line are you using with clang, for some reason MSys-mingw/clang-11 and

 clang -x cuda --cuda-gpu-arch=sm_75 -std=c++14 -I. -nocudalib -nocudainc t.cu

does NOT set __CUDACC__ which is required to trigger the issue.

from config.

jzmaddock avatar jzmaddock commented on July 28, 2024

Ah, -nocudainc is the issue, but without that I get other issues.

from config.

jzmaddock avatar jzmaddock commented on July 28, 2024

OK reproduced on Ubuntu with clang-11 and CUDA 11 SDK. The above fix addresses the original issue so this one is closing down now.

@bernhardmgruber : your issue indicates that something has forward declared boost::in_place_factory_base and then used it in is_base_of: this is indeed an error, and should be so. You will need to provide more information in a separate issue though as I'm unable to reproduce with current develop and either clang-10 or 11 and CUDA 11. You could try including boost/utlity/in_place_factory.hpp at the start of your test file to see if this fixes things? If so then it's a question of tracking down who the culprit is (ie which library is instantiating is_base_of on an incomplete type).

from config.

jzmaddock avatar jzmaddock commented on July 28, 2024

@bernhardmgruber this should work for you also: https://cuda.godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:cuda,selection:(endColumn:1,endLineNumber:8,positionColumn:1,positionLineNumber:8,selectionStartColumn:1,selectionStartLineNumber:8,startColumn:1,startLineNumber:8),source:'%23include+%3Cboost/config.hpp%3E%0A%23undef+BOOST_NO_CXX11_VARIADIC_TEMPLATES%0A%23undef+BOOST_NO_VARIADIC_TEMPLATES%0A%0A%0A%23include+%3Cboost/metaparse/string.hpp%3E%0A%0A//+%23if+BOOST_CUDA_VERSION+%3C+7050000%0A//+%23error%0A//+%23endif%0A%0A//+%23if+defined+BOOST_NO_CXX11_VARIADIC_TEMPLATES%0A//+%23error%0A//+%23endif%0A%0A//+static_assert(BOOST_METAPARSE_STD+%3E%3D+2011,+%22%22)%3B%0A%0Ausing+T+%3D+BOOST_METAPARSE_STRING(%22asfd%22)%3B%0A'),l:'5',n:'0',o:'CUDA+C%2B%2B+source+%231',t:'0')),k:40.469973890339425,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:cuclang1100,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:cuda,libs:!(),options:'-std%3Dc%2B%2B14+-O3+-I/opt/compiler-explorer/libs/boost_1_77_0/',selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1,tree:'1'),l:'5',n:'0',o:'clang+11.0.0+sm_75+CUDA-10.2+(CUDA+C%2B%2B,+Editor+%231,+Compiler+%231)',t:'0')),k:33.33333333333333,l:'4',m:50,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compiler:1,editor:1,fontScale:14,fontUsePx:'0',tree:'1',wrap:'1'),l:'5',n:'0',o:'Output+of+clang+11.0.0+sm_75+CUDA-10.2+(Compiler+%231)',t:'0')),header:(),l:'4',m:50,n:'0',o:'',s:0,t:'0')),k:59.530026109660575,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4

from config.

bernhardmgruber avatar bernhardmgruber commented on July 28, 2024

@jzmaddock thank you! We have something similar in our code now. Unfortunately, the problem persists and now moved to Boost.Format. See: #406.

from config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.