Skip to content

convert array ops to library calls#7032

Merged
dlang-bot merged 2 commits intodlang:masterfrom
MartinNowak:arrayOps
Aug 19, 2017
Merged

convert array ops to library calls#7032
dlang-bot merged 2 commits intodlang:masterfrom
MartinNowak:arrayOps

Conversation

@MartinNowak
Copy link
Member

@MartinNowak MartinNowak commented Jul 26, 2017

  • capture expression tree as reverse polish notation
  • pass scalar subtrees as single argument

Requires dlang/druntime#1891, dlang/druntime#1899, dlang/druntime#1903
Supplemental dlang/dlang.org#1846

@dlang-bot
Copy link
Contributor

dlang-bot commented Jul 26, 2017

Thanks for your pull request, @MartinNowak!

Bugzilla references

Auto-close Bugzilla Description
10523 Don't call array op functions for short vector ops

/*
example output from druntime
----
../../druntime/import/core/internal/arrayop.d(160): Error: static assert "Binary op '+=' not supported for element type string."
Copy link
Member

Choose a reason for hiding this comment

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

Using backticks instead of ' will enable color syntax highlighting!

Copy link
Member Author

Choose a reason for hiding this comment

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

Surprising that it also works for static asserts, will change.

@WalterBright
Copy link
Member

Very nice work. Will approve as soon as the changes are incorporated.

@WalterBright
Copy link
Member

@MartinNowak needs a rebase

@MartinNowak
Copy link
Member Author

Done @WalterBright

@PetarKirov
Copy link
Member

PetarKirov commented Aug 9, 2017

I really like the approach taken here, but I wonder if this could be useful for third-party linear algebra libraries like mir/ndslice. I.e. use the standard function template overloading mechanism - libraries would provide arrayOp overloads and the compiler would choose the most specialized one. Of course for array operands, druntime's overload would be the most specialized one.

@MartinNowak
Copy link
Member Author

I really like the approach taken here, but I wonder if this could be useful for third-party linear algebra libraries like mir/ndslice. I.e. use the standard function template overloading mechanism - libraries would provide arrayOp overloads and the compiler would choose the most specialized one. Of course for array operands, druntime's overload would be the most specialized one.

Extensibility was not really a requirement for the story.
A simple extension point would be to change the qualified object._arrayOp to an unqualified _arrayOp.
https://github.com/dlang/dmd/pull/7032/files#diff-01366d4347de4bb6861fc2c52694b84aR133
Extensibility would also make sense for the normal array operands, e.g. for huge arrays and runtime-CPU/GPU/FPGA specializations.
We don't have much experience with such extension points yet, but if there is interest, it should be trivial for anyone to change the compiler to experiment with the idea.

@MartinNowak
Copy link
Member Author

Need dlang/druntime#1899 to fix runnable/arrayop.d.

@MartinNowak
Copy link
Member Author

Yikes, someone bluntly added mixed type vector operations (int -> float, even worse int -> double) conversions (#4218).
I will only support scalar loops for those, as using complex core.simd chains is completely out of scope.
Fortunately gdc/ldc will still be able to auto-vectorize such loops.

@MartinNowak
Copy link
Member Author

Done dlang/druntime#1903.

@MartinNowak MartinNowak removed this from the 2.076.0 milestone Aug 18, 2017
@MartinNowak MartinNowak changed the base branch from stable to master August 18, 2017 11:12
- capture expression tree as reverse polish notation
- pass scalar subtrees as single argument
- fixes Issue 10523 - don't call array op functions for short vector ops
- now left-to-right evaluated like everything else
@MartinNowak
Copy link
Member Author

Rebased to trigger a retest now that the druntime pulls are merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants