boostorg / compute

A C++ GPU Computing Library for OpenCL
http://boostorg.github.io/compute/
Boost Software License 1.0
1.55k stars 333 forks source link

Build program failure when use default_random_engine. #854

Closed kilasuelika closed 3 years ago

kilasuelika commented 3 years ago

I want to generate some random normal numbers. My code:

#include <iostream>
#include <boost/compute.hpp>

namespace compute = boost::compute;

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

    // print the device's name and platform
    std::cout << "hello from " << device.name();
    std::cout << " (platform: " << device.platform().name() << ")" << std::endl;

    compute::vector<float> vec(100, context);
    compute::default_random_engine engine(queue);

    // setup the uniform distribution to produce floats between 1 and 100
    //compute::uniform_real_distribution<float> distribution(1.0, 100.0);
    //distribution.generate(vec.begin(), vec.end(), engine, queue);
    return 0;
}

Error occurs at compute::default_random_engine engine(queue); on runtime. Saying:

terminate called after throwing an instance of 'boost::wrapexcept<boost::compute::program_build_failure>'
  what():  Build Program Failure

I also tried mersenne_twister_engine<int>, no luck.

kilasuelika commented 3 years ago

By catch the error and print build_log, I realized it's because my GPU opencl version is 1.1 which is too low.