GC-GPU integration#169
Conversation
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Co-authored-by: Andrey Pavlenko <andrey.a.pavlenko@gmail.com> Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
| shape(module_input_shape.begin(), module_input_shape.end()) { | ||
| if (shape.size() != tensor.get_shape().size()) { | ||
| // validate that the shape difference is due to trailing '1's | ||
| for (size_t i = 0; i < shape.size(); ++i) { | ||
| if (shape[i] != tensor.get_shape()[i]) { | ||
| OPENVINO_THROW("Mismatch in shape sizes"); | ||
| } | ||
| } | ||
| for (size_t i = shape.size(); i < tensor.get_shape().size(); ++i) { | ||
| if (tensor.get_shape()[i] != 1) { | ||
| OPENVINO_THROW("Mismatch in shape sizes"); | ||
| } | ||
| } | ||
| } | ||
| strides.resize(shape.size()); |
There was a problem hiding this comment.
This is needed due to the fact that GPU memory formats could hold at least 4-dimensions, causing trailing extra dims (<64x128x1x1> instead of <64x128>). This code compares input tensors' dimensions with the input dimensions of a MLIR module and trims extra dims.
| @@ -38,21 +51,71 @@ void CreateMLIRSubgraphOp(ProgramBuilder& p, const std::shared_ptr<ov::op::mlir: | |||
|
|
|||
There was a problem hiding this comment.
We probably don't need this synchronization anymore since we pass the same queue to GC and submit our kernels to it.
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
|
|
||
| void TRANSFORMATIONS_API transformMLIR(std::shared_ptr<ov::Model> model); | ||
| void TRANSFORMATIONS_API transformMLIR(std::shared_ptr<ov::Model> model, | ||
| std::shared_ptr<ov::EvaluationContext> loweringContext); |
There was a problem hiding this comment.
loweringContext stores ocl_context for mlir_op::gpu
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
|
|
||
| OpenCL(bool out_of_order_queue = true) | ||
| { | ||
| OpenCL(bool out_of_order_queue = true) { |
There was a problem hiding this comment.
this was fixed by openvino's linter
| @@ -23,8 +23,7 @@ struct OpenCL { | |||
| bool _supports_usm; | |||
There was a problem hiding this comment.
moved this class from tests/unit_tests/utils to tests/common/utils in order to reuse it in sanity tests for the GPU integration
| _queue = cl::CommandQueue(_context, _device, props); | ||
| } | ||
|
|
||
| OpenCL(cl_context context, bool out_of_order_queue = true) |
There was a problem hiding this comment.
it's more convenient to construct this object from cl_context in sanity tests for GPU integration, since we can simply request the context from compiled model and construct this class
|
@vladimir-paramuzov @slyalin @kurapov-peter @AndreyPavlenko I think this PR is now in a state where it can be reviewed |
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
|
Should we merge #167 before merging this PR? Are both PRs ready to be merged? If they don't have obvious breaking changes, it is more convenient to continue development in the main mlir branch. I have a merged version of mlir branch and master branch from main openvino repository. So to avoid you fighting with merge conflicts on your side I would recommend to merge mentioned two PRs and then I redo the merge with master openvino branch on my side. @kurapov-peter, @AndreyPavlenko, @dchigarev? |
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
I think this PR is already in a state where it can be merged. There's one more question though regarding gpu-runtime headers exposure that I would like to discuss. The questions is, whether it's okay that we include GPU runtime headers to the |
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
kurapov-peter
left a comment
There was a problem hiding this comment.
Looks good to me. Would TPP need anything from evaluation context btw?
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
|
@vladimir-paramuzov, please approve explicitly and we will merge. |
Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
|
@slyalin I believe we've got all approves we needed |
Bumps [alabaster](https://github.com/sphinx-doc/alabaster) from 0.7.14 to 0.7.16. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/sphinx-doc/alabaster/releases">alabaster's releases</a>.</em></p> <blockquote> <h2>Alabaster 0.7.16</h2> <p>Changelog: <a href="https://alabaster.readthedocs.io/en/latest/changelog.html">https://alabaster.readthedocs.io/en/latest/changelog.html</a></p> <h2>Alabaster 0.7.15</h2> <p>Changelog: <a href="https://alabaster.readthedocs.io/en/latest/changelog.html">https://alabaster.readthedocs.io/en/latest/changelog.html</a></p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/sphinx-doc/alabaster/blob/master/docs/changelog.rst">alabaster's changelog</a>.</em></p> <blockquote> <h2>:git_tag:<code>0.7.16</code> -- 2024-01-10</h2> <ul> <li>:bug:<code>215</code> Do not display <code>logo_name</code> if it is set to <code>False</code>.</li> </ul> <h2>:git_tag:<code>0.7.15</code> -- 2024-01-08</h2> <ul> <li>:feature:<code>213</code> Allow an arbitrary string in the <code>logo_name</code> option.</li> <li>:feature:<code>114</code> Improved sidebar CSS styles.</li> <li>:issue:<code>178</code> Deprecated <code>canonical_url</code> in favor of <code>html_baseurl</code>.</li> <li>:bug:<code>200</code> Removed duplicate <code><meta name="viewport" ... /></code> tag.</li> <li>:bug:<code>188</code> Removed underline from whitespace.</li> <li>:bug:<code>164</code> Removed <code>type="text/javascript"</code> from <!-- raw HTML omitted --> elements.</li> <li>:bug:<code>161</code> Replaced <code>&copy;</code> with unicode decimal code entity <code>[slyalin#169](https://github.com/sphinx-doc/alabaster/issues/169);</code>.</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/sphinx-doc/alabaster/commit/f3fdc049e4b531595bc075718a66677fbca851e3"><code>f3fdc04</code></a> Bump to 0.7.16</li> <li><a href="https://github.com/sphinx-doc/alabaster/commit/39cbbc1b614876118ce1d3209b04ea0c642033b5"><code>39cbbc1</code></a> Do not display logo_name == 'false'</li> <li><a href="https://github.com/sphinx-doc/alabaster/commit/d24c4cba335cf2215600b41589d9e30a4eb96a76"><code>d24c4cb</code></a> Bump to 0.7.15</li> <li><a href="https://github.com/sphinx-doc/alabaster/commit/56f12de4cb6d35781fc9073226299ab90e567ab5"><code>56f12de</code></a> Include documentation in the sdist</li> <li><a href="https://github.com/sphinx-doc/alabaster/commit/2d8d0382077c342b1670cf72a8da70b9ab04bb5b"><code>2d8d038</code></a> Adorn the LICENSE file with a suffix</li> <li><a href="https://github.com/sphinx-doc/alabaster/commit/a31816c198dd3562a4f8a2eb22e7758a1e121ceb"><code>a31816c</code></a> Remove obscenities (<a href="https://redirect.github.com/sphinx-doc/alabaster/issues/173">#173</a>)</li> <li><a href="https://github.com/sphinx-doc/alabaster/commit/166d6e70ce9d52dfb849e51467cb5a23e9595f01"><code>166d6e7</code></a> Replace © with unicode decimal code entity (<a href="https://redirect.github.com/sphinx-doc/alabaster/issues/161">#161</a>)</li> <li><a href="https://github.com/sphinx-doc/alabaster/commit/b9e8d798dfb8f94a07bd96883cc8bd6d60b488cb"><code>b9e8d79</code></a> Deprecate canonical_url in favor of html_baseurl (<a href="https://redirect.github.com/sphinx-doc/alabaster/issues/178">#178</a>)</li> <li><a href="https://github.com/sphinx-doc/alabaster/commit/848e71871b0da4fbb73cee84157f169641a7c9b6"><code>848e718</code></a> Allow an arbitrary string in the logo_name option (<a href="https://redirect.github.com/sphinx-doc/alabaster/issues/213">#213</a>)</li> <li><a href="https://github.com/sphinx-doc/alabaster/commit/6922a16732eab173c1fec74dd8e903f8ad0f4222"><code>6922a16</code></a> Improve sidebar styles</li> <li>Additional commits viewable in <a href="https://github.com/sphinx-doc/alabaster/compare/0.7.14...0.7.16">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Alina Kladieva <alina.kladieva@intel.com>
This PR adds an integration with graph-compiler's GPU pipeline. The integration means passing GPU buffers (usm ptr/cl_mem), cl queue and cl events as is to GC for execution.
A set of sanity tests was also added to test the integration.
How to build and run tests
Build LLVM with IMEX patches:
Build OV from this branch:
Run sanity tests:
Run benchmark_app:
What was changed and how it works
1. Common
MLIREvaluateclass was split into twoThere are now two classes:
MLIREvaluate(generic evaluation) andMLIREvaluateGcGPU. They both implement the interface ofMLIREvaluateBaseand an actual instance is created based onmlir_modeparameter inMLIREvaluateBase::create().This was done because these two evaluation classes operate with different objects in order to lower and invoke recieved MLIR module. Generic
MLIREvaluateoperates onmlir::EvaluationEngineandmlir::Module, whileMLIREvaluateGcGPUoperates with gc-specific runtime objects (mlir::gc::OclModuleBuilder,mlir::gc::OclModule, etc...).2. Context/device information is now forwarded to
MLIREvaluateBase::create()We need context + device information for the gc-gpu-runtime in order to build a module. That's why we now extract
ocl_contextandcl_device_idfromRemoteContextImplinTransformationsPipelineand forward it all the way toMLIREvaluateBase::create()usingov::EvaluationContextmap.3. Separation between
MLIREvaluate::invokeandMLIREvaluate::invoke_packedA new invocation method was added to
MLIREvaluateBaseinterface (::invoke()). In comparison with::invoke_packed()that accepts memref arguments in theMemrefDescriptorformat,::invoke()takes tensor vectors as is.GC-GPU runtime expects arguments to be in a non-packed format (pointers only) if all memrefs in the compiled mlir module have static shapes. Otherwise it expects "packed" format (MemrefDescriptors).
A query method was added to determine which method of
MLIREvaluateto call.(@AndreyPavlenko may provide more info on why we need this separation)
4. Actual OCL implementations ofcldnn::stream/buffer/eventare now exposed tointel_gpu/src/plugin/ops/mlir_op.cppBase classes of stream/buffer/event do not have a method to get a handle of an actual underlying object (cl_queue/cl_mem/cl_event). In order to obtain these handles and pass them to gc-gpu runtime, the instances of these abstract objects are being dynamic-casted to their presumable implementations (ocl::gpu_buffer / ocl_stream / ocl_base_event). In order to do that we have to expose declaration of these ocl-specific implementations toops/mlir_op.cppby modifying its include directories. Are we okay with this?^--- this was replaced with the one below
4.
cldnn::stream/buffer/event/deviceare now able to return an underlying ocl handleIn order to get an actual cl object and pass it to the graph compiler's GPU runtime, the
void* get_handle()method was added tocldnn::stream/buffer/device/eventinterfaces. The method is supposed to return a pointer to an opencl handle from C-api (cl_mem,cl_command_queue,cl_device_id, ...) since gc-gpu runtime takes these instead of c++ wrappers.5.
cldnn::stream::create_base_event(...)can now take a pointer tocl_event(in order to propagate
cl_eventreturned from gc-gpu runtime tocldnn::eventthat is returned fromMLIROp::evaluate())