boostorg / compute

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

Cannot run example on README.md: what(): Out of Host Memory #862

Closed 1552980358 closed 3 years ago

1552980358 commented 3 years ago

Source code from README.md of this repo

#include <vector>
#include <algorithm>
#include <boost/compute.hpp>

namespace compute = boost::compute;

int main()
{
    // get the default compute device
    compute::device gpu = compute::system::default_device();

    // create a compute context and command queue
    compute::context ctx(gpu);
    compute::command_queue queue(ctx, gpu);

    // generate random numbers on the host
    std::vector<float> host_vector(1000000);
    std::generate(host_vector.begin(), host_vector.end(), rand);

    // create vector on the device
    compute::vector<float> device_vector(1000000, ctx);

    // copy data to the device
    compute::copy(
        host_vector.begin(), host_vector.end(), device_vector.begin(), queue
    );

    // sort data on the device
    compute::sort(
        device_vector.begin(), device_vector.end(), queue
    );

    // copy data back to the host
    compute::copy(
        device_vector.begin(), device_vector.end(), host_vector.begin(), queue
    );

    return 0;
}

Output message

terminate called after throwing an instance of 'boost::wrapexcept<boost::compute::opencl_error>'
  what():  Out of Host Memory

CPU: AMD Ryzen 7 3700X GPU: RX 6700XT 12GB RAM: 16GB IDE: CLion Toolchain: Cygwin

1552980358 commented 3 years ago

Just use MingW64 to compile