Initial open source release of OpenCL 2.2 CTS.

This commit is contained in:
Kedar Patil
2017-05-16 18:25:37 +05:30
parent 6911ba5116
commit 2821bf1323
1035 changed files with 343518 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
set(MODULE_NAME MEM_HOST_FLAGS)
set(${MODULE_NAME}_SOURCES
main.cpp
mem_host_buffer.cpp
mem_host_image.cpp
../../test_common/harness/errorHelpers.c
../../test_common/harness/threadTesting.c
../../test_common/harness/testHarness.c
../../test_common/harness/genericThread.cpp
../../test_common/harness/kernelHelpers.c
../../test_common/harness/typeWrappers.cpp
../../test_common/harness/mt19937.c
../../test_common/harness/conversions.c
../../test_common/harness/ThreadPool.c
../../test_common/harness/msvc9.c
../../test_common/harness/parseParameters.cpp
)
include(../CMakeCommon.txt)

View File

@@ -0,0 +1,252 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef test_conformance_cHost_MemoryBlock_h
#define test_conformance_cHost_MemoryBlock_h
#include "../../test_common/harness/compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
template < class T> class C_host_memory_block
{
public:
int num_elements;
int element_size;
T *pData;
C_host_memory_block();
~C_host_memory_block();
void Init(int num_elem, T &value);
void Init(int num_elem);
void Set_to(T & val);
void Set_to_zero();
bool Equal_to(T &val);
size_t Count(T &val);
bool Equal(C_host_memory_block < T > & another);
bool Equal_rect(C_host_memory_block < T > & another,
size_t * host_origin,
size_t * region,
size_t host_row_pitch,
size_t host_slice_pitch);
bool Equal(T *pData, int num_elements);
bool Equal_rect_from_orig(C_host_memory_block < T > & another,
size_t * soffset,
size_t * region,
size_t host_row_pitch,
size_t host_slice_pitch);
bool Equal_rect_from_orig(T* another_pdata,
size_t * soffset,
size_t * region,
size_t host_row_pitch,
size_t host_slice_pitch);
};
template < class T >
C_host_memory_block<T>::C_host_memory_block()
{
pData = NULL;
element_size = sizeof (T);
num_elements = 0;
}
template < class T>
C_host_memory_block<T>::~C_host_memory_block()
{
if (pData!=NULL) delete pData;
num_elements = 0;
}
template < class T >
void C_host_memory_block<T>::Init(int num_elem, T & value)
{
if (pData!=NULL) delete pData;
pData= new T [num_elem];
for (int i=0; i<num_elem; i++)
pData[i] = value;
num_elements= num_elem;
}
template < class T >
void C_host_memory_block<T>::Init(int num_elem)
{
if (pData!=NULL) delete pData;
pData = new T [num_elem];
for (int i=0; i<num_elem; i++)
pData[i]= (T) i;
num_elements = num_elem;
}
template < class T >
void C_host_memory_block<T>::Set_to_zero()
{
T v = 0;
Set_to(v);
}
template < class T >
void C_host_memory_block<T>::Set_to(T &val)
{
for (int i=0; i<num_elements; i++)
pData[i] = val;
}
template < class T >
bool C_host_memory_block<T>::Equal_to(T &val)
{
int count = 0;
for (int i=0; i<num_elements; i++) {
if (pData[i] == val)
count++;
}
return (count== num_elements);
}
template < class T >
bool C_host_memory_block<T>::Equal(C_host_memory_block < T > & another)
{
int count = 0;
for (int i=0; i<num_elements; i++) {
if (pData[i] == another.pData[i])
count++;
}
return (count== num_elements);
}
template < class T >
bool C_host_memory_block<T>::Equal(T *pIn_Data, int Innum_elements)
{
if (this->num_elements!= Innum_elements)
return false;
int count = 0;
for (int i=0; i<num_elements ; i++ ) {
if (pData[i] == pIn_Data[i])
count++;
}
return ( count== num_elements);
}
template < class T >
size_t C_host_memory_block<T>::Count(T &val)
{
size_t count = 0;
for (int i=0; i<num_elements; i++) {
if (pData[i] == val)
count++;
}
return count;
}
template < class T >
bool C_host_memory_block<T>::Equal_rect(C_host_memory_block < T > & another,
size_t * soffset,
size_t * region,
size_t host_row_pitch,
size_t host_slice_pitch)
{
size_t row_pitch = host_row_pitch ? host_row_pitch : region[0];
size_t slice_pitch = host_slice_pitch ? host_row_pitch : region[1];
size_t count = 0;
size_t total = region[0] * region[1] * region[2];
size_t x, y, z;
size_t orig = (size_t)(soffset[0] + row_pitch*soffset[1] + slice_pitch * soffset[2]);
for (z=0; z<region[2]; z++)
for (y=0; y<region[1]; y++)
for (x=0; x<region[0]; x++)
{
int p1 = (int)(x + row_pitch*y + slice_pitch* z + orig);
if (pData[p1] == another.pData[p1])
count++;
}
return (count == total);
}
template < class T >
bool C_host_memory_block<T>::Equal_rect_from_orig(C_host_memory_block < T > & another,
size_t * soffset,
size_t * region,
size_t host_row_pitch,
size_t host_slice_pitch)
{
size_t row_pitch = host_row_pitch ? host_row_pitch : region[0];
size_t slice_pitch = host_slice_pitch ? host_row_pitch : region[1];
size_t count = 0;
size_t total = region[0] * region[1] * region[2];
size_t x, y, z;
size_t orig = soffset[0] + row_pitch * soffset[1] + slice_pitch * soffset[2];
for (z=0; z<region[2]; z++)
for (y=0; y<region[1]; y++)
for (x=0; x<region[0]; x++)
{
size_t p1 = x + (row_pitch*y) + (slice_pitch*z);
size_t p2 = p1 + orig;
if (pData[p2] == another.pData[p1])
count++;
}
return (count == total);
}
template < class T >
bool C_host_memory_block<T>::Equal_rect_from_orig(T* another_pdata,
size_t * soffset,
size_t * region,
size_t host_row_pitch,
size_t host_slice_pitch)
{
size_t row_pitch = host_row_pitch ? host_row_pitch : region[0];
size_t slice_pitch = host_slice_pitch ? host_row_pitch : region[1];
size_t count = 0;
size_t total = region[0] * region[1] * region[2];
size_t x, y, z;
size_t orig = soffset[0] + row_pitch*soffset[1] + slice_pitch * soffset[2];
for (z=0; z<region[2]; z++)
for (y=0; y<region[1]; y++)
for (x=0; x<region[0]; x++)
{
size_t p1 = x + (row_pitch * y) + (slice_pitch * z);
size_t p2 = p1 + orig;
if (pData[p2] == another_pdata[p1])
count++;
}
return (count == total);
}
#endif

View File

@@ -0,0 +1,46 @@
ifdef BUILD_WITH_ATF
ATF = -framework ATF
USE_ATF = -DUSE_ATF
endif
SRCS = main.cpp \
mem_host_buffer.cpp \
mem_host_image.cpp \
../../test_common/harness/errorHelpers.c \
../../test_common/harness/threadTesting.c \
../../test_common/harness/testHarness.c \
../../test_common/harness/genericThread.cpp \
../../test_common/harness/kernelHelpers.c \
../../test_common/harness/typeWrappers.cpp \
../../test_common/harness/mt19937.c \
../../test_common/harness/conversions.c \
../../test_common/harness/ThreadPool.c \
DEFINES = DONT_TEST_GARBAGE_POINTERS
SOURCES = $(abspath $(SRCS))
LIBPATH += -L/System/Library/Frameworks/OpenCL.framework/Libraries
LIBPATH += -L.
HEADERS =
TARGET = test_mem_host_flags
INCLUDE =
COMPILERFLAGS = -c -Wall -g -Wshorten-64-to-32
CC = c++
CFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
CXXFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
LIBRARIES = -framework OpenCL -framework OpenGL -framework GLUT -framework AppKit ${ATF}
OBJECTS := ${SOURCES:.c=.o}
OBJECTS := ${OBJECTS:.cpp=.o}
TARGETOBJECT =
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CC) $(RC_CFLAGS) $(OBJECTS) -o $@ $(LIBPATH) $(LIBRARIES)
clean:
rm -f $(TARGET) $(OBJECTS)
.DEFAULT:
@echo The target \"$@\" does not exist in Makefile.

View File

