[Compute] Conflict between boost::compute::zip_iterator and boost::iterators::zip_iterator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Compute] Conflict between boost::compute::zip_iterator and boost::iterators::zip_iterator

Boost - Dev mailing list
I'd like to use boost::compute and boost::range together, like below, but if I uncomment the '#include <boost/range/combine.hpp>' line I get an error saying that boost::compute::zip_iterator and boost::iterators::zip_iterator are ambiguous. Is there a way around this, so that I can use boost::compute and boost::range together in the same cpp file? I am using on Windows vs2015 64bit. Boost 1.67.0.

Code:

#include <vector>
#include <iostream>
#include <algorithm>
//#include <boost/range/combine.hpp>
#include <boost/compute/lambda.hpp>
#include <boost/compute/functional/math.hpp>
#include <boost/compute/container/vector.hpp>
#include <boost/compute/algorithm/transform.hpp>

namespace compute = boost::compute;
using compute::float4_;
using compute::lambda::_1;
using compute::lambda::_2;
using compute::lambda::distance;

int main()
{
    // get default device and setup context
    compute::device device = compute::system::default_device();
    compute::context context(device);
    compute::command_queue queue(context, device);

    // generate random data on the host
    std::vector<float4_> a(10000);
    std::vector<float4_> b(10000);
    std::vector<float> r(10000);
    std::generate((float*)a.data(), (float*)(a.data() + a.size()), rand);
    std::generate((float*)b.data(), (float*)(b.data() + b.size()), rand);

    // create a vector on the device
    compute::vector<float4_> _a(a.size(), context);
    compute::vector<float4_> _b(b.size(), context);
    compute::vector<float> _r(r.size(), context);

    // transfer data from the host to the device
    compute::copy(a.begin(), a.end(), _a.begin(), queue);
    compute::copy(b.begin(), b.end(), _b.begin(), queue);

    boost::compute::transform(
        _a.begin(), _a.end(),
        _b.begin(),
        _r.begin(),
        distance(_1, _2),
        queue
    );

    // copy values back to the host
    compute::copy(_r.begin(), _r.end(), r.begin(), queue);

    for (int i = 0; i < a.size(); ++i)
    {
        float4_ va = a[i];
        float4_ vb = b[i];
        float vr = r[i];
        float e = std::sqrt(std::pow(va[0] - vb[0], 2) +
            std::pow(va[1] - vb[1], 2) +
            std::pow(va[2] - vb[2], 2) +
            std::pow(va[3] - vb[3], 2));

        std::cout << std::setprecision(12);

        if (std::abs(e - vr) > 1e-2)
            std::cout << e << " != " << vr << "\n";
    }

    return 0;
}

Error, truncated for brevity. I can post the full error log if it is helpful:

1>------ Build started: Project: demo, Configuration: Debug x64 ------ 1> demo.cpp 1> This header is implementation detail and provided for backwards compatibility. 1>C:\local\boost_1_67_0\boost/compute/algorithm/transform.hpp(67): error C2668: 'boost::compute::make_zip_iterator': ambiguous call to overloaded function 1> C:\local\boost_1_67_0\boost/compute/iterator/zip_iterator.hpp(276): note: could be 'boost::compute::zip_iterator,boost::compute::buffer_iterator,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>> boost::compute::make_zip_iterator,boost::compute::buffer_iterator,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>>(IteratorTuple)' 1> with 1> [

Thanks,
Madison

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [Compute] Conflict between boost::compute::zip_iterator and boost::iterators::zip_iterator

Boost - Dev mailing list
AMDG

On 07/17/2018 10:04 PM, Madison via Boost wrote:

> I'd like to use boost::compute and boost::range together, like below, but if I uncomment the '#include <boost/range/combine.hpp>' line I get an error saying that boost::compute::zip_iterator and boost::iterators::zip_iterator are ambiguous. Is there a way around this, so that I can use boost::compute and boost::range together in the same cpp file? I am using on Windows vs2015 64bit. Boost 1.67.0.
>
> Code:
>
> //#include <boost/range/combine.hpp>
> #include <boost/compute/algorithm/transform.hpp>
>
> <snip>
> Error, truncated for brevity. I can post the full error log if it is helpful:
>
> 1>------ Build started: Project: demo, Configuration: Debug x64 ------ 1> demo.cpp 1> This header is implementation detail and provided for backwards compatibility. 1>C:\local\boost_1_67_0\boost/compute/algorithm/transform.hpp(67): error C2668: 'boost::compute::make_zip_iterator': ambiguous call to overloaded function <snip>
>

The call to make_zip_iterator in boost/compute/algorithm/transform.hpp
needs to be qualified to prevent ADL from kicking in.

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Fw: [Compute] Conflict between boost::compute::zip_iterator and boost::iterators::zip_iterator

Boost - Dev mailing list
Thanks, Steven, that worked. I've posted the answer in my stack overflow question. Is it ok if I use your name to give credit on SO?

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost