MCPcopy Create free account
hub / github.com/creatale/node-dv / evaluateScoreForDevice

Function evaluateScoreForDevice

deps/tesseract/opencl/openclwrapper.cpp:2557–2609  ·  view source on GitHub ↗

evaluate devices

Source from the content-addressed store, hash-verified

2555
2556// evaluate devices
2557static ds_status evaluateScoreForDevice( ds_device *device, void *inputData) {
2558 // overwrite statuc gpuEnv w/ current device
2559 // so native opencl calls can be used; they use static gpuEnv
2560 printf("\n[DS] Device: \"%s\" (%s) evaluation...\n", device->oclDeviceName, device->type==DS_DEVICE_OPENCL_DEVICE ? "OpenCL" : "Native" );
2561 GPUEnv *env = NULL;
2562 if (device->type == DS_DEVICE_OPENCL_DEVICE) {
2563 env = new GPUEnv;
2564 //printf("[DS] populating tmp GPUEnv from device\n");
2565 populateGPUEnvFromDevice( env, device->oclDeviceID);
2566 env->mnFileCount = 0; //argc;
2567 env->mnKernelCount = 0UL;
2568 //printf("[DS] compiling kernels for tmp GPUEnv\n");
2569 OpenclDevice::gpuEnv = *env;
2570 OpenclDevice::CompileKernelFile(env, "");
2571 }
2572
2573 TessScoreEvaluationInputData *input = (TessScoreEvaluationInputData *)inputData;
2574
2575 // pixReadTiff
2576 double composeRGBPixelTime = composeRGBPixelMicroBench( env, *input, device->type );
2577
2578 // HistogramRect
2579 double histogramRectTime = histogramRectMicroBench( env, *input, device->type );
2580
2581 // ThresholdRectToPix
2582 double thresholdRectToPixTime = thresholdRectToPixMicroBench( env, *input, device->type );
2583
2584 // getLineMasks
2585 double getLineMasksMorphTime = getLineMasksMorphMicroBench( env, *input, device->type );
2586
2587
2588 // weigh times (% of cpu time)
2589 // these weights should be the % execution time that the native cpu code took
2590 float composeRGBPixelWeight = 1.2f;
2591 float histogramRectWeight = 2.4f;
2592 float thresholdRectToPixWeight = 4.5f;
2593 float getLineMasksMorphWeight = 5.0f;
2594
2595 float weightedTime = composeRGBPixelWeight * composeRGBPixelTime +
2596 histogramRectWeight * histogramRectTime +
2597 thresholdRectToPixWeight * thresholdRectToPixTime +
2598 getLineMasksMorphWeight * getLineMasksMorphTime;
2599 device->score = new TessDeviceScore;
2600 ((TessDeviceScore *)device->score)->time = weightedTime;
2601
2602 printf("[DS] Device: \"%s\" (%s) evaluated\n", device->oclDeviceName, device->type==DS_DEVICE_OPENCL_DEVICE ? "OpenCL" : "Native" );
2603 printf("[DS]%25s: %f (w=%.1f)\n", "composeRGBPixel", composeRGBPixelTime, composeRGBPixelWeight );
2604 printf("[DS]%25s: %f (w=%.1f)\n", "HistogramRect", histogramRectTime, histogramRectWeight );
2605 printf("[DS]%25s: %f (w=%.1f)\n", "ThresholdRectToPix", thresholdRectToPixTime, thresholdRectToPixWeight );
2606 printf("[DS]%25s: %f (w=%.1f)\n", "getLineMasksMorph", getLineMasksMorphTime, getLineMasksMorphWeight );
2607 printf("[DS]%25s: %f\n", "Score", ((TessDeviceScore *)device->score)->time );
2608 return DS_SUCCESS;
2609}
2610
2611// initial call to select device
2612ds_device OpenclDevice::getDeviceSelection( ) {

Callers

nothing calls this directly

Calls 5

populateGPUEnvFromDeviceFunction · 0.85
histogramRectMicroBenchFunction · 0.85

Tested by

no test coverage detected