@@ -0,0 +1,326 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef test_conformance_checkers_h
#define test_conformance_checkers_h
#include "../../test_common/harness/compat.h"
#include <stdio.h>
#include <string.h>
#include "procs.h"
#include "C_host_memory_block.h"
#define TEST_VALUE 5
typedef cl_char TEST_ELEMENT_TYPE;
enum {SUCCESS, FAILURE=-1000};
extern const char *buffer_write_kernel_code[];
enum BUFFER_TYPE {_BUFFER, _Sub_BUFFER};
template < class T > class cBuffer_checker
{
public:
cBuffer_checker(cl_device_id deviceID, cl_context context,
cl_command_queue queue);
~cBuffer_checker();
cl_device_id m_deviceID;
cl_context m_context;
cl_command_queue m_queue;
clMemWrapper m_buffer, m_buffer_parent;
enum BUFFER_TYPE m_buffer_type;
cl_buffer_region m_sub_buffer_region;
cl_int err;
cl_bool m_blocking;
cl_mem_flags buffer_mem_flag;
C_host_memory_block<T> host_m_0, host_m_1, host_m_2;
int m_nNumber_elements;
void *pData, *pData2;
void * pHost_ptr; // the host ptr at creation
size_t buffer_origin[3];
size_t host_origin[3];
size_t region[3];
size_t buffer_row_pitch;
size_t buffer_slice_pitch;
size_t host_row_pitch;
size_t host_slice_pitch;
size_t buffer_origin_bytes[3];
size_t host_origin_bytes[3];
size_t region_bytes[3];
size_t buffer_row_pitch_bytes;
size_t buffer_slice_pitch_bytes;
size_t host_row_pitch_bytes;
size_t host_slice_pitch_bytes;
cl_int CreateBuffer(cl_mem_flags buffer_mem_flag, void * pdata);
int get_block_size_bytes() { return (int)(m_nNumber_elements * sizeof(T)); };
virtual cl_int SetupBuffer() = 0;
virtual cl_int Setup_Test_Environment();
virtual cl_int SetupASSubBuffer(cl_mem_flags parent_buffer_flag);
virtual cl_int verify(cl_int err, cl_event & event);
virtual cl_int Check_GetMemObjectInfo(cl_mem_flags buffer_mem_flag);
void Init_rect(int bufforg[3], int host_org[3], int region[3],
int buffer_pitch[2], int host_pitch[2]);
void Init_rect();
virtual cl_int verify_RW_Buffer() = 0;
virtual cl_int verify_RW_Buffer_rect() = 0;
virtual cl_int verify_RW_Buffer_mapping() = 0;
};
template < class T >
cBuffer_checker<T>::cBuffer_checker(cl_device_id deviceID, cl_context context,
cl_command_queue queue)
{
m_nNumber_elements = 0;
m_deviceID = deviceID;
m_context = context;
m_queue = queue;
m_blocking = false;
buffer_mem_flag = CL_MEM_READ_WRITE;
pData = pData2 = NULL;
buffer_origin[0] = buffer_origin[1] = buffer_origin[2] = 0;
host_origin[0] = host_origin[1] = host_origin[2] = 0;
region[0] = region[1] = region[2] = 0;
buffer_row_pitch = buffer_slice_pitch = host_row_pitch = host_slice_pitch = 0;
buffer_origin_bytes[0] = buffer_origin_bytes[1] = buffer_origin_bytes[2] = 0;
host_origin_bytes[0] = host_origin_bytes[1] = host_origin_bytes[2] = 0;
region_bytes[0] = region_bytes[1] = region_bytes[2] = 0;
buffer_row_pitch_bytes = buffer_slice_pitch_bytes = 0;
host_row_pitch_bytes = host_slice_pitch_bytes = 0;
pHost_ptr = NULL;
}
template < class T >
cBuffer_checker<T>::~cBuffer_checker()
{
}
template < class T >
cl_int cBuffer_checker<T>::SetupBuffer()
{
m_buffer_type = _BUFFER;
return CL_SUCCESS;
}
template < class T >
cl_int cBuffer_checker<T>::Setup_Test_Environment()
{
return CL_SUCCESS;
}
template < class T >
cl_int cBuffer_checker<T>::SetupASSubBuffer(cl_mem_flags parent_buffer_flag)
{
m_buffer_type = _Sub_BUFFER;
int supersize = 8000;
this-> m_nNumber_elements = 1000;
T vv1= TEST_VALUE;
int block_size_in_byte = (int)(supersize * sizeof(T));
this->host_m_0.Init(supersize);
m_buffer_parent = clCreateBuffer(this->m_context, parent_buffer_flag,
block_size_in_byte, this->host_m_0.pData, &err);
test_error(err, "clCreateBuffer error");
int size = this->m_nNumber_elements; // the size of subbuffer in elements
cl_uint base_addr_align_bits;
err = clGetDeviceInfo(m_deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof base_addr_align_bits, &base_addr_align_bits, NULL);
test_error(err,"clGetDeviceInfo for CL_DEVICE_MEM_BASE_ADDR_ALIGN");
int base_addr_align_bytes = base_addr_align_bits/8;
int buffer_origin[3] = {base_addr_align_bytes, 0, 0};
int host_origin[3] = {0, 0, 0};
int region[3] = {size, 1, 1};
int buffer_pitch[2] = {0, 0};
int host_pitch[2] = {0, 0};
this->Init_rect(buffer_origin, host_origin, region, buffer_pitch, host_pitch);
this->m_nNumber_elements = size; // the size of subbuffer in elements
this->host_m_1.Init(this->m_nNumber_elements, vv1);
this->m_sub_buffer_region.origin = this->buffer_origin_bytes[0]; // in bytes
this->m_sub_buffer_region.size = this->region_bytes[0];
cl_event event;
cl_int err = CL_SUCCESS;
err = clEnqueueReadBufferRect(this->m_queue, m_buffer_parent, CL_TRUE,
this->buffer_origin_bytes,
this->host_origin_bytes,
this->region_bytes,
this->buffer_row_pitch_bytes,
this->buffer_slice_pitch_bytes,
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))) {
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;
return err;
if (this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
} else {
err = CL_SUCCESS;
}
cl_mem_flags f;
if (parent_buffer_flag & CL_MEM_HOST_READ_ONLY)
f = CL_MEM_HOST_READ_ONLY;
else if (parent_buffer_flag & CL_MEM_HOST_WRITE_ONLY)
f = CL_MEM_HOST_WRITE_ONLY;
else if (parent_buffer_flag & CL_MEM_HOST_NO_ACCESS)
f = CL_MEM_HOST_NO_ACCESS;
m_buffer = clCreateSubBuffer(m_buffer_parent, f, CL_BUFFER_CREATE_TYPE_REGION,
&(this->m_sub_buffer_region), &err);
test_error(err, "clCreateSubBuffer error");
if (parent_buffer_flag | CL_MEM_USE_HOST_PTR)
{
this->pHost_ptr = (this->host_m_0.pData + this->m_sub_buffer_region.origin/sizeof(T));
}
T vv2 = 0;
this->host_m_2.Init(this->m_nNumber_elements, vv2);
return err;
}
template < class T >
cl_int cBuffer_checker<T>::verify(cl_int err, cl_event & event)
{
return CL_SUCCESS;
}
template < class T >
cl_int cBuffer_checker<T>::CreateBuffer(cl_mem_flags buffer_mem_flag, void *pdata)
{
cl_int err = CL_SUCCESS;
int block_size_in_byte= m_nNumber_elements* sizeof(T);
m_buffer = clCreateBuffer(m_context, buffer_mem_flag, block_size_in_byte, pdata, &err);
return err;
};
template < class T >
cl_int cBuffer_checker<T>::Check_GetMemObjectInfo(cl_mem_flags buffer_mem_flag)
{
cl_int err = CL_SUCCESS;
cl_mem_flags buffer_mem_flag_Check;
err = clGetMemObjectInfo(this->m_buffer, CL_MEM_FLAGS, sizeof(cl_mem_flags),
&buffer_mem_flag_Check, NULL);
if (buffer_mem_flag_Check != buffer_mem_flag) {
log_error("clGetMemObjectInfo result differs from the specified result\n");
return err;
}
cl_uint count = 0;
err = clGetMemObjectInfo(this->m_buffer, CL_MEM_REFERENCE_COUNT,
sizeof(cl_uint), &count, NULL);
if (count > 1)
log_info("========= buffer count %d\n", count);
test_error(err, "clGetMemObjectInfo failed");
return err;
}
template < class T >
void cBuffer_checker<T>::Init_rect ()
{
int buffer_origin[3] = {10, 0, 0};
int host_origin[3] = {10, 0, 0};
int region[3] = {8, 1, 1};
int buffer_pitch[2] = {0, 0};
int host_pitch[2] = {0, 0};
this->Init_rect(buffer_origin, host_origin, region, buffer_pitch, host_pitch);
}
template < class T >
void cBuffer_checker<T>::Init_rect(int bufforg[3], int host_org[3],
int region_in[3], int buffer_pitch[2], int host_pitch[2])
{
buffer_origin[0] = bufforg[0];
buffer_origin[1] = bufforg[1];
buffer_origin[2] = bufforg[2];
host_origin[0] = host_org[0];
host_origin[1] = host_org[1];
host_origin[2] = host_org[2];
region[0] = region_in[0];
region[1] = region_in[1];
region[2] = region_in[2];
buffer_row_pitch = buffer_pitch[0];
buffer_slice_pitch = buffer_pitch[1];
host_row_pitch = host_pitch[0];
host_slice_pitch = host_pitch[1];
int sizeof_element = sizeof(T);
for (int k=0; k<3; k++)
{
buffer_origin_bytes[k] = buffer_origin[k] * sizeof_element;
host_origin_bytes [k] = host_origin[k] * sizeof_element;
}
region_bytes[0] = region[0] * sizeof_element;
region_bytes[1] = region[1];
region_bytes[2] = region[2];
buffer_row_pitch_bytes = buffer_row_pitch* sizeof_element;
buffer_slice_pitch_bytes = buffer_slice_pitch* sizeof_element;
host_row_pitch_bytes = host_row_pitch* sizeof_element;
host_slice_pitch_bytes = host_slice_pitch* sizeof_element;
}
#endif

View File

