Skip to content

Simplify OpenCL info dumping code#15814

Merged
opencv-pushbot merged 1 commit into3.4from
unknown repository
Nov 6, 2019
Merged

Simplify OpenCL info dumping code#15814
opencv-pushbot merged 1 commit into3.4from
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Oct 30, 2019

Simplify OpenCL info dumping code:

  • Reduce code nesting
  • Drop redundant .c_str() calls

Just a cleanup. Makes line lengths more reasonable.

{
platform->getDevice(current_device, j);
const char* deviceTypeStr = (current_device.type() == Device::TYPE_CPU) ? "CPU" :
(current_device.type() == Device::TYPE_GPU ? current_device.hostUnifiedMemory() ? "iGPU" : "dGPU" : "unknown");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines would benefit of even further refactoring, consider extracting a function for getting deviceTypeStr

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to avoid touching that part, because device.type() looks odd to me. It's type is int and not cl_device_type. It's also different from Device::TYPE_* enum, because condition of having iGPU is "device.type() == Device::TYPE_GPU && device.hostUnifiedMemory()" instead of "device.type() == Device::TYPE_IGPU".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just did this refactoring in #15883. I would appreciate a review from you!

@cbachhuber
Copy link
Copy Markdown
Contributor

Thank you for this PR, good work!

* Reduce code nesting
* Drop redundant .c_str() calls
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

BTW, try to avoid huge patches which don't fix anything

@opencv-pushbot opencv-pushbot merged commit 6d5b900 into opencv:3.4 Nov 6, 2019
@ghost ghost deleted the 3.4-ocl-cleanup branch November 6, 2019 12:18
@alalek alalek mentioned this pull request Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants