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

[CPU]fix offset in store emitter issue #26083

Merged

Conversation

tiger100256-hu
Copy link
Contributor

@tiger100256-hu tiger100256-hu commented Aug 15, 2024

Details:

  • offset in store emitter is offset of dst gpr register, and should parse together with reg_dst

Tickets:

@github-actions github-actions bot added the category: CPU OpenVINO CPU plugin label Aug 15, 2024
@chenhu-wang
Copy link
Contributor

Please help change
const int offset = in_idxs.size() == 2 ? in_idxs[1] : 0;
to
const int offset = out_idxs.size() == 2 ? out_idxs[1] : 0;
in https://github.com/openvinotoolkit/openvino/blob/master/src/plugins/intel_cpu/src/emitters/plugin/x64/jit_load_store_emitters.cpp#L679

to fix the bug. Thanks!

@tiger100256-hu tiger100256-hu changed the title fix store emitter in_idxs checking issue [CPU]fix offset in store emitter issue Aug 20, 2024
@tiger100256-hu tiger100256-hu marked this pull request as ready for review August 20, 2024 11:53
@tiger100256-hu tiger100256-hu requested review from a team as code owners August 20, 2024 11:53
@chenhu-wang
Copy link
Contributor

chenhu-wang commented Aug 21, 2024

@a-sidorova , for store emitter, the offset of dst gpr is passed with input vec reg. This seems like confusing and not friendly to use, could error prone, such as this change:#22816. We moved the offset as part of dst gpr. Could you please taka a look? Thanks!

@@ -676,7 +676,7 @@ void jit_store_emitter::emit_data() const {
}

void jit_store_emitter::emit_impl(const std::vector<size_t> &in_idxs, const std::vector<size_t> &out_idxs) const {
const int offset = in_idxs.size() == 2 ? in_idxs[1] : 0;
const int offset = out_idxs.size() == 2 ? out_idxs[1] : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please also add a description regarding offset for store and load emitter?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. Otherwise this is sacred knowledge which is known by a few developers

@a-sidorova
Copy link
Contributor

a-sidorova commented Aug 21, 2024

@a-sidorova , for store emitter, the offset of dst gpr is passed with input vec reg. This seems like confusing and not friendly to use, could error prone, such as this change:#22816. We moved the offset as part of dst gpr. Could you please taka a look? Thanks!

As I remember, the purpose of using offset as input of store_emitter was to pass the offset to the emitter as the separate input emitter/node (for example, when the offset can be dynamic in snippets). This idea was proposed by @dmitry-gorokhov a few years ago.

@dmitry-gorokhov could you please share your opinion about moving of passing offset to output in store_emitter? In my opinion, the offset is attribute which is passed from another emitter/node/kernel. Because of that the offset is input parameter or me and should be passed in input indexes as before.

@dmitry-gorokhov
Copy link
Contributor

dmitry-gorokhov commented Aug 21, 2024

@a-sidorova , for store emitter, the offset of dst gpr is passed with input vec reg. This seems like confusing and not friendly to use, could error prone, such as this change:#22816. We moved the offset as part of dst gpr. Could you please taka a look? Thanks!

As I remember, the purpose of using offset as input of store_emitter was to pass the offset to the emitter as the separate input emitter/node (for example, when the offset can be dynamic in snippets). This idea was proposed by @dmitry-gorokhov a few years ago.

@dmitry-gorokhov could you please share your opinion about moving of passing offset to output in store_emitter? In my opinion, the offset is attribute which is passed from another emitter/node/kernel. Because of that the offset is input parameter or me and should be passed in input indexes as before.

There are no strict requirements on emitters arguments placement. So we can adjust in any way if the solution considered msot convinient.
Initial idea was to aling basic emitters signature with usual ISA rules. E.g. 2 arguments of vmovups (dst, src). From this assumption vector mask should be associated with vector register and be part of inputs/outputs respectivly. Same about offset - it should be associated with the ptr.

The point about offset as input parameter is correct, but seems it correponds to another level of abstraction: execution graph. In the graph Store operation may obtain offset as an input if this is simplier way to express pointer arithmetic. On the other hand Emitter is an abstraction over ISA which might be used in different contexts, not only inside Snippets.
One of the possible solutions is to have separate adapter inside Snippets emitters scope which will remap parameters in desired way.

@@ -136,7 +136,7 @@ struct jit_move_scale_kernel : public jit_uni_move_scale_kernel, public jit_gene
emitters[seed].reset(new jit_store_emitter(this, isa, src_prc, dst_prc, elt_num));
}

emitters[seed]->emit_code({static_cast<size_t>(vmm_src.getIdx()), 0}, {static_cast<size_t>(reg_dst.getIdx())},
emitters[seed]->emit_code({static_cast<size_t>(vmm_src.getIdx())}, {static_cast<size_t>(reg_dst.getIdx()), 0},
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: offset = 0 is set by default in jit_store_emitter::emit_impl() so we don't need to manually pass zero everywhere

@@ -676,7 +676,7 @@ void jit_store_emitter::emit_data() const {
}

void jit_store_emitter::emit_impl(const std::vector<size_t> &in_idxs, const std::vector<size_t> &out_idxs) const {
const int offset = in_idxs.size() == 2 ? in_idxs[1] : 0;
const int offset = out_idxs.size() == 2 ? out_idxs[1] : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. Otherwise this is sacred knowledge which is known by a few developers

@dmitry-gorokhov dmitry-gorokhov added this to the 2024.4 milestone Aug 22, 2024
@@ -676,7 +677,8 @@ void jit_store_emitter::emit_data() const {
}

void jit_store_emitter::emit_impl(const std::vector<size_t> &in_idxs, const std::vector<size_t> &out_idxs) const {
const int offset = in_idxs.size() == 2 ? in_idxs[1] : 0;
// offset in store emitter is the offset of dst gpr register, should be parsed from out_ids.
Copy link
Contributor

@a-sidorova a-sidorova Aug 22, 2024

Choose a reason for hiding this comment

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

Minor: The best place for this comment in the corresponding header file before class definitions 😃 Another developer will take a look at interface and won't find the description for offset. And only after searching in files, he will find this comment.

@dmitry-gorokhov dmitry-gorokhov added this pull request to the merge queue Aug 26, 2024
Merged via the queue into openvinotoolkit:master with commit db44fb6 Aug 26, 2024
140 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: CPU OpenVINO CPU plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants