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

A question about vector #424

Open
wangshuxihe00 opened this issue Jul 3, 2024 · 2 comments
Open

A question about vector #424

wangshuxihe00 opened this issue Jul 3, 2024 · 2 comments
Labels

Comments

@wangshuxihe00
Copy link

The insert function here can only be inserted from the last position, which is obviously different from the intention of insert, which should be inserted from any position.

@wangshuxihe00
Copy link
Author

There are also some problems, such as the fact that the insert function in std supports different input parameters, while the stdgpu has only one parameter. There are also such problems in other places, are these specially made because of the features of the device side?

@stotko
Copy link
Owner

stotko commented Jul 5, 2024

While inserting at the the end of the container is straightforward, inserting from an arbitrary position would involve temporary memory allocations. Once could of course first shift the entries located after the insertion position to their new positions, but doing this in parallel only works reliably if the respective memory regions do not overlap (when end() - insert_position <= inserted_elements.size()).

Supporting more versions of insert also depends on deciding on which side this function is most useful, i.e. whether it should be called only from host/CPU or from device/GPU. The version that inserts a single value would be better on the device-side, yet supporting inserting at arbitrary positions might be expensive as all subsequent values need to be shifted in a thread-safe way.

So, these (documented) limitations are present since implementing these features on the device side efficiently is not trivial. Nevertheless, the situation is far from ideal and any suggestions for improvements are very welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants