Skip to content

OCL: add cache for OpenCL compiled programs#10018

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
alalek:ocl_binary_cache
Nov 23, 2017
Merged

OCL: add cache for OpenCL compiled programs#10018
opencv-pushbot merged 1 commit intoopencv:masterfrom
alalek:ocl_binary_cache

Conversation

@alalek
Copy link
Copy Markdown
Member

@alalek alalek commented Nov 3, 2017

Default cache locations is under:

  • Linux: /home/<user>/.cache/opencv/ (in general)
  • Windows: C:\Users\<user>\AppData\Local\Temp\opencv\
  • MacOSX: $TMPDIR/opencv/
  • Android: no defaults, not used, but can be enabled via environment configuration
  • FreeBSD/other BSD: not tested
  • other(iOS/EMSCRIPTEN/etc): not supported / disabled

Verified on these configuraions:

  • with Intel iGPU (Linux/Windows/MacOSX)
  • with AMD dGPU (Windows)
docker_image-Docs=docs-js
docker_image:Custom=powerpc64le

namespace cv { namespace utils { namespace fs {


CV_EXPORTS bool isExist(const cv::String& path);
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.

it's wrong grammar. I suggest doesExist(), isValidPath(), pathExist(), isFileOrDirectory() etc.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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


struct Impl;
inline Impl* getImpl() const { return (Impl*)p; }
//protected:
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.

why Impl* p is not protected anymore if we have getImpl()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because "p" is not protected initially. It is "TODO" mark for future releases.
Accurate testing of libva / directx / opengl integrations is required before apply this.

* @param configuration_name optional name of configuration parameter name which overrides default behavior.
* @return Path to cache directory. Returns empty string if cache directories support is not available. Returns "disabled" if cache disabled by user.
*/
CV_EXPORTS cv::String getOpenCVCacheDirectory(const char* sub_directory_name, const char* configuration_name = NULL);
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.

should we use getOCLCacheDirectory or getOpenCLCacheDirectory name? I think, using OpenCV word in OpenCV function name is unnecessary

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This function is designed not for OpenCL programs cache only, it can be reused in multiple places (ocl4dnn tuning results cache, probably DL MO cache, etc).
Thanks, renamed to getCacheDirectory (without OpenCV, because we already in cv namespace).

void lock(); //< acquire exclusive (writer) lock
void unlock(); //< release exclusive (writer) lock

void lock_sharable(); //< acquire sharable (reader) lock
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.

We are trying to use mixed case names for methods everywhere in OpenCV. Can we do it here as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is not OpenCV specific name. Also this is not a part of external public API (not available on some platforms).

Renamed to lock_shared() (typo is here) which is used in:


explicit inline optional_lock_guard(Mutex* m) : mutex_(m) { if (mutex_) mutex_->lock(); }

inline ~optional_lock_guard() { if (mutex_) mutex_->unlock(); }
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.

can we use mixed case name for the class?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is not OpenCV specific name and not a part of external public API.

Name is selected to be consistent with declarations above: lock_guard, shared_lock_guard (both have alternative implementation in modern C++ / boost library under the same names).

File is renamed to "lock.private.hpp".

@vpisarev vpisarev self-assigned this Nov 23, 2017
@vpisarev
Copy link
Copy Markdown
Contributor

👍

@opencv-pushbot opencv-pushbot merged commit 8e6280f into opencv:master Nov 23, 2017
@alalek alalek mentioned this pull request May 22, 2021
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants