mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
[NFC] clang-format mem_host_flags (#1607)
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
committed by
GitHub
parent
8066e69b11
commit
4278d544dc
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -22,59 +22,48 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
template < class T> class C_host_memory_block
|
template <class T> class C_host_memory_block {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
int num_elements;
|
int num_elements;
|
||||||
int element_size;
|
int element_size;
|
||||||
T *pData;
|
T *pData;
|
||||||
|
|
||||||
C_host_memory_block();
|
C_host_memory_block();
|
||||||
~C_host_memory_block();
|
~C_host_memory_block();
|
||||||
void Init(int num_elem, T &value);
|
void Init(int num_elem, T &value);
|
||||||
void Init(int num_elem);
|
void Init(int num_elem);
|
||||||
void Set_to(T & val);
|
void Set_to(T &val);
|
||||||
void Set_to_zero();
|
void Set_to_zero();
|
||||||
bool Equal_to(T &val);
|
bool Equal_to(T &val);
|
||||||
size_t Count(T &val);
|
size_t Count(T &val);
|
||||||
bool Equal(C_host_memory_block < T > & another);
|
bool Equal(C_host_memory_block<T> &another);
|
||||||
bool Equal_rect(C_host_memory_block < T > & another,
|
bool Equal_rect(C_host_memory_block<T> &another, size_t *host_origin,
|
||||||
size_t * host_origin,
|
size_t *region, size_t host_row_pitch,
|
||||||
size_t * region,
|
size_t host_slice_pitch);
|
||||||
size_t host_row_pitch,
|
bool Equal(T *pData, int num_elements);
|
||||||
size_t host_slice_pitch);
|
|
||||||
bool Equal(T *pData, int num_elements);
|
|
||||||
|
|
||||||
bool Equal_rect_from_orig(C_host_memory_block < T > & another,
|
bool Equal_rect_from_orig(C_host_memory_block<T> &another, size_t *soffset,
|
||||||
size_t * soffset,
|
size_t *region, size_t host_row_pitch,
|
||||||
size_t * region,
|
size_t host_slice_pitch);
|
||||||
size_t host_row_pitch,
|
|
||||||
size_t host_slice_pitch);
|
|
||||||
|
|
||||||
bool Equal_rect_from_orig(T* another_pdata,
|
bool Equal_rect_from_orig(T *another_pdata, size_t *soffset, size_t *region,
|
||||||
size_t * soffset,
|
size_t host_row_pitch, size_t host_slice_pitch);
|
||||||
size_t * region,
|
|
||||||
size_t host_row_pitch,
|
|
||||||
size_t host_slice_pitch);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template < class T >
|
template <class T> C_host_memory_block<T>::C_host_memory_block()
|
||||||
C_host_memory_block<T>::C_host_memory_block()
|
|
||||||
{
|
{
|
||||||
pData = NULL;
|
pData = NULL;
|
||||||
element_size = sizeof (T);
|
element_size = sizeof(T);
|
||||||
num_elements = 0;
|
num_elements = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T>
|
template <class T> C_host_memory_block<T>::~C_host_memory_block()
|
||||||
C_host_memory_block<T>::~C_host_memory_block()
|
|
||||||
{
|
{
|
||||||
if (pData != NULL) delete[] pData;
|
if (pData != NULL) delete[] pData;
|
||||||
num_elements = 0;
|
num_elements = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T> void C_host_memory_block<T>::Init(int num_elem, T &value)
|
||||||
void C_host_memory_block<T>::Init(int num_elem, T & value)
|
|
||||||
{
|
{
|
||||||
if (pData != NULL) delete[] pData;
|
if (pData != NULL) delete[] pData;
|
||||||
pData = new T[num_elem];
|
pData = new T[num_elem];
|
||||||
@@ -83,8 +72,7 @@ void C_host_memory_block<T>::Init(int num_elem, T & value)
|
|||||||
num_elements = num_elem;
|
num_elements = num_elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T> void C_host_memory_block<T>::Init(int num_elem)
|
||||||
void C_host_memory_block<T>::Init(int num_elem)
|
|
||||||
{
|
{
|
||||||
if (pData != NULL) delete[] pData;
|
if (pData != NULL) delete[] pData;
|
||||||
pData = new T[num_elem];
|
pData = new T[num_elem];
|
||||||
@@ -92,158 +80,149 @@ void C_host_memory_block<T>::Init(int num_elem)
|
|||||||
|
|
||||||
num_elements = num_elem;
|
num_elements = num_elem;
|
||||||
}
|
}
|
||||||
template < class T >
|
template <class T> void C_host_memory_block<T>::Set_to_zero()
|
||||||
void C_host_memory_block<T>::Set_to_zero()
|
|
||||||
{
|
{
|
||||||
T v = 0;
|
T v = 0;
|
||||||
Set_to(v);
|
Set_to(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T> void C_host_memory_block<T>::Set_to(T &val)
|
||||||
void C_host_memory_block<T>::Set_to(T &val)
|
|
||||||
{
|
{
|
||||||
for (int i=0; i<num_elements; i++)
|
for (int i = 0; i < num_elements; i++) pData[i] = val;
|
||||||
pData[i] = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T> bool C_host_memory_block<T>::Equal_to(T &val)
|
||||||
bool C_host_memory_block<T>::Equal_to(T &val)
|
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i=0; i<num_elements; i++) {
|
for (int i = 0; i < num_elements; i++)
|
||||||
if (pData[i] == val)
|
{
|
||||||
count++;
|
if (pData[i] == val) count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (count== num_elements);
|
return (count == num_elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
bool C_host_memory_block<T>::Equal(C_host_memory_block < T > & another)
|
bool C_host_memory_block<T>::Equal(C_host_memory_block<T> &another)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i=0; i<num_elements; i++) {
|
for (int i = 0; i < num_elements; i++)
|
||||||
if (pData[i] == another.pData[i])
|
{
|
||||||
count++;
|
if (pData[i] == another.pData[i]) count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (count== num_elements);
|
return (count == num_elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
bool C_host_memory_block<T>::Equal(T *pIn_Data, int Innum_elements)
|
bool C_host_memory_block<T>::Equal(T *pIn_Data, int Innum_elements)
|
||||||
{
|
{
|
||||||
if (this->num_elements!= Innum_elements)
|
if (this->num_elements != Innum_elements) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i=0; i<num_elements ; i++ ) {
|
for (int i = 0; i < num_elements; i++)
|
||||||
if (pData[i] == pIn_Data[i])
|
{
|
||||||
count++;
|
if (pData[i] == pIn_Data[i]) count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( count== num_elements);
|
return (count == num_elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T> size_t C_host_memory_block<T>::Count(T &val)
|
||||||
size_t C_host_memory_block<T>::Count(T &val)
|
|
||||||
{
|
{
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for (int i=0; i<num_elements; i++) {
|
for (int i = 0; i < num_elements; i++)
|
||||||
if (pData[i] == val)
|
{
|
||||||
count++;
|
if (pData[i] == val) count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
bool C_host_memory_block<T>::Equal_rect(C_host_memory_block < T > & another,
|
bool C_host_memory_block<T>::Equal_rect(C_host_memory_block<T> &another,
|
||||||
size_t * soffset,
|
size_t *soffset, size_t *region,
|
||||||
size_t * region,
|
|
||||||
size_t host_row_pitch,
|
size_t host_row_pitch,
|
||||||
size_t host_slice_pitch)
|
size_t host_slice_pitch)
|
||||||
{
|
{
|
||||||
size_t row_pitch = host_row_pitch ? host_row_pitch : region[0];
|
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 slice_pitch = host_slice_pitch ? host_row_pitch : region[1];
|
||||||
|
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
size_t total = region[0] * region[1] * region[2];
|
size_t total = region[0] * region[1] * region[2];
|
||||||
|
|
||||||
size_t x, y, z;
|
size_t x, y, z;
|
||||||
size_t orig = (size_t)(soffset[0] + row_pitch*soffset[1] + slice_pitch * soffset[2]);
|
size_t orig = (size_t)(soffset[0] + row_pitch * soffset[1]
|
||||||
for (z=0; z<region[2]; z++)
|
+ slice_pitch * soffset[2]);
|
||||||
for (y=0; y<region[1]; y++)
|
for (z = 0; z < region[2]; z++)
|
||||||
for (x=0; x<region[0]; x++)
|
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])
|
int p1 = (int)(x + row_pitch * y + slice_pitch * z + orig);
|
||||||
count++;
|
if (pData[p1] == another.pData[p1]) count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (count == total);
|
return (count == total);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
bool C_host_memory_block<T>::Equal_rect_from_orig(C_host_memory_block < T > & another,
|
bool C_host_memory_block<T>::Equal_rect_from_orig(
|
||||||
size_t * soffset,
|
C_host_memory_block<T> &another, size_t *soffset, size_t *region,
|
||||||
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_row_pitch,
|
||||||
size_t host_slice_pitch)
|
size_t host_slice_pitch)
|
||||||
{
|
{
|
||||||
size_t row_pitch = host_row_pitch ? host_row_pitch : region[0];
|
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 slice_pitch = host_slice_pitch ? host_row_pitch : region[1];
|
||||||
|
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
size_t total = region[0] * region[1] * region[2];
|
size_t total = region[0] * region[1] * region[2];
|
||||||
|
|
||||||
size_t x, y, z;
|
size_t x, y, z;
|
||||||
size_t orig = soffset[0] + row_pitch * soffset[1] + slice_pitch * soffset[2];
|
size_t orig =
|
||||||
for (z=0; z<region[2]; z++)
|
soffset[0] + row_pitch * soffset[1] + slice_pitch * soffset[2];
|
||||||
for (y=0; y<region[1]; y++)
|
for (z = 0; z < region[2]; z++)
|
||||||
for (x=0; x<region[0]; x++)
|
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;
|
size_t p1 = x + (row_pitch * y) + (slice_pitch * z);
|
||||||
if (pData[p2] == another.pData[p1])
|
size_t p2 = p1 + orig;
|
||||||
count++;
|
if (pData[p2] == another_pdata[p1]) count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (count == total);
|
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
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -27,291 +27,316 @@
|
|||||||
#define TEST_VALUE 5
|
#define TEST_VALUE 5
|
||||||
typedef cl_char TEST_ELEMENT_TYPE;
|
typedef cl_char TEST_ELEMENT_TYPE;
|
||||||
|
|
||||||
enum {SUCCESS, FAILURE=-1000};
|
enum
|
||||||
|
{
|
||||||
|
SUCCESS,
|
||||||
|
FAILURE = -1000
|
||||||
|
};
|
||||||
|
|
||||||
extern const char *buffer_write_kernel_code[];
|
extern const char *buffer_write_kernel_code[];
|
||||||
|
|
||||||
enum BUFFER_TYPE {_BUFFER, _Sub_BUFFER};
|
enum BUFFER_TYPE
|
||||||
|
|
||||||
template < class T > class cBuffer_checker
|
|
||||||
{
|
{
|
||||||
public:
|
_BUFFER,
|
||||||
cBuffer_checker(cl_device_id deviceID, cl_context context,
|
_Sub_BUFFER
|
||||||
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 >
|
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,
|
cBuffer_checker<T>::cBuffer_checker(cl_device_id deviceID, cl_context context,
|
||||||
cl_command_queue queue)
|
cl_command_queue queue)
|
||||||
{
|
{
|
||||||
m_nNumber_elements = 0;
|
m_nNumber_elements = 0;
|
||||||
|
|
||||||
m_deviceID = deviceID;
|
m_deviceID = deviceID;
|
||||||
m_context = context;
|
m_context = context;
|
||||||
m_queue = queue;
|
m_queue = queue;
|
||||||
|
|
||||||
m_blocking = false;
|
m_blocking = false;
|
||||||
|
|
||||||
buffer_mem_flag = CL_MEM_READ_WRITE;
|
buffer_mem_flag = CL_MEM_READ_WRITE;
|
||||||
pData = pData2 = NULL;
|
pData = pData2 = NULL;
|
||||||
|
|
||||||
buffer_origin[0] = buffer_origin[1] = buffer_origin[2] = 0;
|
buffer_origin[0] = buffer_origin[1] = buffer_origin[2] = 0;
|
||||||
host_origin[0] = host_origin[1] = host_origin[2] = 0;
|
host_origin[0] = host_origin[1] = host_origin[2] = 0;
|
||||||
region[0] = region[1] = region[2] = 0;
|
region[0] = region[1] = region[2] = 0;
|
||||||
buffer_row_pitch = buffer_slice_pitch = host_row_pitch = host_slice_pitch = 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;
|
buffer_origin_bytes[0] = buffer_origin_bytes[1] = buffer_origin_bytes[2] =
|
||||||
host_origin_bytes[0] = host_origin_bytes[1] = host_origin_bytes[2] = 0;
|
0;
|
||||||
region_bytes[0] = region_bytes[1] = region_bytes[2] = 0;
|
host_origin_bytes[0] = host_origin_bytes[1] = host_origin_bytes[2] = 0;
|
||||||
buffer_row_pitch_bytes = buffer_slice_pitch_bytes = 0;
|
region_bytes[0] = region_bytes[1] = region_bytes[2] = 0;
|
||||||
host_row_pitch_bytes = host_slice_pitch_bytes = 0;
|
buffer_row_pitch_bytes = buffer_slice_pitch_bytes = 0;
|
||||||
|
host_row_pitch_bytes = host_slice_pitch_bytes = 0;
|
||||||
|
|
||||||
pHost_ptr = NULL;
|
pHost_ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T> cBuffer_checker<T>::~cBuffer_checker() {}
|
||||||
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()
|
||||||
template < class T >
|
|
||||||
cl_int cBuffer_checker<T>::SetupBuffer()
|
|
||||||
{
|
{
|
||||||
m_buffer_type = _BUFFER;
|
return CL_SUCCESS;
|
||||||
return CL_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
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)
|
cl_int cBuffer_checker<T>::SetupASSubBuffer(cl_mem_flags parent_buffer_flag)
|
||||||
{
|
{
|
||||||
m_buffer_type = _Sub_BUFFER;
|
m_buffer_type = _Sub_BUFFER;
|
||||||
|
|
||||||
int supersize = 8000;
|
int supersize = 8000;
|
||||||
this-> m_nNumber_elements = 1000;
|
this->m_nNumber_elements = 1000;
|
||||||
T vv1= TEST_VALUE;
|
T vv1 = TEST_VALUE;
|
||||||
|
|
||||||
int block_size_in_byte = (int)(supersize * sizeof(T));
|
int block_size_in_byte = (int)(supersize * sizeof(T));
|
||||||
|
|
||||||
this->host_m_0.Init(supersize);
|
this->host_m_0.Init(supersize);
|
||||||
|
|
||||||
m_buffer_parent = clCreateBuffer(this->m_context, parent_buffer_flag,
|
m_buffer_parent =
|
||||||
block_size_in_byte, this->host_m_0.pData, &err);
|
clCreateBuffer(this->m_context, parent_buffer_flag, block_size_in_byte,
|
||||||
test_error(err, "clCreateBuffer error");
|
this->host_m_0.pData, &err);
|
||||||
|
test_error(err, "clCreateBuffer error");
|
||||||
|
|
||||||
int size = this->m_nNumber_elements; // the size of subbuffer in elements
|
int size = this->m_nNumber_elements; // the size of subbuffer in elements
|
||||||
|
|
||||||
cl_uint base_addr_align_bits;
|
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);
|
err = clGetDeviceInfo(m_deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN,
|
||||||
test_error(err,"clGetDeviceInfo for 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 base_addr_align_bytes = base_addr_align_bits / 8;
|
||||||
|
|
||||||
int buffer_origin[3] = {base_addr_align_bytes, 0, 0};
|
int buffer_origin[3] = { base_addr_align_bytes, 0, 0 };
|
||||||
int host_origin[3] = {0, 0, 0};
|
int host_origin[3] = { 0, 0, 0 };
|
||||||
int region[3] = {size, 1, 1};
|
int region[3] = { size, 1, 1 };
|
||||||
int buffer_pitch[2] = {0, 0};
|
int buffer_pitch[2] = { 0, 0 };
|
||||||
int host_pitch[2] = {0, 0};
|
int host_pitch[2] = { 0, 0 };
|
||||||
this->Init_rect(buffer_origin, host_origin, region, buffer_pitch, host_pitch);
|
this->Init_rect(buffer_origin, host_origin, region, buffer_pitch,
|
||||||
|
host_pitch);
|
||||||
|
|
||||||
this->m_nNumber_elements = size; // the size of subbuffer in elements
|
this->m_nNumber_elements = size; // the size of subbuffer in elements
|
||||||
this->host_m_1.Init(this->m_nNumber_elements, vv1);
|
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.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_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
err = clEnqueueReadBufferRect(
|
err = clEnqueueReadBufferRect(
|
||||||
this->m_queue, m_buffer_parent, CL_TRUE, this->buffer_origin_bytes,
|
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->host_origin_bytes, this->region_bytes,
|
||||||
this->buffer_slice_pitch_bytes, this->host_row_pitch_bytes,
|
this->buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes,
|
||||||
this->host_slice_pitch_bytes, this->host_m_1.pData, 0, NULL,
|
this->host_row_pitch_bytes, this->host_slice_pitch_bytes,
|
||||||
NULL); // update the mem_1
|
this->host_m_1.pData, 0, NULL,
|
||||||
|
NULL); // 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;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
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;
|
return err;
|
||||||
} 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 >
|
template <class T>
|
||||||
cl_int cBuffer_checker<T>::verify(cl_int err, cl_event & event)
|
cl_int cBuffer_checker<T>::verify(cl_int err, cl_event &event)
|
||||||
{
|
{
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_checker<T>::CreateBuffer(cl_mem_flags buffer_mem_flag, void *pdata)
|
cl_int cBuffer_checker<T>::CreateBuffer(cl_mem_flags buffer_mem_flag,
|
||||||
|
void *pdata)
|
||||||
{
|
{
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
int block_size_in_byte= m_nNumber_elements* sizeof(T);
|
int block_size_in_byte = m_nNumber_elements * sizeof(T);
|
||||||
|
|
||||||
m_buffer = clCreateBuffer(m_context, buffer_mem_flag, block_size_in_byte, pdata, &err);
|
m_buffer = clCreateBuffer(m_context, buffer_mem_flag, block_size_in_byte,
|
||||||
|
pdata, &err);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
};
|
};
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_checker<T>::Check_GetMemObjectInfo(cl_mem_flags buffer_mem_flag)
|
cl_int cBuffer_checker<T>::Check_GetMemObjectInfo(cl_mem_flags buffer_mem_flag)
|
||||||
{
|
{
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
cl_mem_flags buffer_mem_flag_Check;
|
cl_mem_flags buffer_mem_flag_Check;
|
||||||
err = clGetMemObjectInfo(this->m_buffer, CL_MEM_FLAGS, sizeof(cl_mem_flags),
|
err = clGetMemObjectInfo(this->m_buffer, CL_MEM_FLAGS, sizeof(cl_mem_flags),
|
||||||
&buffer_mem_flag_Check, NULL);
|
&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");
|
||||||
|
|
||||||
if (buffer_mem_flag_Check != buffer_mem_flag) {
|
|
||||||
log_error("clGetMemObjectInfo result differs from the specified result\n");
|
|
||||||
return err;
|
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 >
|
template <class T> void cBuffer_checker<T>::Init_rect()
|
||||||
void cBuffer_checker<T>::Init_rect ()
|
|
||||||
{
|
{
|
||||||
int buffer_origin[3] = {10, 0, 0};
|
int buffer_origin[3] = { 10, 0, 0 };
|
||||||
int host_origin[3] = {10, 0, 0};
|
int host_origin[3] = { 10, 0, 0 };
|
||||||
int region[3] = {8, 1, 1};
|
int region[3] = { 8, 1, 1 };
|
||||||
int buffer_pitch[2] = {0, 0};
|
int buffer_pitch[2] = { 0, 0 };
|
||||||
int host_pitch[2] = {0, 0};
|
int host_pitch[2] = { 0, 0 };
|
||||||
|
|
||||||
this->Init_rect(buffer_origin, host_origin, region, buffer_pitch, host_pitch);
|
this->Init_rect(buffer_origin, host_origin, region, buffer_pitch,
|
||||||
|
host_pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
void cBuffer_checker<T>::Init_rect(int bufforg[3], int host_org[3],
|
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])
|
int region_in[3], int buffer_pitch[2],
|
||||||
|
int host_pitch[2])
|
||||||
{
|
{
|
||||||
buffer_origin[0] = bufforg[0];
|
buffer_origin[0] = bufforg[0];
|
||||||
buffer_origin[1] = bufforg[1];
|
buffer_origin[1] = bufforg[1];
|
||||||
buffer_origin[2] = bufforg[2];
|
buffer_origin[2] = bufforg[2];
|
||||||
|
|
||||||
host_origin[0] = host_org[0];
|
host_origin[0] = host_org[0];
|
||||||
host_origin[1] = host_org[1];
|
host_origin[1] = host_org[1];
|
||||||
host_origin[2] = host_org[2];
|
host_origin[2] = host_org[2];
|
||||||
|
|
||||||
region[0] = region_in[0];
|
region[0] = region_in[0];
|
||||||
region[1] = region_in[1];
|
region[1] = region_in[1];
|
||||||
region[2] = region_in[2];
|
region[2] = region_in[2];
|
||||||
|
|
||||||
buffer_row_pitch = buffer_pitch[0];
|
buffer_row_pitch = buffer_pitch[0];
|
||||||
buffer_slice_pitch = buffer_pitch[1];
|
buffer_slice_pitch = buffer_pitch[1];
|
||||||
host_row_pitch = host_pitch[0];
|
host_row_pitch = host_pitch[0];
|
||||||
host_slice_pitch = host_pitch[1];
|
host_slice_pitch = host_pitch[1];
|
||||||
|
|
||||||
int sizeof_element = sizeof(T);
|
int sizeof_element = sizeof(T);
|
||||||
for (int k=0; k<3; k++)
|
for (int k = 0; k < 3; k++)
|
||||||
{
|
{
|
||||||
buffer_origin_bytes[k] = buffer_origin[k] * sizeof_element;
|
buffer_origin_bytes[k] = buffer_origin[k] * sizeof_element;
|
||||||
host_origin_bytes [k] = host_origin[k] * sizeof_element;
|
host_origin_bytes[k] = host_origin[k] * sizeof_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
region_bytes[0] = region[0] * sizeof_element;
|
region_bytes[0] = region[0] * sizeof_element;
|
||||||
region_bytes[1] = region[1];
|
region_bytes[1] = region[1];
|
||||||
region_bytes[2] = region[2];
|
region_bytes[2] = region[2];
|
||||||
buffer_row_pitch_bytes = buffer_row_pitch* sizeof_element;
|
buffer_row_pitch_bytes = buffer_row_pitch * sizeof_element;
|
||||||
buffer_slice_pitch_bytes = buffer_slice_pitch* sizeof_element;
|
buffer_slice_pitch_bytes = buffer_slice_pitch * sizeof_element;
|
||||||
host_row_pitch_bytes = host_row_pitch* sizeof_element;
|
host_row_pitch_bytes = host_row_pitch * sizeof_element;
|
||||||
host_slice_pitch_bytes = host_slice_pitch* sizeof_element;
|
host_slice_pitch_bytes = host_slice_pitch * sizeof_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -18,138 +18,149 @@
|
|||||||
|
|
||||||
#include "checker_image_mem_host_write_only.hpp"
|
#include "checker_image_mem_host_write_only.hpp"
|
||||||
|
|
||||||
template < class T>
|
template <class T>
|
||||||
class cImage_check_mem_host_no_access : public cImage_check_mem_host_write_only<T>
|
class cImage_check_mem_host_no_access
|
||||||
{
|
: public cImage_check_mem_host_write_only<T> {
|
||||||
public:
|
public:
|
||||||
cImage_check_mem_host_no_access (cl_device_id deviceID, cl_context context, cl_command_queue queue)
|
cImage_check_mem_host_no_access(cl_device_id deviceID, cl_context context,
|
||||||
: cImage_check_mem_host_write_only <T> (deviceID,context, queue)
|
cl_command_queue queue)
|
||||||
{
|
: cImage_check_mem_host_write_only<T>(deviceID, context, queue)
|
||||||
}
|
{}
|
||||||
|
|
||||||
~cImage_check_mem_host_no_access() {};
|
~cImage_check_mem_host_no_access(){};
|
||||||
|
|
||||||
cl_int verify_RW_Image();
|
cl_int verify_RW_Image();
|
||||||
cl_int verify_RW_Image_Mapping();
|
cl_int verify_RW_Image_Mapping();
|
||||||
};
|
};
|
||||||
|
|
||||||
template < class T>
|
template <class T> cl_int cImage_check_mem_host_no_access<T>::verify_RW_Image()
|
||||||
cl_int cImage_check_mem_host_no_access<T>:: verify_RW_Image()
|
|
||||||
{
|
{
|
||||||
this->Init_rect();
|
this->Init_rect();
|
||||||
|
|
||||||
cl_event event;
|
cl_event event;
|
||||||
size_t img_orig[3] = {0, 0, 0};
|
size_t img_orig[3] = { 0, 0, 0 };
|
||||||
size_t img_region[3] = {0, 0, 0};
|
size_t img_region[3] = { 0, 0, 0 };
|
||||||
img_region[0] = this->m_cl_Image_desc.image_width;
|
img_region[0] = this->m_cl_Image_desc.image_width;
|
||||||
img_region[1] = this->m_cl_Image_desc.image_height;
|
img_region[1] = this->m_cl_Image_desc.image_height;
|
||||||
img_region[2] = this->m_cl_Image_desc.image_depth;
|
img_region[2] = this->m_cl_Image_desc.image_depth;
|
||||||
|
|
||||||
int color[4] = {0xFF, 0xFF, 0xFF, 0xFF};
|
int color[4] = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
err = clEnqueueFillImage(this->m_queue, this->m_Image,
|
err = clEnqueueFillImage(this->m_queue, this->m_Image, &color, img_orig,
|
||||||
&color,
|
img_region, 0, NULL, &event);
|
||||||
img_orig, img_region,
|
test_error(err, "clEnqueueFillImage error");
|
||||||
0, NULL, &event);
|
|
||||||
test_error(err, "clEnqueueFillImage error");
|
|
||||||
|
|
||||||
if (!this->m_blocking) {
|
if (!this->m_blocking)
|
||||||
err = clWaitForEvents(1, &event);
|
{
|
||||||
test_error(err, "clWaitForEvents error");
|
err = clWaitForEvents(1, &event);
|
||||||
}
|
test_error(err, "clWaitForEvents error");
|
||||||
|
}
|
||||||
|
|
||||||
err = clReleaseEvent(event);
|
err = clReleaseEvent(event);
|
||||||
test_error(err, "clReleaseEvent error");
|
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]);
|
||||||
|
|
||||||
T v = 0xFFFFFFFF;
|
T v = 0xFFFFFFFF;
|
||||||
int tot = (int)(this->host_m_2.Count(v));
|
int tot = (int)(this->host_m_2.Count(v));
|
||||||
if(tot != total){
|
if (tot != total)
|
||||||
log_error("Buffer data content difference found\n");
|
{
|
||||||
return FAILURE;
|
log_error("Buffer data content difference found\n");
|
||||||
}
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
err = clEnqueueWriteImage(this->m_queue, this->m_Image, this->m_blocking,
|
err = clEnqueueWriteImage(
|
||||||
this->buffer_origin, this->region,
|
this->m_queue, this->m_Image, this->m_blocking, this->buffer_origin,
|
||||||
this-> buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes,
|
this->region, this->buffer_row_pitch_bytes,
|
||||||
this->host_m_1.pData, 0, NULL, &event);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
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>
|
template <class T>
|
||||||
cl_int cImage_check_mem_host_no_access<T>::verify_RW_Image_Mapping()
|
cl_int cImage_check_mem_host_no_access<T>::verify_RW_Image_Mapping()
|
||||||
{
|
{
|
||||||
this->Init_rect();
|
this->Init_rect();
|
||||||
|
|
||||||
cl_event event;
|
cl_event event;
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
|
|
||||||
T * dataPtr = (T*) clEnqueueMapImage(this->m_queue, this->m_Image, this->m_blocking,
|
T* dataPtr = (T*)clEnqueueMapImage(
|
||||||
CL_MAP_WRITE,
|
this->m_queue, this->m_Image, this->m_blocking, CL_MAP_WRITE,
|
||||||
this->buffer_origin, this->region,
|
this->buffer_origin, this->region, &(this->buffer_row_pitch_bytes),
|
||||||
&(this-> buffer_row_pitch_bytes),
|
&(this->buffer_slice_pitch_bytes), 0, NULL, &event, &err);
|
||||||
&(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;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
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
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -18,273 +18,293 @@
|
|||||||
|
|
||||||
#include "checker.h"
|
#include "checker.h"
|
||||||
|
|
||||||
template < class T> class cImage_check_mem_host_read_only : public cBuffer_checker<T>
|
template <class T>
|
||||||
{
|
class cImage_check_mem_host_read_only : public cBuffer_checker<T> {
|
||||||
public:
|
public:
|
||||||
cImage_check_mem_host_read_only(cl_device_id deviceID, cl_context context, cl_command_queue queue)
|
cImage_check_mem_host_read_only(cl_device_id deviceID, cl_context context,
|
||||||
: cBuffer_checker <T> (deviceID, context, queue)
|
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_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_type = CL_MEM_OBJECT_IMAGE1D;
|
||||||
m_cl_Image_desc.image_width = 0;
|
m_cl_Image_desc.image_width = 0;
|
||||||
m_cl_Image_desc.image_height = 0;
|
m_cl_Image_desc.image_height = 0;
|
||||||
m_cl_Image_desc.image_depth = 0;
|
m_cl_Image_desc.image_depth = 0;
|
||||||
m_cl_Image_desc.image_array_size = 0;
|
m_cl_Image_desc.image_array_size = 0;
|
||||||
m_cl_Image_desc.image_row_pitch = 0;
|
m_cl_Image_desc.image_row_pitch = 0;
|
||||||
m_cl_Image_desc.image_slice_pitch = 0;
|
m_cl_Image_desc.image_slice_pitch = 0;
|
||||||
m_cl_Image_desc.num_mip_levels = 0;
|
m_cl_Image_desc.num_mip_levels = 0;
|
||||||
m_cl_Image_desc.num_samples = 0;
|
m_cl_Image_desc.num_samples = 0;
|
||||||
m_cl_Image_desc.mem_object = NULL;
|
m_cl_Image_desc.mem_object = NULL;
|
||||||
|
|
||||||
m_Image = NULL;
|
m_Image = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
~cImage_check_mem_host_read_only()
|
~cImage_check_mem_host_read_only(){};
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
cl_int get_image_elements();
|
cl_int get_image_elements();
|
||||||
|
|
||||||
cl_image_format m_cl_image_format;
|
cl_image_format m_cl_image_format;
|
||||||
cl_image_desc m_cl_Image_desc;
|
cl_image_desc m_cl_Image_desc;
|
||||||
clMemWrapper m_Image;
|
clMemWrapper m_Image;
|
||||||
|
|
||||||
virtual cl_int SetupImage();
|
virtual cl_int SetupImage();
|
||||||
virtual cl_int SetupBuffer();
|
virtual cl_int SetupBuffer();
|
||||||
virtual cl_int verify_RW_Image();
|
virtual cl_int verify_RW_Image();
|
||||||
|
|
||||||
virtual cl_int verify_RW_Image_Mapping();
|
virtual cl_int verify_RW_Image_Mapping();
|
||||||
virtual cl_int verify_data(T *pdtaIn);
|
virtual cl_int verify_data(T *pdtaIn);
|
||||||
virtual cl_int verify_data_with_offset(T *pdtaIn, size_t *offset);
|
virtual cl_int verify_data_with_offset(T *pdtaIn, size_t *offset);
|
||||||
|
|
||||||
cl_int get_image_content_size();
|
cl_int get_image_content_size();
|
||||||
cl_int get_image_data_size();
|
cl_int get_image_data_size();
|
||||||
|
|
||||||
virtual cl_int verify_RW_Buffer();
|
virtual cl_int verify_RW_Buffer();
|
||||||
virtual cl_int verify_RW_Buffer_rect();
|
virtual cl_int verify_RW_Buffer_rect();
|
||||||
virtual cl_int verify_RW_Buffer_mapping();
|
virtual cl_int verify_RW_Buffer_mapping();
|
||||||
cl_int verify_mapping_ptr(T *ptr);
|
cl_int verify_mapping_ptr(T *ptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cImage_check_mem_host_read_only< T >::verify_mapping_ptr( T* dataPtr)
|
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] *
|
int offset_pixel = (int)(this->buffer_origin[0]
|
||||||
this->buffer_row_pitch_bytes/ sizeof(T) + this->buffer_origin[2] *
|
+ this->buffer_origin[1]
|
||||||
this->buffer_slice_pitch_bytes/sizeof(T));
|
* this->buffer_row_pitch_bytes / sizeof(T)
|
||||||
|
+ this->buffer_origin[2]
|
||||||
|
* this->buffer_slice_pitch_bytes / sizeof(T));
|
||||||
|
|
||||||
dataPtr = dataPtr - offset_pixel;
|
dataPtr = dataPtr - offset_pixel;
|
||||||
|
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
|
|
||||||
if (this->buffer_mem_flag & CL_MEM_USE_HOST_PTR)
|
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");
|
if (this->pHost_ptr != this->host_m_1.pData)
|
||||||
return FAILURE;
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dataPtr != this->host_m_1.pData)
|
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("Mapped host pointer difference found\n");
|
log_error("Buffer data difference found\n");
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cImage_check_mem_host_read_only< T >::verify_RW_Buffer() { return CL_SUCCESS; };
|
cl_int
|
||||||
|
cImage_check_mem_host_read_only<T>::verify_data_with_offset(T *pDataIN,
|
||||||
template < class T >
|
size_t *offset)
|
||||||
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();
|
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 >
|
template <class T> cl_int cImage_check_mem_host_read_only<T>::verify_RW_Image()
|
||||||
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 *
|
this->Init_rect();
|
||||||
m_cl_Image_desc.image_depth * m_cl_Image_desc.image_array_size));
|
|
||||||
|
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 = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent 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 >
|
template <class T>
|
||||||
cl_int cImage_check_mem_host_read_only< T >::get_image_data_size()
|
cl_int cImage_check_mem_host_read_only<T>::verify_RW_Image_Mapping()
|
||||||
{
|
{
|
||||||
size_t slice_pitch = m_cl_Image_desc.image_slice_pitch ? m_cl_Image_desc.image_slice_pitch :
|
cl_event event;
|
||||||
(m_cl_Image_desc.image_height * m_cl_Image_desc.image_width);
|
cl_int err = CL_SUCCESS;
|
||||||
return (slice_pitch * m_cl_Image_desc.image_depth * m_cl_Image_desc.image_array_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < class T >
|
T *dataPtr = (T *)clEnqueueMapImage(
|
||||||
cl_int cImage_check_mem_host_read_only< T >::get_image_elements()
|
this->m_queue, this->m_Image, this->m_blocking, CL_MAP_READ,
|
||||||
{
|
this->buffer_origin, this->region, &(this->buffer_row_pitch_bytes),
|
||||||
return ((cl_int)(m_cl_Image_desc.image_width*m_cl_Image_desc.image_height *
|
&(this->buffer_slice_pitch_bytes), 0, NULL, &event, &err);
|
||||||
m_cl_Image_desc.image_depth * m_cl_Image_desc.image_array_size));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < class T >
|
if (!this->m_blocking)
|
||||||
cl_int cImage_check_mem_host_read_only< T >::SetupImage()
|
{
|
||||||
{
|
err = clWaitForEvents(1, &event);
|
||||||
int all = (int)(m_cl_Image_desc.image_width * m_cl_Image_desc.image_height *
|
test_error(err, "clWaitForEvents error");
|
||||||
m_cl_Image_desc.image_depth * m_cl_Image_desc.image_array_size);
|
}
|
||||||
|
|
||||||
T v = TEST_VALUE;
|
err = clReleaseEvent(event);
|
||||||
this->host_m_1.Init(all, v);
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
cl_int err = CL_SUCCESS;
|
err = this->verify_mapping_ptr(dataPtr);
|
||||||
this-> m_Image = clCreateImage(this->m_context, this->buffer_mem_flag,
|
test_error(err, "clEnqueueMapImage error");
|
||||||
&( 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);
|
err = this->verify_data(dataPtr);
|
||||||
|
test_error(err, "verify_data error");
|
||||||
|
|
||||||
return err;
|
err = clEnqueueUnmapMemObject(this->m_queue, this->m_Image, dataPtr, 0,
|
||||||
}
|
NULL, &event);
|
||||||
|
test_error(err, "clEnqueueUnmapMemObject error");
|
||||||
|
|
||||||
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);
|
err = clWaitForEvents(1, &event);
|
||||||
test_error(err, "clWaitForEvents error");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
|
||||||
|
|
||||||
err = clReleaseEvent(event);
|
err = clReleaseEvent(event);
|
||||||
test_error(err, "clReleaseEvent error");
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
err = this->verify_data(this->host_m_2.pData);
|
dataPtr = (T *)clEnqueueMapImage(
|
||||||
test_error(err, "verify_data error");
|
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);
|
||||||
|
|
||||||
err = clEnqueueWriteImage(this->m_queue, this->m_Image, this->m_blocking,
|
if (err == CL_SUCCESS)
|
||||||
this->buffer_origin, this->region,
|
{
|
||||||
this->buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes,
|
log_error("Calling clEnqueueMapImage (CL_MAP_WRITE) on a memory object "
|
||||||
this->host_m_2.pData, 0, NULL, &event);
|
"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;
|
||||||
|
}
|
||||||
|
|
||||||
if (err == CL_SUCCESS) {
|
return err;
|
||||||
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 = clReleaseEvent(event);
|
|
||||||
test_error(err, "clReleaseEvent 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");
|
|
||||||
|
|
||||||
err = clReleaseEvent(event);
|
|
||||||
test_error(err, "clReleaseEvent 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
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -19,184 +19,201 @@
|
|||||||
|
|
||||||
#include "checker_mem_host_write_only.hpp"
|
#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 >
|
template <class T>
|
||||||
{
|
class cBuffer_check_mem_host_no_access
|
||||||
|
: public cBuffer_check_mem_host_write_only<T> {
|
||||||
public:
|
public:
|
||||||
cBuffer_check_mem_host_no_access(cl_device_id deviceID, cl_context context, cl_command_queue queue)
|
cBuffer_check_mem_host_no_access(cl_device_id deviceID, cl_context context,
|
||||||
: cBuffer_check_mem_host_write_only < T > (deviceID, context, queue)
|
cl_command_queue queue)
|
||||||
{
|
: cBuffer_check_mem_host_write_only<T>(deviceID, context, queue){};
|
||||||
};
|
|
||||||
|
|
||||||
cBuffer_check_mem_host_no_access()
|
cBuffer_check_mem_host_no_access(){};
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual cl_int SetupBuffer();
|
virtual cl_int SetupBuffer();
|
||||||
virtual cl_int SetupASSubBuffer(cl_mem_flags parent_buffer_flag);
|
virtual cl_int SetupASSubBuffer(cl_mem_flags parent_buffer_flag);
|
||||||
virtual cl_int Setup_Test_Environment();
|
virtual cl_int Setup_Test_Environment();
|
||||||
|
|
||||||
cl_int verify_RW_Buffer();
|
cl_int verify_RW_Buffer();
|
||||||
cl_int verify_RW_Buffer_rect();
|
cl_int verify_RW_Buffer_rect();
|
||||||
cl_int verify_RW_Buffer_mapping();
|
cl_int verify_RW_Buffer_mapping();
|
||||||
};
|
};
|
||||||
|
|
||||||
template < class T >
|
template <class T> cl_int cBuffer_check_mem_host_no_access<T>::SetupBuffer()
|
||||||
cl_int cBuffer_check_mem_host_no_access< T >::SetupBuffer()
|
|
||||||
{
|
{
|
||||||
this->m_nNumber_elements = 1000;
|
this->m_nNumber_elements = 1000;
|
||||||
T vv1 = TEST_VALUE;
|
T vv1 = TEST_VALUE;
|
||||||
this->host_m_1.Init( this->m_nNumber_elements, vv1);
|
this->host_m_1.Init(this->m_nNumber_elements, vv1);
|
||||||
|
|
||||||
T vv2 = 0;
|
T vv2 = 0;
|
||||||
this->host_m_2.Init( this->m_nNumber_elements, vv2);
|
this->host_m_2.Init(this->m_nNumber_elements, vv2);
|
||||||
|
|
||||||
cl_int err;
|
cl_int err;
|
||||||
int block_size_in_byte = this->get_block_size_bytes();
|
int block_size_in_byte = this->get_block_size_bytes();
|
||||||
this->m_buffer = clCreateBuffer(this->m_context, this->buffer_mem_flag,
|
this->m_buffer =
|
||||||
block_size_in_byte, this->host_m_1.pData, &err);
|
clCreateBuffer(this->m_context, this->buffer_mem_flag,
|
||||||
test_error(err, "clCreateBuffer error");
|
block_size_in_byte, this->host_m_1.pData, &err);
|
||||||
err = this->Check_GetMemObjectInfo(this->buffer_mem_flag);
|
test_error(err, "clCreateBuffer error");
|
||||||
|
err = this->Check_GetMemObjectInfo(this->buffer_mem_flag);
|
||||||
|
|
||||||
if (this->buffer_mem_flag | CL_MEM_USE_HOST_PTR)
|
if (this->buffer_mem_flag | CL_MEM_USE_HOST_PTR)
|
||||||
{
|
{
|
||||||
this->pHost_ptr = (void *)this->host_m_1.pData;
|
this->pHost_ptr = (void *)this->host_m_1.pData;
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_no_access< T >::SetupASSubBuffer(cl_mem_flags parent_buffer_flag)
|
cl_int cBuffer_check_mem_host_no_access<T>::SetupASSubBuffer(
|
||||||
|
cl_mem_flags parent_buffer_flag)
|
||||||
{
|
{
|
||||||
return cBuffer_checker<T>::SetupASSubBuffer(parent_buffer_flag);
|
return cBuffer_checker<T>::SetupASSubBuffer(parent_buffer_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_no_access< T >::Setup_Test_Environment()
|
cl_int cBuffer_check_mem_host_no_access<T>::Setup_Test_Environment()
|
||||||
{
|
{
|
||||||
cBuffer_check_mem_host_write_only<T>::Setup_Test_Environment();
|
cBuffer_check_mem_host_write_only<T>::Setup_Test_Environment();
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T>
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_no_access< T >::verify_RW_Buffer()
|
cl_int cBuffer_check_mem_host_no_access<T>::verify_RW_Buffer()
|
||||||
{
|
{
|
||||||
cl_event event;
|
cl_event event;
|
||||||
cl_int err = clEnqueueReadBuffer(this->m_queue, this->m_buffer, this->m_blocking, 0,
|
cl_int err = clEnqueueReadBuffer(
|
||||||
this->get_block_size_bytes(), this->host_m_1.pData,
|
this->m_queue, this->m_buffer, this->m_blocking, 0,
|
||||||
0, NULL, &event);
|
this->get_block_size_bytes(), this->host_m_1.pData, 0, NULL, &event);
|
||||||
|
|
||||||
if (err == CL_SUCCESS) {
|
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;
|
log_error(
|
||||||
return FAILURE;
|
"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;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
log_info("Test succeeded\n\n");
|
0, this->get_block_size_bytes(),
|
||||||
err = CL_SUCCESS;
|
this->host_m_1.pData, 0, NULL, &event);
|
||||||
}
|
|
||||||
|
|
||||||
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking, 0,
|
if (err == CL_SUCCESS)
|
||||||
this->get_block_size_bytes(), this->host_m_1.pData,
|
{
|
||||||
0, NULL, &event);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if (err == CL_SUCCESS) {
|
return err;
|
||||||
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 >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_no_access< T >::verify_RW_Buffer_rect()
|
cl_int cBuffer_check_mem_host_no_access<T>::verify_RW_Buffer_rect()
|
||||||
{
|
{
|
||||||
this->Init_rect();
|
this->Init_rect();
|
||||||
cl_event event;
|
cl_event event;
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
err = clEnqueueReadBufferRect(this->m_queue, this->m_buffer, this->m_blocking,
|
err = clEnqueueReadBufferRect(
|
||||||
this->buffer_origin_bytes,
|
this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
this->host_origin_bytes,
|
this->buffer_origin_bytes, this->host_origin_bytes, this->region_bytes,
|
||||||
this->region_bytes,
|
this->buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes,
|
||||||
this->buffer_row_pitch_bytes,
|
this->host_row_pitch_bytes, this->host_slice_pitch_bytes,
|
||||||
this->buffer_slice_pitch_bytes,
|
this->host_m_2.pData, 0, NULL, &event);
|
||||||
this->host_row_pitch_bytes,
|
|
||||||
this->host_slice_pitch_bytes,
|
|
||||||
this->host_m_2.pData,
|
|
||||||
0, NULL, &event);
|
|
||||||
|
|
||||||
if (err == CL_SUCCESS) {
|
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;
|
log_error(
|
||||||
return FAILURE;
|
"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;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
err = clEnqueueWriteBufferRect(
|
||||||
log_info("Test succeeded\n\n");
|
this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
err = CL_SUCCESS;
|
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);
|
||||||
|
|
||||||
err = clEnqueueWriteBufferRect(this->m_queue, this->m_buffer, this->m_blocking,
|
if (err == CL_SUCCESS)
|
||||||
this->buffer_origin_bytes ,
|
{
|
||||||
this->host_origin_bytes,
|
log_error(
|
||||||
this->region_bytes,
|
"Calling clEnqueueWriteBufferRect on a memory object created with "
|
||||||
this->buffer_row_pitch_bytes,
|
"the CL_MEM_HOST_NO_ACCESS flag should not return CL_SUCCESS\n");
|
||||||
this->buffer_slice_pitch_bytes,
|
err = FAILURE;
|
||||||
this->host_row_pitch_bytes,
|
return FAILURE;
|
||||||
this->host_slice_pitch_bytes,
|
}
|
||||||
this->host_m_2.pData,
|
else
|
||||||
0, NULL, &event);
|
{
|
||||||
|
log_info("Test succeeded\n\n");
|
||||||
|
err = CL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (err == CL_SUCCESS) {
|
return err;
|
||||||
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 >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_no_access< T >::verify_RW_Buffer_mapping()
|
cl_int cBuffer_check_mem_host_no_access<T>::verify_RW_Buffer_mapping()
|
||||||
{
|
{
|
||||||
cl_event event;
|
cl_event event;
|
||||||
cl_int err;
|
cl_int err;
|
||||||
|
|
||||||
void *dataPtr;
|
void *dataPtr;
|
||||||
dataPtr = clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking, CL_MAP_READ,
|
dataPtr = clEnqueueMapBuffer(
|
||||||
0, this->get_block_size_bytes(), 0, NULL, &event, &err);
|
this->m_queue, this->m_buffer, this->m_blocking, CL_MAP_READ, 0,
|
||||||
if (err == CL_SUCCESS) {
|
this->get_block_size_bytes(), 0, NULL, &event, &err);
|
||||||
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");
|
if (err == CL_SUCCESS)
|
||||||
err = FAILURE;
|
{
|
||||||
return FAILURE;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
dataPtr = clEnqueueMapBuffer(
|
||||||
log_info("Test succeeded\n\n");
|
this->m_queue, this->m_buffer, this->m_blocking, CL_MAP_WRITE, 0,
|
||||||
err = CL_SUCCESS;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
dataPtr = clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking, CL_MAP_WRITE,
|
return err;
|
||||||
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
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -18,259 +18,275 @@
|
|||||||
|
|
||||||
#include "checker.h"
|
#include "checker.h"
|
||||||
|
|
||||||
template < class T> class cBuffer_check_mem_host_read_only : public cBuffer_checker<T>
|
template <class T>
|
||||||
{
|
class cBuffer_check_mem_host_read_only : public cBuffer_checker<T> {
|
||||||
public:
|
public:
|
||||||
cBuffer_check_mem_host_read_only(cl_device_id deviceID, cl_context context, cl_command_queue queue)
|
cBuffer_check_mem_host_read_only(cl_device_id deviceID, cl_context context,
|
||||||
: cBuffer_checker <T> (deviceID, context, queue)
|
cl_command_queue queue)
|
||||||
{
|
: cBuffer_checker<T>(deviceID, context, queue){};
|
||||||
};
|
|
||||||
|
|
||||||
~cBuffer_check_mem_host_read_only()
|
~cBuffer_check_mem_host_read_only(){};
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual cl_int Check_GetMemObjectInfo(cl_mem_flags buffer_mem_flag);
|
virtual cl_int Check_GetMemObjectInfo(cl_mem_flags buffer_mem_flag);
|
||||||
virtual cl_int SetupBuffer();
|
virtual cl_int SetupBuffer();
|
||||||
virtual cl_int SetupASSubBuffer( cl_mem_flags flag_p);
|
virtual cl_int SetupASSubBuffer(cl_mem_flags flag_p);
|
||||||
virtual cl_int Setup_Test_Environment();
|
virtual cl_int Setup_Test_Environment();
|
||||||
|
|
||||||
cl_int verifyData(cl_int err, cl_event & event);
|
cl_int verifyData(cl_int err, cl_event &event);
|
||||||
cl_int verify_RW_Buffer();
|
cl_int verify_RW_Buffer();
|
||||||
cl_int verify_RW_Buffer_rect();
|
cl_int verify_RW_Buffer_rect();
|
||||||
cl_int verify_RW_Buffer_mapping();
|
cl_int verify_RW_Buffer_mapping();
|
||||||
};
|
};
|
||||||
|
|
||||||
template < class T >
|
template <class T> cl_int cBuffer_check_mem_host_read_only<T>::SetupBuffer()
|
||||||
cl_int cBuffer_check_mem_host_read_only< T >::SetupBuffer()
|
|
||||||
{
|
{
|
||||||
this->m_buffer_type = _BUFFER;
|
this->m_buffer_type = _BUFFER;
|
||||||
|
|
||||||
this->m_nNumber_elements = 888;
|
this->m_nNumber_elements = 888;
|
||||||
T vv1 = TEST_VALUE;
|
T vv1 = TEST_VALUE;
|
||||||
this->host_m_1.Init(this->m_nNumber_elements, vv1);
|
this->host_m_1.Init(this->m_nNumber_elements, vv1);
|
||||||
this->host_m_0.Init(this->m_nNumber_elements, vv1);
|
this->host_m_0.Init(this->m_nNumber_elements, vv1);
|
||||||
|
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
int block_size_in_byte = (int)(this->m_nNumber_elements * sizeof(T));
|
int block_size_in_byte = (int)(this->m_nNumber_elements * sizeof(T));
|
||||||
this->m_buffer = clCreateBuffer(this->m_context, this->buffer_mem_flag,
|
this->m_buffer =
|
||||||
block_size_in_byte, this->host_m_1.pData, &err);
|
clCreateBuffer(this->m_context, this->buffer_mem_flag,
|
||||||
test_error(err, "clCreateBuffer error");
|
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)
|
if (this->buffer_mem_flag & CL_MEM_USE_HOST_PTR)
|
||||||
{
|
{
|
||||||
this->pHost_ptr = (void *)this->host_m_1.pData;
|
this->pHost_ptr = (void *)this->host_m_1.pData;
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_read_only<T>::SetupASSubBuffer(cl_mem_flags flag_p)
|
cl_int
|
||||||
|
cBuffer_check_mem_host_read_only<T>::SetupASSubBuffer(cl_mem_flags flag_p)
|
||||||
{
|
{
|
||||||
return cBuffer_checker<T>::SetupASSubBuffer(flag_p);
|
return cBuffer_checker<T>::SetupASSubBuffer(flag_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T>
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_read_only<T>::Setup_Test_Environment()
|
cl_int cBuffer_check_mem_host_read_only<T>::Setup_Test_Environment()
|
||||||
{
|
{
|
||||||
cBuffer_checker<T>::Setup_Test_Environment();
|
cBuffer_checker<T>::Setup_Test_Environment();
|
||||||
T vv2 = 0;
|
T vv2 = 0;
|
||||||
this->host_m_2.Init(this->m_nNumber_elements, vv2);
|
this->host_m_2.Init(this->m_nNumber_elements, vv2);
|
||||||
|
|
||||||
return CL_SUCCESS;
|
return CL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_read_only< T >::Check_GetMemObjectInfo(cl_mem_flags buffer_mem_flag)
|
cl_int cBuffer_check_mem_host_read_only<T>::Check_GetMemObjectInfo(
|
||||||
|
cl_mem_flags buffer_mem_flag)
|
||||||
{
|
{
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
cBuffer_checker<T>::Check_GetMemObjectInfo(buffer_mem_flag);
|
cBuffer_checker<T>::Check_GetMemObjectInfo(buffer_mem_flag);
|
||||||
|
|
||||||
if (buffer_mem_flag & CL_MEM_ALLOC_HOST_PTR)
|
if (buffer_mem_flag & CL_MEM_ALLOC_HOST_PTR)
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
err = clGetMemObjectInfo(this->m_buffer, CL_MEM_SIZE, sizeof(size), &size, NULL);
|
err = clGetMemObjectInfo(this->m_buffer, CL_MEM_SIZE, sizeof(size),
|
||||||
void *pp = NULL;
|
&size, NULL);
|
||||||
err = clGetMemObjectInfo(this->m_buffer, CL_MEM_HOST_PTR, sizeof( pp ), &pp, 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 )) {
|
if (!this->host_m_1.Equal((T *)(this->pData), this->m_nNumber_elements))
|
||||||
log_error("Buffer data difference found\n");
|
{
|
||||||
return FAILURE;
|
log_error("Buffer data difference found\n");
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_read_only< T >::verifyData( cl_int err, cl_event & event )
|
cl_int cBuffer_check_mem_host_read_only<T>::verifyData(cl_int err,
|
||||||
|
cl_event &event)
|
||||||
{
|
{
|
||||||
if (err != CL_SUCCESS) {
|
if (err != CL_SUCCESS)
|
||||||
err = this->m_nERROR_RETURN_CODE;
|
{
|
||||||
|
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");
|
test_error(err, "clEnqueueReadBuffer error");
|
||||||
}
|
|
||||||
|
|
||||||
if (!this->host_m_1.Equal(this->host_m_2)) {
|
if (!this->m_blocking)
|
||||||
err = this->m_nERROR_RETURN_CODE;
|
{
|
||||||
test_error(err, "clEnqueueReadBuffer data difference found");
|
err = clWaitForEvents(1, &event);
|
||||||
}
|
test_error(err, "clWaitForEvents error");
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
if (!this->host_m_1.Equal(this->host_m_2))
|
||||||
}
|
{
|
||||||
|
log_error("Buffer data difference found\n");
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
template < class T >
|
// test write
|
||||||
cl_int cBuffer_check_mem_host_read_only< T >::verify_RW_Buffer()
|
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
err = clReleaseEvent(event);
|
|
||||||
test_error(err, "clReleaseEvent error");
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
err = clReleaseEvent(event);
|
|
||||||
test_error(err, "clReleaseEvent error");
|
|
||||||
|
|
||||||
// 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, this->get_block_size_bytes(),
|
||||||
0, NULL, &event, &err);
|
this->host_m_2.pData, 0, NULL, &event);
|
||||||
test_error(err, "clEnqueueMapBuffer error");
|
|
||||||
|
|
||||||
if (!this->m_blocking) {
|
if (err == CL_SUCCESS)
|
||||||
err = clWaitForEvents(1, &event );
|
{
|
||||||
test_error(err, "clWaitForEvents error");
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if ((this->buffer_mem_flag & CL_MEM_USE_HOST_PTR) && dataPtr != this->pHost_ptr ) {
|
return err;
|
||||||
log_error("Mapped host pointer difference found\n");
|
}
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this->host_m_1.Equal((T*)dataPtr, this->m_nNumber_elements)) {
|
template <class T>
|
||||||
log_error("Buffer content difference found\n");
|
cl_int cBuffer_check_mem_host_read_only<T>::verify_RW_Buffer_rect()
|
||||||
return FAILURE;
|
{
|
||||||
}
|
this->Init_rect();
|
||||||
|
|
||||||
err = clReleaseEvent(event);
|
T vv2 = 0;
|
||||||
test_error(err, "clReleaseEvent error");
|
this->host_m_2.Set_to(vv2);
|
||||||
|
cl_event event;
|
||||||
|
cl_int err = CL_SUCCESS;
|
||||||
|
|
||||||
err = clEnqueueUnmapMemObject(this->m_queue, this->m_buffer, dataPtr, 0,
|
err = clEnqueueReadBufferRect(
|
||||||
nullptr, nullptr);
|
this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
test_error(err, "clEnqueueUnmapMemObject error");
|
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");
|
||||||
|
|
||||||
// test blocking map read
|
if (!this->m_blocking)
|
||||||
clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
{
|
||||||
CL_MAP_WRITE,
|
err = clWaitForEvents(1, &event);
|
||||||
0, this->get_block_size_bytes(),
|
test_error(err, "clWaitForEvents error");
|
||||||
0, NULL, &event, &err);
|
}
|
||||||
|
|
||||||
if (err == CL_SUCCESS) {
|
if (!this->host_m_1.Equal_rect(this->host_m_2, this->host_origin,
|
||||||
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");
|
this->region, this->host_row_pitch,
|
||||||
err = FAILURE;
|
this->host_slice_pitch))
|
||||||
return FAILURE;
|
{
|
||||||
|
log_error("Buffer data diffeence found\n");
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
} else {
|
// test blocking write rect
|
||||||
log_info("Test succeeded\n\n");
|
err = clEnqueueWriteBufferRect(
|
||||||
err = CL_SUCCESS;
|
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);
|
||||||
|
|
||||||
return err;
|
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");
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->host_m_1.Equal((T *)dataPtr, this->m_nNumber_elements))
|
||||||
|
{
|
||||||
|
log_error("Buffer content difference found\n");
|
||||||
|
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
|
||||||
|
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
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -18,338 +18,356 @@
|
|||||||
|
|
||||||
#include "checker.h"
|
#include "checker.h"
|
||||||
|
|
||||||
template < class T> class cBuffer_check_mem_host_write_only : public cBuffer_checker<T>
|
template <class T>
|
||||||
{
|
class cBuffer_check_mem_host_write_only : public cBuffer_checker<T> {
|
||||||
public:
|
public:
|
||||||
cBuffer_check_mem_host_write_only(cl_device_id deviceID, cl_context context, cl_command_queue queue)
|
cBuffer_check_mem_host_write_only(cl_device_id deviceID, cl_context context,
|
||||||
: cBuffer_checker < T > (deviceID, context, queue)
|
cl_command_queue queue)
|
||||||
{
|
: cBuffer_checker<T>(deviceID, context, queue)
|
||||||
this->m_nNumber_elements = 1000;
|
{
|
||||||
};
|
this->m_nNumber_elements = 1000;
|
||||||
|
};
|
||||||
|
|
||||||
~cBuffer_check_mem_host_write_only()
|
~cBuffer_check_mem_host_write_only(){};
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
cl_program program;
|
cl_program program;
|
||||||
cl_kernel kernel;
|
cl_kernel kernel;
|
||||||
|
|
||||||
clMemWrapper m_buffer2;
|
clMemWrapper m_buffer2;
|
||||||
|
|
||||||
cl_int Setup_Test_Environment();
|
cl_int Setup_Test_Environment();
|
||||||
|
|
||||||
cl_int SetupBuffer();
|
cl_int SetupBuffer();
|
||||||
cl_int SetupASSubBuffer(cl_mem_flags flag_p);
|
cl_int SetupASSubBuffer(cl_mem_flags flag_p);
|
||||||
|
|
||||||
cl_int verifyData(cl_int err, cl_event &event );
|
cl_int verifyData(cl_int err, cl_event &event);
|
||||||
cl_int update_host_mem_2();
|
cl_int update_host_mem_2();
|
||||||
|
|
||||||
cl_int verify_RW_Buffer();
|
cl_int verify_RW_Buffer();
|
||||||
cl_int verify_RW_Buffer_rect();
|
cl_int verify_RW_Buffer_rect();
|
||||||
cl_int verify_RW_Buffer_mapping();
|
cl_int verify_RW_Buffer_mapping();
|
||||||
|
|
||||||
C_host_memory_block<T> tmp_host_m;
|
C_host_memory_block<T> tmp_host_m;
|
||||||
|
|
||||||
virtual cl_int verify_Buffer_initialization();
|
virtual cl_int verify_Buffer_initialization();
|
||||||
};
|
};
|
||||||
|
|
||||||
template < class T >
|
template <class T> cl_int cBuffer_check_mem_host_write_only<T>::SetupBuffer()
|
||||||
cl_int cBuffer_check_mem_host_write_only< T >::SetupBuffer()
|
|
||||||
{
|
{
|
||||||
T vv1 = 0;
|
T vv1 = 0;
|
||||||
this->host_m_1.Init( this->m_nNumber_elements, vv1); // zero out buffer
|
this->host_m_1.Init(this->m_nNumber_elements, vv1); // zero out buffer
|
||||||
|
|
||||||
// init buffer to 0
|
// init buffer to 0
|
||||||
cl_int err;
|
cl_int err;
|
||||||
int block_size_in_byte = this->get_block_size_bytes();
|
int block_size_in_byte = this->get_block_size_bytes();
|
||||||
|
|
||||||
this->m_buffer = clCreateBuffer(this->m_context, this->buffer_mem_flag,
|
this->m_buffer =
|
||||||
block_size_in_byte, this->host_m_1.pData, &err);
|
clCreateBuffer(this->m_context, this->buffer_mem_flag,
|
||||||
test_error(err, "clCreateBuffer error");
|
block_size_in_byte, this->host_m_1.pData, &err);
|
||||||
|
test_error(err, "clCreateBuffer error");
|
||||||
|
|
||||||
err = this->Check_GetMemObjectInfo(this->buffer_mem_flag);
|
err = this->Check_GetMemObjectInfo(this->buffer_mem_flag);
|
||||||
|
|
||||||
if (this->buffer_mem_flag | CL_MEM_USE_HOST_PTR)
|
if (this->buffer_mem_flag | CL_MEM_USE_HOST_PTR)
|
||||||
{
|
{
|
||||||
this->pHost_ptr = (void *)this->host_m_1.pData;
|
this->pHost_ptr = (void *)this->host_m_1.pData;
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_write_only<T>::SetupASSubBuffer(cl_mem_flags flag_p)
|
cl_int
|
||||||
|
cBuffer_check_mem_host_write_only<T>::SetupASSubBuffer(cl_mem_flags flag_p)
|
||||||
{
|
{
|
||||||
return cBuffer_checker<T>::SetupASSubBuffer(flag_p);
|
return cBuffer_checker<T>::SetupASSubBuffer(flag_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_write_only< T >::Setup_Test_Environment()
|
cl_int cBuffer_check_mem_host_write_only<T>::Setup_Test_Environment()
|
||||||
{
|
{
|
||||||
cl_int err;
|
cl_int err;
|
||||||
T vv2 = 0;
|
T vv2 = 0;
|
||||||
this->host_m_2.Init(this->m_nNumber_elements, vv2);
|
this->host_m_2.Init(this->m_nNumber_elements, vv2);
|
||||||
|
|
||||||
// init buffer2 to 0
|
// init buffer2 to 0
|
||||||
cl_mem_flags buffer_mem_flag2 = CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_READ_ONLY;
|
cl_mem_flags buffer_mem_flag2 =
|
||||||
this->m_buffer2 = clCreateBuffer(this->m_context, buffer_mem_flag2,
|
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_READ_ONLY;
|
||||||
this->get_block_size_bytes(), this->host_m_2.pData, &err);
|
this->m_buffer2 = clCreateBuffer(this->m_context, buffer_mem_flag2,
|
||||||
test_error(err, "clCreateBuffer error\n");
|
this->get_block_size_bytes(),
|
||||||
|
this->host_m_2.pData, &err);
|
||||||
|
test_error(err, "clCreateBuffer error\n");
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_write_only< T >::verify_Buffer_initialization()
|
cl_int cBuffer_check_mem_host_write_only<T>::verify_Buffer_initialization()
|
||||||
{
|
{
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
|
|
||||||
if (this->host_m_1.pData == NULL || this->host_m_2.pData == NULL) {
|
if (this->host_m_1.pData == NULL || this->host_m_2.pData == NULL)
|
||||||
log_error("Data not ready\n");
|
{
|
||||||
return FAILURE;
|
log_error("Data not ready\n");
|
||||||
}
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
update_host_mem_2();
|
update_host_mem_2();
|
||||||
|
|
||||||
if (!this->host_m_1.Equal(this->host_m_2)){
|
if (!this->host_m_1.Equal(this->host_m_2))
|
||||||
log_error("Buffer content difference found\n");
|
{
|
||||||
return FAILURE;
|
log_error("Buffer content difference found\n");
|
||||||
}
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class T >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_write_only< T >::verify_RW_Buffer()
|
cl_int cBuffer_check_mem_host_write_only<T>::verify_RW_Buffer()
|
||||||
{
|
{
|
||||||
T vv1 = TEST_VALUE;
|
T vv1 = TEST_VALUE;
|
||||||
T vv2 = 0;
|
T vv2 = 0;
|
||||||
this->host_m_2.Set_to(vv2);
|
this->host_m_2.Set_to(vv2);
|
||||||
|
|
||||||
tmp_host_m.Init(this->host_m_1.num_elements, vv1) ;
|
tmp_host_m.Init(this->host_m_1.num_elements, vv1);
|
||||||
|
|
||||||
cl_event event;
|
cl_event event;
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking, 0,
|
err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
this->get_block_size_bytes(), tmp_host_m.pData,
|
0, this->get_block_size_bytes(),
|
||||||
0, NULL, &event);
|
tmp_host_m.pData, 0, NULL, &event);
|
||||||
if (err != CL_SUCCESS ) {
|
if (err != CL_SUCCESS)
|
||||||
|
{
|
||||||
|
test_error(err, "clEnqueueWriteBuffer error");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->m_blocking)
|
||||||
|
{
|
||||||
|
err = clWaitForEvents(1, &event);
|
||||||
|
test_error(err, "clWaitForEvents error")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent 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);
|
||||||
test_error(err, "clEnqueueWriteBuffer error");
|
test_error(err, "clEnqueueWriteBuffer error");
|
||||||
}
|
|
||||||
|
|
||||||
if (!this->m_blocking){
|
vv1 = TEST_VALUE;
|
||||||
err = clWaitForEvents(1, &event);
|
tmp_host_m.Set_to(vv1);
|
||||||
test_error(err, "clWaitForEvents error")
|
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, "clEnqueueWriteBufferRect error");
|
||||||
|
|
||||||
err = clReleaseEvent(event);
|
if (!this->m_blocking)
|
||||||
test_error(err, "clReleaseEvent error");
|
{
|
||||||
|
err = clWaitForEvents(1, &event);
|
||||||
|
test_error(err, "clWaitForEvents 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");
|
{
|
||||||
return FAILURE;
|
log_error("Test data should be different\n");
|
||||||
}
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
update_host_mem_2();
|
err = clReleaseEvent(event_1);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
if (!tmp_host_m.Equal(this->host_m_2)){
|
update_host_mem_2();
|
||||||
log_error("Buffer content difference found\n");
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = clEnqueueReadBuffer(this->m_queue, this->m_buffer, CL_TRUE, 0,
|
size_t tot_in_reg = this->region[0] * this->region[1] * this->region[2];
|
||||||
this->get_block_size_bytes(), this->host_m_2.pData,
|
if (!tmp_host_m.Equal_rect(this->host_m_2, this->host_origin, this->region,
|
||||||
0, NULL, &event);
|
this->host_row_pitch, this->host_slice_pitch))
|
||||||
|
{
|
||||||
|
log_error("Buffer rect content difference found\n");
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
if ( err == CL_SUCCESS ) {
|
if (this->host_m_2.Count(vv1) != tot_in_reg)
|
||||||
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;
|
log_error("Buffer rect content difference found\n");
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
err = clEnqueueReadBufferRect(
|
||||||
log_info("Test succeeded\n\n");
|
this->m_queue, this->m_buffer, this->m_blocking,
|
||||||
err = CL_SUCCESS;
|
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);
|
||||||
|
|
||||||
return err;
|
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 >
|
template <class T>
|
||||||
cl_int cBuffer_check_mem_host_write_only< T >::verify_RW_Buffer_rect()
|
cl_int cBuffer_check_mem_host_write_only<T>::update_host_mem_2()
|
||||||
{
|
{
|
||||||
this->Init_rect();
|
size_t global_work_size[3] = { 0, 1, 1 };
|
||||||
|
global_work_size[0] = this->get_block_size_bytes();
|
||||||
|
|
||||||
T vv1= TEST_VALUE;
|
cl_event event, event_2;
|
||||||
this->host_m_1.Set_to(vv1);
|
cl_int err = clEnqueueCopyBuffer(
|
||||||
|
this->m_queue, this->m_buffer, this->m_buffer2, 0, 0,
|
||||||
|
this->m_nNumber_elements * sizeof(T), 0, NULL, &event);
|
||||||
|
test_error(err, "clEnqueueCopyBuffer error");
|
||||||
|
|
||||||
T vv2 = 0;
|
this->host_m_2.Set_to_zero();
|
||||||
this->host_m_2.Set_to(vv2);
|
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");
|
||||||
|
|
||||||
cl_event event, event_1;
|
clWaitForEvents(1, &event_2);
|
||||||
|
|
||||||
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);
|
|
||||||
test_error(err, "clEnqueueWriteBuffer error");
|
|
||||||
|
|
||||||
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, "clEnqueueWriteBufferRect 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = clReleaseEvent(event_1);
|
|
||||||
test_error(err, "clReleaseEvent error");
|
|
||||||
err = clReleaseEvent(event);
|
|
||||||
test_error(err, "clReleaseEvent error");
|
|
||||||
|
|
||||||
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);
|
|
||||||
test_error(err, "clEnqueueCopyBuffer error");
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
err = clReleaseEvent(event_2);
|
|
||||||
test_error(err, "clReleaseEvent error");
|
|
||||||
|
|
||||||
err = clReleaseEvent(event);
|
|
||||||
test_error(err, "clReleaseEvent 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");
|
test_error(err, "clWaitForEvents error");
|
||||||
}
|
|
||||||
|
|
||||||
err = clReleaseEvent(event);
|
err = clReleaseEvent(event_2);
|
||||||
test_error(err, "clReleaseEvent error");
|
test_error(err, "clReleaseEvent error");
|
||||||
|
|
||||||
update_host_mem_2();
|
err = clReleaseEvent(event);
|
||||||
|
test_error(err, "clReleaseEvent error");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
if ((this->buffer_mem_flag & CL_MEM_USE_HOST_PTR) && dataPtr != this->pHost_ptr){
|
template <class T>
|
||||||
log_error("Mapped host pointer difference found\n");
|
cl_int cBuffer_check_mem_host_write_only<T>::verify_RW_Buffer_mapping()
|
||||||
return FAILURE;
|
{
|
||||||
}
|
T vv2 = 0;
|
||||||
|
this->host_m_2.Set_to(vv2);
|
||||||
|
|
||||||
if(!this->host_m_2.Equal((T*)dataPtr, this->m_nNumber_elements)) {
|
cl_event event;
|
||||||
log_error("Buffer content difference found\n");
|
cl_int err = CL_SUCCESS;
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = clEnqueueUnmapMemObject(this->m_queue, this->m_buffer, dataPtr, 0,
|
void *dataPtr;
|
||||||
nullptr, nullptr);
|
int size = this->get_block_size_bytes();
|
||||||
test_error(err, "clEnqueueUnmapMemObject error");
|
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");
|
||||||
|
|
||||||
// test map read
|
if (!this->m_blocking)
|
||||||
clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking,
|
{
|
||||||
CL_MAP_READ,
|
err = clWaitForEvents(1, &event);
|
||||||
0, this->get_block_size_bytes(),
|
test_error(err, "clWaitForEvents error");
|
||||||
0, NULL, &event, &err);
|
}
|
||||||
|
|
||||||
if (err == CL_SUCCESS) {
|
err = clReleaseEvent(event);
|
||||||
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");
|
test_error(err, "clReleaseEvent error");
|
||||||
err = FAILURE;
|
|
||||||
|
|
||||||
} else {
|
update_host_mem_2();
|
||||||
log_info("Test succeeded\n\n");
|
|
||||||
err = CL_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = clEnqueueUnmapMemObject(this->m_queue, this->m_buffer, dataPtr, 0,
|
||||||
|
nullptr, nullptr);
|
||||||
|
test_error(err, "clEnqueueUnmapMemObject error");
|
||||||
|
|
||||||
|
// 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
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if !defined (__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
#include <CL/cl.h>
|
#include <CL/cl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -30,18 +30,18 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
test_definition test_list[] = {
|
test_definition test_list[] = {
|
||||||
ADD_TEST( mem_host_read_only_buffer ),
|
ADD_TEST(mem_host_read_only_buffer),
|
||||||
ADD_TEST( mem_host_read_only_subbuffer ),
|
ADD_TEST(mem_host_read_only_subbuffer),
|
||||||
ADD_TEST( mem_host_write_only_buffer ),
|
ADD_TEST(mem_host_write_only_buffer),
|
||||||
ADD_TEST( mem_host_write_only_subbuffer ),
|
ADD_TEST(mem_host_write_only_subbuffer),
|
||||||
ADD_TEST( mem_host_no_access_buffer ),
|
ADD_TEST(mem_host_no_access_buffer),
|
||||||
ADD_TEST( mem_host_no_access_subbuffer ),
|
ADD_TEST(mem_host_no_access_subbuffer),
|
||||||
ADD_TEST( mem_host_read_only_image ),
|
ADD_TEST(mem_host_read_only_image),
|
||||||
ADD_TEST( mem_host_write_only_image ),
|
ADD_TEST(mem_host_write_only_image),
|
||||||
ADD_TEST( mem_host_no_access_image ),
|
ADD_TEST(mem_host_no_access_image),
|
||||||
};
|
};
|
||||||
|
|
||||||
const int test_num = ARRAY_SIZE( test_list );
|
const int test_num = ARRAY_SIZE(test_list);
|
||||||
|
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -26,463 +26,498 @@
|
|||||||
#include "checker_mem_host_write_only.hpp"
|
#include "checker_mem_host_write_only.hpp"
|
||||||
#include "checker_mem_host_no_access.hpp"
|
#include "checker_mem_host_no_access.hpp"
|
||||||
|
|
||||||
static int test_mem_host_read_only_buffer_RW(cl_device_id deviceID, cl_context context,
|
static int test_mem_host_read_only_buffer_RW(
|
||||||
cl_command_queue queue, cl_bool blocking,
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
cl_mem_flags buffer_mem_flag,
|
cl_bool blocking, cl_mem_flags buffer_mem_flag,
|
||||||
cl_mem_flags parent_buffer_flag,
|
cl_mem_flags parent_buffer_flag, enum BUFFER_TYPE buffer_type)
|
||||||
enum BUFFER_TYPE buffer_type)
|
|
||||||
{
|
{
|
||||||
log_info("%s\n", __FUNCTION__);
|
log_info("%s\n", __FUNCTION__);
|
||||||
cBuffer_check_mem_host_read_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
|
cBuffer_check_mem_host_read_only<TEST_ELEMENT_TYPE> checker(deviceID,
|
||||||
checker.m_blocking = blocking;
|
context, queue);
|
||||||
checker.buffer_mem_flag = buffer_mem_flag;
|
checker.m_blocking = blocking;
|
||||||
cl_int err;
|
checker.buffer_mem_flag = buffer_mem_flag;
|
||||||
switch (buffer_type) {
|
cl_int err;
|
||||||
case _BUFFER:
|
switch (buffer_type)
|
||||||
err = checker.SetupBuffer();
|
{
|
||||||
break;
|
case _BUFFER: err = checker.SetupBuffer(); break;
|
||||||
case _Sub_BUFFER:
|
case _Sub_BUFFER:
|
||||||
err = checker.SetupASSubBuffer(parent_buffer_flag);
|
err = checker.SetupASSubBuffer(parent_buffer_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
checker.Setup_Test_Environment();
|
checker.Setup_Test_Environment();
|
||||||
err= checker.verify_RW_Buffer();
|
err = checker.verify_RW_Buffer();
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test_mem_host_read_only_buffer_RW_Rect(cl_device_id deviceID, cl_context context,
|
static int test_mem_host_read_only_buffer_RW_Rect(
|
||||||
cl_command_queue queue, cl_bool blocking,
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
cl_mem_flags buffer_mem_flag,
|
cl_bool blocking, cl_mem_flags buffer_mem_flag,
|
||||||
cl_mem_flags parent_buffer_flag,
|
cl_mem_flags parent_buffer_flag, enum BUFFER_TYPE buffer_type)
|
||||||
enum BUFFER_TYPE buffer_type)
|
|
||||||
{
|
{
|
||||||
log_info("%s\n", __FUNCTION__);
|
log_info("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
cBuffer_check_mem_host_read_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
|
cBuffer_check_mem_host_read_only<TEST_ELEMENT_TYPE> checker(deviceID,
|
||||||
checker.m_blocking = blocking;
|
context, queue);
|
||||||
checker.buffer_mem_flag = buffer_mem_flag;
|
checker.m_blocking = blocking;
|
||||||
cl_int err;
|
checker.buffer_mem_flag = buffer_mem_flag;
|
||||||
switch (buffer_type) {
|
cl_int err;
|
||||||
case _BUFFER:
|
switch (buffer_type)
|
||||||
err= checker.SetupBuffer();
|
{
|
||||||
break;
|
case _BUFFER: err = checker.SetupBuffer(); break;
|
||||||
case _Sub_BUFFER:
|
case _Sub_BUFFER:
|
||||||
err= checker.SetupASSubBuffer(parent_buffer_flag);
|
err = checker.SetupASSubBuffer(parent_buffer_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
checker.Setup_Test_Environment();
|
checker.Setup_Test_Environment();
|
||||||
err = checker.verify_RW_Buffer_rect();
|
err = checker.verify_RW_Buffer_rect();
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test_mem_host_read_only_buffer_RW_Mapping(cl_device_id deviceID, cl_context context,
|
static int test_mem_host_read_only_buffer_RW_Mapping(
|
||||||
cl_command_queue queue, cl_bool blocking,
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
cl_mem_flags buffer_mem_flag,
|
cl_bool blocking, cl_mem_flags buffer_mem_flag,
|
||||||
cl_mem_flags parent_buffer_flag,
|
cl_mem_flags parent_buffer_flag, enum BUFFER_TYPE buffer_type)
|
||||||
enum BUFFER_TYPE buffer_type)
|
|
||||||
{
|
{
|
||||||
log_info("%s\n", __FUNCTION__);
|
log_info("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
cBuffer_check_mem_host_read_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
|
cBuffer_check_mem_host_read_only<TEST_ELEMENT_TYPE> checker(deviceID,
|
||||||
checker.m_blocking = blocking;
|
context, queue);
|
||||||
checker.buffer_mem_flag = buffer_mem_flag;
|
checker.m_blocking = blocking;
|
||||||
cl_int err;
|
checker.buffer_mem_flag = buffer_mem_flag;
|
||||||
switch (buffer_type) {
|
cl_int err;
|
||||||
case _BUFFER:
|
switch (buffer_type)
|
||||||
err= checker.SetupBuffer();
|
{
|
||||||
break;
|
case _BUFFER: err = checker.SetupBuffer(); break;
|
||||||
case _Sub_BUFFER:
|
case _Sub_BUFFER:
|
||||||
err= checker.SetupASSubBuffer(parent_buffer_flag);
|
err = checker.SetupASSubBuffer(parent_buffer_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
checker.Setup_Test_Environment();
|
checker.Setup_Test_Environment();
|
||||||
err = checker.verify_RW_Buffer_mapping();
|
err = checker.verify_RW_Buffer_mapping();
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_mem_host_read_only_buffer(cl_device_id deviceID, cl_context context,
|
int test_mem_host_read_only_buffer(cl_device_id deviceID, cl_context context,
|
||||||
cl_command_queue queue, int num_elements)
|
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_flags buffer_mem_flags[2] = {
|
||||||
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_READ_ONLY};
|
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_int err = CL_SUCCESS;
|
||||||
|
|
||||||
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
|
cl_bool blocking[2] = { CL_TRUE, CL_FALSE };
|
||||||
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(
|
||||||
buffer_mem_flags[k], 0, _BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[k], 0,
|
||||||
test_error(err, __FUNCTION__);
|
_BUFFER);
|
||||||
|
test_error(err, __FUNCTION__);
|
||||||
|
|
||||||
err = test_mem_host_read_only_buffer_RW_Rect(deviceID, context, queue, blocking[i],
|
err = test_mem_host_read_only_buffer_RW_Rect(
|
||||||
buffer_mem_flags[k],0, _BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[k], 0,
|
||||||
test_error(err, __FUNCTION__);
|
_BUFFER);
|
||||||
|
test_error(err, __FUNCTION__);
|
||||||
|
|
||||||
err = test_mem_host_read_only_buffer_RW_Mapping(deviceID, context, queue, blocking[i],
|
err = test_mem_host_read_only_buffer_RW_Mapping(
|
||||||
buffer_mem_flags[k],0, _BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[k], 0,
|
||||||
test_error(err, __FUNCTION__);
|
_BUFFER);
|
||||||
}
|
test_error(err, __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_mem_host_read_only_subbuffer(cl_device_id deviceID, cl_context context,
|
int test_mem_host_read_only_subbuffer(cl_device_id deviceID, cl_context context,
|
||||||
cl_command_queue queue, int num_elements)
|
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 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_flags buffer_mem_flags[4] = {
|
||||||
CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,
|
0, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
|
||||||
CL_MEM_READ_WRITE | CL_MEM_COPY_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_int err = CL_SUCCESS;
|
||||||
|
|
||||||
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
|
cl_bool blocking[2] = { CL_TRUE, CL_FALSE };
|
||||||
|
|
||||||
for (int p=0; p<1; p++) {
|
for (int p = 0; p < 1; p++)
|
||||||
for (int k=0; k<4; k++)
|
{
|
||||||
for (int i=0; i<2; i++)
|
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);
|
err = test_mem_host_read_only_buffer_RW(
|
||||||
test_error(err, __FUNCTION__);
|
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],
|
err = test_mem_host_read_only_buffer_RW_Rect(
|
||||||
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[k],
|
||||||
test_error(err, __FUNCTION__);
|
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],
|
err = test_mem_host_read_only_buffer_RW_Mapping(
|
||||||
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[k],
|
||||||
test_error(err, __FUNCTION__);
|
parent_buffer_mem_flags[p], _Sub_BUFFER);
|
||||||
}
|
test_error(err, __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================== Write only
|
//=============================== Write only
|
||||||
|
|
||||||
static cl_int test_mem_host_write_only_buffer_RW(cl_device_id deviceID, cl_context context,
|
static cl_int test_mem_host_write_only_buffer_RW(
|
||||||
cl_command_queue queue, cl_bool blocking,
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
cl_mem_flags buffer_mem_flag,
|
cl_bool blocking, cl_mem_flags buffer_mem_flag,
|
||||||
cl_mem_flags parent_buffer_flag,
|
cl_mem_flags parent_buffer_flag, enum BUFFER_TYPE buffer_type)
|
||||||
enum BUFFER_TYPE buffer_type)
|
|
||||||
{
|
{
|
||||||
log_info("%s\n", __FUNCTION__);
|
log_info("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
cBuffer_check_mem_host_write_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
|
cBuffer_check_mem_host_write_only<TEST_ELEMENT_TYPE> checker(
|
||||||
|
deviceID, context, queue);
|
||||||
|
|
||||||
checker.m_blocking = blocking;
|
checker.m_blocking = blocking;
|
||||||
checker.buffer_mem_flag = buffer_mem_flag;
|
checker.buffer_mem_flag = buffer_mem_flag;
|
||||||
cl_int err;
|
cl_int err;
|
||||||
switch (buffer_type) {
|
switch (buffer_type)
|
||||||
case _BUFFER:
|
{
|
||||||
err = checker.SetupBuffer();
|
case _BUFFER: err = checker.SetupBuffer(); break;
|
||||||
break;
|
case _Sub_BUFFER:
|
||||||
case _Sub_BUFFER:
|
err = checker.SetupASSubBuffer(parent_buffer_flag);
|
||||||
err = checker.SetupASSubBuffer( parent_buffer_flag );
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
checker.Setup_Test_Environment();
|
checker.Setup_Test_Environment();
|
||||||
err= checker.verify_RW_Buffer();
|
err = checker.verify_RW_Buffer();
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cl_int test_mem_host_write_only_buffer_RW_Rect(cl_device_id deviceID, cl_context context,
|
static cl_int test_mem_host_write_only_buffer_RW_Rect(
|
||||||
cl_command_queue queue, cl_bool blocking,
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
cl_mem_flags buffer_mem_flag,
|
cl_bool blocking, cl_mem_flags buffer_mem_flag,
|
||||||
cl_mem_flags parent_buffer_flag,
|
cl_mem_flags parent_buffer_flag, enum BUFFER_TYPE buffer_type)
|
||||||
enum BUFFER_TYPE buffer_type)
|
|
||||||
{
|
{
|
||||||
log_info("%s\n", __FUNCTION__);
|
log_info("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
cBuffer_check_mem_host_write_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
|
cBuffer_check_mem_host_write_only<TEST_ELEMENT_TYPE> checker(
|
||||||
checker.m_blocking = blocking;
|
deviceID, context, queue);
|
||||||
checker.buffer_mem_flag = buffer_mem_flag;
|
checker.m_blocking = blocking;
|
||||||
cl_int err;
|
checker.buffer_mem_flag = buffer_mem_flag;
|
||||||
switch (buffer_type) {
|
cl_int err;
|
||||||
case _BUFFER:
|
switch (buffer_type)
|
||||||
err= checker.SetupBuffer();
|
{
|
||||||
break;
|
case _BUFFER: err = checker.SetupBuffer(); break;
|
||||||
case _Sub_BUFFER:
|
case _Sub_BUFFER:
|
||||||
err= checker.SetupASSubBuffer(parent_buffer_flag);
|
err = checker.SetupASSubBuffer(parent_buffer_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
checker.Setup_Test_Environment();
|
checker.Setup_Test_Environment();
|
||||||
err= checker.verify_RW_Buffer_rect();
|
err = checker.verify_RW_Buffer_rect();
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cl_int test_mem_host_write_only_buffer_RW_Mapping(cl_device_id deviceID, cl_context context,
|
static cl_int test_mem_host_write_only_buffer_RW_Mapping(
|
||||||
cl_command_queue queue, cl_bool blocking,
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
cl_mem_flags buffer_mem_flag,
|
cl_bool blocking, cl_mem_flags buffer_mem_flag,
|
||||||
cl_mem_flags parent_buffer_flag,
|
cl_mem_flags parent_buffer_flag, enum BUFFER_TYPE buffer_type)
|
||||||
enum BUFFER_TYPE buffer_type)
|
|
||||||
{
|
{
|
||||||
log_info("%s\n", __FUNCTION__);
|
log_info("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
cBuffer_check_mem_host_write_only< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
|
cBuffer_check_mem_host_write_only<TEST_ELEMENT_TYPE> checker(
|
||||||
checker.m_blocking = blocking;
|
deviceID, context, queue);
|
||||||
checker.buffer_mem_flag = buffer_mem_flag;
|
checker.m_blocking = blocking;
|
||||||
cl_int err;
|
checker.buffer_mem_flag = buffer_mem_flag;
|
||||||
switch (buffer_type) {
|
cl_int err;
|
||||||
case _BUFFER:
|
switch (buffer_type)
|
||||||
err= checker.SetupBuffer();
|
{
|
||||||
break;
|
case _BUFFER: err = checker.SetupBuffer(); break;
|
||||||
case _Sub_BUFFER:
|
case _Sub_BUFFER:
|
||||||
err= checker.SetupASSubBuffer(parent_buffer_flag);
|
err = checker.SetupASSubBuffer(parent_buffer_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
checker.Setup_Test_Environment();
|
checker.Setup_Test_Environment();
|
||||||
err= checker.verify_RW_Buffer_mapping();
|
err = checker.verify_RW_Buffer_mapping();
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_mem_host_write_only_buffer(cl_device_id deviceID, cl_context context,
|
int test_mem_host_write_only_buffer(cl_device_id deviceID, cl_context context,
|
||||||
cl_command_queue queue, int num_elements)
|
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_flags buffer_mem_flags[2] = {
|
||||||
CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_WRITE_ONLY};
|
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_int err = CL_SUCCESS;
|
||||||
|
|
||||||
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
|
cl_bool blocking[2] = { CL_TRUE, CL_FALSE };
|
||||||
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_write_only_buffer_RW(deviceID, context, queue, blocking[i],
|
err = test_mem_host_write_only_buffer_RW(
|
||||||
buffer_mem_flags[k], 0, _BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[k], 0,
|
||||||
test_error(err, __FUNCTION__);
|
_BUFFER);
|
||||||
|
test_error(err, __FUNCTION__);
|
||||||
|
|
||||||
err = test_mem_host_write_only_buffer_RW_Rect(deviceID, context, queue, blocking[i],
|
err = test_mem_host_write_only_buffer_RW_Rect(
|
||||||
buffer_mem_flags[k], 0, _BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[k], 0,
|
||||||
test_error(err, __FUNCTION__);
|
_BUFFER);
|
||||||
|
test_error(err, __FUNCTION__);
|
||||||
|
|
||||||
err = test_mem_host_write_only_buffer_RW_Mapping(deviceID, context, queue, blocking[i],
|
err = test_mem_host_write_only_buffer_RW_Mapping(
|
||||||
buffer_mem_flags[k], 0, _BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[k], 0,
|
||||||
test_error(err, __FUNCTION__);
|
_BUFFER);
|
||||||
}
|
test_error(err, __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_mem_host_write_only_subbuffer(cl_device_id deviceID, cl_context context,
|
int test_mem_host_write_only_subbuffer(cl_device_id deviceID,
|
||||||
|
cl_context context,
|
||||||
cl_command_queue queue, int num_elements)
|
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 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_flags buffer_mem_flags[4] = {
|
||||||
CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,
|
0, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
|
||||||
CL_MEM_READ_WRITE | CL_MEM_COPY_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_int err = CL_SUCCESS;
|
||||||
|
|
||||||
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
|
cl_bool blocking[2] = { CL_TRUE, CL_FALSE };
|
||||||
|
|
||||||
for (int p=0; p<1; p++) {
|
for (int p = 0; p < 1; p++)
|
||||||
for (int m=0; m<4; m++) {
|
{
|
||||||
for (int i=0; i< 2; i++)
|
for (int m = 0; m < 4; m++)
|
||||||
{
|
{
|
||||||
err = test_mem_host_write_only_buffer_RW(deviceID, context, queue, blocking[i],
|
for (int i = 0; i < 2; i++)
|
||||||
buffer_mem_flags[m], parent_buffer_mem_flags[p], _Sub_BUFFER);
|
{
|
||||||
test_error(err, __FUNCTION__);
|
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],
|
err = test_mem_host_write_only_buffer_RW_Rect(
|
||||||
buffer_mem_flags[m], parent_buffer_mem_flags[p], _Sub_BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[m],
|
||||||
test_error(err, __FUNCTION__);
|
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],
|
err = test_mem_host_write_only_buffer_RW_Mapping(
|
||||||
buffer_mem_flags[m] , parent_buffer_mem_flags[p], _Sub_BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[m],
|
||||||
test_error(err, __FUNCTION__);
|
parent_buffer_mem_flags[p], _Sub_BUFFER);
|
||||||
}
|
test_error(err, __FUNCTION__);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===================== NO ACCESS
|
//===================== NO ACCESS
|
||||||
|
|
||||||
static cl_int test_mem_host_no_access_buffer_RW(cl_device_id deviceID, cl_context context,
|
static cl_int test_mem_host_no_access_buffer_RW(
|
||||||
cl_command_queue queue, cl_bool blocking,
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
cl_mem_flags buffer_mem_flag,
|
cl_bool blocking, cl_mem_flags buffer_mem_flag,
|
||||||
cl_mem_flags parent_buffer_flag,
|
cl_mem_flags parent_buffer_flag, enum BUFFER_TYPE buffer_type)
|
||||||
enum BUFFER_TYPE buffer_type)
|
|
||||||
{
|
{
|
||||||
log_info("%s\n", __FUNCTION__);
|
log_info("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
cBuffer_check_mem_host_no_access< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
|
cBuffer_check_mem_host_no_access<TEST_ELEMENT_TYPE> checker(deviceID,
|
||||||
checker.m_blocking = blocking;
|
context, queue);
|
||||||
checker.buffer_mem_flag = buffer_mem_flag;
|
checker.m_blocking = blocking;
|
||||||
|
checker.buffer_mem_flag = buffer_mem_flag;
|
||||||
|
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
switch (buffer_type) {
|
switch (buffer_type)
|
||||||
case _BUFFER:
|
{
|
||||||
err= checker.SetupBuffer();
|
case _BUFFER: err = checker.SetupBuffer(); break;
|
||||||
break;
|
case _Sub_BUFFER:
|
||||||
case _Sub_BUFFER:
|
err = checker.SetupASSubBuffer(parent_buffer_flag);
|
||||||
err= checker.SetupASSubBuffer(parent_buffer_flag);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
checker.Setup_Test_Environment();
|
checker.Setup_Test_Environment();
|
||||||
err= checker.verify_RW_Buffer_mapping();
|
err = checker.verify_RW_Buffer_mapping();
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cl_int test_mem_host_no_access_buffer_RW_Rect(cl_device_id deviceID, cl_context context,
|
static cl_int test_mem_host_no_access_buffer_RW_Rect(
|
||||||
cl_command_queue queue, cl_bool blocking,
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
cl_mem_flags buffer_mem_flag,
|
cl_bool blocking, cl_mem_flags buffer_mem_flag,
|
||||||
cl_mem_flags parent_buffer_flag,
|
cl_mem_flags parent_buffer_flag, enum BUFFER_TYPE buffer_type)
|
||||||
enum BUFFER_TYPE buffer_type)
|
|
||||||
{
|
{
|
||||||
log_info( "%s\n", __FUNCTION__);
|
log_info("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
cBuffer_check_mem_host_no_access< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
|
cBuffer_check_mem_host_no_access<TEST_ELEMENT_TYPE> checker(deviceID,
|
||||||
checker.m_blocking = blocking;
|
context, queue);
|
||||||
checker.buffer_mem_flag = buffer_mem_flag;
|
checker.m_blocking = blocking;
|
||||||
cl_int err;
|
checker.buffer_mem_flag = buffer_mem_flag;
|
||||||
switch (buffer_type) {
|
cl_int err;
|
||||||
case _BUFFER:
|
switch (buffer_type)
|
||||||
err= checker.SetupBuffer();
|
{
|
||||||
break;
|
case _BUFFER: err = checker.SetupBuffer(); break;
|
||||||
case _Sub_BUFFER:
|
case _Sub_BUFFER:
|
||||||
err= checker.SetupASSubBuffer(parent_buffer_flag);
|
err = checker.SetupASSubBuffer(parent_buffer_flag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
checker.Setup_Test_Environment();
|
checker.Setup_Test_Environment();
|
||||||
err= checker.verify_RW_Buffer_mapping();
|
err = checker.verify_RW_Buffer_mapping();
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cl_int test_mem_host_no_access_buffer_RW_Mapping(cl_device_id deviceID, cl_context context,
|
static cl_int test_mem_host_no_access_buffer_RW_Mapping(
|
||||||
cl_command_queue queue, cl_bool blocking,
|
cl_device_id deviceID, cl_context context, cl_command_queue queue,
|
||||||
cl_mem_flags buffer_mem_flag,
|
cl_bool blocking, cl_mem_flags buffer_mem_flag,
|
||||||
cl_mem_flags parent_buffer_flag,
|
cl_mem_flags parent_buffer_flag, enum BUFFER_TYPE buffer_type)
|
||||||
enum BUFFER_TYPE buffer_type)
|
|
||||||
{
|
{
|
||||||
log_info("%s\n", __FUNCTION__);
|
log_info("%s\n", __FUNCTION__);
|
||||||
|
|
||||||
cBuffer_check_mem_host_no_access< TEST_ELEMENT_TYPE > checker(deviceID, context, queue);
|
cBuffer_check_mem_host_no_access<TEST_ELEMENT_TYPE> checker(deviceID,
|
||||||
|
context, queue);
|
||||||
|
|
||||||
checker.m_blocking = blocking;
|
checker.m_blocking = blocking;
|
||||||
checker.buffer_mem_flag = buffer_mem_flag;
|
checker.buffer_mem_flag = buffer_mem_flag;
|
||||||
cl_int err;
|
cl_int err;
|
||||||
switch (buffer_type) {
|
switch (buffer_type)
|
||||||
case _BUFFER:
|
{
|
||||||
err= checker.SetupBuffer();
|
case _BUFFER: err = checker.SetupBuffer(); break;
|
||||||
break;
|
case _Sub_BUFFER:
|
||||||
case _Sub_BUFFER:
|
err = checker.SetupASSubBuffer(parent_buffer_flag);
|
||||||
err= checker.SetupASSubBuffer(parent_buffer_flag);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
checker.Setup_Test_Environment();
|
checker.Setup_Test_Environment();
|
||||||
err= checker.verify_RW_Buffer_mapping();
|
err = checker.verify_RW_Buffer_mapping();
|
||||||
test_error(err, __FUNCTION__);
|
test_error(err, __FUNCTION__);
|
||||||
clFinish(queue);
|
clFinish(queue);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_mem_host_no_access_buffer(cl_device_id deviceID, cl_context context,
|
int test_mem_host_no_access_buffer(cl_device_id deviceID, cl_context context,
|
||||||
cl_command_queue queue, int num_elements)
|
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_flags buffer_mem_flag[2] = {
|
||||||
CL_MEM_READ_WRITE | CL_MEM_COPY_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_COPY_HOST_PTR | CL_MEM_HOST_NO_ACCESS
|
||||||
|
};
|
||||||
|
|
||||||
cl_int err = CL_SUCCESS;
|
cl_int err = CL_SUCCESS;
|
||||||
|
|
||||||
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
|
cl_bool blocking[2] = { CL_TRUE, CL_FALSE };
|
||||||
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_no_access_buffer_RW(deviceID, context, queue, blocking[i],
|
{
|
||||||
buffer_mem_flag[k], 0, _BUFFER);
|
err = test_mem_host_no_access_buffer_RW(
|
||||||
test_error(err, __FUNCTION__);
|
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],
|
err = test_mem_host_no_access_buffer_RW_Rect(
|
||||||
buffer_mem_flag[k], 0, _BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flag[k], 0,
|
||||||
test_error(err, __FUNCTION__);
|
_BUFFER);
|
||||||
|
test_error(err, __FUNCTION__);
|
||||||
|
|
||||||
err = test_mem_host_no_access_buffer_RW_Mapping(deviceID, context, queue, blocking[i],
|
err = test_mem_host_no_access_buffer_RW_Mapping(
|
||||||
buffer_mem_flag[k], 0, _BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flag[k], 0,
|
||||||
test_error(err, __FUNCTION__);
|
_BUFFER);
|
||||||
}
|
test_error(err, __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_mem_host_no_access_subbuffer(cl_device_id deviceID, cl_context context,
|
int test_mem_host_no_access_subbuffer(cl_device_id deviceID, cl_context context,
|
||||||
cl_command_queue queue, int num_elements)
|
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_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_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_flags buffer_mem_flags[4] = {
|
||||||
CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,
|
0, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
|
||||||
CL_MEM_READ_WRITE | CL_MEM_COPY_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_int err = CL_SUCCESS;
|
||||||
|
|
||||||
cl_bool blocking[2] = {CL_TRUE, CL_FALSE};
|
cl_bool blocking[2] = { CL_TRUE, CL_FALSE };
|
||||||
for (int p=0; p<3; p++) {
|
for (int p = 0; p < 3; p++)
|
||||||
for (int k=0; k<4; k++) {
|
{
|
||||||
for (int i=0; i<2; i++) {
|
for (int k = 0; k < 4; k++)
|
||||||
err += test_mem_host_no_access_buffer_RW(deviceID, context, queue, blocking[i],
|
{
|
||||||
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
|
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],
|
err += test_mem_host_no_access_buffer_RW_Rect(
|
||||||
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
|
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],
|
err += test_mem_host_no_access_buffer_RW_Mapping(
|
||||||
buffer_mem_flags[k], parent_buffer_mem_flags[p], _Sub_BUFFER);
|
deviceID, context, queue, blocking[i], buffer_mem_flags[k],
|
||||||
}
|
parent_buffer_mem_flags[p], _Sub_BUFFER);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -20,26 +20,44 @@
|
|||||||
|
|
||||||
#define NUM_FLAGS 4
|
#define NUM_FLAGS 4
|
||||||
|
|
||||||
extern int test_mem_host_read_only_buffer(cl_device_id deviceID, cl_context context,
|
extern int test_mem_host_read_only_buffer(cl_device_id deviceID,
|
||||||
cl_command_queue queue, int num_elements);
|
cl_context context,
|
||||||
extern int test_mem_host_read_only_subbuffer(cl_device_id deviceID, cl_context context,
|
cl_command_queue queue,
|
||||||
cl_command_queue queue, int num_elements);
|
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,
|
extern int test_mem_host_write_only_buffer(cl_device_id deviceID,
|
||||||
cl_command_queue queue, int num_elements);
|
cl_context context,
|
||||||
extern int test_mem_host_write_only_subbuffer(cl_device_id deviceID, cl_context context,
|
cl_command_queue queue,
|
||||||
cl_command_queue queue, int num_elements);
|
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,
|
extern int test_mem_host_no_access_buffer(cl_device_id deviceID,
|
||||||
cl_command_queue queue, int num_elements);
|
cl_context context,
|
||||||
extern int test_mem_host_no_access_subbuffer(cl_device_id deviceID, cl_context context,
|
cl_command_queue queue,
|
||||||
cl_command_queue queue, int num_elements);
|
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,
|
extern int test_mem_host_read_only_image(cl_device_id deviceID,
|
||||||
cl_command_queue queue, int num_elements);
|
cl_context context,
|
||||||
extern int test_mem_host_write_only_image(cl_device_id deviceID, cl_context context,
|
cl_command_queue queue,
|
||||||
cl_command_queue queue, int num_elements);
|
int num_elements);
|
||||||
extern int test_mem_host_no_access_image(cl_device_id deviceID, cl_context context,
|
extern int test_mem_host_write_only_image(cl_device_id deviceID,
|
||||||
cl_command_queue queue, int num_elements);
|
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__
|
#endif // #ifndef __PROCS_H__
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -23,10 +23,10 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#if !defined (__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
#include <CL/cl.h>
|
#include <CL/cl.h>
|
||||||
#else
|
#else
|
||||||
//#include <OpenCL/cl.h>
|
// #include <OpenCL/cl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "harness/imageHelpers.h"
|
#include "harness/imageHelpers.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user