Skip to content
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

[SYCL] Support for load/store cache controls #11584

Merged
merged 38 commits into from
Nov 10, 2023
Merged

Conversation

rdeodhar
Copy link
Contributor

This change adds SYCL language support for load store cache controls using SPIR-V ops.

@rdeodhar rdeodhar requested review from a team as code owners October 18, 2023 22:12
streaming,
invalidate_after_read,
const_cached
const_cached,
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the value of adding a coma here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No real value. Can be removed. Some enums in the compiler tend to use dangling commas.

llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp Outdated Show resolved Hide resolved
Comment on lines +103 to +105
/// Builds a metadata node for a SPIR-V decoration for cache controls
/// where decoration code and value are both uint32_t integers.
/// The value encodes a cache level and a cache control type.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a design document or specifications for LLVM/SPIR-V levels?
Cache controls are using annotated pointer design. Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SPIR-V extension is here: https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/INTEL/SPV_INTEL_cache_controls.asciidoc

This implementation builds upon annotated_ptr by adding new properties.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. I also find KhronosGroup/SPIRV-LLVM-Translator#2140, which documents the LLVM IR representation of cache controls.

@asudarsa
Copy link
Contributor

Is this related to #11597 (prefetch hints) in any way? Thanks

/// where decoration code and value are both uint32_t integers.
/// The value encodes a cache level and a cache control type.
///
/// @param Ctx [in] the LLVM Context.
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment does not seem to match the signature. Can you pls check? Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

streaming = 3
};
uint32_t CacheProp;
if (Name == "sycl-cache-read-uncached")
Copy link
Contributor

Choose a reason for hiding this comment

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

May be use StringSwitch here?

@rdeodhar rdeodhar temporarily deployed to WindowsCILock October 25, 2023 03:11 — with GitHub Actions Inactive
cached,
streaming,
invalidate,
const_cached,
Copy link
Contributor

Choose a reason for hiding this comment

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

How about:

Suggested change
const_cached,
constant

cache_mode::const_cached has some redundancy compared to cache_mode::constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

Comment on lines 140 to 141
through,
back
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer:

Suggested change
through,
back
write_through,
write_back

I think including "write" in the name here would help readability. These are established terms for how caches work, whereas "through" and "back" by themselves are not. Including "write" in the name here also makes it clear that passing these two modes through to read_hint will give an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are not user-visible, but I'll make the change you suggest.

Copy link
Contributor

@KseniyaTikhomirova KseniyaTikhomirova left a comment

Choose a reason for hiding this comment

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

LGTM

write_back = 2,
write_streaming = 3
};
// SYCL encodings of read/write control
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, add a warning that definition of cache_mode enum must match the definition from sycl/include/sycl/ext/intel/experimental/cache_control_properties.hpp.
Ideally, we should have a single definition across all source files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, done

namespace intel {
namespace experimental {

enum class cache_mode {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, add a warning that definition of cache_mode enum must match the definition from llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, done.

@againull againull requested a review from a team November 9, 2023 19:03
@rdeodhar rdeodhar requested review from MrSidims and removed request for a team November 9, 2023 19:04
@againull
Copy link
Contributor

againull commented Nov 9, 2023

@intel/dpcpp-tools-reviewers Could you please give your +1 considering that @rdeodhar addressed comments from @asudarsa and seems that @asudarsa is on vacation.

Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

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

CompileTimePropertiesPass changes as well as the result IR in the test seems legit

@againull againull merged commit 25c8b70 into intel:sycl Nov 10, 2023
11 checks passed
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.

8 participants