SWDEV-470698 - fix formatting, add format check workflow (#657)
Ta zmiana jest zawarta w:
1 rodzic
5840940caa
złożenie
f7338717ae
1574 plików zmienionych
+162903
-199277
Żadne pliki nie pasują do Twojego wyszukiwania
@@ -38,13 +38,11 @@
|
||||
static const unsigned int Sizes[NUM_SIZES] = {256, 512, 1024, 2048};
|
||||
|
||||
#define NUM_FORMATS 1
|
||||
static const cl_image_format formats[NUM_FORMATS] = {
|
||||
{CL_RGBA, CL_UNSIGNED_INT8}};
|
||||
static const char *textFormats[NUM_FORMATS] = {"R8G8B8A8"};
|
||||
static const cl_image_format formats[NUM_FORMATS] = {{CL_RGBA, CL_UNSIGNED_INT8}};
|
||||
static const char* textFormats[NUM_FORMATS] = {"R8G8B8A8"};
|
||||
static const unsigned int formatSize[NUM_FORMATS] = {4};
|
||||
|
||||
static const unsigned int Iterations[2] = {1,
|
||||
OCLPerfMapImageWriteSpeed::NUM_ITER};
|
||||
static const unsigned int Iterations[2] = {1, OCLPerfMapImageWriteSpeed::NUM_ITER};
|
||||
|
||||
OCLPerfMapImageWriteSpeed::OCLPerfMapImageWriteSpeed() {
|
||||
_numSubTests = NUM_SIZES * NUM_FORMATS * 2;
|
||||
@@ -52,18 +50,16 @@ OCLPerfMapImageWriteSpeed::OCLPerfMapImageWriteSpeed() {
|
||||
|
||||
OCLPerfMapImageWriteSpeed::~OCLPerfMapImageWriteSpeed() {}
|
||||
|
||||
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 OCLPerfMapImageWriteSpeed::open(unsigned int test, char *units,
|
||||
double &conversion,
|
||||
void OCLPerfMapImageWriteSpeed::open(unsigned int test, char* units, double& conversion,
|
||||
unsigned int deviceId) {
|
||||
cl_uint typeOfDevice = type_;
|
||||
cl_uint numPlatforms;
|
||||
cl_platform_id platform = NULL;
|
||||
cl_uint num_devices = 0;
|
||||
cl_device_id *devices = NULL;
|
||||
cl_device_id* devices = NULL;
|
||||
cl_device_id device = NULL;
|
||||
_crcword = 0;
|
||||
conversion = 1.0f;
|
||||
@@ -78,7 +74,7 @@ void OCLPerfMapImageWriteSpeed::open(unsigned int test, char *units,
|
||||
error_ = _wrapper->clGetPlatformIDs(0, NULL, &numPlatforms);
|
||||
CHECK_RESULT(error_ != CL_SUCCESS, "clGetPlatformIDs failed");
|
||||
if (0 < numPlatforms) {
|
||||
cl_platform_id *platforms = new cl_platform_id[numPlatforms];
|
||||
cl_platform_id* platforms = new cl_platform_id[numPlatforms];
|
||||
error_ = _wrapper->clGetPlatformIDs(numPlatforms, platforms, NULL);
|
||||
CHECK_RESULT(error_ != CL_SUCCESS, "clGetPlatformIDs failed");
|
||||
#if 0
|
||||
@@ -88,13 +84,12 @@ void OCLPerfMapImageWriteSpeed::open(unsigned int test, char *units,
|
||||
#endif
|
||||
platform = platforms[_platformIndex];
|
||||
char pbuf[100];
|
||||
error_ = _wrapper->clGetPlatformInfo(platforms[_platformIndex],
|
||||
CL_PLATFORM_VENDOR, sizeof(pbuf), pbuf,
|
||||
NULL);
|
||||
error_ = _wrapper->clGetPlatformInfo(platforms[_platformIndex], CL_PLATFORM_VENDOR,
|
||||
sizeof(pbuf), pbuf, NULL);
|
||||
num_devices = 0;
|
||||
/* Get the number of requested devices */
|
||||
error_ = _wrapper->clGetDeviceIDs(platforms[_platformIndex], typeOfDevice,
|
||||
0, NULL, &num_devices);
|
||||
error_ =
|
||||
_wrapper->clGetDeviceIDs(platforms[_platformIndex], typeOfDevice, 0, NULL, &num_devices);
|
||||
// Runtime returns an error when no GPU devices are present instead of just
|
||||
// returning 0 devices
|
||||
// CHECK_RESULT(error_ != CL_SUCCESS, "clGetDeviceIDs failed");
|
||||
@@ -120,35 +115,33 @@ void OCLPerfMapImageWriteSpeed::open(unsigned int test, char *units,
|
||||
*/
|
||||
CHECK_RESULT(platform == 0, "Couldn't find AMD platform, cannot proceed");
|
||||
|
||||
devices = (cl_device_id *)malloc(num_devices * sizeof(cl_device_id));
|
||||
devices = (cl_device_id*)malloc(num_devices * sizeof(cl_device_id));
|
||||
CHECK_RESULT(devices == 0, "no devices");
|
||||
|
||||
/* Get the requested device */
|
||||
error_ = _wrapper->clGetDeviceIDs(platform, typeOfDevice, num_devices,
|
||||
devices, NULL);
|
||||
error_ = _wrapper->clGetDeviceIDs(platform, typeOfDevice, num_devices, devices, NULL);
|
||||
CHECK_RESULT(error_ != CL_SUCCESS, "clGetDeviceIDs failed");
|
||||
|
||||
CHECK_RESULT(_deviceId >= num_devices, "Requested deviceID not available");
|
||||
device = devices[_deviceId];
|
||||
size_t size;
|
||||
cl_bool imageSupport_ = false;
|
||||
error_ = _wrapper->clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT,
|
||||
sizeof(imageSupport_), &imageSupport_, &size);
|
||||
error_ = _wrapper->clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT, sizeof(imageSupport_),
|
||||
&imageSupport_, &size);
|
||||
if (!imageSupport_) {
|
||||
printf("\n%s\n", "Image not supported, skipping this test!");
|
||||
skip_ = true;
|
||||
return;
|
||||
}
|
||||
context_ = _wrapper->clCreateContext(NULL, 1, &device, notify_callback, NULL,
|
||||
&error_);
|
||||
context_ = _wrapper->clCreateContext(NULL, 1, &device, notify_callback, NULL, &error_);
|
||||
CHECK_RESULT(context_ == 0, "clCreateContext failed");
|
||||
|
||||
cmd_queue_ = _wrapper->clCreateCommandQueue(context_, device, 0, NULL);
|
||||
CHECK_RESULT(cmd_queue_ == 0, "clCreateCommandQueue failed");
|
||||
|
||||
cl_mem_flags flags = CL_MEM_READ_ONLY;
|
||||
outBuffer_ = _wrapper->clCreateImage2D(context_, flags, &formats[bufnum_],
|
||||
bufSize_, bufSize_, 0, NULL, &error_);
|
||||
outBuffer_ = _wrapper->clCreateImage2D(context_, flags, &formats[bufnum_], bufSize_, bufSize_, 0,
|
||||
NULL, &error_);
|
||||
CHECK_RESULT(outBuffer_ == 0, "clCreateImage(outBuffer) failed");
|
||||
}
|
||||
|
||||
@@ -158,19 +151,17 @@ void OCLPerfMapImageWriteSpeed::run(void) {
|
||||
}
|
||||
CPerfCounter timer;
|
||||
|
||||
void *mem;
|
||||
void* mem;
|
||||
size_t origin[3] = {0, 0, 0};
|
||||
size_t region[3] = {bufSize_, bufSize_, 1};
|
||||
size_t image_row_pitch;
|
||||
size_t image_slice_pitch;
|
||||
// Warm up
|
||||
mem = _wrapper->clEnqueueMapImage(
|
||||
cmd_queue_, outBuffer_, CL_TRUE, CL_MAP_WRITE, origin, region,
|
||||
&image_row_pitch, &image_slice_pitch, 0, NULL, NULL, &error_);
|
||||
mem = _wrapper->clEnqueueMapImage(cmd_queue_, outBuffer_, CL_TRUE, CL_MAP_WRITE, origin, region,
|
||||
&image_row_pitch, &image_slice_pitch, 0, NULL, NULL, &error_);
|
||||
|
||||
CHECK_RESULT(error_, "clEnqueueMapImage failed");
|
||||
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, outBuffer_, mem, 0,
|
||||
NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, outBuffer_, mem, 0, NULL, NULL);
|
||||
CHECK_RESULT(error_, "clEnqueueUnmapBuffer failed");
|
||||
error_ = _wrapper->clFinish(cmd_queue_);
|
||||
CHECK_RESULT(error_, "clFinish failed");
|
||||
@@ -178,13 +169,11 @@ void OCLPerfMapImageWriteSpeed::run(void) {
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
for (unsigned int i = 0; i < numIter; i++) {
|
||||
mem = _wrapper->clEnqueueMapImage(
|
||||
cmd_queue_, outBuffer_, CL_TRUE, CL_MAP_WRITE, origin, region,
|
||||
&image_row_pitch, &image_slice_pitch, 0, NULL, NULL, &error_);
|
||||
mem = _wrapper->clEnqueueMapImage(cmd_queue_, outBuffer_, CL_TRUE, CL_MAP_WRITE, origin, region,
|
||||
&image_row_pitch, &image_slice_pitch, 0, NULL, NULL, &error_);
|
||||
|
||||
CHECK_RESULT(error_, "clEnqueueMapImage failed");
|
||||
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, outBuffer_, mem, 0,
|
||||
NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, outBuffer_, mem, 0, NULL, NULL);
|
||||
CHECK_RESULT(error_, "clEnqueueUnmapBuffer failed");
|
||||
error_ = _wrapper->clFinish(cmd_queue_);
|
||||
CHECK_RESULT(error_, "clFinish failed");
|
||||
@@ -194,15 +183,14 @@ void OCLPerfMapImageWriteSpeed::run(void) {
|
||||
double sec = timer.GetElapsedTime();
|
||||
|
||||
// Image map write bandwidth in GB/s
|
||||
double perf = ((double)bufSize_ * bufSize_ * formatSize[bufnum_] * numIter *
|
||||
(double)(1e-09)) /
|
||||
sec;
|
||||
double perf =
|
||||
((double)bufSize_ * bufSize_ * formatSize[bufnum_] * numIter * (double)(1e-09)) / sec;
|
||||
|
||||
_perfInfo = (float)perf;
|
||||
|
||||
char buf[256];
|
||||
SNPRINTF(buf, sizeof(buf), " (%4dx%4d) fmt:%s i: %4d (GB/s) ", bufSize_,
|
||||
bufSize_, textFormats[bufnum_], numIter);
|
||||
SNPRINTF(buf, sizeof(buf), " (%4dx%4d) fmt:%s i: %4d (GB/s) ", bufSize_, bufSize_,
|
||||
textFormats[bufnum_], numIter);
|
||||
testDescString = buf;
|
||||
}
|
||||
|
||||
@@ -212,13 +200,11 @@ unsigned int OCLPerfMapImageWriteSpeed::close(void) {
|
||||
}
|
||||
if (outBuffer_) {
|
||||
error_ = _wrapper->clReleaseMemObject(outBuffer_);
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS,
|
||||
"clReleaseMemObject(outBuffer_) failed");
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS, "clReleaseMemObject(outBuffer_) failed");
|
||||
}
|
||||
if (cmd_queue_) {
|
||||
error_ = _wrapper->clReleaseCommandQueue(cmd_queue_);
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS,
|
||||
"clReleaseCommandQueue failed");
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS, "clReleaseCommandQueue failed");
|
||||
}
|
||||
if (context_) {
|
||||
error_ = _wrapper->clReleaseContext(context_);
|
||||
|
||||
Reference in new issue
Zablokuj użytkownika