cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

settle
Challenger

enqueueFillBuffer with CL_MEM_HOST_READ_ONLY or CL_MEM_HOST_NO_ACCESS

I found in that if a memory object has CL_MEM_HOST_READ_ONLY or CL_MEM_HOST_NO_ACCESS set, then it cannot be written to via enqueueWrite* or enqueueMap*.  Does that also mean that such a memory object cannot be written to via enqueueFillBuffer?

Also just to clarify things for me, can a cpu device (which is the host) and corresponding command queue enqueue a kernel that writes to those kinds of memory objects?

Sorry if I confused the properties of the above host access types, and I'd greatly appreciate any help.

0 Likes
1 Solution

The flags I'm wondering about are from 5.2.1 Creating Buffer Objects in the OpenCL 1.2 Specification:

cl_mem_flagsDescription
CL_MEM_HOST_WRITE_ONLY

This flag specifies that the host will only write to the

memory object (using OpenCL APIs that enqueue a

write or a map for write). This can be used to

optimize write access from the host (e.g. enable writecombined

allocations for memory objects for devices

that communicate with the host over a system bus

such as PCIe).

CL_MEM_HOST_READ_ONLY

This flag specifies that the host will only read the

memory object (using OpenCL APIs that enqueue a

read or a map for read).

CL_MEM_HOST_WRITE_ONLY and

CL_MEM_HOST_READ_ONLY are mutually

exclusive.

CL_MEM_HOST_NO_ACCESS

This flag specifies that the host will not read or write

the memory object.

CL_MEM_HOST_WRITE_ONLY or

CL_MEM_HOST_READ_ONLY and

CL_MEM_HOST_NO_ACCESS are mutually

exclusive.

Table 5.3 List of supported cl_mem_flags values

The enqueueFillBuffer command is from 5.2.3 Filling Buffer Objects.

The function clEnqueueFillBuffer enqueues a command to fill a buffer object with a pattern of a given pattern size. The usage information which indicates whether the memory object can be read or written by a kernel and/or the host and is given by the cl_mem_flags argument value specified when buffer is created is ignored by clEnqueueFillBuffer.

So that I guess that answers my question (sorry I didn't see this line earlier).

My remaining question is can a memory object with flags CL_MEM_HOST_READ_ONLY or CL_MEM_HOST_NO_ACCESS be written by a kernel running on a CPU device's command queue (since a CPU device is the host, right?).

I hope that helps clarify my question.  Thanks!

View solution in original post

0 Likes
4 Replies
binying
Challenger

Could give more details?

0 Likes

The flags I'm wondering about are from 5.2.1 Creating Buffer Objects in the OpenCL 1.2 Specification:

cl_mem_flagsDescription
CL_MEM_HOST_WRITE_ONLY

This flag specifies that the host will only write to the

memory object (using OpenCL APIs that enqueue a

write or a map for write). This can be used to

optimize write access from the host (e.g. enable writecombined

allocations for memory objects for devices

that communicate with the host over a system bus

such as PCIe).

CL_MEM_HOST_READ_ONLY

This flag specifies that the host will only read the

memory object (using OpenCL APIs that enqueue a

read or a map for read).

CL_MEM_HOST_WRITE_ONLY and

CL_MEM_HOST_READ_ONLY are mutually

exclusive.

CL_MEM_HOST_NO_ACCESS

This flag specifies that the host will not read or write

the memory object.

CL_MEM_HOST_WRITE_ONLY or

CL_MEM_HOST_READ_ONLY and

CL_MEM_HOST_NO_ACCESS are mutually

exclusive.

Table 5.3 List of supported cl_mem_flags values

The enqueueFillBuffer command is from 5.2.3 Filling Buffer Objects.

The function clEnqueueFillBuffer enqueues a command to fill a buffer object with a pattern of a given pattern size. The usage information which indicates whether the memory object can be read or written by a kernel and/or the host and is given by the cl_mem_flags argument value specified when buffer is created is ignored by clEnqueueFillBuffer.

So that I guess that answers my question (sorry I didn't see this line earlier).

My remaining question is can a memory object with flags CL_MEM_HOST_READ_ONLY or CL_MEM_HOST_NO_ACCESS be written by a kernel running on a CPU device's command queue (since a CPU device is the host, right?).

I hope that helps clarify my question.  Thanks!

0 Likes

My experience is that

Buffer bufferAA= Buffer(context, CL_MEM_READ_ONLY, size* sizeof(int));

queue.enqueueWriteBuffer(bufferAA, CL_TRUE, 0, size * sizeof(int), AA);

kernel.setArg..

queue.enqueueNDRangeKernel...

So that the host writes the buffer and the device reads.

But

------------------------------

Buffer bufferAA= Buffer(context, CL_MEM_HOST_READ_ONLY, size * sizeof(int));

queue.enqueueWriteBuffer(bufferAA, CL_TRUE, 0, size * sizeof(int), AA);

kernel.setArg..

queue.enqueueNDRangeKernel...

Although there appears to be no error, one gets unexpected number, say,  as if the AA were zeros.

0 Likes

if you dont get error then it is bug as according to spec you should get CL_INVALID_OPERATION