Skip to content

[sycl-post-link] Add device image property for assert feature #3881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 16, 2021

Conversation

vmaksimo
Copy link
Contributor

@vmaksimo vmaksimo commented Jun 4, 2021

A property with the name of the kernel is added whenever the kernel uses assert.
Details: https://github.com/intel/llvm/blob/sycl/sycl/doc/Assert.md#online-linking-fallback-__devicelib_assert_fail

AlexeySachkov
AlexeySachkov previously approved these changes Jun 15, 2021
Copy link
Contributor

@AlexeySachkov AlexeySachkov left a comment

Choose a reason for hiding this comment

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

LGTM to me, but the call graph traversal could be optimized further

Comment on lines +303 to +306
// If we know, that this function does not contain assert, we still
// should investigate another instructions in the function.
if (!hasAssertionInCallGraphMap[CF])
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

This kind of defeats the purpose of the cache, i.e. if we have a huge sub-graph which is known not to have an assertion and it is used from a several kernels, than we would traverse it fully several times.

If I understand correctly, this "if" is needed, because we go upwards by call stack to mark all functions as ones that definitely do not call assert. Technically, "definitely" word is not correct here: if we have a function which calls two other functions and we have only traversed a single call tree and didn't find an assertion, then we can't say that the top-level function definitely don't call assert - it only might not call assert.

A few ideas how to fix this:

  • move upwards only until we are sure that all callees of the current function do not call an assertion. As soon as we have encountered a branch in a call three for which the answer is not known, we stop there. Unfortunately, this is likely to require additional data to store or additional actions to perform, so I'm not sure if it worth it.
  • during the first traverse, only put true values into the map, then perform a second graph traversal and mark everything you haven't marked in the first one with false

Since assert is an extension, I would expect more kernels/functions without it than kernels/functions with it. Therefore, I think that having an early exit when we know that particular sub-tree does not have an assert is important optimization.

However, this is not a functional problem and if @s-kanaev would like to get this patch sooner, than we can postpone optimizing our graph traversal and do that in a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll work on further graph traversal optimization and apply it in a separate PR

if (hasAssertionInCallGraphMap.count(CF)) {
// If we know, that this function does not contain assert, we still
// should investigate another instructions in the function.
if (!hasAssertionInCallGraphMap[CF])
Copy link
Contributor

Choose a reason for hiding this comment

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

map::find method may be used to search CF in hasAssertionInCallGraphMap once here.

@vladimirlaz vladimirlaz merged commit 65d1562 into intel:sycl Jun 16, 2021
alexbatashev pushed a commit to alexbatashev/llvm that referenced this pull request Jun 18, 2021
* upstream/sycl: (776 commits)
  Align CMake requirements with upstream. (intel#3928)
  [SYCL] Deprecate [[intel::reqd_work_group_size]] attribute spelling (intel#3927)
  [SYCL] Fix post commit after PR 2292 (intel#3939)
  {SYCL][PI][L0] - Eliminate std::string construction/destruction overhead. (intel#3931)
  [ESIMD] Overloading sycl sin,cos,exp,log functions for ESIMD arguments (intel#3717)
  [sycl-post-link] Add device image property for assert feature (intel#3881)
  [SYCL] Split read/write lockings (intel#2292)
  Handle OpSpecConstantOp with Select
  Handle OpSpecConstantOp with SMod
  Add tests for SConvert, UConvert, BitCast OpSpecConstantOp
  Fix attachment of decoration to spec constants
  Implement support for dynamic memmove
  Align clang-tidy/format versions to LLVM version
  Handle OpSpecConstantOp for integer comparisons
  Handle OpSpecConstantOp for SNegate, Not, and LogicalNot
  Extend OpSpecConstantOp testing for initializers
  Use IRBuilder for folding
  Fix translating of compile unit
  Support buffers in LinalgFoldUnitExtentDims
  [gn build] Port d0a5d86
  ...
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.

5 participants