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

Tests: make sure function chaining move optimization is applied #152

Closed
mratsim opened this issue Nov 9, 2017 · 1 comment
Closed

Tests: make sure function chaining move optimization is applied #152

mratsim opened this issue Nov 9, 2017 · 1 comment

Comments

@mratsim
Copy link
Owner

mratsim commented Nov 9, 2017

With the following {call} syntax, the unsafe version is automatically used if the previous argument was the result of another function.

This avoids temporaries when function chaining. Also one only needs to use unsafe at the very start of the chain to have the whole chain being no-copy.

We need to test this, best way probably is to have a when defined(test) or when declared(test) in the template that increments a test global counter

when defined(arraymancer_test):
  var move_count_asContiguous = 0
  var move_count_permute = 0


template asContiguous*[T](t: Tensor[T]{call}, layout: OrderType = rowMajor, force: bool = false): Tensor[T] =
  when declared(arraymancer_test):
     inc move_count_asContiguous

  unsafeContiguous(t, layout, force)

template permute*[T](t: Tensor[T]{call}, dims: varargs[int]): Tensor[T] =
  when defined(arraymancer_test):
     inc move_count_permute

  unsafePermute(t, dims)
@mratsim
Copy link
Owner Author

mratsim commented Nov 26, 2017

Obsoleted by #160

@mratsim mratsim closed this as completed Nov 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant