fix opencl build on OSX (issue 1272)

This commit is contained in:
Zdenko Podobný 2014-08-18 09:37:21 +02:00
parent 524ee27f01
commit 5755a5cecb
2 changed files with 20 additions and 7 deletions

View File

@ -16,6 +16,12 @@
#ifdef USE_OPENCL
#if ON_APPLE
#define TIMESPEC mach_timespec
#else
#define TIMESPEC timespec
#endif
#include "opencl_device_selection.h"
GPUEnv OpenclDevice::gpuEnv;
@ -2661,9 +2667,9 @@ PERF_COUNT_START("HistogramRectOCL")
int requestedOccupancy = 10;
int numWorkGroups = numCUs * requestedOccupancy;
int numThreads = block_size*numWorkGroups;
size_t local_work_size[] = {block_size};
size_t global_work_size[] = {numThreads};
size_t red_global_work_size[] = {block_size*kHistogramSize*bytes_per_pixel};
size_t local_work_size[] = {static_cast<size_t>(block_size)};
size_t global_work_size[] = {static_cast<size_t>(numThreads)};
size_t red_global_work_size[] = {static_cast<size_t>(block_size*kHistogramSize*bytes_per_pixel)};
/* map histogramAllChannels as write only */
int numBins = kHistogramSize*bytes_per_pixel*numWorkGroups;
@ -2980,7 +2986,7 @@ double composeRGBPixelMicroBench( GPUEnv *env, TessScoreEvaluationInputData inpu
LARGE_INTEGER freq, time_funct_start, time_funct_end;
QueryPerformanceFrequency(&freq);
#else
timespec time_funct_start, time_funct_end;
TIMESPEC time_funct_start, time_funct_end;
#endif
// input data
l_uint32 *tiffdata = (l_uint32 *)input.imageData;// same size and random data; data doesn't change workload
@ -3052,7 +3058,7 @@ double histogramRectMicroBench( GPUEnv *env, TessScoreEvaluationInputData input,
LARGE_INTEGER freq, time_funct_start, time_funct_end;
QueryPerformanceFrequency(&freq);
#else
timespec time_funct_start, time_funct_end;
TIMESPEC time_funct_start, time_funct_end;
#endif
unsigned char pixelHi = (unsigned char)255;
@ -3155,7 +3161,7 @@ double thresholdRectToPixMicroBench( GPUEnv *env, TessScoreEvaluationInputData i
LARGE_INTEGER freq, time_funct_start, time_funct_end;
QueryPerformanceFrequency(&freq);
#else
timespec time_funct_start, time_funct_end;
TIMESPEC time_funct_start, time_funct_end;
#endif
// input data
@ -3229,7 +3235,7 @@ double getLineMasksMorphMicroBench( GPUEnv *env, TessScoreEvaluationInputData in
LARGE_INTEGER freq, time_funct_start, time_funct_end;
QueryPerformanceFrequency(&freq);
#else
timespec time_funct_start, time_funct_end;
TIMESPEC time_funct_start, time_funct_end;
#endif
// input data

View File

@ -56,6 +56,13 @@
#include <time.h>
#endif
#if ON_APPLE
#include <mach/clock.h>
#include <mach/mach.h>
#define CLOCK_MONOTONIC SYSTEM_CLOCK
#define clock_gettime clock_get_time
#endif
/************************************************************************************
* enable/disable reporting of performance
* PERF_REPORT_LEVEL