I want to use `clEnqueueReadBufferRect` in OpenCL. To do it, I need to define the `region` as one of its passing arguement. But there is a inconsistency between references of OpenCL
In online [reference](https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/clEnqueueWriteBufferRect.html), it is mention that

> 
> The (width, height, depth) in bytes of the 2D or 3D rectangle being read or written. For a 2D rectangle copy, the depth value given by region [2] should be 1.
> 
> 
> 

but in the [reference book](https://www.khronos.org/registry/OpenCL/specs/opencl-1.2.pdf), page 77, it is mentioned that

> 
> region defines the (width in bytes, height in rows, depth in slices) of the 2D or 3D rectangle being read or written. For a 2D rectangle copy, the depth value given by region [2] should be 1. The values in region cannot be 0
> 
> 
> 

but unfortunately, none of those guides worked for me and I should provide region in (width in columns, height in rows, depth in slices), otherwise, when I defined them as byte not rows/columns, I got the error `CL_INVALID_VALUE`. Now which one is correct?

```
    #define WGX 16
    #define WGY 16
    #include "misc.hpp"

    int main(int argc, char** argv)
    {
    int i;
    int n = 1000; 
    int filterWidth = 3;
    int filterRadius = (int) filterWidth/2;
    int padding      = filterRadius * 2;
    double h = 1.0 / n;

    int width_x[2];
    int height_x[2];

    int deviceWidth[2];
    int deviceHeight[2];  
    int deviceDataSize[2];

    for (i = 0; i < 2; ++i)
    {
        set_domain_length(n, n, height_x[i], width_x[i], i);
    }

    float* x = new float [height_x[0]    * width_x[0]];

    init_unknown(x,             height_x[0], width_x[0], 0);

    set_bndryCond(x, width_x[0], h);

    std::vector<cl::Platform> platforms;
    cl::Platform::get(&platforms);

    assert(platforms.size() > 0);
    cl::Platform myPlatform = platforms[0];

    std::vector<cl::Device> devices;
    myPlatform.getDevices(CL_DEVICE_TYPE_GPU, &devices);

    assert(devices.size() > 0);

    cl::Device myDevice = devices[0];
    cl_display_info(myPlatform, myDevice);
    cl::Context context(myDevice);

    std::ifstream kernelFile("iterative_scheme.cl");

    std::string src(std::istreambuf_iterator<char>(kernelFile), (std::istreambuf_iterator<char>()));

    cl::Program::Sources sources(1,std::make_pair(src.c_str(),src.length() + 1));
    cl::Program program(context, sources);

    cl::CommandQueue queue(context, myDevice);

    deviceWidth[0]    = roundUp(width_x[0], WGX);
    deviceHeight[0]   = height_x[0];  
    deviceDataSize[0] = deviceWidth[0] * deviceHeight[0] * sizeof(float);

    cl::Buffer buffer_x;
    try
    {
        buffer_x = cl::Buffer(context, CL_MEM_READ_WRITE,  deviceDataSize[0]);

    } catch (cl::Error& error)
    {
        std::cout << "     ---> Problem in creating buffer(s) " << std::endl;
        std::cout << "     ---> " << getErrorString(error) << std::endl;
        exit(0);
    }

    cl::size_t<3> buffer_origin;
    buffer_origin[0] = 0;
    buffer_origin[1] = 0;
    buffer_origin[2] = 0;

    cl::size_t<3> host_origin;
    host_origin[0] = 0;
    host_origin[1] = 0;
    host_origin[2] = 0;

    cl::size_t<3> region;
    region[0] = (size_t)(deviceWidth[0] * sizeof(float));
    region[1] = (size_t)(height_x[0]);
    region[2] = 1;

    std::cout << "===> Start writing data to device" << std::endl;
    try
    {
        queue.enqueueWriteBufferRect(buffer_x, CL_TRUE, buffer_origin, host_origin, region,
                                    deviceWidth[0] * sizeof(float), 0, width_x[0] * sizeof(float), 0, x);

    } catch (cl::Error& error)
    {
        std::cout << "     ---> Problem in writing data from Host to Device: " << std::endl;
        std::cout << "     ---> " << getErrorString(error) << std::endl;
        exit(0);
    }

    // Build the program  
    std::cout << "===> Start building program" << std::endl;

    try
    {
        program.build("-cl-std=CL2.0");
        std::cout << "     ---> Build Successfully " << std::endl;
    } catch(cl::Error& error)
    {
        std::cout << "     ---> Problem in building program " << std::endl;
        std::cout << "     ---> " << getErrorString(error) << std::endl;
        std::cout << "     ---> " << program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(myDevice) << std::endl;
        exit(0);
    }

    std::cout << "===> Start reading data from device" << std::endl;
    // read result y and residual from the device 
    buffer_origin[0] = (size_t)(filterRadius * sizeof(float));
    buffer_origin[1] = (size_t)filterRadius;
    buffer_origin[2] = 0;

    host_origin[0] = (size_t)(filterRadius * sizeof(float));
    host_origin[1] = (size_t)filterRadius;
    host_origin[2] = 0;

    // region of x
    region[0] = (size_t)((width_x[0]  - padding) * sizeof(float));
    region[1] = (size_t)(height_x[0] - padding);
    region[2] = 1;

    try
    {
        queue.enqueueReadBufferRect(buffer_x, CL_TRUE, buffer_origin, host_origin,
            region, deviceWidth[0] * sizeof(float), 0, deviceWidth[0] * sizeof(float), 0, x);
    } catch (cl::Error& error)
    {
        std::cout << "     ---> Problem reading buffer in device: "  << std::endl;
        std::cout << "     ---> " << getErrorString(error) << std::endl;
        exit(0);
    }

    delete[] (x);
    return 0;
    } 

```