meta_kernel::compile is very slow, even for cached source
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- performance
Research direction
Start by profiling meta_kernel::compile and its reported calls to clCreateKernel, sha1, and program::build_with_source; the issue names no source files or tests. Determine how cached programs still incur repeated kernel creation and hashing, then benchmark that cached path to confirm substantially lower overhead without losing the existing build caching.
Written by the indexing model from the issue text.
Description
Hi,
I am currently benchmarking the overhead of boost::compute. My test-program is computing nothing big and the equivalent cpu program finishes in no measurable runtime. The OpenCL version takes several seconds, so i decided to check with valgrind-callgrind where this time is lost. My program utilizes 11 different kernels and the runtime is the Intel OpenCL cpu implementation. I am using callgrind with O1 optimizations.
71% of total run-time is spent in 8149 calls to meta_kernel::compile.
Inside, we have over all 8149 calls:
total-runtime% function
43.21% clCreateKernel
14.5% compute::detail::sha1::sha1
8.7% program::build_with_source
As a sanity check:
1.6% meta_kernel::source
1.2% clEnqueueNDRangeKernel
so, roughly 58% of total running time is spent on figuring out whether the program is already build and creating the kernel afterwards. Compiling and caching works fine, we have exactly 11 calls to build_with_source.
The problem is that compute assumes that kernels are throw-away objects. This is unfortunately not the case. e.g. on NVIDIA, clCreateKernel is reported to have an overhead of roughly 1ms. My runtime seems to be in the same order. The programs built with meta_kernel have only one kernel function, so one easy workaround would be to cache the kernel together with the program.
Also, sha1 is terribly slow. The hash function should not take an order of magnitude longer than creating the source in the first place.
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 340
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/compute
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
constant_iterator and counting_iterator dereference attempts to bind a const object to a referenceOpen
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
All issues in boostorg/compute
Similar issues
-
new issue
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
llvm/llvm-project#245835 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 72/100
EchoTools/nevr-runtime#2823 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
triton-lang/triton#12945 ·
Maintainers usually reply within 1 day
-
Releases do not move the `latest` Docker tag: the branch `30.12` is taken for the latest release branchPossibly taken @alexey-milovidov claimed this today. Opencomp-ci-infrastructure unexpected behaviour
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ClickHouse/ClickHouse#134282 ·
Maintainers usually reply within 1 day