summaryrefslogtreecommitdiff
path: root/opencl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-03-28 19:05:23 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-03-28 19:09:23 +0100
commitd0c9cb0c253ea9cff472a811dafb80043d7889a8 (patch)
treed929461e59727b4ebcd5197256d6bad2612b3c8d /opencl
parent3a32d02b618f0b7e41758ec7832bff0051d98c72 (diff)
Clean up C-style casts from pointers to void
Change-Id: I7e6315bf2a2e3d6e089ef8f5eacc69d2b413374a
Diffstat (limited to 'opencl')
-rw-r--r--opencl/inc/opencl_device_selection.h14
-rw-r--r--opencl/source/opencl_device.cxx28
-rw-r--r--opencl/source/openclwrapper.cxx2
3 files changed, 22 insertions, 22 deletions
diff --git a/opencl/inc/opencl_device_selection.h b/opencl/inc/opencl_device_selection.h
index 14ec814682f3..263b8c006b2f 100644
--- a/opencl/inc/opencl_device_selection.h
+++ b/opencl/inc/opencl_device_selection.h
@@ -101,7 +101,7 @@ inline ds_status initDSProfile(ds_profile** p, const char* version)
if (p == NULL) return DS_INVALID_PROFILE;
- profile = (ds_profile*)malloc(sizeof(ds_profile));
+ profile = static_cast<ds_profile*>(malloc(sizeof(ds_profile)));
if (profile == NULL) return DS_MEMORY_ERROR;
memset(profile, 0, sizeof(ds_profile));
@@ -109,7 +109,7 @@ inline ds_status initDSProfile(ds_profile** p, const char* version)
clGetPlatformIDs(0, NULL, &numPlatforms);
if (numPlatforms != 0)
{
- platforms = (cl_platform_id*)malloc(numPlatforms * sizeof(cl_platform_id));
+ platforms = static_cast<cl_platform_id*>(malloc(numPlatforms * sizeof(cl_platform_id)));
if (platforms == NULL)
{
status = DS_MEMORY_ERROR;
@@ -136,7 +136,7 @@ inline ds_status initDSProfile(ds_profile** p, const char* version)
}
if (numDevices != 0)
{
- devices = (cl_device_id*)malloc(numDevices * sizeof(cl_device_id));
+ devices = static_cast<cl_device_id*>(malloc(numDevices * sizeof(cl_device_id)));
if (devices == NULL)
{
status = DS_MEMORY_ERROR;
@@ -145,7 +145,7 @@ inline ds_status initDSProfile(ds_profile** p, const char* version)
}
profile->numDevices = numDevices + 1; // +1 to numDevices to include the native CPU
- profile->devices = (ds_device*)malloc(profile->numDevices * sizeof(ds_device));
+ profile->devices = static_cast<ds_device*>(malloc(profile->numDevices * sizeof(ds_device)));
if (profile->devices == NULL)
{
profile->numDevices = 0;
@@ -185,13 +185,13 @@ inline ds_status initDSProfile(ds_profile** p, const char* version)
clGetDeviceInfo(profile->devices[next].oclDeviceID, CL_DEVICE_NAME
, DS_DEVICE_NAME_LENGTH, &buffer, NULL);
length = strlen(buffer);
- profile->devices[next].oclDeviceName = (char*)malloc(length + 1);
+ profile->devices[next].oclDeviceName = static_cast<char*>(malloc(length + 1));
memcpy(profile->devices[next].oclDeviceName, buffer, length + 1);
clGetDeviceInfo(profile->devices[next].oclDeviceID, CL_DRIVER_VERSION
, DS_DEVICE_NAME_LENGTH, &buffer, NULL);
length = strlen(buffer);
- profile->devices[next].oclDriverVersion = (char*)malloc(length + 1);
+ profile->devices[next].oclDriverVersion = static_cast<char*>(malloc(length + 1));
memcpy(profile->devices[next].oclDriverVersion, buffer, length + 1);
}
}
@@ -390,7 +390,7 @@ inline ds_status readProFile(const char* fileName, char** content, size_t* conte
size = pos;
rewind(input);
- binary = (char*)malloc(size);
+ binary = static_cast<char*>(malloc(size));
if (binary == NULL)
{
fclose(input);
diff --git a/opencl/source/opencl_device.cxx b/opencl/source/opencl_device.cxx
index 2a95d1c4b1a3..fcceb00ebdbb 100644
--- a/opencl/source/opencl_device.cxx
+++ b/opencl/source/opencl_device.cxx
@@ -219,7 +219,7 @@ ds_status releaseScore(void* score)
{
if (NULL != score)
{
- delete (LibreOfficeDeviceScore*)score;
+ delete static_cast<LibreOfficeDeviceScore*>(score);
}
return DS_SUCCESS;
}
@@ -270,8 +270,8 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
{
/* No 64-bit float support */
device->score = (void*)new LibreOfficeDeviceScore;
- ((LibreOfficeDeviceScore*)device->score)->fTime = DBL_MAX;
- ((LibreOfficeDeviceScore*)device->score)->bNoCLErrors = true;
+ static_cast<LibreOfficeDeviceScore*>(device->score)->fTime = DBL_MAX;
+ static_cast<LibreOfficeDeviceScore*>(device->score)->bNoCLErrors = true;
SAL_INFO("opencl.device", "... no fp64 support");
}
else
@@ -295,14 +295,14 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
size_t length;
char* buildLog;
clStatus = clGetProgramBuildInfo(clProgram, device->oclDeviceID, CL_PROGRAM_BUILD_LOG, 0, NULL, &length);
- buildLog = (char*)malloc(length);
+ buildLog = static_cast<char*>(malloc(length));
clGetProgramBuildInfo(clProgram, device->oclDeviceID, CL_PROGRAM_BUILD_LOG, length, buildLog, &length);
SAL_INFO("opencl.device", "Build Errors:\n" << buildLog);
free(buildLog);
device->score = (void*)new LibreOfficeDeviceScore;
- ((LibreOfficeDeviceScore*)device->score)->fTime = DBL_MAX;
- ((LibreOfficeDeviceScore*)device->score)->bNoCLErrors = false;
+ static_cast<LibreOfficeDeviceScore*>(device->score)->fTime = DBL_MAX;
+ static_cast<LibreOfficeDeviceScore*>(device->score)->bNoCLErrors = false;
}
else
{
@@ -311,7 +311,7 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
timerStart(&kernelTime);
/* Run kernel */
- LibreOfficeDeviceEvaluationIO* testData = (LibreOfficeDeviceEvaluationIO*)evalData;
+ LibreOfficeDeviceEvaluationIO* testData = static_cast<LibreOfficeDeviceEvaluationIO*>(evalData);
cl_kernel clKernel = clCreateKernel(clProgram, "DynamicKernel", &clStatus);
DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clCreateKernel");
cl_mem clResult = clCreateBuffer(clContext, CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, sizeof(cl_double) * testData->outputSize, &testData->output[0], &clStatus);
@@ -347,8 +347,8 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
clReleaseKernel(clKernel);
device->score = (void*)new LibreOfficeDeviceScore;
- ((LibreOfficeDeviceScore*)device->score)->fTime = timerCurrent(&kernelTime);
- ((LibreOfficeDeviceScore*)device->score)->bNoCLErrors = true;
+ static_cast<LibreOfficeDeviceScore*>(device->score)->fTime = timerCurrent(&kernelTime);
+ static_cast<LibreOfficeDeviceScore*>(device->score)->bNoCLErrors = true;
}
clReleaseProgram(clProgram);
@@ -363,7 +363,7 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
timer kernelTime;
timerStart(&kernelTime);
- LibreOfficeDeviceEvaluationIO* testData = (LibreOfficeDeviceEvaluationIO*)evalData;
+ LibreOfficeDeviceEvaluationIO* testData = static_cast<LibreOfficeDeviceEvaluationIO*>(evalData);
for (unsigned long j = 0; j < testData->outputSize; j++)
{
double fAverage = 0.0f;
@@ -386,10 +386,10 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
float fInterpretTailFactor = 10.0;
device->score = (void*)new LibreOfficeDeviceScore;
- ((LibreOfficeDeviceScore*)device->score)->fTime = timerCurrent(&kernelTime);
- ((LibreOfficeDeviceScore*)device->score)->bNoCLErrors = true;
+ static_cast<LibreOfficeDeviceScore*>(device->score)->fTime = timerCurrent(&kernelTime);
+ static_cast<LibreOfficeDeviceScore*>(device->score)->bNoCLErrors = true;
- ((LibreOfficeDeviceScore*)device->score)->fTime *= fInterpretTailFactor;
+ static_cast<LibreOfficeDeviceScore*>(device->score)->fTime *= fInterpretTailFactor;
}
return DS_SUCCESS;
}
@@ -403,7 +403,7 @@ ds_status pickBestDevice(ds_profile* profile, int* bestDeviceIdx)
for (unsigned int d = 0; d < profile->numDevices; d++)
{
ds_device device = profile->devices[d];
- LibreOfficeDeviceScore *pScore = (LibreOfficeDeviceScore*)device.score;
+ LibreOfficeDeviceScore *pScore = static_cast<LibreOfficeDeviceScore*>(device.score);
// Check blacklist and whitelist for actual devices
if (device.type == DS_DEVICE_OPENCL_DEVICE)
diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx
index 5f0b9916f471..ad3ead800afa 100644
--- a/opencl/source/openclwrapper.cxx
+++ b/opencl/source/openclwrapper.cxx
@@ -830,7 +830,7 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
// initialisation below.) Because otherwise the code crashes in
// initOpenCLRunEnv(). Confused? You should be.
- gpuEnv.mpArryDevsID = (cl_device_id*) malloc( sizeof(cl_device_id) );
+ gpuEnv.mpArryDevsID = static_cast<cl_device_id*>(malloc( sizeof(cl_device_id) ));
gpuEnv.mpArryDevsID[0] = pDeviceId;
return !initOpenCLRunEnv(0);