Code Monkey home page Code Monkey logo

Comments (5)

FdyCN avatar FdyCN commented on June 14, 2024 1

I think something else is going on here. I tried this simple example and it worked fine for me:

    cl_int errorCode = CL_SUCCESS;
    std::vector<int> my_vec(256);
    std::shared_ptr<cl::Buffer> buffer = std::make_shared<cl::Buffer>(
        context,
        CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
        my_vec.size() * sizeof(my_vec[0]),
        my_vec.data(),
        &errorCode);

Note that the overload at the line indicated above is:

template< typename IteratorType >
Buffer::Buffer(
    const Context &context,
    IteratorType startIterator,
    IteratorType endIterator,
    bool readOnly,
    bool useHostPtr,
    cl_int* err)

That doesn't look like the overload that you want. Can you check if there is something happening to cause this overload to be chosen instead?

I checked my expression. i found it's my fault about data type clarify, it works after i changed to this:

std::shared_ptr<cl::Buffer> buffer0 = std::make_shared<cl::Buffer>(*(clContext->GetCLContext()), 
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,                                     
(cl::size_type)storage->bufferSize_,
const_cast<void *>(src), 
&status);

storage->bufferSize_ is "int" so it causes function overload. Thank you so much for your help!

from opencl-headers.

bashbaug avatar bashbaug commented on June 14, 2024

Hello, yes, we switched to a single opencl.hpp approximately a year ago:

KhronosGroup/OpenCL-CLHPP#104

The new opencl.hpp is an improved version of cl.hpp. It supports all versions of OpenCL so it should work just fine for your OpenCL 1.2 implementation. Give it a try and please don't hesitate to let us know if you find any issues. Thanks!

from opencl-headers.

FdyCN avatar FdyCN commented on June 14, 2024

Hello, yes, we switched to a single opencl.hpp approximately a year ago:

KhronosGroup/OpenCL-CLHPP#104

The new opencl.hpp is an improved version of cl.hpp. It supports all versions of OpenCL so it should work just fine for your OpenCL 1.2 implementation. Give it a try and please don't hesitate to let us know if you find any issues. Thanks!

Thanks so much for your reply, and i appreciate all you guys' contribution in OpenCL.

from opencl-headers.

FdyCN avatar FdyCN commented on June 14, 2024

@bashbaug I got one more question. when i use shared_ptr< cl::Buffer > for alloc like these, they will be wrong:

  std::shared_ptr<cl::Buffer> buffer = std::shared_ptr<cl::Buffer>(new cl::Buffer(
        *(clContext->GetCLContext()), CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, storage->bufferSize_, src, &status));
    std::shared_ptr<cl::Buffer> buffer0 = std::make_shared<cl::Buffer>(
        *(clContext->GetCLContext()), CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, storage->bufferSize_, src, &status);

and they come the same error when compile:

CL/opencl.hpp:9131:58: error: no type named 'value_type' in 'std::__1::iterator_traits<int>'
    typedef typename std::iterator_traits<IteratorType>::value_type DataType;

HOWEVER, when i createImage2d by using shared_ptr style. It will work. Why cl::Buffer wrong? holp you can help me, thanks!

from opencl-headers.

bashbaug avatar bashbaug commented on June 14, 2024

I think something else is going on here. I tried this simple example and it worked fine for me:

    cl_int errorCode = CL_SUCCESS;
    std::vector<int> my_vec(256);
    std::shared_ptr<cl::Buffer> buffer = std::make_shared<cl::Buffer>(
        context,
        CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
        my_vec.size() * sizeof(my_vec[0]),
        my_vec.data(),
        &errorCode);

Note that the overload at the line indicated above is:

template< typename IteratorType >
Buffer::Buffer(
    const Context &context,
    IteratorType startIterator,
    IteratorType endIterator,
    bool readOnly,
    bool useHostPtr,
    cl_int* err)

That doesn't look like the overload that you want. Can you check if there is something happening to cause this overload to be chosen instead?

from opencl-headers.

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.