Skip to content

[SYCL][Matrix spec] keep deletion of assign op and copy ctor but change signature of joint_matrix_mad #11007

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 2 commits into from
Sep 18, 2023

Conversation

dkhaldi
Copy link
Contributor

@dkhaldi dkhaldi commented Aug 29, 2023

@gmlueck, in #7964, we explicitly deleted the copy ctor and assign op because we added joint_matrix_copy that is used to actually copy matrix data.
However, when deleting them in implementation, failures occur as joint_matrix_mad uses them.
This PR proposes to change the signature of joint_matrix_mad so these ctors are not used.

@dkhaldi dkhaldi requested a review from a team as a code owner August 29, 2023 16:04
@dkhaldi
Copy link
Contributor Author

dkhaldi commented Aug 31, 2023

gentle ping @gmlueck

operator are group functions as defined in section 4.17.3 of the core
SYCL specification. They must be encountered in converged control flow
by all work-items in the `Group`. Note that the assignment operator
and the copy constructor do not copy the entire matrix content.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to say that the copy constructor and assignment operator don't copy the matrix content? How would the application even be able to tell whether the matrix content was copied? Isn't the content of the matrix hidden behind this abstract joint_matrix type?

I'm thinking now that we could replace joint_matrix_copy with an assignment operator that allows the user to copy from a matrix with different Use and T (type). That way, matrix copy operations will always be done via the assignment operator. That seems clearer than having both an assignment operator and a joint_matrix_copy function.

Copy link
Contributor Author

@dkhaldi dkhaldi Sep 8, 2023

Choose a reason for hiding this comment

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

@gmlueck, if we have the assignment op do the actual data copy, = joint_matrix_mad that uses assignment op would do extra unnecessary copy of the data (

)

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like neither joint_matrix_copy nor the assignment operator should copy anything to/from memory. The only memory operations are joint_matrix_load and joint_matrix_store. It seems like both joint_matrix_copy and the assignment operator should both just copy some "handle" that represents the register(s) that hold the matrix content?

In your implementation today, what is the difference between the implementation of joint_matrix_copy and the copy operator?

Here's another way to think about it. Consider a code snippet like this:

joint_matrix<sub_group, int8_t, use::a, Rows, Cols, layout::row_major> m1;
joint_matrix<sub_group, int8_t, use::a, Rows, Cols, layout::row_major> m2;
joint_matrix_load(sg, m1, ptr1, Rows);  // Load "m1" with data from "ptr1"
m2 = m1;
joint_matrix_load(sg, m1, ptr2, Rows);  // Load "m1" with data from "ptr2"

I think a user would expect the matrix m2 to still contain the data loaded from ptr1 after the end of that code snippet. Isn't this the same semantic as joint_matrix_copy?

@dkhaldi dkhaldi changed the title [SYCL][Matrix spec] Do not delete assign op and copy ctor as they are needed for joint_matrix_mad [SYCL][Matrix spec] keep deletion of assign op and copy ctor but change signature of joint_matrix_mad Sep 15, 2023
@dkhaldi
Copy link
Contributor Author

dkhaldi commented Sep 15, 2023

@gmlueck, can you please review?
This capture what we decided to do:

  • keep deletion of copy ctor and assign op
  • change signature of joint_matrix_mad by having D as input

I also did some cleanup: replace deprecated multi_ptr() with address_space_cast, replace one instance of get_wi_data (left by accident) by joint_matrix_apply.

Copy link
Contributor

@gmlueck gmlueck left a comment

Choose a reason for hiding this comment

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

The changes look good, but the description of the PR is outdated:

@gmlueck, in #7964, we explicitly deleted the copy ctor and assign op because we added joint_matrix_copy that is used to actually copy matrix data.
However, when deleting them in implementation, failures occur as joint_matrix_mad uses them.
This PR proposes to keep them as implemented currently in https://github.com/intel/llvm/blob/sycl/sycl/include/sycl/ext/oneapi/matrix/matrix-unified.hpp#L68
and add clarification that they don't copy matrix data.

Can you update the description, so the merged commit accurately describes what happened?

@dkhaldi
Copy link
Contributor Author

dkhaldi commented Sep 15, 2023

The changes look good, but the description of the PR is outdated:

@gmlueck, in #7964, we explicitly deleted the copy ctor and assign op because we added joint_matrix_copy that is used to actually copy matrix data.
However, when deleting them in implementation, failures occur as joint_matrix_mad uses them.
This PR proposes to keep them as implemented currently in https://github.com/intel/llvm/blob/sycl/sycl/include/sycl/ext/oneapi/matrix/matrix-unified.hpp#L68
and add clarification that they don't copy matrix data.

Can you update the description, so the merged commit accurately describes what happened?

Done

@dkhaldi
Copy link
Contributor Author

dkhaldi commented Sep 18, 2023

@intel/llvm-gatekeepers, can you please merge this?

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.

3 participants