Skip to content

Conversation

iburyl
Copy link
Contributor

@iburyl iburyl commented Dec 21, 2020

Implements marray class type, its operators and aliases as defined by SYCL 2020 provisional

Signed-off-by: iburylov [email protected]

@iburyl iburyl requested a review from a team as a code owner December 21, 2020 15:35
@iburyl iburyl requested a review from smaslov-intel December 21, 2020 15:35
Signed-off-by: iburylov <[email protected]>
@smaslov-intel
Copy link
Contributor

Implements marray class type, its operators and aliases as defined by SYCL 2020 provisional

@iburyl , please point to the spec bits that this implements.
@intel/llvm-reviewers-runtime , someone please help me review this too

Copy link
Contributor

@alexbatashev alexbatashev left a comment

Choose a reason for hiding this comment

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

sycl.hpp has changed its permissions. Is that necessary?

Other comments are minor nits.

@iburyl
Copy link
Contributor Author

iburyl commented Dec 22, 2020

This is chapter 4.16.3.1 Math array interface of the spec: SYCL 2020 provisional.
There is one change as compared to spec: all operators where defined as friend inside class, which is more aligned with what we can expect in 2020 final.

…reverted back permission for sycl.hpp

Signed-off-by: iburylov <[email protected]>
@iburyl
Copy link
Contributor Author

iburyl commented Dec 22, 2020

I am sure the failed test on memory consumption is not related to this PR

Copy link
Contributor

@s-kanaev s-kanaev left a comment

Choose a reason for hiding this comment

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

-Should there be any tests on added class behaviour?-

Sorry, I've missed a file there.

alexbatashev
alexbatashev previously approved these changes Dec 22, 2020
Copy link
Contributor

@romanovvlad romanovvlad left a comment

Choose a reason for hiding this comment

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

Stylistic comments.
Could you please use the same style of naming types and vars? Things defined by the spec, probably, can be ignored.

Copy link
Contributor

@smaslov-intel smaslov-intel left a comment

Choose a reason for hiding this comment

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

LGTM

@romanovvlad romanovvlad merged commit 5eebd1e into intel:sycl Dec 22, 2020
Copy link
Contributor

@keryell keryell left a comment

Choose a reason for hiding this comment

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

Do not merge that fast around vacation time, when the review bandwidth is probably lower...

typename = typename std::enable_if<sizeof...(ArgTN) == NumElements>::type>
marray(const ArgTN &... Args) : MData{Args...} {}

marray(const marray<Type, NumElements> &Rhs) {
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 you need to define explicitly these 2 copy and move constructors instead of relying on the default one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mostly because they are explicitly present in the spec.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting side effect of the specification...
In the specification we say that they do exist, not that you have to implement them explicitly if the compiler do this for you in the implementation. :-)
Probably you can remove them for sycl::vec and so on.
You deserve some laziness by using some = default; when required. :-)
In the same way you do not define the destructor even it is described in the common property of SYCL objects.


const_reference operator[](std::size_t index) const { return MData[index]; }

marray &operator=(const marray<Type, NumElements> &Rhs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not relying on the synthesized one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it is explicitly present in the spec.

return Ret;
}

friend marray operator+(marray &Lhs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you are up to date to our latest bug fixes! Good. :-)
But there is a missing const

// && dataT != cl_half
template <typename T = DataT>
friend typename std::enable_if<std::is_integral<T>::value, marray>::type
operator~(marray &Lhs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have the feeling that there are a lot of const lacking in the neighborhood

   operator~(const marray &Lhs) {

sycl::marray<int, 1> marray_from_one_elem(1);

// Check broadcasting operator=
sycl::marray<float, 4> b_marray(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.

Probably in the following we need more const or rvalue to test that it can compile in that case...

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.

6 participants