SWDEV-470698 - fix formatting, add format check workflow (#657)
This commit is contained in:
committed by
GitHub
parent
5840940caa
commit
f7338717ae
@@ -42,11 +42,10 @@ typedef struct {
|
||||
} testStruct;
|
||||
|
||||
testStruct testList[] = {
|
||||
{1, -1}, {1, -1}, {10, 1}, {10, -1}, {100, 1},
|
||||
{100, 10}, {100, -1}, {1000, 1}, {1000, 10}, {1000, 100},
|
||||
{1000, -1}, {10000, 1}, {10000, 10}, {10000, 100}, {10000, 1000},
|
||||
{10000, -1}, {100000, 1}, {100000, 10}, {100000, 100}, {100000, 1000},
|
||||
{100000, 10000}, {100000, -1},
|
||||
{1, -1}, {1, -1}, {10, 1}, {10, -1}, {100, 1}, {100, 10},
|
||||
{100, -1}, {1000, 1}, {1000, 10}, {1000, 100}, {1000, -1}, {10000, 1},
|
||||
{10000, 10}, {10000, 100}, {10000, 1000}, {10000, -1}, {100000, 1}, {100000, 10},
|
||||
{100000, 100}, {100000, 1000}, {100000, 10000}, {100000, -1},
|
||||
};
|
||||
|
||||
unsigned int mapTestList[] = {1, 1, 10, 100, 1000, 10000, 100000};
|
||||
@@ -69,16 +68,15 @@ OCLPerfDispatchSpeed::OCLPerfDispatchSpeed() {
|
||||
|
||||
OCLPerfDispatchSpeed::~OCLPerfDispatchSpeed() {}
|
||||
|
||||
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 OCLPerfDispatchSpeed::open(unsigned int test, char *units,
|
||||
double &conversion, unsigned int deviceId) {
|
||||
void OCLPerfDispatchSpeed::open(unsigned int test, char* units, double& conversion,
|
||||
unsigned int deviceId) {
|
||||
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;
|
||||
@@ -105,7 +103,7 @@ void OCLPerfDispatchSpeed::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
|
||||
@@ -115,13 +113,11 @@ void OCLPerfDispatchSpeed::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], type_, 0, NULL,
|
||||
&num_devices);
|
||||
error_ = _wrapper->clGetDeviceIDs(platforms[_platformIndex], type_, 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");
|
||||
@@ -145,19 +141,17 @@ void OCLPerfDispatchSpeed::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, type_, num_devices, devices, NULL);
|
||||
error_ = _wrapper->clGetDeviceIDs(platform, type_, num_devices, devices, NULL);
|
||||
CHECK_RESULT(error_ != CL_SUCCESS, "clGetDeviceIDs failed");
|
||||
|
||||
CHECK_RESULT(_deviceId >= num_devices, "Requested deviceID not available");
|
||||
device = devices[_deviceId];
|
||||
|
||||
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);
|
||||
@@ -167,9 +161,8 @@ void OCLPerfDispatchSpeed::open(unsigned int test, char *units,
|
||||
CHECK_RESULT(outBuffer_ == 0, "clCreateBuffer(outBuffer) failed");
|
||||
|
||||
genShader();
|
||||
char *tmp = (char *)shader_.c_str();
|
||||
program_ = _wrapper->clCreateProgramWithSource(
|
||||
context_, 1, (const char **)&tmp, NULL, &error_);
|
||||
char* tmp = (char*)shader_.c_str();
|
||||
program_ = _wrapper->clCreateProgramWithSource(context_, 1, (const char**)&tmp, NULL, &error_);
|
||||
CHECK_RESULT(program_ == 0, "clCreateProgramWithSource failed");
|
||||
|
||||
error_ = _wrapper->clBuildProgram(program_, 1, &device, "", NULL, NULL);
|
||||
@@ -177,9 +170,8 @@ void OCLPerfDispatchSpeed::open(unsigned int test, char *units,
|
||||
if (error_ != CL_SUCCESS) {
|
||||
cl_int intError;
|
||||
char log[16384];
|
||||
intError =
|
||||
_wrapper->clGetProgramBuildInfo(program_, device, CL_PROGRAM_BUILD_LOG,
|
||||
16384 * sizeof(char), log, NULL);
|
||||
intError = _wrapper->clGetProgramBuildInfo(program_, device, CL_PROGRAM_BUILD_LOG,
|
||||
16384 * sizeof(char), log, NULL);
|
||||
printf("Build error -> %s\n", log);
|
||||
|
||||
CHECK_RESULT(0, "clBuildProgram failed");
|
||||
@@ -187,8 +179,7 @@ void OCLPerfDispatchSpeed::open(unsigned int test, char *units,
|
||||
kernel_ = _wrapper->clCreateKernel(program_, "_dispatchSpeed", &error_);
|
||||
CHECK_RESULT(kernel_ == 0, "clCreateKernel failed");
|
||||
|
||||
error_ =
|
||||
_wrapper->clSetKernelArg(kernel_, 0, sizeof(cl_mem), (void *)&outBuffer_);
|
||||
error_ = _wrapper->clSetKernelArg(kernel_, 0, sizeof(cl_mem), (void*)&outBuffer_);
|
||||
}
|
||||
|
||||
void OCLPerfDispatchSpeed::run(void) {
|
||||
@@ -203,9 +194,9 @@ void OCLPerfDispatchSpeed::run(void) {
|
||||
cl_int eventStatus;
|
||||
|
||||
if (doWarmup) {
|
||||
error_ = _wrapper->clEnqueueNDRangeKernel(
|
||||
cmd_queue_, kernel_, 1, NULL, (const size_t *)global_work_size,
|
||||
(const size_t *)local_work_size, 0, NULL, &event);
|
||||
error_ = _wrapper->clEnqueueNDRangeKernel(cmd_queue_, kernel_, 1, NULL,
|
||||
(const size_t*)global_work_size,
|
||||
(const size_t*)local_work_size, 0, NULL, &event);
|
||||
|
||||
CHECK_RESULT(error_, "clEnqueueNDRangeKernel failed");
|
||||
_wrapper->clFinish(cmd_queue_);
|
||||
@@ -214,24 +205,21 @@ void OCLPerfDispatchSpeed::run(void) {
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
for (unsigned int i = 0; i < testList[_openTest].iterations; i++) {
|
||||
error_ = _wrapper->clEnqueueNDRangeKernel(
|
||||
cmd_queue_, kernel_, 1, NULL, (const size_t *)global_work_size,
|
||||
(const size_t *)local_work_size, 0, NULL, &event);
|
||||
error_ = _wrapper->clEnqueueNDRangeKernel(cmd_queue_, kernel_, 1, NULL,
|
||||
(const size_t*)global_work_size,
|
||||
(const size_t*)local_work_size, 0, NULL, &event);
|
||||
|
||||
CHECK_RESULT(error_, "clEnqueueNDRangeKernel failed");
|
||||
if ((testList[_openTest].flushEvery > 0) &&
|
||||
(((i + 1) % testList[_openTest].flushEvery) == 0)) {
|
||||
if ((testList[_openTest].flushEvery > 0) && (((i + 1) % testList[_openTest].flushEvery) == 0)) {
|
||||
if (sleep) {
|
||||
_wrapper->clFinish(cmd_queue_);
|
||||
} else {
|
||||
_wrapper->clFlush(cmd_queue_);
|
||||
error_ =
|
||||
_wrapper->clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||
sizeof(cl_int), &eventStatus, NULL);
|
||||
error_ = _wrapper->clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(cl_int),
|
||||
&eventStatus, NULL);
|
||||
while (eventStatus > 0) {
|
||||
error_ =
|
||||
_wrapper->clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||
sizeof(cl_int), &eventStatus, NULL);
|
||||
error_ = _wrapper->clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||
sizeof(cl_int), &eventStatus, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,12 +231,11 @@ void OCLPerfDispatchSpeed::run(void) {
|
||||
_wrapper->clFinish(cmd_queue_);
|
||||
} else {
|
||||
_wrapper->clFlush(cmd_queue_);
|
||||
error_ = _wrapper->clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||
sizeof(cl_int), &eventStatus, NULL);
|
||||
error_ = _wrapper->clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(cl_int),
|
||||
&eventStatus, NULL);
|
||||
while (eventStatus > 0) {
|
||||
error_ =
|
||||
_wrapper->clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS,
|
||||
sizeof(cl_int), &eventStatus, NULL);
|
||||
error_ = _wrapper->clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(cl_int),
|
||||
&eventStatus, NULL);
|
||||
}
|
||||
}
|
||||
_wrapper->clReleaseEvent(event);
|
||||
@@ -258,10 +245,10 @@ void OCLPerfDispatchSpeed::run(void) {
|
||||
|
||||
// microseconds per launch
|
||||
double perf = (1000000.f * sec / testList[_openTest].iterations);
|
||||
const char *waitType;
|
||||
const char *extraChar;
|
||||
const char *n;
|
||||
const char *warmup;
|
||||
const char* waitType;
|
||||
const char* extraChar;
|
||||
const char* n;
|
||||
const char* warmup;
|
||||
if (sleep) {
|
||||
waitType = "sleep";
|
||||
extraChar = "";
|
||||
@@ -280,13 +267,10 @@ void OCLPerfDispatchSpeed::run(void) {
|
||||
_perfInfo = (float)perf;
|
||||
char buf[256];
|
||||
if (testList[_openTest].flushEvery > 0) {
|
||||
SNPRINTF(buf, sizeof(buf),
|
||||
" %7d dispatches %s%sing every %5d %6s (us/disp)",
|
||||
testList[_openTest].iterations, waitType, n,
|
||||
testList[_openTest].flushEvery, warmup);
|
||||
SNPRINTF(buf, sizeof(buf), " %7d dispatches %s%sing every %5d %6s (us/disp)",
|
||||
testList[_openTest].iterations, waitType, n, testList[_openTest].flushEvery, warmup);
|
||||
} else {
|
||||
SNPRINTF(buf, sizeof(buf),
|
||||
" %7d dispatches (%s%s) %6s (us/disp)",
|
||||
SNPRINTF(buf, sizeof(buf), " %7d dispatches (%s%s) %6s (us/disp)",
|
||||
testList[_openTest].iterations, waitType, extraChar, warmup);
|
||||
}
|
||||
testDescString = buf;
|
||||
@@ -295,8 +279,7 @@ void OCLPerfDispatchSpeed::run(void) {
|
||||
unsigned int OCLPerfDispatchSpeed::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 (kernel_) {
|
||||
error_ = _wrapper->clReleaseKernel(kernel_);
|
||||
@@ -308,8 +291,7 @@ unsigned int OCLPerfDispatchSpeed::close(void) {
|
||||
}
|
||||
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_);
|
||||
@@ -326,11 +308,9 @@ OCLPerfMapDispatchSpeed::OCLPerfMapDispatchSpeed() {
|
||||
|
||||
void OCLPerfMapDispatchSpeed::run(void) {
|
||||
cl_mem outBuffer;
|
||||
outBuffer = _wrapper->clCreateBuffer(context_, CL_MEM_ALLOC_HOST_PTR,
|
||||
bufSize_, NULL, &error_);
|
||||
outBuffer = _wrapper->clCreateBuffer(context_, CL_MEM_ALLOC_HOST_PTR, bufSize_, NULL, &error_);
|
||||
CHECK_RESULT(outBuffer_ == 0, "clCreateBuffer(outBuffer) failed");
|
||||
error_ =
|
||||
_wrapper->clSetKernelArg(kernel_, 0, sizeof(cl_mem), (void *)&outBuffer);
|
||||
error_ = _wrapper->clSetKernelArg(kernel_, 0, sizeof(cl_mem), (void*)&outBuffer);
|
||||
|
||||
int global = bufSize_ / sizeof(cl_float);
|
||||
int local = 64;
|
||||
@@ -341,9 +321,9 @@ void OCLPerfMapDispatchSpeed::run(void) {
|
||||
CPerfCounter timer;
|
||||
|
||||
if (doWarmup) {
|
||||
error_ = _wrapper->clEnqueueNDRangeKernel(
|
||||
cmd_queue_, kernel_, 1, NULL, (const size_t *)global_work_size,
|
||||
(const size_t *)local_work_size, 0, NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueNDRangeKernel(cmd_queue_, kernel_, 1, NULL,
|
||||
(const size_t*)global_work_size,
|
||||
(const size_t*)local_work_size, 0, NULL, NULL);
|
||||
|
||||
CHECK_RESULT(error_, "clEnqueueNDRangeKernel failed");
|
||||
_wrapper->clFinish(cmd_queue_);
|
||||
@@ -351,19 +331,18 @@ void OCLPerfMapDispatchSpeed::run(void) {
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
void *mem;
|
||||
void* mem;
|
||||
for (unsigned int i = 0; i < mapTestList[_openTest]; i++) {
|
||||
mem = _wrapper->clEnqueueMapBuffer(cmd_queue_, outBuffer, CL_TRUE,
|
||||
CL_MAP_WRITE_INVALIDATE_REGION, 0,
|
||||
bufSize_, 0, NULL, NULL, &error_);
|
||||
mem =
|
||||
_wrapper->clEnqueueMapBuffer(cmd_queue_, outBuffer, CL_TRUE, CL_MAP_WRITE_INVALIDATE_REGION,
|
||||
0, bufSize_, 0, NULL, NULL, &error_);
|
||||
|
||||
CHECK_RESULT(error_, "clEnqueueMapBuffer 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->clEnqueueNDRangeKernel(
|
||||
cmd_queue_, kernel_, 1, NULL, (const size_t *)global_work_size,
|
||||
(const size_t *)local_work_size, 0, NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueNDRangeKernel(cmd_queue_, kernel_, 1, NULL,
|
||||
(const size_t*)global_work_size,
|
||||
(const size_t*)local_work_size, 0, NULL, NULL);
|
||||
|
||||
CHECK_RESULT(error_, "clEnqueueNDRangeKernel failed");
|
||||
}
|
||||
@@ -374,7 +353,7 @@ void OCLPerfMapDispatchSpeed::run(void) {
|
||||
|
||||
// microseconds per launch
|
||||
double perf = (1000000.f * sec / mapTestList[_openTest]);
|
||||
const char *warmup;
|
||||
const char* warmup;
|
||||
if (doWarmup) {
|
||||
warmup = "warmup";
|
||||
} else {
|
||||
@@ -383,8 +362,8 @@ void OCLPerfMapDispatchSpeed::run(void) {
|
||||
|
||||
_perfInfo = (float)perf;
|
||||
char buf[256];
|
||||
SNPRINTF(buf, sizeof(buf), " %7d maps and dispatches %6s (us/disp)",
|
||||
mapTestList[_openTest], warmup);
|
||||
SNPRINTF(buf, sizeof(buf), " %7d maps and dispatches %6s (us/disp)", mapTestList[_openTest],
|
||||
warmup);
|
||||
testDescString = buf;
|
||||
|
||||
_wrapper->clReleaseMemObject(outBuffer);
|
||||
|
||||
Reference in New Issue
Block a user