AnsweredAssumed Answered

clEnqueueMigrateMemObjects vs cl::CommandQueue::enqueueMigrateMemObjects

Question asked by Meteorhead on Jan 3, 2013
Latest reply on Jan 8, 2013 by Meteorhead



I have been tweaking the code I recently attached in another topic, and have come cross a problem where the C API works perfectly fine, whereas the C++ wrapper always fails. The error code is -38 which corresponds to CL_INVALID_COMMAND_QUEUE, and the spec says:

CL_INVALID_COMMAND_QUEUE if command_queue is not a valid command_queue.


Now, I know for sure that the command_queue is alright, otherwise everything else would fail afterwards. Since there is a finish on the queue right after the command is issued, no such problem can occur, where something gets deleted on the stack while the operation is still in progress. Everything that is in memory stays there until the operation finishes. If I obtain all the C handlers from the warpper objects, and call the old C API, everything works fine, but the wrapper function corresponding to the same functionality fails. I checked cl.hpp to see what it does differently, but I could not find my mistake. It seems to do the correct stuff, so the problem must be on my side. What am I doing wrong?


    std::vector<cl::Buffer> input1_buffs(devices.size()), input2_buffs(devices.size()), output_buffs(devices.size());
    for(unsigned int i = 0 ; i < devices.size() ; ++i)
        cl_buffer_region region;
        region.origin = i*batch_size;
        region.size = batch_size;
   = input1_buffer.createSubBuffer(CL_MEM_READ_ONLY, CL_BUFFER_CREATE_TYPE_REGION, &region);
   = input2_buffer.createSubBuffer(CL_MEM_READ_ONLY, CL_BUFFER_CREATE_TYPE_REGION, &region);
   = output_buffer.createSubBuffer(CL_MEM_WRITE_ONLY,CL_BUFFER_CREATE_TYPE_REGION, &region);

            // A little C API (dunno why the wrapper does not work)
            cl_mem send[3] = {,,};
            cl_int error = CL_SUCCESS;
            clEnqueueMigrateMemObjects(, 3, send, NULL, 0, NULL, NULL);
            if(error != CL_SUCCESS) {std::cerr << "clEnqueueMigrateMemObjects(" << error << ")" << std::endl; return EXIT_FAILURE;}
            // C++ wrapper that does not seem to work
            std::vector<cl::Memory> send(3);
        catch(cl::Error err) {std::cerr << err.what() << "(" << err.err() << ")" << std::endl; return EXIT_FAILURE;}


A little help would be apreciated. (Naturally not both parts of the code are present at the same time)