mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-26 08:49:02 +00:00
[NFC] clang-format mem_host_flags/checker_image_mem_host_write_only.hpp (#1600)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
committed by
GitHub
parent
59a1198e5f
commit
8066e69b11
@@ -18,14 +18,15 @@
|
||||
|
||||
#include "checker_image_mem_host_read_only.hpp"
|
||||
|
||||
template < class T> class cImage_check_mem_host_write_only : public cImage_check_mem_host_read_only<T>
|
||||
{
|
||||
template <class T>
|
||||
class cImage_check_mem_host_write_only
|
||||
: public cImage_check_mem_host_read_only<T> {
|
||||
|
||||
public:
|
||||
cImage_check_mem_host_write_only(cl_device_id deviceID, cl_context context, cl_command_queue queue)
|
||||
cImage_check_mem_host_write_only(cl_device_id deviceID, cl_context context,
|
||||
cl_command_queue queue)
|
||||
: cImage_check_mem_host_read_only<T>(deviceID, context, queue)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
~cImage_check_mem_host_write_only(){};
|
||||
|
||||
@@ -51,7 +52,8 @@ cl_int cImage_check_mem_host_write_only<T>::Setup_Test_Environment()
|
||||
this->host_m_0.Init(all, vv2);
|
||||
|
||||
cl_int err = CL_SUCCESS;
|
||||
this->m_Image_2 = clCreateImage(this->m_context,
|
||||
this->m_Image_2 = clCreateImage(
|
||||
this->m_context,
|
||||
CL_MEM_READ_WRITE | CL_MEM_HOST_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||
&(this->m_cl_image_format), &(this->m_cl_Image_desc),
|
||||
this->host_m_2.pData, &err);
|
||||
@@ -73,16 +75,12 @@ cl_int cImage_check_mem_host_write_only< T >::update_host_mem_2()
|
||||
|
||||
cl_event event;
|
||||
cl_int err = CL_SUCCESS;
|
||||
err = clEnqueueCopyImage(this->m_queue,
|
||||
this->m_Image,
|
||||
this->m_Image_2,
|
||||
orig,
|
||||
orig,
|
||||
img_region,
|
||||
0, NULL, &event);
|
||||
err = clEnqueueCopyImage(this->m_queue, this->m_Image, this->m_Image_2,
|
||||
orig, orig, img_region, 0, NULL, &event);
|
||||
test_error(err, "clEnqueueCopyImage error");
|
||||
|
||||
if (!this->m_blocking) {
|
||||
if (!this->m_blocking)
|
||||
{
|
||||
err = clWaitForEvents(1, &event);
|
||||
test_error(err, "clWaitForEvents error");
|
||||
}
|
||||
@@ -92,13 +90,14 @@ cl_int cImage_check_mem_host_write_only< T >::update_host_mem_2()
|
||||
|
||||
this->host_m_2.Set_to_zero();
|
||||
|
||||
err = clEnqueueReadImage(this->m_queue, this->m_Image_2, this->m_blocking,
|
||||
this->buffer_origin, this->region,
|
||||
this->buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes,
|
||||
this->host_m_2.pData, 0, NULL, &event);
|
||||
err = clEnqueueReadImage(
|
||||
this->m_queue, this->m_Image_2, this->m_blocking, this->buffer_origin,
|
||||
this->region, this->buffer_row_pitch_bytes,
|
||||
this->buffer_slice_pitch_bytes, this->host_m_2.pData, 0, NULL, &event);
|
||||
test_error(err, "clEnqueueReadImage error");
|
||||
|
||||
if (!this->m_blocking) {
|
||||
if (!this->m_blocking)
|
||||
{
|
||||
err = clWaitForEvents(1, &event);
|
||||
test_error(err, "clWaitForEvents error");
|
||||
}
|
||||
@@ -109,13 +108,13 @@ cl_int cImage_check_mem_host_write_only< T >::update_host_mem_2()
|
||||
return err;
|
||||
}
|
||||
|
||||
template < class T >
|
||||
cl_int cImage_check_mem_host_write_only<T>::verify_data()
|
||||
template <class T> cl_int cImage_check_mem_host_write_only<T>::verify_data()
|
||||
{
|
||||
cl_int err = CL_SUCCESS;
|
||||
if (!this->host_m_1.Equal_rect_from_orig(this->host_m_2, this->buffer_origin,
|
||||
this->region, this->host_row_pitch,
|
||||
this->host_slice_pitch)) {
|
||||
if (!this->host_m_1.Equal_rect_from_orig(
|
||||
this->host_m_2, this->buffer_origin, this->region,
|
||||
this->host_row_pitch, this->host_slice_pitch))
|
||||
{
|
||||
log_error("Image and host data difference found\n");
|
||||
return FAILURE;
|
||||
}
|
||||
@@ -123,7 +122,8 @@ cl_int cImage_check_mem_host_write_only<T>::verify_data()
|
||||
int total = (int)(this->region[0] * this->region[1] * this->region[2]);
|
||||
T v = TEST_VALUE;
|
||||
int tot = (int)(this->host_m_2.Count(v));
|
||||
if(tot != total) {
|
||||
if (tot != total)
|
||||
{
|
||||
log_error("Image data content difference found\n");
|
||||
return FAILURE;
|
||||
}
|
||||
@@ -131,8 +131,7 @@ cl_int cImage_check_mem_host_write_only<T>::verify_data()
|
||||
return err;
|
||||
}
|
||||
|
||||
template < class T >
|
||||
cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image()
|
||||
template <class T> cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image()
|
||||
{
|
||||
cl_int err = CL_SUCCESS;
|
||||
|
||||
@@ -146,13 +145,12 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image()
|
||||
img_region[2] = this->m_cl_Image_desc.image_depth;
|
||||
|
||||
int color[4] = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
err = clEnqueueFillImage(this->m_queue,
|
||||
this->m_Image,
|
||||
&color,
|
||||
img_orig, img_region,
|
||||
0, NULL, &event); // Fill the buffer with data
|
||||
err = clEnqueueFillImage(this->m_queue, this->m_Image, &color, img_orig,
|
||||
img_region, 0, NULL,
|
||||
&event); // Fill the buffer with data
|
||||
|
||||
if (!this->m_blocking) {
|
||||
if (!this->m_blocking)
|
||||
{
|
||||
err = clWaitForEvents(1, &event);
|
||||
test_error(err, "clWaitForEvents error");
|
||||
}
|
||||
@@ -163,13 +161,14 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image()
|
||||
|
||||
T v = TEST_VALUE;
|
||||
|
||||
err= clEnqueueWriteImage(this->m_queue, this->m_Image, this->m_blocking,
|
||||
this->buffer_origin, this->region,
|
||||
this->buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes,
|
||||
this->host_m_0.pData, 0, NULL, &event);
|
||||
err = clEnqueueWriteImage(
|
||||
this->m_queue, this->m_Image, this->m_blocking, this->buffer_origin,
|
||||
this->region, this->buffer_row_pitch_bytes,
|
||||
this->buffer_slice_pitch_bytes, this->host_m_0.pData, 0, NULL, &event);
|
||||
test_error(err, "clEnqueueWriteImage error"); // Test writing to buffer
|
||||
|
||||
if (!this->m_blocking) {
|
||||
if (!this->m_blocking)
|
||||
{
|
||||
err = clWaitForEvents(1, &event);
|
||||
test_error(err, "clWaitForEvents error");
|
||||
}
|
||||
@@ -179,32 +178,41 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image()
|
||||
|
||||
update_host_mem_2(); // Read buffer contents into mem_2
|
||||
|
||||
err = this->verify_data(); // Compare the contents of mem_2 and mem_1,
|
||||
err =
|
||||
this->verify_data(); // Compare the contents of mem_2 and mem_1,
|
||||
// mem_1 is same as mem_0 in setup test environment
|
||||
test_error(err, "verify_data error");
|
||||
|
||||
v = 0;
|
||||
this->host_m_2.Set_to(v);
|
||||
err = clEnqueueReadImage(this->m_queue, this->m_Image, this->m_blocking,
|
||||
this->buffer_origin, this->region,
|
||||
this->buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes,
|
||||
this->host_m_1.pData, 0, NULL, &event);
|
||||
err = clEnqueueReadImage(
|
||||
this->m_queue, this->m_Image, this->m_blocking, this->buffer_origin,
|
||||
this->region, this->buffer_row_pitch_bytes,
|
||||
this->buffer_slice_pitch_bytes, this->host_m_1.pData, 0, NULL, &event);
|
||||
|
||||
if (err == CL_SUCCESS){
|
||||
log_error("Calling clEnqueueReadImage on a memory object created with the CL_MEM_HOST_WRITE_ONLY flag should not return CL_SUCCESS\n");
|
||||
if (err == CL_SUCCESS)
|
||||
{
|
||||
log_error(
|
||||
"Calling clEnqueueReadImage on a memory object created with the "
|
||||
"CL_MEM_HOST_WRITE_ONLY flag should not return CL_SUCCESS\n");
|
||||
err = FAILURE;
|
||||
return FAILURE;
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("Test succeeded\n\n");
|
||||
err = CL_SUCCESS;
|
||||
}
|
||||
|
||||
/* Qualcomm fix: 12506 Do not wait on invalid event/ no need for syncronization calls after clEnqueueReadImage fails
|
||||
/* Qualcomm fix: 12506 Do not wait on invalid event/ no need for
|
||||
syncronization calls after clEnqueueReadImage fails
|
||||
*
|
||||
* The call to clEnqueueReadImage fails as expected and returns an invalid event on
|
||||
* which clWaitForEvents cannot be called. (It will rightly fail with a CL_INVALID_EVENT error)
|
||||
* Further, we don't need to do any additional flushes or finishes here since we were in sync
|
||||
* The call to clEnqueueReadImage fails as expected and returns an invalid
|
||||
event on
|
||||
* which clWaitForEvents cannot be called. (It will rightly fail with a
|
||||
CL_INVALID_EVENT error)
|
||||
* Further, we don't need to do any additional flushes or finishes here
|
||||
since we were in sync
|
||||
* before the (failing) call to clEnqueueReadImage
|
||||
|
||||
if (!this->m_blocking) {
|
||||
@@ -233,11 +241,11 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image_Mapping()
|
||||
|
||||
|
||||
// Fill image with pattern
|
||||
err = clEnqueueFillImage(this->m_queue, this->m_Image,
|
||||
&color, img_orig, img_region,
|
||||
0, NULL, &event);
|
||||
err = clEnqueueFillImage(this->m_queue, this->m_Image, &color, img_orig,
|
||||
img_region, 0, NULL, &event);
|
||||
|
||||
if (!this->m_blocking) {
|
||||
if (!this->m_blocking)
|
||||
{
|
||||
err = clWaitForEvents(1, &event);
|
||||
test_error(err, "clWaitForEvents error");
|
||||
}
|
||||
@@ -246,15 +254,14 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image_Mapping()
|
||||
test_error(err, "clReleaseEvent error");
|
||||
|
||||
// Map image for writing
|
||||
T* dataPtr = (T*) clEnqueueMapImage(this->m_queue, this->m_Image,
|
||||
this->m_blocking, CL_MAP_WRITE,
|
||||
this->buffer_origin, this->region,
|
||||
&(this->buffer_row_pitch_bytes),
|
||||
&(this->buffer_slice_pitch_bytes),
|
||||
0, NULL, &event, &err);
|
||||
T* dataPtr = (T*)clEnqueueMapImage(
|
||||
this->m_queue, this->m_Image, this->m_blocking, CL_MAP_WRITE,
|
||||
this->buffer_origin, this->region, &(this->buffer_row_pitch_bytes),
|
||||
&(this->buffer_slice_pitch_bytes), 0, NULL, &event, &err);
|
||||
test_error(err, "clEnqueueMapImage CL_MAP_WRITE pointer error");
|
||||
|
||||
if (!this->m_blocking) {
|
||||
if (!this->m_blocking)
|
||||
{
|
||||
err = clWaitForEvents(1, &event);
|
||||
test_error(err, "clWaitForEvents error");
|
||||
}
|
||||
@@ -279,11 +286,12 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image_Mapping()
|
||||
test_error(err, "verify_data error");
|
||||
|
||||
// Unmap memory object
|
||||
err = clEnqueueUnmapMemObject(this->m_queue, this->m_Image, dataPtr,
|
||||
0, NULL, &event);
|
||||
err = clEnqueueUnmapMemObject(this->m_queue, this->m_Image, dataPtr, 0,
|
||||
NULL, &event);
|
||||
test_error(err, "clEnqueueUnmapMemObject error");
|
||||
|
||||
if (!this->m_blocking) {
|
||||
if (!this->m_blocking)
|
||||
{
|
||||
err = clWaitForEvents(1, &event);
|
||||
test_error(err, "clWaitForEvents error");
|
||||
}
|
||||
@@ -291,19 +299,21 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image_Mapping()
|
||||
err = clReleaseEvent(event);
|
||||
test_error(err, "clReleaseEvent error");
|
||||
|
||||
dataPtr = (T*) clEnqueueMapImage(this->m_queue, this->m_Image, this->m_blocking,
|
||||
CL_MAP_READ,
|
||||
this->buffer_origin, this->region,
|
||||
&(this->buffer_row_pitch_bytes),
|
||||
&(this->buffer_slice_pitch_bytes),
|
||||
0, NULL, &event, &err);
|
||||
dataPtr = (T*)clEnqueueMapImage(
|
||||
this->m_queue, this->m_Image, this->m_blocking, CL_MAP_READ,
|
||||
this->buffer_origin, this->region, &(this->buffer_row_pitch_bytes),
|
||||
&(this->buffer_slice_pitch_bytes), 0, NULL, &event, &err);
|
||||
|
||||
if (err == CL_SUCCESS) {
|
||||
log_error("Calling clEnqueueMapImage (CL_MAP_READ) on a memory object created with the CL_MEM_HOST_WRITE_ONLY flag should not return CL_SUCCESS\n");
|
||||
if (err == CL_SUCCESS)
|
||||
{
|
||||
log_error("Calling clEnqueueMapImage (CL_MAP_READ) on a memory object "
|
||||
"created with the CL_MEM_HOST_WRITE_ONLY flag should not "
|
||||
"return CL_SUCCESS\n");
|
||||
err = FAILURE;
|
||||
return FAILURE;
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info("Test succeeded\n\n");
|
||||
err = CL_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user