SWDEV-470698 - fix formatting, add format check workflow (#657)

Этот коммит содержится в:
Danylo Lytovchenko
2025-08-20 16:28:06 +02:00
коммит произвёл GitHub
родитель 5840940caa
Коммит f7338717ae
1574 изменённых файлов: 162972 добавлений и 199346 удалений
+83 -142
Просмотреть файл
@@ -40,7 +40,7 @@ struct PerfCounterInfo {
};
struct DeviceCounterInfo {
const char *deviceName_; //!< Device name
const char* deviceName_; //!< Device name
unsigned int devId_; //!< Device id
PerfCounterInfo perfCounter_[2]; //!< Perforamnce counter array
};
@@ -48,77 +48,45 @@ struct DeviceCounterInfo {
static const DeviceCounterInfo DeviceInfo[]{
#ifdef _WIN32
// GFX11 supports performance counter on Windows only.
{"gfx1100",
11,
{{139, 0, 4}, {74, 0, 13}}}, // {SQWGP, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1101",
11,
{{139, 0, 4}, {74, 0, 13}}}, // {SQWGP, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1102",
11,
{{139, 0, 4}, {74, 0, 13}}}, // {SQWGP, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1103",
11,
{{139, 0, 4}, {74, 0, 13}}}, // {SQWGP, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1100", 11, {{139, 0, 4}, {74, 0, 13}}}, // {SQWGP, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1101", 11, {{139, 0, 4}, {74, 0, 13}}}, // {SQWGP, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1102", 11, {{139, 0, 4}, {74, 0, 13}}}, // {SQWGP, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1103", 11, {{139, 0, 4}, {74, 0, 13}}}, // {SQWGP, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
#endif
// GFX10
{"gfx1000",
10,
{{15, 0, 4}, {74, 0, 13}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1010",
10,
{{15, 0, 4}, {74, 0, 13}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1011",
10,
{{15, 0, 4}, {74, 0, 13}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1012",
10,
{{15, 0, 4}, {74, 0, 13}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1000", 10, {{15, 0, 4}, {74, 0, 13}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1010", 10, {{15, 0, 4}, {74, 0, 13}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1011", 10, {{15, 0, 4}, {74, 0, 13}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
{"gfx1012", 10, {{15, 0, 4}, {74, 0, 13}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {CPC,
// reg 0, Me1 busy for packet decode}
// GFX9
{"gfx900",
9,
{{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx901",
9,
{{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx902",
9,
{{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx903",
9,
{{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx904",
9,
{{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx905",
9,
{{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx906",
9,
{{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx907",
9,
{{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx900", 9, {{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx901", 9, {{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx902", 9, {{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx903", 9, {{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx904", 9, {{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx905", 9, {{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx906", 9, {{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
{"gfx907", 9, {{14, 0, 4}, {97, 1, 2}}}, // {SQ, reg 0, SQ_PERF_SEL_WAVES}, {MCVML2_l,
// reg 0, BigK bank 0 hits}
};
const int DeviceCounterSize = sizeof(DeviceInfo) / sizeof(DeviceCounterInfo);
static const char *sha256_kernel =
static const char* sha256_kernel =
"typedef uint UINT;\n"
"\n"
"#define VECTOR_LEN 1\n"
@@ -368,41 +336,36 @@ OCLPerfCounters::~OCLPerfCounters() {}
bool OCLPerfCounters::setData(cl_mem buffer, unsigned int val) {
bool retVal = false;
unsigned int *data = (unsigned int *)_wrapper->clEnqueueMapBuffer(
cmd_queue_, buffer, true, CL_MAP_WRITE, 0, bufSize_, 0, NULL, NULL,
&error_);
unsigned int* data = (unsigned int*)_wrapper->clEnqueueMapBuffer(
cmd_queue_, buffer, true, CL_MAP_WRITE, 0, bufSize_, 0, NULL, NULL, &error_);
if (error_ != CL_SUCCESS) {
printf("\nError code : %d\n", error_);
} else {
for (unsigned int i = 0; i < width_; i++) data[i] = val;
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, buffer, data, 0,
NULL, NULL);
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, buffer, data, 0, NULL, NULL);
if (error_ == CL_SUCCESS) retVal = true;
}
return retVal;
}
void OCLPerfCounters::checkData(cl_mem buffer) {
unsigned int *data = (unsigned int *)_wrapper->clEnqueueMapBuffer(
cmd_queue_, buffer, true, CL_MAP_READ, 0, bufSize_, 0, NULL, NULL,
&error_);
unsigned int* data = (unsigned int*)_wrapper->clEnqueueMapBuffer(
cmd_queue_, buffer, true, CL_MAP_READ, 0, bufSize_, 0, NULL, NULL, &error_);
for (unsigned int i = 0; i < width_; i++) {
}
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, buffer, data, 0, NULL,
NULL);
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, buffer, data, 0, NULL, NULL);
}
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 OCLPerfCounters::open(unsigned int test, char *units, double &conversion,
void OCLPerfCounters::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;
@@ -434,7 +397,7 @@ void OCLPerfCounters::open(unsigned int test, char *units, double &conversion,
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
@@ -444,13 +407,11 @@ void OCLPerfCounters::open(unsigned int test, char *units, double &conversion,
#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");
@@ -471,15 +432,13 @@ void OCLPerfCounters::open(unsigned int test, char *units, double &conversion,
* If we could find our platform, use it. If not, die as we need the AMD
* platform for these extensions.
*/
CHECK_RESULT(platform == 0,
"Couldn't find platform with GPU devices, cannot proceed");
CHECK_RESULT(platform == 0, "Couldn't find platform with GPU devices, 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");
@@ -487,14 +446,12 @@ void OCLPerfCounters::open(unsigned int test, char *units, double &conversion,
global_device = device;
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");
char charbuf[1024];
size_t retsize;
error_ = _wrapper->clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, 1024,
charbuf, &retsize);
error_ = _wrapper->clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, 1024, charbuf, &retsize);
CHECK_RESULT(error_ != CL_SUCCESS, "clGetDeviceInfo failed");
cmd_queue_ = _wrapper->clCreateCommandQueue(context_, device, 0, NULL);
@@ -504,26 +461,24 @@ void OCLPerfCounters::open(unsigned int test, char *units, double &conversion,
outBuffer_ = new cl_mem[4];
for (int i = 0; i < num_input_buf_; ++i) {
inBuffer_[i] =
_wrapper->clCreateBuffer(context_, 0, bufSize_, NULL, &error_);
inBuffer_[i] = _wrapper->clCreateBuffer(context_, 0, bufSize_, NULL, &error_);
CHECK_RESULT(inBuffer_[i] == 0, "clCreateBuffer(inBuffer) failed");
bool result = setData(inBuffer_[i], 0xdeadbeef);
CHECK_RESULT(result != true, "clEnqueueMapBuffer buffer failed");
}
for (int i = 0; i < num_output_buf_; ++i) {
outBuffer_[i] =
_wrapper->clCreateBuffer(context_, 0, bufSize_, NULL, &error_);
outBuffer_[i] = _wrapper->clCreateBuffer(context_, 0, bufSize_, NULL, &error_);
CHECK_RESULT(outBuffer_[i] == 0, "clCreateBuffer(outBuffer) failed");
bool result = setData(outBuffer_[i], 0xdeadbeef);
CHECK_RESULT(result != true, "clEnqueueMapBuffer buffer failed");
}
program_ = _wrapper->clCreateProgramWithSource(
context_, 1, (const char **)&sha256_kernel, NULL, &error_);
program_ =
_wrapper->clCreateProgramWithSource(context_, 1, (const char**)&sha256_kernel, NULL, &error_);
CHECK_RESULT(program_ == 0, "clCreateProgramWithSource failed");
const char *buildOps = NULL;
const char* buildOps = NULL;
if (isAMD) {
// Enable caching
buildOps = "-fno-alias";
@@ -533,9 +488,8 @@ void OCLPerfCounters::open(unsigned int test, char *units, double &conversion,
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");
@@ -543,18 +497,15 @@ void OCLPerfCounters::open(unsigned int test, char *units, double &conversion,
kernel_ = _wrapper->clCreateKernel(program_, "CryptThread", &error_);
CHECK_RESULT(kernel_ == 0, "clCreateKernel failed");
error_ = _wrapper->clSetKernelArg(kernel_, 0, sizeof(cl_mem),
(void *)&inBuffer_[0]);
error_ = _wrapper->clSetKernelArg(kernel_, 1, sizeof(cl_mem),
(void *)&outBuffer_[0]);
error_ = _wrapper->clSetKernelArg(kernel_, 2, sizeof(cl_uint),
(void *)&blockSize_);
error_ = _wrapper->clSetKernelArg(kernel_, 0, sizeof(cl_mem), (void*)&inBuffer_[0]);
error_ = _wrapper->clSetKernelArg(kernel_, 1, sizeof(cl_mem), (void*)&outBuffer_[0]);
error_ = _wrapper->clSetKernelArg(kernel_, 2, sizeof(cl_uint), (void*)&blockSize_);
// Foo is not part of the original test, this can be used to see how much of
// the performance is limited by fetch. Set foo to 0 and all threads will
// fetch the same 1k block. This way they will all be in cache and hit max
// fetch speed.
unsigned int foo = 1;
error_ = _wrapper->clSetKernelArg(kernel_, 3, sizeof(cl_uint), (void *)&foo);
error_ = _wrapper->clSetKernelArg(kernel_, 3, sizeof(cl_uint), (void*)&foo);
}
void OCLPerfCounters::run(void) {
@@ -582,8 +533,7 @@ void OCLPerfCounters::run(void) {
properties[2][0] = CL_PERFCOUNTER_GPU_EVENT_INDEX;
properties[3][0] = CL_PERFCOUNTER_NONE;
err = _wrapper->clGetDeviceInfo(global_device, CL_DEVICE_NAME, 1024,
deviceName, NULL);
err = _wrapper->clGetDeviceInfo(global_device, CL_DEVICE_NAME, 1024, deviceName, NULL);
CHECK_RESULT(err != CL_SUCCESS, "clGetDeviceInfo failed");
// Remove target ID features
@@ -607,52 +557,46 @@ void OCLPerfCounters::run(void) {
if (!found) {
char msg[256];
SNPRINTF(msg, sizeof(msg), "Unsupported device(%s) for the test!\t",
deviceName);
SNPRINTF(msg, sizeof(msg), "Unsupported device(%s) for the test!\t", deviceName);
testDescString = msg;
return;
}
perfCounter =
_wrapper->clCreatePerfCounterAMD(global_device, &properties[0][0], &err);
perfCounter = _wrapper->clCreatePerfCounterAMD(global_device, &properties[0][0], &err);
CHECK_RESULT(err != CL_SUCCESS, "Create PerfCounter failed\n");
// set clock mode
cl_set_device_clock_mode_input_amd setClockModeInput;
setClockModeInput.clock_mode = CL_DEVICE_CLOCK_MODE_PROFILING_AMD;
cl_set_device_clock_mode_output_amd setClockModeOutput = {};
_wrapper->clSetDeviceClockModeAMD(global_device, setClockModeInput,
&setClockModeOutput);
_wrapper->clSetDeviceClockModeAMD(global_device, setClockModeInput, &setClockModeOutput);
_wrapper->clEnqueueBeginPerfCounterAMD(cmd_queue_, 1, &perfCounter, 0, NULL,
NULL);
_wrapper->clEnqueueBeginPerfCounterAMD(cmd_queue_, 1, &perfCounter, 0, NULL, NULL);
for (unsigned int i = 0; i < MAX_ITERATIONS; i++) {
error_ = _wrapper->clSetKernelArg(kernel_, 0, sizeof(cl_mem),
(void *)&inBuffer_[i % num_input_buf_]);
error_ =
_wrapper->clSetKernelArg(kernel_, 0, sizeof(cl_mem), (void*)&inBuffer_[i % num_input_buf_]);
error_ = _wrapper->clSetKernelArg(kernel_, 1, sizeof(cl_mem),
(void *)&outBuffer_[i % num_output_buf_]);
(void*)&outBuffer_[i % num_output_buf_]);
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_ != CL_SUCCESS, "clEnqueueNDRangeKernel failed");
_wrapper->clEnqueueEndPerfCounterAMD(cmd_queue_, 1, &perfCounter, 0, NULL,
&perfEvent);
_wrapper->clEnqueueEndPerfCounterAMD(cmd_queue_, 1, &perfCounter, 0, NULL, &perfEvent);
clWaitForEvents(1, &perfEvent);
// set clock mode to default
setClockModeInput.clock_mode = CL_DEVICE_CLOCK_MODE_DEFAULT_AMD;
_wrapper->clSetDeviceClockModeAMD(global_device, setClockModeInput,
&setClockModeOutput);
_wrapper->clSetDeviceClockModeAMD(global_device, setClockModeInput, &setClockModeOutput);
error_ = _wrapper->clGetPerfCounterInfoAMD(perfCounter, CL_PERFCOUNTER_DATA,
sizeof(cl_ulong), &result, NULL);
error_ = _wrapper->clGetPerfCounterInfoAMD(perfCounter, CL_PERFCOUNTER_DATA, sizeof(cl_ulong),
&result, NULL);
CHECK_RESULT(error_ != CL_SUCCESS,
"clGetPerfCounterInfoAMD failed (Hint (Linux): install hsa-amd-aqlprofile)\n");
"clGetPerfCounterInfoAMD failed (Hint (Linux): install hsa-amd-aqlprofile)\n");
err = _wrapper->clReleasePerfCounterAMD(perfCounter);
CHECK_RESULT(err != CL_SUCCESS, "Release PerfCounter failed\n");
@@ -680,16 +624,14 @@ unsigned int OCLPerfCounters::close(void) {
if (inBuffer_) {
for (int i = 0; i < num_input_buf_; ++i) {
error_ = _wrapper->clReleaseMemObject(inBuffer_[i]);
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS,
"clReleaseMemObject(inBuffer_) failed");
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS, "clReleaseMemObject(inBuffer_) failed");
}
delete[] inBuffer_;
}
if (outBuffer_) {
for (int i = 0; i < num_output_buf_; ++i) {
error_ = _wrapper->clReleaseMemObject(outBuffer_[i]);
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS,
"clReleaseMemObject(outBuffer_) failed");
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS, "clReleaseMemObject(outBuffer_) failed");
}
delete[] outBuffer_;
}
@@ -703,8 +645,7 @@ unsigned int OCLPerfCounters::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_);