Closed vakokako closed 8 months ago
Thanks for your feedback, I made the changes.
Also, can you come up with use cases when this check would not work correctly? i.e. some elements in the container aren't located between the first and last element in memory?
Hey, @JohanMabille, just reminding you that this exists))
Thanks for doing it, I had totally forgotten it Oo
Thanks!
Currently the default behaviour of
xsemantic_base<D>::operator=(const xexpression<E>& e)
is to create a temporary copy ofe
to avoid any problems with overlapping memory. However, if the user doesn't use some obscure strides for the containers, a check if the pointers frombegin
andend
elements don't overlap is sufficient. Based on our benchmarks, depending on the size of the containers brings huge speedups for some use cases (up to90%
in case of views). This is also achievable withnoalias
, but it's hard to enforce its usage and adding a compilation flagXTENSOR_FORCE_TEMPORARY_MEMORY_IN_ASSIGNMENTS
that allows changing this behaviour is highly beneficial.I'm also attaching the benchmark results we obtained: xtensor_assign_benchmark_results.ods
Explanation behind benchmark names.
Benchmark was written as single templated function, so based on the template parameters in the benchmark name, the benchmarked operation looked as following, where both containers are 2d, with last number parameter being the size of single dimension: ```cpp DstOperation(DstContainer) = SrcOperation(xtensor<..., 2>) ```