@@ -0,0 +1,151 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef test_conformance_checker_Image_MEM_HOST_NO_ACCESS_h
#define test_conformance_checker_Image_MEM_HOST_NO_ACCESS_h
#include "checker_image_mem_host_write_only.hpp"
template < class T>
class cImage_check_mem_host_no_access : public cImage_check_mem_host_write_only<T>
{
public:
cImage_check_mem_host_no_access (cl_device_id deviceID, cl_context context, cl_command_queue queue)
: cImage_check_mem_host_write_only <T> (deviceID,context, queue)
{
}
~cImage_check_mem_host_no_access() {};
cl_int verify_RW_Image();
cl_int verify_RW_Image_Mapping();
};
template < class T>
cl_int cImage_check_mem_host_no_access<T>:: verify_RW_Image()
{
this->Init_rect();
cl_event event;
size_t img_orig[3] = {0, 0, 0};
size_t img_region[3] = {0, 0, 0};
img_region[0] = this->m_cl_Image_desc.image_width;
img_region[1] = this->m_cl_Image_desc.image_height;
img_region[2] = this->m_cl_Image_desc.image_depth;
int color[4] = {0xFF, 0xFF, 0xFF, 0xFF};
cl_int err = CL_SUCCESS;
err = clEnqueueFillImage(this->m_queue, this->m_Image,
&color,
img_orig, img_region,
0, NULL, &event);
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
this->update_host_mem_2();
int total = (int)(this->region[0] * this->region[1] * this->region[2]);
T v = 0xFFFFFFFF;
int tot = (int)(this->host_m_2.Count(v));
if(tot != total){
log_error("Buffer data content difference found\n");
return FAILURE;
}
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_1.pData, 0, NULL, &event);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueWriteImage on a memory object created with the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
err = FAILURE;
return err;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
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_2.pData, 0, NULL, &event);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueReadImage on a memory object created with the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
err = FAILURE;
return err;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
template < class T>
cl_int cImage_check_mem_host_no_access<T>::verify_RW_Image_Mapping()
{
this->Init_rect();
cl_event event;
cl_int err = CL_SUCCESS;
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);
if ( err == CL_SUCCESS) {
log_error("Calling clEnqueueMapImage (CL_MAP_WRITE) on a memory object created with the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
err = FAILURE;
return err;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
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_NO_ACCESS flag should not return CL_SUCCESS\n");
err = FAILURE;
return err;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
#endif

View File

@@ -0,0 +1,281 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef test_conformance_checker_Image_MEM_HOST_READ_ONLY_h
#define test_conformance_checker_Image_MEM_HOST_READ_ONLY_h
#include "checker.h"
template < class T> class cImage_check_mem_host_read_only : public cBuffer_checker<T>
{
public:
cImage_check_mem_host_read_only(cl_device_id deviceID, cl_context context, cl_command_queue queue)
: cBuffer_checker <T> (deviceID, context, queue)
{
m_cl_image_format.image_channel_order = CL_RGBA;
m_cl_image_format.image_channel_data_type = CL_UNSIGNED_INT8;
m_cl_Image_desc.image_type = CL_MEM_OBJECT_IMAGE1D;
m_cl_Image_desc.image_width = 0;
m_cl_Image_desc.image_height = 0;
m_cl_Image_desc.image_depth = 0;
m_cl_Image_desc.image_array_size = 0;
m_cl_Image_desc.image_row_pitch = 0;
m_cl_Image_desc.image_slice_pitch = 0;
m_cl_Image_desc.num_mip_levels = 0;
m_cl_Image_desc.num_samples = 0;
m_cl_Image_desc.mem_object = NULL;
m_Image = NULL;
};
~cImage_check_mem_host_read_only()
{
};
cl_int get_image_elements();
cl_image_format m_cl_image_format;
cl_image_desc m_cl_Image_desc;
clMemWrapper m_Image;
virtual cl_int SetupImage();
virtual cl_int SetupBuffer();
virtual cl_int verify_RW_Image();
virtual cl_int verify_RW_Image_Mapping();
virtual cl_int verify_data(T *pdtaIn);
virtual cl_int verify_data_with_offset(T *pdtaIn, size_t *offset);
cl_int get_image_content_size();
cl_int get_image_data_size();
virtual cl_int verify_RW_Buffer();
virtual cl_int verify_RW_Buffer_rect();
virtual cl_int verify_RW_Buffer_mapping();
cl_int verify_mapping_ptr(T *ptr);
};
template < class T >
cl_int cImage_check_mem_host_read_only< T >::verify_mapping_ptr( T* dataPtr)
{
int offset_pixel = (int)(this->buffer_origin[0] + this->buffer_origin[1] *
this->buffer_row_pitch_bytes/ sizeof(T) + this->buffer_origin[2] *
this->buffer_slice_pitch_bytes/sizeof(T));
dataPtr = dataPtr - offset_pixel;
cl_int err = CL_SUCCESS;
if (this->buffer_mem_flag & CL_MEM_USE_HOST_PTR)
{
if (this->pHost_ptr != this->host_m_1.pData)
{
log_error("Host memory pointer difference found\n");
return FAILURE;
}
if(dataPtr != this->host_m_1.pData)
{
log_error("Mapped host pointer difference found\n");
return FAILURE;
}
}
return err;
}
template < class T >
cl_int cImage_check_mem_host_read_only< T >::verify_RW_Buffer() { return CL_SUCCESS; };
template < class T >
cl_int cImage_check_mem_host_read_only< T >::verify_RW_Buffer_rect() { return CL_SUCCESS; };
template < class T >
cl_int cImage_check_mem_host_read_only< T >::verify_RW_Buffer_mapping() { return CL_SUCCESS; };
template < class T >
cl_int cImage_check_mem_host_read_only< T >::SetupBuffer()
{
return cBuffer_checker< T >::SetupBuffer();
}
template < class T >
cl_int cImage_check_mem_host_read_only< T >::get_image_content_size()
{
return ((cl_int)(m_cl_Image_desc.image_width*m_cl_Image_desc.image_height *
m_cl_Image_desc.image_depth * m_cl_Image_desc.image_array_size));
}
template < class T >
cl_int cImage_check_mem_host_read_only< T >::get_image_data_size()
{
size_t slice_pitch = m_cl_Image_desc.image_slice_pitch ? m_cl_Image_desc.image_slice_pitch :
(m_cl_Image_desc.image_height * m_cl_Image_desc.image_width);
return (slice_pitch * m_cl_Image_desc.image_depth * m_cl_Image_desc.image_array_size);
}
template < class T >
cl_int cImage_check_mem_host_read_only< T >::get_image_elements()
{
return ((cl_int)(m_cl_Image_desc.image_width*m_cl_Image_desc.image_height *
m_cl_Image_desc.image_depth * m_cl_Image_desc.image_array_size));
}
template < class T >
cl_int cImage_check_mem_host_read_only< T >::SetupImage()
{
int all = (int)(m_cl_Image_desc.image_width * m_cl_Image_desc.image_height *
m_cl_Image_desc.image_depth * m_cl_Image_desc.image_array_size);
T v = TEST_VALUE;
this->host_m_1.Init(all, v);
cl_int err = CL_SUCCESS;
this-> m_Image = clCreateImage(this->m_context, this->buffer_mem_flag,
&( this-> m_cl_image_format), &(this-> m_cl_Image_desc),
this->host_m_1.pData, &err);
test_error(err , "clCreateImage error");
this-> pHost_ptr = (void *) (this->host_m_1.pData);
return err;
}
template < class T >
cl_int cImage_check_mem_host_read_only< T >::verify_data(T *pDataIN)
{
cl_int err = CL_SUCCESS;
if (!this->host_m_1.Equal_rect_from_orig(pDataIN, this->buffer_origin,
this->region, this->host_row_pitch,
this->host_slice_pitch)) {
log_error("Buffer data difference found\n");
return FAILURE;
}
return err;
}
template < class T >
cl_int cImage_check_mem_host_read_only< T >::verify_data_with_offset(T *pDataIN,
size_t *offset)
{
cl_int err = CL_SUCCESS;
if (!this->host_m_2.Equal_rect_from_orig(pDataIN, offset, this->region,
this->host_row_pitch,
this->host_slice_pitch)) {
log_error("Buffer data difference found\n");
return FAILURE;
}
return err;
}
template < class T >
cl_int cImage_check_mem_host_read_only< T >::verify_RW_Image()
{
this->Init_rect();
int imge_content_size = this->get_image_content_size();
T v = 0;
this->host_m_2.Init( imge_content_size, v);
cl_event event;
cl_int err = CL_SUCCESS;
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_2.pData, 0, NULL, &event);
test_error(err, "clEnqueueReadImage error");
if ( !this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
err = this->verify_data(this->host_m_2.pData);
test_error(err, "verify_data error");
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_2.pData, 0, NULL, &event);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueWriteImage on a memory object created with the CL_MEM_HOST_READ_ONLY flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
template < class T >
cl_int cImage_check_mem_host_read_only< T >::verify_RW_Image_Mapping()
{
cl_event event;
cl_int err = CL_SUCCESS;
T * 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 (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
err= this->verify_mapping_ptr(dataPtr);
test_error(err, "clEnqueueMapImage error");
err = this->verify_data(dataPtr);
test_error(err, "verify_data error");
err= clEnqueueUnmapMemObject (this->m_queue, this->m_Image, dataPtr, 0, NULL, &event);
test_error(err, "clEnqueueUnmapMemObject error");
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
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);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueMapImage (CL_MAP_WRITE) on a memory object created with the CL_MEM_HOST_READ_ONLY flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
#endif

View File

@@ -0,0 +1,293 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef test_conformance_checker_Image_MEM_HOST_WRITE_ONLY_h
#define test_conformance_checker_Image_MEM_HOST_WRITE_ONLY_h
#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>
{
public:
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() {};
clMemWrapper m_Image_2;
cl_int verify_RW_Image();
cl_int verify_RW_Image_Mapping();
cl_int Setup_Test_Environment();
cl_int update_host_mem_2();
cl_int verify_data();
};
template < class T >
cl_int cImage_check_mem_host_write_only<T>::Setup_Test_Environment()
{
int all= this->get_image_elements();
T vv2 = 0;
this->host_m_2.Init( all, vv2);
vv2 = TEST_VALUE;
this->host_m_0.Init( all, vv2);
cl_int err = CL_SUCCESS;
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);
test_error(err, "clCreateImage error");
return err;
}
// Copy image data from a write_only image to a read_write image and read the
// contents.
template < class T >
cl_int cImage_check_mem_host_write_only< T >::update_host_mem_2()
{
size_t orig[3] = {0, 0, 0};
size_t img_region[3] = {0, 0, 0};
img_region[0] = this->m_cl_Image_desc.image_width;
img_region[1] = this->m_cl_Image_desc.image_height;
img_region[2] = this->m_cl_Image_desc.image_depth;
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);
test_error(err, "clEnqueueCopyImage error");
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
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);
test_error(err, "clEnqueueReadImage error");
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
return err;
}
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)) {
log_error("Image and host data difference found\n");
return FAILURE;
}
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) {
log_error("Image data content difference found\n");
return FAILURE;
}
return err;
}
template < class T >
cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image()
{
cl_int err = CL_SUCCESS;
this->Init_rect();
cl_event event;
size_t img_orig[3] = {0, 0, 0};
size_t img_region[3] = {0, 0, 0};
img_region[0] = this->m_cl_Image_desc.image_width;
img_region[1] = this->m_cl_Image_desc.image_height;
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
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
test_error(err, "clEnqueueFillImage error");
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);
test_error(err, "clEnqueueWriteImage error"); // Test writing to buffer
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
update_host_mem_2(); // Read buffer contents into mem_2
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);
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 {
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
*
* 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) {
err = clWaitForEvents(1, &event);
test_error(err, " clWaitForEvents error")
}
Qualcomm fix: end*/
return err;
}
template < class T >
cl_int cImage_check_mem_host_write_only<T>::verify_RW_Image_Mapping()
{
this->Init_rect();
cl_event event;
size_t img_orig[3] = {0, 0, 0};
size_t img_region[3] = {0, 0, 0};
img_region[0] = this->m_cl_Image_desc.image_width;
img_region[1] = this->m_cl_Image_desc.image_height;
img_region[2] = this->m_cl_Image_desc.image_depth;
int color[4] = {0xFF, 0xFF, 0xFF, 0xFF};
cl_int err = CL_SUCCESS;
// Fill image with pattern
err = clEnqueueFillImage(this->m_queue, this->m_Image,
&color, img_orig, img_region,
0, NULL, &event);
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents 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);
test_error(err, "clEnqueueMapImage CL_MAP_WRITE pointer error");
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
// Verify map pointer
err = this->verify_mapping_ptr(dataPtr);
test_error(err, "clEnqueueMapImage CL_MAP_WRITE pointer error");
// Verify mapped data
// The verify_data_with_offset method below compares dataPtr against
// this->host_m_2.pData. The comparison should start at origin {0, 0, 0}.
update_host_mem_2();
// Check the content of mem and host_ptr
size_t offset[3] = {0, 0, 0};
err = cImage_check_mem_host_read_only<T>::verify_data_with_offset(dataPtr,
offset);
test_error(err, "verify_data error");
// Unmap memory object
err = clEnqueueUnmapMemObject(this->m_queue, this->m_Image, dataPtr,
0, NULL, &event);
test_error(err, "clEnqueueUnmapMemObject error");
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents 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);
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 {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
#endif

View File

@@ -0,0 +1,202 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef test_conformance_check_mem_host_no_access_h
#define test_conformance_check_mem_host_no_access_h
#include "checker_mem_host_write_only.hpp"
template < class T> class cBuffer_check_mem_host_no_access : public cBuffer_check_mem_host_write_only< T >
{
public:
cBuffer_check_mem_host_no_access(cl_device_id deviceID, cl_context context, cl_command_queue queue)
: cBuffer_check_mem_host_write_only < T > (deviceID, context, queue)
{
};
cBuffer_check_mem_host_no_access()
{
};
virtual cl_int SetupBuffer();
virtual cl_int SetupASSubBuffer(cl_mem_flags parent_buffer_flag);
virtual cl_int Setup_Test_Environment();
cl_int verify_RW_Buffer();
cl_int verify_RW_Buffer_rect();
cl_int verify_RW_Buffer_mapping();
};
template < class T >
cl_int cBuffer_check_mem_host_no_access< T >::SetupBuffer()
{
this->m_nNumber_elements = 1000;
T vv1 = TEST_VALUE;
this->host_m_1.Init( this->m_nNumber_elements, vv1);
T vv2 = 0;
this->host_m_2.Init( this->m_nNumber_elements, vv2);
cl_int err;
int block_size_in_byte = this->get_block_size_bytes();
this->m_buffer = clCreateBuffer(this->m_context, this->buffer_mem_flag,
block_size_in_byte, this->host_m_1.pData, &err);
test_error(err, "clCreateBuffer error");
err = this->Check_GetMemObjectInfo(this->buffer_mem_flag);
if (this->buffer_mem_flag | CL_MEM_USE_HOST_PTR)
{
this->pHost_ptr = (void *)this->host_m_1.pData;
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_no_access< T >::SetupASSubBuffer(cl_mem_flags parent_buffer_flag)
{
return cBuffer_checker<T>::SetupASSubBuffer(parent_buffer_flag);
}
template < class T >
cl_int cBuffer_check_mem_host_no_access< T >::Setup_Test_Environment()
{
cBuffer_check_mem_host_write_only<T>::Setup_Test_Environment();
return CL_SUCCESS;
}
template < class T>
cl_int cBuffer_check_mem_host_no_access< T >::verify_RW_Buffer()
{
cl_event event;
cl_int err = clEnqueueReadBuffer(this->m_queue, this->m_buffer, this->m_blocking, 0,
this->get_block_size_bytes(), this->host_m_1.pData,
0, NULL, &event);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueWriteBuffer on a memory object created with the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking, 0,
this->get_block_size_bytes(), this->host_m_1.pData,
0, NULL, &event);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueWriteBuffer on a memory object created with the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_no_access< T >::verify_RW_Buffer_rect()
{
this->Init_rect();
cl_event event;
cl_int err = CL_SUCCESS;
err = clEnqueueReadBufferRect(this->m_queue, this->m_buffer, this->m_blocking,
this->buffer_origin_bytes,
this->host_origin_bytes,
this->region_bytes,
this->buffer_row_pitch_bytes,
this->buffer_slice_pitch_bytes,
this->host_row_pitch_bytes,
this->host_slice_pitch_bytes,
this->host_m_2.pData,
0, NULL, &event);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueReadBufferRect on a memory object created with the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
err = clEnqueueWriteBufferRect(this->m_queue, this->m_buffer, this->m_blocking,
this->buffer_origin_bytes ,
this->host_origin_bytes,
this->region_bytes,
this->buffer_row_pitch_bytes,
this->buffer_slice_pitch_bytes,
this->host_row_pitch_bytes,
this->host_slice_pitch_bytes,
this->host_m_2.pData,
0, NULL, &event);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueWriteBufferRect on a memory object created with the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_no_access< T >::verify_RW_Buffer_mapping()
{
cl_event event;
cl_int err;
void *dataPtr;
dataPtr = clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking, CL_MAP_READ,
0, this->get_block_size_bytes(), 0, NULL, &event, &err);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueMapBuffer (CL_MAP_READ) on a memory object created with the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
dataPtr = clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking, CL_MAP_WRITE,
0, this->get_block_size_bytes(), 0, NULL, &event, &err);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueMapBuffer (CL_MAP_WRITE) on a memory object created with the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
#endif

View File

@@ -0,0 +1,264 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef test_conformance_check_mem_host_read_only_h
#define test_conformance_check_mem_host_read_only_h
#include "checker.h"
template < class T> class cBuffer_check_mem_host_read_only : public cBuffer_checker<T>
{
public:
cBuffer_check_mem_host_read_only(cl_device_id deviceID, cl_context context, cl_command_queue queue)
: cBuffer_checker <T> (deviceID, context, queue)
{
};
~cBuffer_check_mem_host_read_only()
{
};
virtual cl_int Check_GetMemObjectInfo(cl_mem_flags buffer_mem_flag);
virtual cl_int SetupBuffer();
virtual cl_int SetupASSubBuffer( cl_mem_flags flag_p);
virtual cl_int Setup_Test_Environment();
cl_int verifyData(cl_int err, cl_event & event);
cl_int verify_RW_Buffer();
cl_int verify_RW_Buffer_rect();
cl_int verify_RW_Buffer_mapping();
};
template < class T >
cl_int cBuffer_check_mem_host_read_only< T >::SetupBuffer()
{
this->m_buffer_type = _BUFFER;
this->m_nNumber_elements = 888;
T vv1 = TEST_VALUE;
this->host_m_1.Init(this->m_nNumber_elements, vv1);
this->host_m_0.Init(this->m_nNumber_elements, vv1);
cl_int err = CL_SUCCESS;
int block_size_in_byte = (int)(this->m_nNumber_elements * sizeof(T));
this->m_buffer = clCreateBuffer(this->m_context, this->buffer_mem_flag,
block_size_in_byte, this->host_m_1.pData, &err);
test_error(err, "clCreateBuffer error");
if (this->buffer_mem_flag | CL_MEM_USE_HOST_PTR)
{
this->pHost_ptr = (void *)this->host_m_1.pData;
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_read_only<T>::SetupASSubBuffer(cl_mem_flags flag_p)
{
return cBuffer_checker<T>::SetupASSubBuffer(flag_p);
}
template < class T>
cl_int cBuffer_check_mem_host_read_only<T>::Setup_Test_Environment()
{
cBuffer_checker<T>::Setup_Test_Environment();
T vv2 = 0;
this->host_m_2.Init(this->m_nNumber_elements, vv2);
return CL_SUCCESS;
}
template < class T >
cl_int cBuffer_check_mem_host_read_only< T >::Check_GetMemObjectInfo(cl_mem_flags buffer_mem_flag)
{
cl_int err = CL_SUCCESS;
cBuffer_checker<T>::Check_GetMemObjectInfo(buffer_mem_flag);
if (buffer_mem_flag & CL_MEM_ALLOC_HOST_PTR)
{
size_t size = 0;
err = clGetMemObjectInfo(this->m_buffer, CL_MEM_SIZE, sizeof(size), &size, NULL);
void *pp = NULL;
err = clGetMemObjectInfo(this->m_buffer, CL_MEM_HOST_PTR, sizeof( pp ), &pp, NULL);
if (!this->host_m_1.Equal( (T*) (this->pData), this->m_nNumber_elements )) {
log_error("Buffer data difference found\n");
return FAILURE;
}
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_read_only< T >::verifyData( cl_int err, cl_event & event )
{
if (err != CL_SUCCESS) {
err = this->m_nERROR_RETURN_CODE;
test_error(err, "clEnqueueReadBuffer error");
}
if (!this->host_m_1.Equal(this->host_m_2)) {
err = this->m_nERROR_RETURN_CODE;
test_error(err, "clEnqueueReadBuffer data difference found");
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_read_only< T >::verify_RW_Buffer()
{
cl_event event;
cl_int err = CL_SUCCESS;
err = clEnqueueReadBuffer(this->m_queue, this->m_buffer, this->m_blocking,
0, this->get_block_size_bytes(), this->host_m_2.pData,
0, NULL, &event);
test_error(err, "clEnqueueReadBuffer error");
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
if (!this->host_m_1.Equal(this->host_m_2)) {
log_error("Buffer data difference found\n");
return FAILURE;
}
// test write
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking,
0, this->get_block_size_bytes(), this->host_m_2.pData,
0, NULL, &event);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueWriteBuffer on a memory object created with the CL_MEM_HOST_READ_ONLY flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_read_only< T >::verify_RW_Buffer_rect()
{
this->Init_rect();
T vv2 = 0;
this->host_m_2.Set_to( vv2 );
cl_event event;
cl_int err = CL_SUCCESS;
err = clEnqueueReadBufferRect(this->m_queue, this->m_buffer, this->m_blocking,
this->buffer_origin_bytes,
this->host_origin_bytes,
this->region_bytes,
this->buffer_row_pitch_bytes,
this->buffer_slice_pitch_bytes,
this->host_row_pitch_bytes,
this->host_slice_pitch_bytes,
this->host_m_2.pData,
0, NULL, &event);
test_error(err, "clEnqueueReadBufferRect error");
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
if (! this->host_m_1.Equal_rect(this->host_m_2, this->host_origin, this->region,
this->host_row_pitch, this->host_slice_pitch)) {
log_error("Buffer data diffeence found\n");
return FAILURE;
}
// test blocking write rect
err = clEnqueueWriteBufferRect(this->m_queue, this->m_buffer, this->m_blocking,
this->buffer_origin_bytes,
this->host_origin_bytes,
this->region_bytes,
this->buffer_row_pitch_bytes,
this->buffer_slice_pitch_bytes,
this->host_row_pitch_bytes,
this->host_slice_pitch_bytes,
this->host_m_2.pData,
0, NULL, &event);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueWriteBufferRect on a memory object created with the CL_MEM_HOST_READ_ONLY flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_read_only< T >::verify_RW_Buffer_mapping()
{
cl_int err = CL_SUCCESS;
cl_event event;
void *dataPtr;
dataPtr = clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking,
CL_MAP_READ,
0, this->get_block_size_bytes(),
0, NULL, &event, &err);
test_error(err, "clEnqueueMapBuffer error");
if (!this->m_blocking) {
err = clWaitForEvents(1, &event );
test_error(err, "clWaitForEvents error");
}
if ((this->buffer_mem_flag & CL_MEM_USE_HOST_PTR) && dataPtr != this->pHost_ptr ) {
log_error("Mapped host pointer difference found\n");
}
if(!this->host_m_1.Equal((T*)dataPtr, this->m_nNumber_elements)) {
log_error("Buffer content difference found\n");
return FAILURE;
}
// test blocking map read
clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking,
CL_MAP_WRITE,
0, this->get_block_size_bytes(),
0, NULL, &event, &err);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueMapBuffer (CL_MAP_WRITE) on a memory object created with the CL_MEM_HOST_READ_ONLY flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
#endif

View File

@@ -0,0 +1,333 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef test_conformance_check_mem_host_write_only__h
#define test_conformance_check_mem_host_write_only__h
#include "checker.h"
template < class T> class cBuffer_check_mem_host_write_only : public cBuffer_checker<T>
{
public:
cBuffer_check_mem_host_write_only(cl_device_id deviceID, cl_context context, cl_command_queue queue)
: cBuffer_checker < T > (deviceID, context, queue)
{
this->m_nNumber_elements = 1000;
};
~cBuffer_check_mem_host_write_only()
{
};
cl_program program;
cl_kernel kernel;
clMemWrapper m_buffer2;
cl_int Setup_Test_Environment();
cl_int SetupBuffer();
cl_int SetupASSubBuffer(cl_mem_flags flag_p);
cl_int verifyData(cl_int err, cl_event &event );
cl_int update_host_mem_2();
cl_int verify_RW_Buffer();
cl_int verify_RW_Buffer_rect();
cl_int verify_RW_Buffer_mapping();
C_host_memory_block<T> tmp_host_m;
virtual cl_int verify_Buffer_initialization();
};
template < class T >
cl_int cBuffer_check_mem_host_write_only< T >::SetupBuffer()
{
T vv1 = 0;
this->host_m_1.Init( this->m_nNumber_elements, vv1); // zero out buffer
// init buffer to 0
cl_int err;
int block_size_in_byte = this->get_block_size_bytes();
this->m_buffer = clCreateBuffer(this->m_context, this->buffer_mem_flag,
block_size_in_byte, this->host_m_1.pData, &err);
test_error(err, "clCreateBuffer error");
err = this->Check_GetMemObjectInfo(this->buffer_mem_flag);
if (this->buffer_mem_flag | CL_MEM_USE_HOST_PTR)
{
this->pHost_ptr = (void *)this->host_m_1.pData;
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_write_only<T>::SetupASSubBuffer(cl_mem_flags flag_p)
{
return cBuffer_checker<T>::SetupASSubBuffer(flag_p);
}
template < class T >
cl_int cBuffer_check_mem_host_write_only< T >::Setup_Test_Environment()
{
cl_int err;
T vv2 = 0;
this->host_m_2.Init(this->m_nNumber_elements, vv2);
// init buffer2 to 0
cl_mem_flags buffer_mem_flag2 = CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_READ_ONLY;
this->m_buffer2 = clCreateBuffer(this->m_context, buffer_mem_flag2,
this->get_block_size_bytes(), this->host_m_2.pData, &err);
test_error(err, "clCreateBuffer error\n");
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_write_only< T >::verify_Buffer_initialization()
{
cl_int err = CL_SUCCESS;
if (this->host_m_1.pData == NULL || this->host_m_2.pData == NULL) {
log_error("Data not ready\n");
return FAILURE;
}
update_host_mem_2();
if (!this->host_m_1.Equal(this->host_m_2)){
log_error("Buffer content difference found\n");
return FAILURE;
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_write_only< T >::verify_RW_Buffer()
{
T vv1 = TEST_VALUE;
T vv2 = 0;
this->host_m_2.Set_to(vv2);
tmp_host_m.Init(this->host_m_1.num_elements, vv1) ;
cl_event event;
cl_int err = CL_SUCCESS;
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking, 0,
this->get_block_size_bytes(), tmp_host_m.pData,
0, NULL, &event);
if (err != CL_SUCCESS ) {
test_error(err, "clEnqueueWriteBuffer error");
}
if (!this->m_blocking){
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error")
}
if (tmp_host_m.Equal(this->host_m_2)){
log_error("Test data should be different\n");
return FAILURE;
}
update_host_mem_2();
if (!tmp_host_m.Equal(this->host_m_2)){
log_error("Buffer content difference found\n");
return FAILURE;
}
err = clEnqueueReadBuffer(this->m_queue, this->m_buffer, CL_TRUE, 0,
this->get_block_size_bytes(), this->host_m_2.pData,
0, NULL, &event);
if ( err == CL_SUCCESS ) {
log_error("Calling clEnqueueReadBuffer on a memory object created with the CL_MEM_HOST_WRITE_ONLY flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_write_only< T >::verify_RW_Buffer_rect()
{
this->Init_rect();
T vv1= TEST_VALUE;
this->host_m_1.Set_to(vv1);
T vv2 = 0;
this->host_m_2.Set_to(vv2);
cl_event event, event_1;
cl_int err = CL_SUCCESS;
vv1 = 0;
C_host_memory_block< T > tmp_host_m;
tmp_host_m.Init(this->host_m_1.num_elements, vv1); // zero out the buffer
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, CL_TRUE, 0,
this->get_block_size_bytes(), tmp_host_m.pData,
0, NULL, &event_1);
vv1 = TEST_VALUE;
tmp_host_m.Set_to(vv1);
err = clEnqueueWriteBufferRect(this->m_queue, this->m_buffer, this->m_blocking,
this->buffer_origin_bytes,
this->host_origin_bytes,
this->region_bytes,
this->buffer_row_pitch_bytes,
this->buffer_slice_pitch_bytes,
this->host_row_pitch_bytes,
this->host_slice_pitch_bytes,
tmp_host_m.pData,
1, &event_1, &event);
test_error(err, "clEnqueueWriteBuffer error");
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error")
}
if (tmp_host_m.Equal(this->host_m_2)) {
log_error("Test data should be different\n");
return FAILURE;
}
update_host_mem_2();
size_t tot_in_reg = this->region[0] * this->region[1] * this->region[2];
if (!tmp_host_m.Equal_rect(this->host_m_2, this->host_origin, this->region,
this->host_row_pitch, this->host_slice_pitch)) {
log_error("Buffer rect content difference found\n");
return FAILURE;
}
if (this->host_m_2.Count(vv1) != tot_in_reg)
{
log_error("Buffer rect content difference found\n");
return FAILURE;
}
err = clEnqueueReadBufferRect(this->m_queue, this->m_buffer, this->m_blocking,
this->buffer_origin_bytes,
this->host_origin_bytes,
this->region_bytes,
this->buffer_row_pitch_bytes,
this->buffer_slice_pitch_bytes,
this->host_row_pitch_bytes,
this->host_slice_pitch_bytes,
this->host_m_2.pData,
0, NULL, &event);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueReadBufferRect on a memory object created with the CL_MEM_HOST_WRITE_ONLY flag should not return CL_SUCCESS\n");
err = FAILURE;
return FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_write_only< T >::update_host_mem_2()
{
size_t global_work_size[3] = {0, 1, 1};
global_work_size[0] = this->get_block_size_bytes();
cl_event event, event_2;
cl_int err = clEnqueueCopyBuffer(this->m_queue, this->m_buffer, this->m_buffer2, 0, 0,
this->m_nNumber_elements* sizeof (T), 0, NULL, &event);
this->host_m_2.Set_to_zero();
err = clEnqueueReadBuffer(this->m_queue, this->m_buffer2, CL_TRUE, 0,
this->get_block_size_bytes(), this->host_m_2.pData,
1, &event, &event_2);
test_error(err, "clEnqueueReadBuffer error");
clWaitForEvents(1, &event_2);
test_error(err, "clWaitForEvents error");
return err;
}
template < class T >
cl_int cBuffer_check_mem_host_write_only< T >::verify_RW_Buffer_mapping()
{
T vv2 = 0;
this->host_m_2.Set_to(vv2);
cl_event event;
cl_int err = CL_SUCCESS;
void *dataPtr;
int size = this->get_block_size_bytes();
dataPtr = clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking,
CL_MAP_WRITE,
0, size,
0, NULL, &event, &err);
test_error(err, "clEnqueueMapBuffer error");
if (!this->m_blocking) {
err = clWaitForEvents(1, &event);
test_error(err, "clWaitForEvents error");
}
update_host_mem_2();
if ((this->buffer_mem_flag & CL_MEM_USE_HOST_PTR) && dataPtr != this->pHost_ptr){
log_error("Mapped host pointer difference found\n");
return FAILURE;
}
if(!this->host_m_2.Equal((T*)dataPtr, this->m_nNumber_elements)) {
log_error("Buffer content difference found\n");
return FAILURE;
}
// test map read
clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking,
CL_MAP_READ,
0, this->get_block_size_bytes(),
0, NULL, &event, &err);
if (err == CL_SUCCESS) {
log_error("Calling clEnqueueMapBuffer (CL_MAP_READ) on a memory object created with the MEM_HOST_WRITE_ONLY flag should not return CL_SUCCESS\n");
err = FAILURE;
} else {
log_info("Test succeeded\n\n");
err = CL_SUCCESS;
}
return err;
}
#endif

View File

@@ -0,0 +1,68 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "../../test_common/harness/compat.h"
#include <stdio.h>
#include <string.h>
#if !defined (__APPLE__)
#include <CL/cl.h>
#endif
#include "procs.h"
#include "../../test_common/harness/testHarness.h"
#if !defined(_WIN32)
#include <unistd.h>
#endif
basefn clfn_list[] = {test_mem_host_read_only_buffer,
test_mem_host_read_only_subbuffer,
test_mem_host_write_only_buffer,
test_mem_host_write_only_subbuffer,
test_mem_host_no_access_buffer,
test_mem_host_no_access_subbuffer,
test_mem_host_read_only_image,
test_mem_host_write_only_image,
test_mem_host_no_access_image};
const char *clfn_names[] = {"test_mem_host_read_only_buffer",
"test_mem_host_read_only_subbuffer",
"test_mem_host_write_only_buffer",
"test_mem_host_write_only_subbuffer",
"test_mem_host_no_access_buffer",
"test_mem_host_no_access_subbuffer",
"test_mem_host_read_only_image",
"test_mem_host_write_only_image",
"test_mem_host_no_access_image",
};
ct_assert((sizeof(clfn_names) / sizeof(clfn_names[0])) == (sizeof(clfn_list) / sizeof(clfn_list[0])));
int num_fns = sizeof(clfn_names) / sizeof(char *);
cl_device_type gDeviceType = CL_DEVICE_TYPE_DEFAULT;
bool gTestRounding = true;
int main(int argc, const char *argv[])
{
int error = 0;
test_start();// in fact no code
log_info("1st part, non gl-sharing objects...\n");
error = runTestHarness(argc, argv, num_fns, clfn_list, clfn_names, false, false, 0);
return error;
}

View File

@@ -0,0 +1,487 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "../../test_common/harness/compat.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "procs.h"
#include "checker_mem_host_read_only.hpp"
#include "checker_mem_host_write_only.hpp"
#include "checker_mem_host_no_access.hpp"
static int test_mem_host_read_only_buffer_RW(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_flags parent_buffer_flag,
enum BUFFER_TYPE buffer_type)
{
log_info("%s\n", __FUNCTION__);
cBuffer_check_mem_host_read_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
cl_int err;
switch (buffer_type) {
case _BUFFER:
err = checker.SetupBuffer();
break;
case _Sub_BUFFER:
err = checker.SetupASSubBuffer(parent_buffer_flag);
break;
}
test_error(err, __FUNCTION__);
checker.Setup_Test_Environment();
err= checker.verify_RW_Buffer();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
static int test_mem_host_read_only_buffer_RW_Rect(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_flags parent_buffer_flag,
enum BUFFER_TYPE buffer_type)
{
log_info("%s\n", __FUNCTION__);
cBuffer_check_mem_host_read_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
cl_int err;
switch (buffer_type) {
case _BUFFER:
err= checker.SetupBuffer();
break;
case _Sub_BUFFER:
err= checker.SetupASSubBuffer(parent_buffer_flag);
break;
}
test_error(err, __FUNCTION__);
checker.Setup_Test_Environment();
err = checker.verify_RW_Buffer_rect();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
static int test_mem_host_read_only_buffer_RW_Mapping(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_flags parent_buffer_flag,
enum BUFFER_TYPE buffer_type)
{
log_info("%s\n", __FUNCTION__);
cBuffer_check_mem_host_read_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
cl_int err;
switch (buffer_type) {
case _BUFFER:
err= checker.SetupBuffer();
break;
case _Sub_BUFFER:
err= checker.SetupASSubBuffer(parent_buffer_flag);
break;
}
test_error(err, __FUNCTION__);
checker.Setup_Test_Environment();
err = checker.verify_RW_Buffer_mapping();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
int test_mem_host_read_only_buffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_mem_flags buffer_mem_flags[2] = {CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_READ_ONLY,
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_READ_ONLY};
cl_int err = CL_SUCCESS;
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
for (int k=0; k<2; k++)
for (int i=0; i< 2; i++)
{
err = test_mem_host_read_only_buffer_RW(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], 0, _BUFFER);
test_error(err, __FUNCTION__);
err = test_mem_host_read_only_buffer_RW_Rect(deviceID, context, queue, blocking[i],
buffer_mem_flags[k],0, _BUFFER);
test_error(err, __FUNCTION__);
err = test_mem_host_read_only_buffer_RW_Mapping(deviceID, context, queue, blocking[i],
buffer_mem_flags[k],0, _BUFFER);
test_error(err, __FUNCTION__);
}
return err;
}
int test_mem_host_read_only_subbuffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_mem_flags parent_buffer_mem_flags[1] = {CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_READ_ONLY};
cl_mem_flags buffer_mem_flags[4] = {0, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR};
cl_int err = CL_SUCCESS;
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
for (int p=0; p<1; p++) {
for (int k=0; k<4; k++)
for (int i=0; i<2; i++)
{
err = test_mem_host_read_only_buffer_RW(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
test_error(err, __FUNCTION__);
err = test_mem_host_read_only_buffer_RW_Rect(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
test_error(err, __FUNCTION__);
err = test_mem_host_read_only_buffer_RW_Mapping(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
test_error(err, __FUNCTION__);
}
}
return err;
}
//=============================== Write only
static cl_int test_mem_host_write_only_buffer_RW(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_flags parent_buffer_flag,
enum BUFFER_TYPE buffer_type)
{
log_info("%s\n", __FUNCTION__);
cBuffer_check_mem_host_write_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
cl_int err;
switch (buffer_type) {
case _BUFFER:
err = checker.SetupBuffer();
break;
case _Sub_BUFFER:
err = checker.SetupASSubBuffer( parent_buffer_flag );
break;
}
test_error(err, __FUNCTION__);
checker.Setup_Test_Environment();
err= checker.verify_RW_Buffer();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
static cl_int test_mem_host_write_only_buffer_RW_Rect(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_flags parent_buffer_flag,
enum BUFFER_TYPE buffer_type)
{
log_info("%s\n", __FUNCTION__);
cBuffer_check_mem_host_write_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
cl_int err;
switch (buffer_type) {
case _BUFFER:
err= checker.SetupBuffer();
break;
case _Sub_BUFFER:
err= checker.SetupASSubBuffer(parent_buffer_flag);
break;
}
test_error(err, __FUNCTION__);
checker.Setup_Test_Environment();
err= checker.verify_RW_Buffer_rect();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
static cl_int test_mem_host_write_only_buffer_RW_Mapping(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_flags parent_buffer_flag,
enum BUFFER_TYPE buffer_type)
{
log_info("%s\n", __FUNCTION__);
cBuffer_check_mem_host_write_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
cl_int err;
switch (buffer_type) {
case _BUFFER:
err= checker.SetupBuffer();
break;
case _Sub_BUFFER:
err= checker.SetupASSubBuffer(parent_buffer_flag);
break;
}
test_error(err, __FUNCTION__);
checker.Setup_Test_Environment();
err= checker.verify_RW_Buffer_mapping();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
int test_mem_host_write_only_buffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_mem_flags buffer_mem_flags[2] = {CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_WRITE_ONLY,
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_WRITE_ONLY};
cl_int err = CL_SUCCESS;
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
for (int k=0; k<2; k++)
for (int i=0; i<2; i++)
{
err = test_mem_host_write_only_buffer_RW(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], 0, _BUFFER);
test_error(err, __FUNCTION__);
err = test_mem_host_write_only_buffer_RW_Rect(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], 0, _BUFFER);
test_error(err, __FUNCTION__);
err = test_mem_host_write_only_buffer_RW_Mapping(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], 0, _BUFFER);
test_error(err, __FUNCTION__);
}
return err;
}
int test_mem_host_write_only_subbuffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_mem_flags parent_buffer_mem_flags[1] = {CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_WRITE_ONLY};
cl_mem_flags buffer_mem_flags[4] = {0, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR};
cl_int err = CL_SUCCESS;
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
for (int p=0; p<1; p++) {
for (int m=0; m<4; m++) {
for (int i=0; i< 2; i++)
{
err = test_mem_host_write_only_buffer_RW(deviceID, context, queue, blocking[i],
buffer_mem_flags[m], parent_buffer_mem_flags[p], _Sub_BUFFER);
test_error(err, __FUNCTION__);
err = test_mem_host_write_only_buffer_RW_Rect(deviceID, context, queue, blocking[i],
buffer_mem_flags[m], parent_buffer_mem_flags[p], _Sub_BUFFER);
test_error(err, __FUNCTION__);
err = test_mem_host_write_only_buffer_RW_Mapping(deviceID, context, queue, blocking[i],
buffer_mem_flags[m] , parent_buffer_mem_flags[p], _Sub_BUFFER);
test_error(err, __FUNCTION__);
}
}
}
return err;
}
//===================== NO ACCESS
static cl_int test_mem_host_no_access_buffer_RW(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_flags parent_buffer_flag,
enum BUFFER_TYPE buffer_type)
{
log_info("%s\n", __FUNCTION__);
cBuffer_check_mem_host_no_access< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
cl_int err = CL_SUCCESS;
switch (buffer_type) {
case _BUFFER:
err= checker.SetupBuffer();
break;
case _Sub_BUFFER:
err= checker.SetupASSubBuffer(parent_buffer_flag);
break;
}
test_error(err, __FUNCTION__);
checker.Setup_Test_Environment();
err= checker.verify_RW_Buffer_mapping();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
static cl_int test_mem_host_no_access_buffer_RW_Rect(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_flags parent_buffer_flag,
enum BUFFER_TYPE buffer_type)
{
log_info( "%s\n", __FUNCTION__);
cBuffer_check_mem_host_no_access< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
cl_int err;
switch (buffer_type) {
case _BUFFER:
err= checker.SetupBuffer();
break;
case _Sub_BUFFER:
err= checker.SetupASSubBuffer(parent_buffer_flag);
break;
}
test_error(err, __FUNCTION__);
checker.Setup_Test_Environment();
err= checker.verify_RW_Buffer_mapping();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
static cl_int test_mem_host_no_access_buffer_RW_Mapping(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_flags parent_buffer_flag,
enum BUFFER_TYPE buffer_type)
{
log_info("%s\n", __FUNCTION__);
cBuffer_check_mem_host_no_access< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
cl_int err;
switch (buffer_type) {
case _BUFFER:
err= checker.SetupBuffer();
break;
case _Sub_BUFFER:
err= checker.SetupASSubBuffer(parent_buffer_flag);
break;
}
test_error(err, __FUNCTION__);
checker.Setup_Test_Environment();
err= checker.verify_RW_Buffer_mapping();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
int test_mem_host_no_access_buffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_mem_flags buffer_mem_flag[2] = {CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS,
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_NO_ACCESS};
cl_int err = CL_SUCCESS;
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
for (int k=0; k<2; k++)
for (int i=0; i<2; i++) {
err = test_mem_host_no_access_buffer_RW(deviceID, context, queue, blocking[i],
buffer_mem_flag[k], 0, _BUFFER);
test_error(err, __FUNCTION__);
err = test_mem_host_no_access_buffer_RW_Rect(deviceID, context, queue, blocking[i],
buffer_mem_flag[k], 0, _BUFFER);
test_error(err, __FUNCTION__);
err = test_mem_host_no_access_buffer_RW_Mapping(deviceID, context, queue, blocking[i],
buffer_mem_flag[k], 0, _BUFFER);
test_error(err, __FUNCTION__);
}
return err;
}
int test_mem_host_no_access_subbuffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_mem_flags parent_buffer_mem_flags[3] = { CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS,
CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS,
CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS};
cl_mem_flags buffer_mem_flags[4] = {0, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR};
cl_int err = CL_SUCCESS;
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
for (int p=0; p<3; p++) {
for (int k=0; k<4; k++) {
for (int i=0; i<2; i++) {
err += test_mem_host_no_access_buffer_RW(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
err += test_mem_host_no_access_buffer_RW_Rect(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
err += test_mem_host_no_access_buffer_RW_Mapping( deviceID, context, queue, blocking[i],
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
}
}
}
return err;
}

View File

@@ -0,0 +1,364 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "../../test_common/harness/compat.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "procs.h"
#include "checker_image_mem_host_read_only.hpp"
#include "checker_image_mem_host_no_access.hpp"
#include "checker_image_mem_host_write_only.hpp"
//======================================
static cl_int test_mem_host_read_only_RW_Image(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_object_type image_type_in,
size_t array_size, size_t *img_dim)
{
log_info("%s ... \n ", __FUNCTION__);
cl_int err = CL_SUCCESS;
cImage_check_mem_host_read_only< int > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
checker.m_cl_Image_desc.image_type = image_type_in;
checker.m_cl_Image_desc.image_width = img_dim[0];
checker.m_cl_Image_desc.image_height = img_dim[1];
checker.m_cl_Image_desc.image_depth = img_dim[2];
checker.m_cl_Image_desc.image_array_size = array_size;
checker.m_cl_Image_desc.image_row_pitch = 0;
checker.m_cl_Image_desc.image_slice_pitch = 0;
checker.m_cl_Image_desc.num_mip_levels = 0;
checker.m_cl_Image_desc.num_samples = 0;
checker.SetupImage();
checker.Init_rect();
err = checker.verify_RW_Image();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
static cl_int test_mem_host_read_only_RW_Image_Mapping(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_object_type image_type_in,
size_t array_size, size_t *img_dim)
{
log_info("%s ... \n ", __FUNCTION__);
cl_int err = CL_SUCCESS;
cImage_check_mem_host_read_only< int > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
checker.m_cl_Image_desc.image_type = image_type_in;
checker.m_cl_Image_desc.image_width = img_dim[0];
checker.m_cl_Image_desc.image_height = img_dim[1];
checker.m_cl_Image_desc.image_depth = img_dim[2];
checker.m_cl_Image_desc.image_array_size = array_size;
checker.m_cl_Image_desc.image_row_pitch = 0;
checker.m_cl_Image_desc.image_slice_pitch = 0;
checker.m_cl_Image_desc.num_mip_levels = 0;
checker.m_cl_Image_desc.num_samples = 0;
checker.SetupImage();
checker.Init_rect();
err = checker.verify_RW_Image_Mapping();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
int test_mem_host_read_only_image(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_mem_flags buffer_mem_flags[2] = { CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_READ_ONLY,
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_READ_ONLY };
cl_int err = CL_SUCCESS;
cl_bool image_support;
err = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_SUPPORT, sizeof image_support, &image_support, NULL);
if (err) {
test_error(err, __FUNCTION__);
return err;
}
if (!image_support) {
log_info("Images are not supported by the device, skipping test...\n");
return 0;
}
cl_mem_object_type img_type[5] = {CL_MEM_OBJECT_IMAGE1D, CL_MEM_OBJECT_IMAGE2D, CL_MEM_OBJECT_IMAGE3D,CL_MEM_OBJECT_IMAGE1D_ARRAY, CL_MEM_OBJECT_IMAGE2D_ARRAY};
size_t img_dims[5][3] = {{200, 1, 1}, {200, 80, 1}, {200, 80, 5}, {200, 1, 1}, {200, 80, 10}}; // in elements
size_t array_size[5] = {1, 10, 1, 10, 1};
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
for (int flag=0; flag<2; flag++)
for (int i=0; i<2; i++) // blocking
{
for(int p=0; p<3; p++)
{
err = test_mem_host_read_only_RW_Image(deviceID, context, queue, blocking[i],
buffer_mem_flags[flag], img_type[p],
array_size[p], img_dims[p]);
test_error(err, __FUNCTION__);
err = test_mem_host_read_only_RW_Image_Mapping(deviceID, context, queue, blocking[i],
buffer_mem_flags[flag], img_type[p],
array_size[p], img_dims[p]);
test_error(err, __FUNCTION__);
}
}
return err;
}
//----------------------------
static cl_int test_MEM_HOST_WRIE_ONLY_Image_RW (cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_object_type image_type_in,
size_t array_size, size_t *img_dim)
{
log_info(" %s ... \n ", __FUNCTION__);
cl_int err = CL_SUCCESS;
cImage_check_mem_host_write_only< int > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
checker.m_cl_Image_desc.image_type = image_type_in;
checker.m_cl_Image_desc.image_width = img_dim[0];
checker.m_cl_Image_desc.image_height = img_dim[1];
checker.m_cl_Image_desc.image_depth = img_dim[2];
checker.m_cl_Image_desc.image_array_size = array_size;
checker.m_cl_Image_desc.image_row_pitch = 0;
checker.m_cl_Image_desc.image_slice_pitch = 0;
checker.m_cl_Image_desc.num_mip_levels = 0;
checker.m_cl_Image_desc.num_samples = 0;
checker.SetupImage();
checker.Init_rect();
checker.Setup_Test_Environment();
err = checker.verify_RW_Image();
clFinish(queue);
test_error(err, __FUNCTION__);
return err;
}
static cl_int test_MEM_HOST_WRITE_ONLY_Image_RW_Mapping(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_object_type image_type_in,
size_t array_size, size_t *img_dim)
{
log_info("%s ... \n ", __FUNCTION__);
cl_int err = CL_SUCCESS;
cImage_check_mem_host_write_only< int > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
checker.m_cl_Image_desc.image_type = image_type_in;
checker.m_cl_Image_desc.image_width = img_dim[0];
checker.m_cl_Image_desc.image_height = img_dim[1];
checker.m_cl_Image_desc.image_depth = img_dim[2];
checker.m_cl_Image_desc.image_array_size = array_size;
checker.m_cl_Image_desc.image_row_pitch = 0;
checker.m_cl_Image_desc.image_slice_pitch = 0;
checker.m_cl_Image_desc.num_mip_levels = 0;
checker.m_cl_Image_desc.num_samples = 0;
checker.SetupImage();
checker.Init_rect();
checker.Setup_Test_Environment();
err = checker.verify_RW_Image_Mapping();
clFinish(queue);
test_error(err, __FUNCTION__);
return err;
}
int test_mem_host_write_only_image(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_mem_flags buffer_mem_flags[2] = { CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_WRITE_ONLY,
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_WRITE_ONLY };
cl_int err = CL_SUCCESS;
cl_bool image_support;
err = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_SUPPORT, sizeof image_support, &image_support, NULL);
if (err) {
test_error(err, __FUNCTION__);
return err;
}
if (!image_support) {
log_info("Images are not supported by the device, skipping test...\n");
return 0;
}
cl_mem_object_type img_type[5]= {CL_MEM_OBJECT_IMAGE1D, CL_MEM_OBJECT_IMAGE2D, CL_MEM_OBJECT_IMAGE3D,
CL_MEM_OBJECT_IMAGE1D_ARRAY, CL_MEM_OBJECT_IMAGE2D_ARRAY};
size_t img_dims[5][3]= {{200, 1, 1}, {200, 80, 1}, {200, 80, 5}, {200, 1, 1}, {200, 80, 1} }; // in elements
size_t array_size[5] = {1, 10, 1, 10, 1};
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
for (int k=0; k<2; k++)
for (int i=0; i<2; i++) // blocking
{
for (int p=0; p<3; p++)
{
err = test_MEM_HOST_WRIE_ONLY_Image_RW(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], img_type[p], array_size[p], img_dims[p]);
test_error(err, __FUNCTION__);
err = test_MEM_HOST_WRITE_ONLY_Image_RW_Mapping(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], img_type[p], array_size[p], img_dims[p]);
test_error(err, __FUNCTION__);
}
}
return err;
}
//--------
static cl_int test_mem_host_no_access_Image_RW(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_object_type image_type_in,
size_t array_size, size_t *img_dim)
{
log_info("%s ... \n", __FUNCTION__);
cl_int err = CL_SUCCESS;
cImage_check_mem_host_no_access< int > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
checker.m_cl_Image_desc.image_type = image_type_in;
checker.m_cl_Image_desc.image_width = img_dim[0];
checker.m_cl_Image_desc.image_height = img_dim[1];
checker.m_cl_Image_desc.image_depth = img_dim[2];
checker.m_cl_Image_desc.image_array_size = array_size;
checker.m_cl_Image_desc.image_row_pitch = 0;
checker.m_cl_Image_desc.image_slice_pitch = 0;
checker.m_cl_Image_desc.num_mip_levels = 0;
checker.m_cl_Image_desc.num_samples = 0;
checker.SetupImage();
checker.Init_rect();
checker.Setup_Test_Environment();
err = checker.verify_RW_Image();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
static cl_int test_mem_host_no_access_Image_RW_Mapping(cl_device_id deviceID, cl_context context,
cl_command_queue queue, cl_bool blocking,
cl_mem_flags buffer_mem_flag,
cl_mem_object_type image_type_in,
size_t array_size, size_t *img_dim)
{
log_info("%s ... \n ", __FUNCTION__);
cl_int err =CL_SUCCESS;
cImage_check_mem_host_no_access< int > checker(deviceID, context, queue);
checker.m_blocking = blocking;
checker.buffer_mem_flag = buffer_mem_flag;
checker.m_cl_Image_desc.image_type = image_type_in;
checker.m_cl_Image_desc.image_width = img_dim[0];
checker.m_cl_Image_desc.image_height = img_dim[1];
checker.m_cl_Image_desc.image_depth = img_dim[2];
checker.m_cl_Image_desc.image_array_size = array_size;
checker.m_cl_Image_desc.image_row_pitch = 0;
checker.m_cl_Image_desc.image_slice_pitch = 0;
checker.m_cl_Image_desc.num_mip_levels = 0;
checker.m_cl_Image_desc.num_samples = 0;
checker.SetupImage();
checker.Init_rect();
checker.Setup_Test_Environment();
err = checker.verify_RW_Image_Mapping();
test_error(err, __FUNCTION__);
clFinish(queue);
return err;
}
int test_mem_host_no_access_image(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_mem_flags buffer_mem_flags[2] = {CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS,
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_NO_ACCESS };
cl_int err = CL_SUCCESS;
cl_bool image_support;
err = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_SUPPORT, sizeof image_support, &image_support, NULL);
if (err) {
test_error(err, __FUNCTION__);
return err;
}
if (!image_support) {
log_info("Images are not supported by the device, skipping test...\n");
return 0;
}
cl_mem_object_type img_type[5] = {CL_MEM_OBJECT_IMAGE1D, CL_MEM_OBJECT_IMAGE2D, CL_MEM_OBJECT_IMAGE3D,
CL_MEM_OBJECT_IMAGE1D_ARRAY, CL_MEM_OBJECT_IMAGE2D_ARRAY};
size_t img_dims[5][3]= {{200, 1, 1}, {200, 80, 1}, {100, 80, 5}, {200, 1, 1}, {200, 80, 1}}; // in elements
size_t array_size [5] = {1, 1, 1, 10, 10};
cl_bool blocking[2] = { CL_TRUE, CL_FALSE};
for (int k=0; k<2; k++)
for (int i=0; i<2; i++) // blocking
{
for (int p =0; p<3; p++)
{
err += test_mem_host_no_access_Image_RW (deviceID, context, queue, blocking[i],
buffer_mem_flags[k], img_type[p], array_size[p], img_dims[p]);
err += test_mem_host_no_access_Image_RW_Mapping(deviceID, context, queue, blocking[i],
buffer_mem_flags[k], img_type[p], array_size[p], img_dims[p]);
}
}
return err;
}

View File

@@ -0,0 +1,45 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef __PROCS_H__
#define __PROCS_H__
#include "testBase.h"
#define NUM_FLAGS 4
extern int test_mem_host_read_only_buffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_mem_host_read_only_subbuffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_mem_host_write_only_buffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_mem_host_write_only_subbuffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_mem_host_no_access_buffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_mem_host_no_access_subbuffer(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_mem_host_read_only_image(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_mem_host_write_only_image(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_mem_host_no_access_image(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements);
#endif // #ifndef __PROCS_H__

View File

@@ -0,0 +1,40 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef _testBase_h
#define _testBase_h
#include "../../test_common/harness/compat.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#if !defined (__APPLE__)
#include <CL/cl.h>
#else
//#include <OpenCL/cl.h>
#endif
#include "../../test_common/harness/imageHelpers.h"
#include "../../test_common/harness/errorHelpers.h"
#include "../../test_common/harness/kernelHelpers.h"
#include "../../test_common/harness/threadTesting.h"
#include "../../test_common/harness/typeWrappers.h"
#include "../../test_common/harness/conversions.h"
#include "../../test_common/harness/mt19937.h"
#endif // _testBase_h