SWDEV-470698 - fix formatting, add format check workflow (#657)
This commit is contained in:
committed by
GitHub
parent
5840940caa
commit
f7338717ae
@@ -41,60 +41,55 @@ static const unsigned int Sizes[NUM_SIZES] = {256, 512, 1024, 2048};
|
||||
|
||||
#if defined(CL_VERSION_2_0)
|
||||
#define NUM_FORMATS 2
|
||||
static const cl_image_format formats[NUM_FORMATS] = {
|
||||
{CL_RGBA, CL_UNSIGNED_INT8}, {CL_sRGBA, CL_UNORM_INT8}};
|
||||
static const char *textFormats[NUM_FORMATS] = {"CL_RGBA , CL_UNSIGNED_INT8",
|
||||
static const cl_image_format formats[NUM_FORMATS] = {{CL_RGBA, CL_UNSIGNED_INT8},
|
||||
{CL_sRGBA, CL_UNORM_INT8}};
|
||||
static const char* textFormats[NUM_FORMATS] = {"CL_RGBA , CL_UNSIGNED_INT8",
|
||||
"CL_sRGBA, CL_UNORM_INT8 "};
|
||||
static const unsigned int formatSize[NUM_FORMATS] = {sizeof(CL_UNSIGNED_INT8),
|
||||
sizeof(CL_UNORM_INT8)};
|
||||
#else
|
||||
#define NUM_FORMATS 1
|
||||
static const cl_image_format formats[NUM_FORMATS] = {
|
||||
{CL_RGBA, CL_UNSIGNED_INT8}};
|
||||
static const char *textFormats[NUM_FORMATS] = {"CL_RGBA , CL_UNSIGNED_INT8"};
|
||||
static const cl_image_format formats[NUM_FORMATS] = {{CL_RGBA, CL_UNSIGNED_INT8}};
|
||||
static const char* textFormats[NUM_FORMATS] = {"CL_RGBA , CL_UNSIGNED_INT8"};
|
||||
static const unsigned int formatSize[NUM_FORMATS] = {sizeof(CL_UNSIGNED_INT8)};
|
||||
#endif
|
||||
|
||||
const static char *strKernel = {KERNEL_CODE(
|
||||
const static char* strKernel = {KERNEL_CODE(
|
||||
\n __constant sampler_t s_nearest = CLK_FILTER_NEAREST | CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE;
|
||||
\n
|
||||
// Read sRGBA image object (input) and convert it to linear RGB values
|
||||
// (results):
|
||||
__kernel void image_kernel(read_only image2d_t input,
|
||||
__global float4 *results) {
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
__kernel void image_kernel(read_only image2d_t input, __global float4* results) {
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
|
||||
int offset = y * get_image_width(input) + x;
|
||||
int offset = y * get_image_width(input) + x;
|
||||
|
||||
int2 coords = (int2)(x, y);
|
||||
float4 tmp = read_imagef(input, s_nearest, coords);
|
||||
if (x < 0 && tmp.x == 0.f) {
|
||||
results[offset] = tmp;
|
||||
}
|
||||
}
|
||||
int2 coords = (int2)(x, y);
|
||||
float4 tmp = read_imagef(input, s_nearest, coords);
|
||||
if (x < 0 && tmp.x == 0.f) {
|
||||
results[offset] = tmp;
|
||||
}
|
||||
}
|
||||
\n)};
|
||||
|
||||
OCLPerfImageReadsRGBA::OCLPerfImageReadsRGBA() {
|
||||
_numSubTests = NUM_SIZES * NUM_FORMATS;
|
||||
}
|
||||
OCLPerfImageReadsRGBA::OCLPerfImageReadsRGBA() { _numSubTests = NUM_SIZES * NUM_FORMATS; }
|
||||
|
||||
OCLPerfImageReadsRGBA::~OCLPerfImageReadsRGBA() {}
|
||||
|
||||
static void CL_CALLBACK notify_callback(const char *errinfo,
|
||||
const void *private_info, size_t cb,
|
||||
void *user_data) {}
|
||||
static void CL_CALLBACK notify_callback(const char* errinfo, const void* private_info, size_t cb,
|
||||
void* user_data) {}
|
||||
|
||||
void OCLPerfImageReadsRGBA::setData(void *ptr, unsigned int size, float value) {
|
||||
unsigned int *ptr_i = (unsigned int *)ptr;
|
||||
void OCLPerfImageReadsRGBA::setData(void* ptr, unsigned int size, float value) {
|
||||
unsigned int* ptr_i = (unsigned int*)ptr;
|
||||
for (unsigned int i = 0; i < size >> 2; i++) {
|
||||
ptr_i[i] = (int)value;
|
||||
value++;
|
||||
}
|
||||
}
|
||||
|
||||
void OCLPerfImageReadsRGBA::open(unsigned int test, char *units,
|
||||
double &conversion, unsigned int deviceId) {
|
||||
void OCLPerfImageReadsRGBA::open(unsigned int test, char* units, double& conversion,
|
||||
unsigned int deviceId) {
|
||||
error_ = CL_SUCCESS;
|
||||
testId_ = test;
|
||||
|
||||
@@ -110,18 +105,16 @@ void OCLPerfImageReadsRGBA::open(unsigned int test, char *units,
|
||||
|
||||
// check device version
|
||||
size_t param_size = 0;
|
||||
char *strVersion = 0;
|
||||
error_ = _wrapper->clGetDeviceInfo(devices_[_deviceId], CL_DEVICE_VERSION, 0,
|
||||
0, ¶m_size);
|
||||
char* strVersion = 0;
|
||||
error_ = _wrapper->clGetDeviceInfo(devices_[_deviceId], CL_DEVICE_VERSION, 0, 0, ¶m_size);
|
||||
CHECK_RESULT(error_ != CL_SUCCESS, "clGetDeviceInfo failed");
|
||||
strVersion = new char[param_size];
|
||||
error_ = _wrapper->clGetDeviceInfo(devices_[_deviceId], CL_DEVICE_VERSION,
|
||||
param_size, strVersion, 0);
|
||||
error_ =
|
||||
_wrapper->clGetDeviceInfo(devices_[_deviceId], CL_DEVICE_VERSION, param_size, strVersion, 0);
|
||||
CHECK_RESULT(error_ != CL_SUCCESS, "clGetDeviceInfo failed");
|
||||
if (strVersion[7] < '2') {
|
||||
skip_ = true;
|
||||
testDescString =
|
||||
"sRGBA Image not supported for < 2.0 devices. Test Skipped.";
|
||||
testDescString = "sRGBA Image not supported for < 2.0 devices. Test Skipped.";
|
||||
delete strVersion;
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +122,7 @@ void OCLPerfImageReadsRGBA::open(unsigned int test, char *units,
|
||||
size_t size;
|
||||
cl_bool imageSupport_ = false;
|
||||
error_ = _wrapper->clGetDeviceInfo(devices_[_deviceId], CL_DEVICE_IMAGE_SUPPORT,
|
||||
sizeof(imageSupport_), &imageSupport_, &size);
|
||||
sizeof(imageSupport_), &imageSupport_, &size);
|
||||
if (!imageSupport_) {
|
||||
printf("\n%s\n", "Image not supported, skipping this test!");
|
||||
skip_ = true;
|
||||
@@ -144,16 +137,14 @@ void OCLPerfImageReadsRGBA::open(unsigned int test, char *units,
|
||||
|
||||
cmd_queue_ = cmdQueues_[_deviceId];
|
||||
|
||||
program_ = _wrapper->clCreateProgramWithSource(context_, 1, &strKernel, NULL,
|
||||
&error_);
|
||||
program_ = _wrapper->clCreateProgramWithSource(context_, 1, &strKernel, NULL, &error_);
|
||||
CHECK_RESULT((error_ != CL_SUCCESS), "clCreateProgramWithSource() failed");
|
||||
|
||||
error_ = _wrapper->clBuildProgram(program_, 1, &devices_[deviceId],
|
||||
"-cl-std=CL2.0", NULL, NULL);
|
||||
error_ = _wrapper->clBuildProgram(program_, 1, &devices_[deviceId], "-cl-std=CL2.0", NULL, NULL);
|
||||
if (error_ != CL_SUCCESS) {
|
||||
char programLog[1024];
|
||||
_wrapper->clGetProgramBuildInfo(program_, devices_[deviceId],
|
||||
CL_PROGRAM_BUILD_LOG, 1024, programLog, 0);
|
||||
_wrapper->clGetProgramBuildInfo(program_, devices_[deviceId], CL_PROGRAM_BUILD_LOG, 1024,
|
||||
programLog, 0);
|
||||
printf("\n%s\n", programLog);
|
||||
fflush(stdout);
|
||||
}
|
||||
@@ -168,13 +159,13 @@ void OCLPerfImageReadsRGBA::open(unsigned int test, char *units,
|
||||
size_t region[3] = {bufSize_, bufSize_, 1};
|
||||
|
||||
// create image
|
||||
imageBuffer_ = _wrapper->clCreateImage2D(
|
||||
context_, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &formats[bufnum_],
|
||||
bufSize_, bufSize_, 0, memptr, &error_);
|
||||
imageBuffer_ =
|
||||
_wrapper->clCreateImage2D(context_, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &formats[bufnum_],
|
||||
bufSize_, bufSize_, 0, memptr, &error_);
|
||||
CHECK_RESULT(imageBuffer_ == 0, "clCreateImage2D(imageBuffer_) failed");
|
||||
|
||||
valueBuffer_ = clCreateBuffer(
|
||||
context_, CL_MEM_WRITE_ONLY | CL_MEM_ALLOC_HOST_PTR, memSize, 0, &error_);
|
||||
valueBuffer_ =
|
||||
clCreateBuffer(context_, CL_MEM_WRITE_ONLY | CL_MEM_ALLOC_HOST_PTR, memSize, 0, &error_);
|
||||
CHECK_RESULT((error_ != CL_SUCCESS), "Error clCreateBuffer()");
|
||||
|
||||
// set kernel arguments
|
||||
@@ -196,8 +187,7 @@ void OCLPerfImageReadsRGBA::run(void) {
|
||||
size_t lws[2] = {8, 8};
|
||||
|
||||
// warm-up
|
||||
error_ = _wrapper->clEnqueueNDRangeKernel(cmd_queue_, kernel_, 2, NULL, gws,
|
||||
lws, 0, NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueNDRangeKernel(cmd_queue_, kernel_, 2, NULL, gws, lws, 0, NULL, NULL);
|
||||
CHECK_RESULT((error_ != CL_SUCCESS), "clEnqueueNDRangeKernel() failed");
|
||||
_wrapper->clFinish(cmd_queue_);
|
||||
|
||||
@@ -205,8 +195,8 @@ void OCLPerfImageReadsRGBA::run(void) {
|
||||
timer.Start();
|
||||
|
||||
for (unsigned int i = 0; i < numIter; ++i) {
|
||||
error_ = _wrapper->clEnqueueNDRangeKernel(cmd_queue_, kernel_, 2, NULL, gws,
|
||||
lws, 0, NULL, NULL);
|
||||
error_ =
|
||||
_wrapper->clEnqueueNDRangeKernel(cmd_queue_, kernel_, 2, NULL, gws, lws, 0, NULL, NULL);
|
||||
CHECK_RESULT((error_ != CL_SUCCESS), "clEnqueueNDRangeKernel() failed");
|
||||
_wrapper->clFinish(cmd_queue_);
|
||||
}
|
||||
@@ -221,8 +211,8 @@ void OCLPerfImageReadsRGBA::run(void) {
|
||||
_perfInfo = (float)perf;
|
||||
char buf[256];
|
||||
unsigned int fmt_num = (testId_ / NUM_SIZES) % NUM_FORMATS;
|
||||
SNPRINTF(buf, sizeof(buf), " (%4dx%4d) fmt:%s(%1d) i: %4d (GB/s) ", bufSize_,
|
||||
bufSize_, textFormats[fmt_num], formatSize[bufnum_], numIter);
|
||||
SNPRINTF(buf, sizeof(buf), " (%4dx%4d) fmt:%s(%1d) i: %4d (GB/s) ", bufSize_, bufSize_,
|
||||
textFormats[fmt_num], formatSize[bufnum_], numIter);
|
||||
testDescString = buf;
|
||||
}
|
||||
|
||||
@@ -235,13 +225,11 @@ unsigned int OCLPerfImageReadsRGBA::close(void) {
|
||||
}
|
||||
if (imageBuffer_) {
|
||||
error_ = _wrapper->clReleaseMemObject(imageBuffer_);
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS,
|
||||
"clReleaseMemObject(imageBuffer_) failed");
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS, "clReleaseMemObject(imageBuffer_) failed");
|
||||
}
|
||||
if (valueBuffer_) {
|
||||
error_ = _wrapper->clReleaseMemObject(valueBuffer_);
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS,
|
||||
"clReleaseMemObject(valueBuffer_) failed");
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS, "clReleaseMemObject(valueBuffer_) failed");
|
||||
}
|
||||
return OCLTestImp::close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user