Skip to content

Small change required to successfully use XTL with nvcc CUDA compiler #183

@gridley

Description

@gridley

Hi,

I was hoping that since XTL works with any C++14 compiler, the compilation of host only CUDA 10 code should work fine with XTL. Normally, I would not attempt this and instead find a replacement that is out-of-the-box compatible with CUDA. However, I need to write some CUDA as part of a large codebase which uses xtensor, openmc. It does seem that xtensor isn't far off from being able to compile host code with nvcc, I only obtain the following errors when compiling the most basic of xtensor programs (the first one on its readthedocs):

gavin@gpad:~/scratch$ nvcc xtensor_example.cu 
/usr/local/include/xtl/xsequence.hpp:136:87: error: expected primary-expression before ‘unsignedstruct sequence_forwarder_impl<R, A, void_t<decltype(std::declval<R>().resize(std::size_t()))>>
                                                                                       ^~~~~~~~
/usr/local/include/xtl/xvariant_impl.hpp: In function ‘constexpr decltype(auto) mpark::visit(Visitor&&, Vs&& ...)’:
/usr/local/include/xtl/xvariant_impl.hpp:2676:96: error: parameter packs not expanded with ‘...’:
     return (detail::all({!vs.valueless_by_exception()...})
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                     ^                                                                                                      
/usr/local/include/xtl/xvariant_impl.hpp:2676:96: note:         ‘vs’
/usr/local/include/xtensor/xstrided_view_base.hpp: In instantiation of ‘void xt::detail::strided_view_args<adj_strides_policy>::fill_args(const S&, ST&&, std::size_t, xt::layout_type, const V&) [with S = xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>; ST = const xt::svector<long int, 4, std::allocator<long int>, true>&; V = std::vector<mpark::variant<long int, xt::xrange_adaptor<xt::placeholders::xtuph, long int, long int>, xt::xrange_adaptor<long int, xt::placeholders::xtuph, long int>, xt::xrange_adaptor<long int, long int, xt::placeholders::xtuph>, xt::xrange_adaptor<long int, xt::placeholders::xtuph, xt::placeholders::xtuph>, xt::xrange_adaptor<xt::placeholders::xtuph, long int, xt::placeholders::xtuph>, xt::xrange_adaptor<xt::placeholders::xtuph, xt::placeholders::xtuph, long int>, xt::xrange_adaptor<long int, long int, long int>, xt::xrange_adaptor<xt::placeholders::xtuph, xt::placeholders::xtuph, xt::placeholders::xtuph>, xt::xrange<long int>, xt::xstepped_range<long int>, xt::xall_tag, xt::xellipsis_tag, xt::xnewaxis_tag> >; adj_strides_policy = xt::detail::no_adj_strides_policy; std::size_t = long unsigned int]’:
/usr/local/include/xtensor/xstrided_view.hpp:593:1:   required from ‘auto xt::strided_view(E&&, const xstrided_slice_vector&) [with E = const xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>&; xt::xstrided_slice_vector = std::vector<mpark::variant<long int, xt::xrange_adaptor<xt::placeholders::xtuph, long int, long int>, xt::xrange_adaptor<long int, xt::placeholders::xtuph, long int>, xt::xrange_adaptor<long int, long int, xt::placeholders::xtuph>, xt::xrange_adaptor<long int, xt::placeholders::xtuph, xt::placeholders::xtuph>, xt::xrange_adaptor<xt::placeholders::xtuph, long int, xt::placeholders::xtuph>, xt::xrange_adaptor<xt::placeholders::xtuph, xt::placeholders::xtuph, long int>, xt::xrange_adaptor<long int, long int, long int>, xt::xrange_adaptor<xt::placeholders::xtuph, xt::placeholders::xtuph, xt::placeholders::xtuph>, xt::xrange<long int>, xt::xstepped_range<long int>, xt::xall_tag, xt::xellipsis_tag, xt::xnewaxis_tag> >]’
/usr/local/include/xtensor/xio.hpp:260:31:   required from ‘void xt::detail::recurser_run(F&, const E&, xt::xstrided_slice_vector&, std::size_t) [with F = xt::detail::printer<xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>, void>; E = xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>; xt::xstrided_slice_vector = std::vector<mpark::variant<long int, xt::xrange_adaptor<xt::placeholders::xtuph, long int, long int>, xt::xrange_adaptor<long int, xt::placeholders::xtuph, long int>, xt::xrange_adaptor<long int, long int, xt::placeholders::xtuph>, xt::xrange_adaptor<long int, xt::placeholders::xtuph, xt::placeholders::xtuph>, xt::xrange_adaptor<xt::placeholders::xtuph, long int, xt::placeholders::xtuph>, xt::xrange_adaptor<xt::placeholders::xtuph, xt::placeholders::xtuph, long int>, xt::xrange_adaptor<long int, long int, long int>, xt::xrange_adaptor<xt::placeholders::xtuph, xt::placeholders::xtuph, xt::placeholders::xtuph>, xt::xrange<long int>, xt::xstepped_range<long int>, xt::xall_tag, xt::xellipsis_tag, xt::xnewaxis_tag> >; std::size_t = long unsigned int]’
/usr/local/include/xtensor/xio.hpp:763:21:   required from ‘std::ostream& xt::pretty_print(const xt::xexpression<D>&, std::ostream&) [with E = xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>; std::ostream = std::basic_ostream<char>]’
/usr/local/include/xtensor/xio.hpp:776:20:   required from ‘std::ostream& xt::operator<<(std::ostream&, const xt::xexpression<D>&) [with E = xt::xarray_container<xt::uvector<double, std::allocator<double> >, (xt::layout_type)1, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>; std::ostream = std::basic_ostream<char>]’
xtensor_example.cu:18:15:   required from here
/usr/local/include/xtensor/xstrided_view_base.hpp:897:6: error: ‘void info’ has incomplete type
                         auto info = xtl::visit(slice_getter, slices[i]);

It seems that a relatively small number of changes could make this work. While I do know some stuff about templates, my knowledge isn't good enough to identify the origin of these errors. I imagine there is some C++17 feature being used here that nvcc doesn't recognize. Since xtensor is supposed to work with C++14, and nvcc is supposed to work with C++14 as well, I thought perhaps this would merit raising an issue.

Any help would be MASSIVELY appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions