SWDEV-470698 - fix formatting, add format check workflow (#657)
This commit is contained in:
1 parent
5840940caa
commit
f7338717ae
1574 files changed
+162903
-199277
No files matched your search
@@ -40,43 +40,35 @@ static const unsigned int Sizes[NUM_SIZES] = {256, 512, 1024, 2048};
|
||||
#if defined(CL_VERSION_2_0)
|
||||
#define NUM_FORMATS 3
|
||||
static const cl_image_format formats[NUM_FORMATS] = {
|
||||
{CL_RGBA, CL_UNSIGNED_INT8},
|
||||
{CL_sRGBA, CL_UNORM_INT8},
|
||||
{CL_DEPTH, CL_UNORM_INT16}};
|
||||
static const char *textFormats[NUM_FORMATS] = {"CL_RGBA , CL_UNSIGNED_INT8",
|
||||
"CL_sRGBA, CL_UNORM_INT8 ",
|
||||
"CL_DEPTH, CL_UNORM_INT16 "};
|
||||
static const unsigned int formatSize[NUM_FORMATS] = {
|
||||
sizeof(CL_UNSIGNED_INT8), sizeof(CL_UNORM_INT8), sizeof(CL_UNORM_INT16)};
|
||||
{CL_RGBA, CL_UNSIGNED_INT8}, {CL_sRGBA, CL_UNORM_INT8}, {CL_DEPTH, CL_UNORM_INT16}};
|
||||
static const char* textFormats[NUM_FORMATS] = {
|
||||
"CL_RGBA , CL_UNSIGNED_INT8", "CL_sRGBA, CL_UNORM_INT8 ", "CL_DEPTH, CL_UNORM_INT16 "};
|
||||
static const unsigned int formatSize[NUM_FORMATS] = {sizeof(CL_UNSIGNED_INT8),
|
||||
sizeof(CL_UNORM_INT8), sizeof(CL_UNORM_INT16)};
|
||||
#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
|
||||
|
||||
OCLPerfImageCreate::OCLPerfImageCreate() {
|
||||
_numSubTests = NUM_SIZES * NUM_FORMATS;
|
||||
}
|
||||
OCLPerfImageCreate::OCLPerfImageCreate() { _numSubTests = NUM_SIZES * NUM_FORMATS; }
|
||||
|
||||
OCLPerfImageCreate::~OCLPerfImageCreate() {}
|
||||
|
||||
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 OCLPerfImageCreate::setData(void *ptr, unsigned int size,
|
||||
unsigned int value) {
|
||||
unsigned int *ptr2 = (unsigned int *)ptr;
|
||||
void OCLPerfImageCreate::setData(void* ptr, unsigned int size, unsigned int value) {
|
||||
unsigned int* ptr2 = (unsigned int*)ptr;
|
||||
for (unsigned int i = 0; i < size >> 2; i++) {
|
||||
ptr2[i] = value;
|
||||
value++;
|
||||
}
|
||||
}
|
||||
|
||||
void OCLPerfImageCreate::open(unsigned int test, char *units,
|
||||
double &conversion, unsigned int deviceId) {
|
||||
void OCLPerfImageCreate::open(unsigned int test, char* units, double& conversion,
|
||||
unsigned int deviceId) {
|
||||
error_ = CL_SUCCESS;
|
||||
testId_ = test;
|
||||
|
||||
@@ -91,18 +83,16 @@ void OCLPerfImageCreate::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;
|
||||
}
|
||||
@@ -110,7 +100,7 @@ void OCLPerfImageCreate::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;
|
||||
@@ -121,7 +111,7 @@ void OCLPerfImageCreate::open(unsigned int test, char *units,
|
||||
memSize = bufSize_ * bufSize_ * formatSize[bufnum_];
|
||||
numIter = 100;
|
||||
|
||||
outBuffer_ = (cl_mem *)malloc(numIter * sizeof(cl_mem));
|
||||
outBuffer_ = (cl_mem*)malloc(numIter * sizeof(cl_mem));
|
||||
memptr = new char[memSize];
|
||||
|
||||
cmd_queue_ = cmdQueues_[_deviceId];
|
||||
@@ -148,7 +138,7 @@ void OCLPerfImageCreate::run(void) {
|
||||
|
||||
setData(memptr, memSize, 0xdeadbeef);
|
||||
|
||||
char *dstmem = new char[memSize];
|
||||
char* dstmem = new char[memSize];
|
||||
size_t origin[3] = {0, 0, 0};
|
||||
size_t region[3] = {1, 1, 1};
|
||||
|
||||
@@ -156,14 +146,12 @@ void OCLPerfImageCreate::run(void) {
|
||||
timer.Start();
|
||||
|
||||
for (unsigned int i = 0; i < numIter; ++i) {
|
||||
outBuffer_[i] =
|
||||
clCreateImage(context_, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
|
||||
&formats[bufnum_], &imageInfo, memptr, &error_);
|
||||
outBuffer_[i] = clCreateImage(context_, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
|
||||
&formats[bufnum_], &imageInfo, memptr, &error_);
|
||||
CHECK_RESULT((error_ != CL_SUCCESS), "Error clCreateImage()");
|
||||
|
||||
error_ =
|
||||
_wrapper->clEnqueueReadImage(cmd_queue_, outBuffer_[i], CL_TRUE, origin,
|
||||
region, 0, 0, dstmem, 0, NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueReadImage(cmd_queue_, outBuffer_[i], CL_TRUE, origin, region, 0, 0,
|
||||
dstmem, 0, NULL, NULL);
|
||||
CHECK_RESULT(error_, "clEnqueueReadImage failed");
|
||||
_wrapper->clFinish(cmd_queue_);
|
||||
}
|
||||
@@ -180,8 +168,8 @@ void OCLPerfImageCreate::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;
|
||||
}
|
||||
|
||||
@@ -196,8 +184,7 @@ unsigned int OCLPerfImageCreate::close(void) {
|
||||
for (unsigned int i = 0; i < numIter; ++i) {
|
||||
if (outBuffer_[i]) {
|
||||
error_ = _wrapper->clReleaseMemObject(outBuffer_[i]);
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS,
|
||||
"clReleaseMemObject(outBuffer_[i]) failed");
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS, "clReleaseMemObject(outBuffer_[i]) failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user