mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-25 16:29:03 +00:00
Mem-leaks from conformance mem_host_flags (#770)
Fix various resource leaks in the tests for mem_host_flags. Signed-off-by: John Kesapides <john.kesapides@arm.com>
This commit is contained in:
@@ -132,6 +132,7 @@ cBuffer_checker<T>::~cBuffer_checker()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template < class T >
|
template < class T >
|
||||||
cl_int cBuffer_checker<T>::SetupBuffer()
|
cl_int cBuffer_checker<T>::SetupBuffer()
|
||||||
{
|
{
|
||||||
@@ -183,28 +184,18 @@ cl_int cBuffer_checker<T>::SetupASSubBuffer(cl_mem_flags parent_buffer_flag)
|
|||||||
this->m_sub_buffer_region.origin = this->buffer_origin_bytes[0]; // in bytes
|
this->m_sub_buffer_region.origin = this->buffer_origin_bytes[0]; // in bytes
|
||||||
this->m_sub_buffer_region.size = this->region_bytes[0];
|
this->m_sub_buffer_region.size = this->region_bytes[0];
|
||||||
|
|
||||||
cl_event event;
|
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
err = clEnqueueReadBufferRect(this->m_queue, m_buffer_parent, CL_TRUE,
|
err = clEnqueueReadBufferRect(
|
||||||
this->buffer_origin_bytes,
|
this->m_queue, m_buffer_parent, CL_TRUE, this->buffer_origin_bytes,
|
||||||
this->host_origin_bytes,
|
this->host_origin_bytes, this->region_bytes, this->buffer_row_pitch_bytes,
|
||||||
this->region_bytes,
|
this->buffer_slice_pitch_bytes, this->host_row_pitch_bytes,
|
||||||
this->buffer_row_pitch_bytes,
|
this->host_slice_pitch_bytes, this->host_m_1.pData, 0, NULL,
|
||||||
this->buffer_slice_pitch_bytes,
|
NULL); // update the mem_1
|
||||||
this->host_row_pitch_bytes,
|
|
||||||
this->host_slice_pitch_bytes,
|
|
||||||
this->host_m_1.pData,
|
|
||||||
0, NULL, &event); // update the mem_1
|
|
||||||
|
|
||||||
if (err == CL_SUCCESS && (parent_buffer_flag & (CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS))) {
|
if (err == CL_SUCCESS && (parent_buffer_flag & (CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS))) {
|
||||||
log_error("Calling clEnqueueReadBufferRect on a memory object created with the CL_MEM_HOST_WRITE_ONLY flag or the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
|
log_error("Calling clEnqueueReadBufferRect on a memory object created with the CL_MEM_HOST_WRITE_ONLY flag or the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
|
||||||
err = FAILURE;
|
err = FAILURE;
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (this->m_blocking) {
|
|
||||||
err = clWaitForEvents(1, &event);
|
|
||||||
test_error(err, "clWaitForEvents error");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
err = CL_SUCCESS;
|
err = CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ cl_int cImage_check_mem_host_no_access<T>:: verify_RW_Image()
|
|||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
this->update_host_mem_2();
|
this->update_host_mem_2();
|
||||||
|
|
||||||
int total = (int)(this->region[0] * this->region[1] * this->region[2]);
|
int total = (int)(this->region[0] * this->region[1] * this->region[2]);
|
||||||
|
|||||||
@@ -206,6 +206,9 @@ cl_int cImage_check_mem_host_read_only< T >::verify_RW_Image()
|
|||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
err = this->verify_data(this->host_m_2.pData);
|
err = this->verify_data(this->host_m_2.pData);
|
||||||
test_error(err, "verify_data error");
|
test_error(err, "verify_data error");
|
||||||
|
|
||||||
@@ -245,6 +248,9 @@ cl_int cImage_check_mem_host_read_only< T >::verify_RW_Image_Mapping()
|
|||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
err= this->verify_mapping_ptr(dataPtr);
|
err= this->verify_mapping_ptr(dataPtr);
|
||||||
test_error(err, "clEnqueueMapImage error");
|
test_error(err, "clEnqueueMapImage error");
|
||||||
|
|
||||||
@@ -257,6 +263,9 @@ cl_int cImage_check_mem_host_read_only< T >::verify_RW_Image_Mapping()
|
|||||||
err = clWaitForEvents(1, &event);
|
err = clWaitForEvents(1, &event);
|
||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
dataPtr = (T*) clEnqueueMapImage(this->m_queue, this->m_Image, this->m_blocking,
|
dataPtr = (T*) clEnqueueMapImage(this->m_queue, this->m_Image, this->m_blocking,
|
||||||
CL_MAP_WRITE,
|
CL_MAP_WRITE,
|
||||||
this->buffer_origin,
|
this->buffer_origin,
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ cl_int cImage_check_mem_host_write_only< T >::update_host_mem_2()
|
|||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
this->host_m_2.Set_to_zero();
|
this->host_m_2.Set_to_zero();
|
||||||
|
|
||||||
err = clEnqueueReadImage(this->m_queue, this->m_Image_2, this->m_blocking,
|
err = clEnqueueReadImage(this->m_queue, this->m_Image_2, this->m_blocking,
|
||||||
@@ -100,6 +103,9 @@ cl_int cImage_check_mem_host_write_only< T >::update_host_mem_2()
|
|||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +158,9 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image()
|
|||||||
}
|
}
|
||||||
test_error(err, "clEnqueueFillImage error");
|
test_error(err, "clEnqueueFillImage error");
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
T v = TEST_VALUE;
|
T v = TEST_VALUE;
|
||||||
|
|
||||||
err= clEnqueueWriteImage(this->m_queue, this->m_Image, this->m_blocking,
|
err= clEnqueueWriteImage(this->m_queue, this->m_Image, this->m_blocking,
|
||||||
@@ -165,6 +174,9 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image()
|
|||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
update_host_mem_2(); // Read buffer contents into mem_2
|
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,
|
||||||
@@ -230,6 +242,9 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image_Mapping()
|
|||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
// Map image for writing
|
// Map image for writing
|
||||||
T* dataPtr = (T*) clEnqueueMapImage(this->m_queue, this->m_Image,
|
T* dataPtr = (T*) clEnqueueMapImage(this->m_queue, this->m_Image,
|
||||||
this->m_blocking, CL_MAP_WRITE,
|
this->m_blocking, CL_MAP_WRITE,
|
||||||
@@ -244,6 +259,9 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image_Mapping()
|
|||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
// Verify map pointer
|
// Verify map pointer
|
||||||
err = this->verify_mapping_ptr(dataPtr);
|
err = this->verify_mapping_ptr(dataPtr);
|
||||||
test_error(err, "clEnqueueMapImage CL_MAP_WRITE pointer error");
|
test_error(err, "clEnqueueMapImage CL_MAP_WRITE pointer error");
|
||||||
@@ -270,6 +288,9 @@ cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image_Mapping()
|
|||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
dataPtr = (T*) clEnqueueMapImage(this->m_queue, this->m_Image, this->m_blocking,
|
dataPtr = (T*) clEnqueueMapImage(this->m_queue, this->m_Image, this->m_blocking,
|
||||||
CL_MAP_READ,
|
CL_MAP_READ,
|
||||||
this->buffer_origin, this->region,
|
this->buffer_origin, this->region,
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ cl_int cBuffer_check_mem_host_read_only< T >::verify_RW_Buffer()
|
|||||||
log_error("Buffer data difference found\n");
|
log_error("Buffer data difference found\n");
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
// test write
|
// test write
|
||||||
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
@@ -190,6 +192,8 @@ cl_int cBuffer_check_mem_host_read_only< T >::verify_RW_Buffer_rect()
|
|||||||
log_error("Buffer data diffeence found\n");
|
log_error("Buffer data diffeence found\n");
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
// test blocking write rect
|
// test blocking write rect
|
||||||
err = clEnqueueWriteBufferRect(this->m_queue, this->m_buffer, this->m_blocking,
|
err = clEnqueueWriteBufferRect(this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
@@ -243,6 +247,13 @@ cl_int cBuffer_check_mem_host_read_only< T >::verify_RW_Buffer_mapping()
|
|||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
|
err = clEnqueueUnmapMemObject(this->m_queue, this->m_buffer, dataPtr, 0,
|
||||||
|
nullptr, nullptr);
|
||||||
|
test_error(err, "clEnqueueUnmapMemObject error");
|
||||||
|
|
||||||
// test blocking map read
|
// test blocking map read
|
||||||
clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
CL_MAP_WRITE,
|
CL_MAP_WRITE,
|
||||||
|
|||||||
@@ -142,6 +142,9 @@ cl_int cBuffer_check_mem_host_write_only< T >::verify_RW_Buffer()
|
|||||||
test_error(err, "clWaitForEvents error")
|
test_error(err, "clWaitForEvents error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
if (tmp_host_m.Equal(this->host_m_2)){
|
if (tmp_host_m.Equal(this->host_m_2)){
|
||||||
log_error("Test data should be different\n");
|
log_error("Test data should be different\n");
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
@@ -218,6 +221,11 @@ cl_int cBuffer_check_mem_host_write_only< T >::verify_RW_Buffer_rect()
|
|||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event_1);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
update_host_mem_2();
|
update_host_mem_2();
|
||||||
|
|
||||||
size_t tot_in_reg = this->region[0] * this->region[1] * this->region[2];
|
size_t tot_in_reg = this->region[0] * this->region[1] * this->region[2];
|
||||||
@@ -277,6 +285,11 @@ cl_int cBuffer_check_mem_host_write_only< T >::update_host_mem_2()
|
|||||||
clWaitForEvents(1, &event_2);
|
clWaitForEvents(1, &event_2);
|
||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
|
|
||||||
|
err = clReleaseEvent(event_2);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,6 +315,9 @@ cl_int cBuffer_check_mem_host_write_only< T >::verify_RW_Buffer_mapping()
|
|||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
update_host_mem_2();
|
update_host_mem_2();
|
||||||
|
|
||||||
if ((this->buffer_mem_flag & CL_MEM_USE_HOST_PTR) && dataPtr != this->pHost_ptr){
|
if ((this->buffer_mem_flag & CL_MEM_USE_HOST_PTR) && dataPtr != this->pHost_ptr){
|
||||||
@@ -314,6 +330,10 @@ cl_int cBuffer_check_mem_host_write_only< T >::verify_RW_Buffer_mapping()
|
|||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = clEnqueueUnmapMemObject(this->m_queue, this->m_buffer, dataPtr, 0,
|
||||||
|
nullptr, nullptr);
|
||||||
|
test_error(err, "clEnqueueUnmapMemObject error");
|
||||||
|
|
||||||
// test map read
|
// test map read
|
||||||
clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
CL_MAP_READ,
|
CL_MAP_READ,
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ int test_mem_host_read_only_buffer(cl_device_id deviceID, cl_context context,
|
|||||||
for (int k=0; k<2; k++)
|
for (int k=0; k<2; k++)
|
||||||
for (int i=0; i< 2; i++)
|
for (int i=0; i< 2; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
err = test_mem_host_read_only_buffer_RW(deviceID, context, queue, blocking[i],
|
err = test_mem_host_read_only_buffer_RW(deviceID, context, queue, blocking[i],
|
||||||
buffer_mem_flags[k], 0, _BUFFER);
|
buffer_mem_flags[k], 0, _BUFFER);
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
|
|||||||
Reference in New Issue
Block a user