-
Notifications
You must be signed in to change notification settings - Fork 57
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
Implement Neg overloaded operator for Array #89
Comments
Like, does cloning an array create a new reference to the same underlying data (shallow copy), or does it make a new array and copy the data across. I assume the latter since that's how it normally works but it might be nice to be explicit for newbies like me. |
Hmm you might want to make that more explicit in a more obvious place in the documentation. At the moment the only hint I can see is that
I might be wrong about this. In any case it is definitely unexpected and worth documenting more. Maybe add something like this:
Also the documentation of Sorry this is a bit off-topic; I'll make another issue if you like. Also I can do a pull request if you're ok with that wording. Edit: Now that I think about it, is this handled by everything being copy-on-write? Well even if so it needs to be documented! |
@Timmmm Thanks for pointing out the mistake in documentation about
Rust uses move semantics and it makes sense to use clone to create a copy of a value if we want to reuse it else where. However, in the case of a struct that is managing native resource such as GPU memory, it is not just copy of few bits or bytes. Copying data from one location to another is expensive operation which should be delayed(copy-on-write) or avoided(using reference counting) depending on the context in which the said Array is being utilised. Hence, Having said that, i have made the corrections to documentation based on your feedback. |
Isn't that why |
@9prady9 @Timmmm To give some background, arrayfire has copy on write semantics internally. This sometimes involves creating shallow copies as long as the data is being read, but create a new copy when data is being written to the array. The underlying logic in the arrayfire lib uses On a related note, arrayfire is not thread safe yet. @9prady9 is working on it. You can see the progress being made here: arrayfire/arrayfire#1706 |
On another note, we are currently working on adding thread safety feature to the upstream(ArrayFire) library on the whole. We made sure all ArrayFire's upstream libraries resource management and the internal resource management is thread safe. However, we don't intend on doing any synchronisation under-the-hood for |
Array should implement the unary negative operator. It is implemented in C++ by making a zero array of the same size and subtracting them. I guess something like this:
Sorry I am new to Rust so that is probably all wrong. Also I can't find a good explanation for how copying/cloning arrays in ArrayFire works.
The text was updated successfully, but these errors were encountered: