SWDEV-470698 - fix formatting, add format check workflow (#657)
This commit is contained in:
committed by
GitHub
parent
5840940caa
commit
f7338717ae
@@ -38,11 +38,10 @@
|
||||
|
||||
#define NUM_SIZES 8
|
||||
// 256KB, 1 MB, 4MB, 16 MB
|
||||
static const unsigned int Sizes[NUM_SIZES] = {
|
||||
1024, 4 * 1024, 8 * 1024, 16 * 1024, 262144, 1048576, 4194304, 16777216};
|
||||
static const unsigned int Sizes[NUM_SIZES] = {1024, 4 * 1024, 8 * 1024, 16 * 1024,
|
||||
262144, 1048576, 4194304, 16777216};
|
||||
|
||||
static const unsigned int Iterations[2] = {
|
||||
1, OCLPerfPinnedBufferReadSpeed::NUM_ITER};
|
||||
static const unsigned int Iterations[2] = {1, OCLPerfPinnedBufferReadSpeed::NUM_ITER};
|
||||
#define NUM_OFFSETS 2
|
||||
static const unsigned int offsets[NUM_OFFSETS] = {0, 16};
|
||||
#define NUM_SUBTESTS (1 + NUM_OFFSETS)
|
||||
@@ -57,19 +56,17 @@ OCLPerfPinnedBufferReadSpeed::OCLPerfPinnedBufferReadSpeed() {
|
||||
|
||||
OCLPerfPinnedBufferReadSpeed::~OCLPerfPinnedBufferReadSpeed() {}
|
||||
|
||||
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) {}
|
||||
|
||||
const char *blkStr[2] = {"n/b", "blk"};
|
||||
const char* blkStr[2] = {"n/b", "blk"};
|
||||
|
||||
void OCLPerfPinnedBufferReadSpeed::open(unsigned int test, char *units,
|
||||
double &conversion,
|
||||
void OCLPerfPinnedBufferReadSpeed::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;
|
||||
@@ -91,7 +88,7 @@ void OCLPerfPinnedBufferReadSpeed::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
|
||||
@@ -101,13 +98,11 @@ void OCLPerfPinnedBufferReadSpeed::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");
|
||||
@@ -131,8 +126,8 @@ void OCLPerfPinnedBufferReadSpeed::open(unsigned int test, char *units,
|
||||
CHECK_RESULT(platform == 0, "Couldn't find AMD platform, cannot proceed");
|
||||
|
||||
char getVersion[128];
|
||||
error_ = _wrapper->clGetPlatformInfo(platform, CL_PLATFORM_VERSION,
|
||||
sizeof(getVersion), getVersion, NULL);
|
||||
error_ = _wrapper->clGetPlatformInfo(platform, CL_PLATFORM_VERSION, sizeof(getVersion),
|
||||
getVersion, NULL);
|
||||
CHECK_RESULT(error_ != CL_SUCCESS, "clGetPlatformInfo failed");
|
||||
platformVersion[0] = getVersion[7];
|
||||
platformVersion[1] = getVersion[8];
|
||||
@@ -150,23 +145,20 @@ void OCLPerfPinnedBufferReadSpeed::open(unsigned int test, char *units,
|
||||
if (_openTest < blockedSubtests) {
|
||||
numIter = Iterations[_openTest / (NUM_SIZES * NUM_SUBTESTS)];
|
||||
} else {
|
||||
numIter = 4 * OCLPerfPinnedBufferReadSpeed::NUM_ITER /
|
||||
((_openTest % NUM_SIZES) + 1);
|
||||
numIter = 4 * OCLPerfPinnedBufferReadSpeed::NUM_ITER / ((_openTest % NUM_SIZES) + 1);
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -177,30 +169,24 @@ void OCLPerfPinnedBufferReadSpeed::open(unsigned int test, char *units,
|
||||
flags |= CL_MEM_ALLOC_HOST_PTR;
|
||||
} else if (useHostPtr) {
|
||||
flags |= CL_MEM_USE_HOST_PTR;
|
||||
hostMem = (char *)malloc(bufSize_ + alignment - 1 + offset);
|
||||
hostMem = (char*)malloc(bufSize_ + alignment - 1 + offset);
|
||||
CHECK_RESULT(hostMem == 0, "malloc(hostMem) failed");
|
||||
alignedMem =
|
||||
(char *)((((intptr_t)hostMem + alignment - 1) & ~(alignment - 1)) +
|
||||
offset);
|
||||
alignedMem = (char*)((((intptr_t)hostMem + alignment - 1) & ~(alignment - 1)) + offset);
|
||||
}
|
||||
inBuffer_ = _wrapper->clCreateBuffer(context_, 0, bufSize_, 0, &error_);
|
||||
CHECK_RESULT(inBuffer_ == 0, "clCreateBuffer(outBuffer) failed");
|
||||
outBuffer_ =
|
||||
_wrapper->clCreateBuffer(context_, flags, bufSize_, alignedMem, &error_);
|
||||
outBuffer_ = _wrapper->clCreateBuffer(context_, flags, bufSize_, alignedMem, &error_);
|
||||
CHECK_RESULT(outBuffer_ == 0, "clCreateBuffer(outBuffer) failed");
|
||||
|
||||
// Force memory to be on GPU if possible
|
||||
{
|
||||
cl_mem memBuffer =
|
||||
_wrapper->clCreateBuffer(context_, 0, bufSize_, NULL, &error_);
|
||||
cl_mem memBuffer = _wrapper->clCreateBuffer(context_, 0, bufSize_, NULL, &error_);
|
||||
CHECK_RESULT(memBuffer == 0, "clCreateBuffer(memBuffer) failed");
|
||||
|
||||
_wrapper->clEnqueueCopyBuffer(cmd_queue_, memBuffer, outBuffer_, 0, 0,
|
||||
bufSize_, 0, NULL, NULL);
|
||||
_wrapper->clEnqueueCopyBuffer(cmd_queue_, memBuffer, outBuffer_, 0, 0, bufSize_, 0, NULL, NULL);
|
||||
_wrapper->clFinish(cmd_queue_);
|
||||
|
||||
_wrapper->clEnqueueCopyBuffer(cmd_queue_, memBuffer, inBuffer_, 0, 0,
|
||||
bufSize_, 0, NULL, NULL);
|
||||
_wrapper->clEnqueueCopyBuffer(cmd_queue_, memBuffer, inBuffer_, 0, 0, bufSize_, 0, NULL, NULL);
|
||||
_wrapper->clFinish(cmd_queue_);
|
||||
|
||||
_wrapper->clReleaseMemObject(memBuffer);
|
||||
@@ -209,23 +195,22 @@ void OCLPerfPinnedBufferReadSpeed::open(unsigned int test, char *units,
|
||||
|
||||
void OCLPerfPinnedBufferReadSpeed::run(void) {
|
||||
CPerfCounter timer;
|
||||
void *mem =
|
||||
_wrapper->clEnqueueMapBuffer(cmd_queue_, outBuffer_, CL_TRUE, CL_MAP_READ,
|
||||
0, bufSize_, 0, NULL, NULL, &error_);
|
||||
void* mem = _wrapper->clEnqueueMapBuffer(cmd_queue_, outBuffer_, CL_TRUE, CL_MAP_READ, 0,
|
||||
bufSize_, 0, NULL, NULL, &error_);
|
||||
CHECK_RESULT(error_, "clEnqueueMapBuffer failed");
|
||||
cl_bool blocking = (_openTest < blockedSubtests) ? CL_TRUE : CL_FALSE;
|
||||
|
||||
// Warm up
|
||||
error_ = _wrapper->clEnqueueReadBuffer(cmd_queue_, inBuffer_, CL_TRUE, 0,
|
||||
bufSize_, mem, 0, NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueReadBuffer(cmd_queue_, inBuffer_, CL_TRUE, 0, bufSize_, mem, 0, NULL,
|
||||
NULL);
|
||||
|
||||
CHECK_RESULT(error_, "clEnqueueReadBuffer failed");
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
for (unsigned int i = 0; i < numIter; i++) {
|
||||
error_ = _wrapper->clEnqueueReadBuffer(cmd_queue_, inBuffer_, blocking, 0,
|
||||
bufSize_, mem, 0, NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueReadBuffer(cmd_queue_, inBuffer_, blocking, 0, bufSize_, mem, 0,
|
||||
NULL, NULL);
|
||||
CHECK_RESULT(error_, "clEnqueueReadBuffer failed");
|
||||
}
|
||||
|
||||
@@ -246,12 +231,11 @@ void OCLPerfPinnedBufferReadSpeed::run(void) {
|
||||
SNPRINTF(str, sizeof(str), "off: %4d USE_HOST_PTR (GB/s)", offset);
|
||||
}
|
||||
char buf[256];
|
||||
SNPRINTF(buf, sizeof(buf), " (%8d bytes) %3s i: %4d %31s ", bufSize_,
|
||||
blkStr[blocking], numIter, str);
|
||||
SNPRINTF(buf, sizeof(buf), " (%8d bytes) %3s i: %4d %31s ", bufSize_, blkStr[blocking], numIter,
|
||||
str);
|
||||
testDescString = buf;
|
||||
|
||||
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, outBuffer_, mem, 0,
|
||||
NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, outBuffer_, mem, 0, NULL, NULL);
|
||||
CHECK_RESULT(error_, "clEnqueueUnmapMemObject failed");
|
||||
}
|
||||
|
||||
@@ -259,18 +243,15 @@ unsigned int OCLPerfPinnedBufferReadSpeed::close(void) {
|
||||
_wrapper->clFinish(cmd_queue_);
|
||||
if (inBuffer_) {
|
||||
error_ = _wrapper->clReleaseMemObject(inBuffer_);
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS,
|
||||
"clReleaseMemObject(inBuffer_) failed");
|
||||
CHECK_RESULT_NO_RETURN(error_ != CL_SUCCESS, "clReleaseMemObject(inBuffer_) failed");
|
||||
}
|
||||
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_);
|
||||
@@ -285,9 +266,8 @@ unsigned int OCLPerfPinnedBufferReadSpeed::close(void) {
|
||||
|
||||
void OCLPerfPinnedBufferReadRectSpeed::run(void) {
|
||||
CPerfCounter timer;
|
||||
void *mem =
|
||||
_wrapper->clEnqueueMapBuffer(cmd_queue_, outBuffer_, CL_TRUE, CL_MAP_READ,
|
||||
0, bufSize_, 0, NULL, NULL, &error_);
|
||||
void* mem = _wrapper->clEnqueueMapBuffer(cmd_queue_, outBuffer_, CL_TRUE, CL_MAP_READ, 0,
|
||||
bufSize_, 0, NULL, NULL, &error_);
|
||||
CHECK_RESULT(error_, "clEnqueueMapBuffer failed");
|
||||
size_t width = static_cast<size_t>(sqrt(static_cast<float>(bufSize_)));
|
||||
cl_bool blocking = (_openTest < blockedSubtests) ? CL_TRUE : CL_FALSE;
|
||||
@@ -304,18 +284,17 @@ void OCLPerfPinnedBufferReadRectSpeed::run(void) {
|
||||
return;
|
||||
}
|
||||
// Warm up
|
||||
error_ = _wrapper->clEnqueueReadBufferRect(
|
||||
cmd_queue_, inBuffer_, CL_TRUE, bufOrigin, hostOrigin, region, width, 0,
|
||||
width, 0, mem, 0, NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueReadBufferRect(cmd_queue_, inBuffer_, CL_TRUE, bufOrigin, hostOrigin,
|
||||
region, width, 0, width, 0, mem, 0, NULL, NULL);
|
||||
|
||||
CHECK_RESULT(error_, "clEnqueueReadBufferRect failed");
|
||||
|
||||
timer.Reset();
|
||||
timer.Start();
|
||||
for (unsigned int i = 0; i < testNumIter; i++) {
|
||||
error_ = _wrapper->clEnqueueReadBufferRect(
|
||||
cmd_queue_, inBuffer_, blocking, bufOrigin, hostOrigin, region, width,
|
||||
0, width, 0, mem, 0, NULL, NULL);
|
||||
error_ =
|
||||
_wrapper->clEnqueueReadBufferRect(cmd_queue_, inBuffer_, blocking, bufOrigin, hostOrigin,
|
||||
region, width, 0, width, 0, mem, 0, NULL, NULL);
|
||||
CHECK_RESULT(error_, "clEnqueueReadBufferRect failed");
|
||||
}
|
||||
|
||||
@@ -337,11 +316,10 @@ void OCLPerfPinnedBufferReadRectSpeed::run(void) {
|
||||
SNPRINTF(str, sizeof(str), "off: %4d USE_HOST_PTR (GB/s)", offset);
|
||||
}
|
||||
char buf[256];
|
||||
SNPRINTF(buf, sizeof(buf), " (%8d bytes) %3s i: %4d %31s ", bufSize_,
|
||||
blkStr[blocking], testNumIter, str);
|
||||
SNPRINTF(buf, sizeof(buf), " (%8d bytes) %3s i: %4d %31s ", bufSize_, blkStr[blocking],
|
||||
testNumIter, str);
|
||||
testDescString = buf;
|
||||
|
||||
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, outBuffer_, mem, 0,
|
||||
NULL, NULL);
|
||||
error_ = _wrapper->clEnqueueUnmapMemObject(cmd_queue_, outBuffer_, mem, 0, NULL, NULL);
|
||||
CHECK_RESULT(error_, "clEnqueueUnmapMemObject failed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user