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

Add a unique_region_t class or some equivalent mechanism #291

Closed
eyalroz opened this issue Jan 1, 2022 · 2 comments
Closed

Add a unique_region_t class or some equivalent mechanism #291

eyalroz opened this issue Jan 1, 2022 · 2 comments

Comments

@eyalroz
Copy link
Owner

eyalroz commented Jan 1, 2022

As we all know (or should know), the C++ standard's smart pointers class suck. Why? Because ownership should be of regions, not pointers, and it's inane to expect allocators or the operating system to keep track of your allocated region sizes based on their starting address. Allocators should return regions, not pointers. The same goes for a smart pointer. You can't make a copy of it, you can't cast it into a container, nothing - unless you also remember the size you allocated.

Now, for the non-ownership-tracking case, we have already solved this for our library, using memory_region_t. It's not perfect, but it's quite usable. I only wish I had the luxury of accepting only memory regions rather than raw-pointers-and-sizes as separate parameters.

Anyway, we have make_unique() variants for various memory spaces, to correspond to what the standard library offers with ownership tracking. But what I would really like people to use is uniquely-owned memory regions: unique_region_t. So, let's add these. I suppose we could have a unique_ptr-like-class under cuda::memory::detail_, with a custom allocator and deleter, which also has a size method and perhaps additional relevant methods. Then for every unique_ptr + make_unique we have now, we could have a unique_region_t + make_unique_region. And then we might consider getting rid of the unique_ptr's altogether.

Alternatively, we could have the allocate() functions always produce an appropriate unique_region_t. That would make use of the library safer in avoiding resource leakage, and would obviate special creation functions.

A third alternative is to make the region_t class have another boolean value, indicating ownership, like the properly-CUDA-ish wrappers (stream_t, event_t, context_t, program_t etc.). That would avoid "definition inflation" in the library - and maybe even reduce the amount of definitions if we get rid of the unique_ptr's. But it would make region_t a more "suspicious" class.

@eyalroz eyalroz changed the title Add a unique_region_t class Add a unique_region_t class or some equivalent mechanism Jan 1, 2022
@eyalroz
Copy link
Owner Author

eyalroz commented Jan 1, 2022

@codecircuit : Ping...

eyalroz added a commit that referenced this issue Feb 11, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 12, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 13, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 13, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 13, 2024
…an. It should provide the most flexibility in our example programs (and typical user programs) for direct use without explicit casting, re-specifying types and sizes, etc.
eyalroz added a commit that referenced this issue Feb 14, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 15, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 16, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 26, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 26, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 27, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 27, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Feb 29, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Mar 1, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
@eyalroz
Copy link
Owner Author

eyalroz commented Mar 1, 2024

This will happen with v0.6.9

eyalroz added a commit that referenced this issue Mar 1, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Mar 1, 2024
…hould provide the most flexibility in our example programs (and typical user programs) for direct use without explicit casting, re-specifying types and sizes, etc.
eyalroz added a commit that referenced this issue Mar 8, 2024
…hould provide the most flexibility in our example programs (and typical user programs) for direct use without explicit casting, re-specifying types and sizes, etc.
eyalroz added a commit that referenced this issue Mar 10, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Mar 10, 2024
…hould provide the most flexibility in our example programs (and typical user programs) for direct use without explicit casting, re-specifying types and sizes, etc.
eyalroz added a commit that referenced this issue Mar 10, 2024
…hould provide the most flexibility in our example programs (and typical user programs) for direct use without explicit casting, re-specifying types and sizes, etc.
eyalroz added a commit that referenced this issue Mar 10, 2024
…hould provide the most flexibility in our example programs (and typical user programs) for direct use without explicit casting, re-specifying types and sizes, etc.
eyalroz added a commit that referenced this issue Mar 10, 2024
…hould provide the most flexibility in our example programs (and typical user programs) for direct use without explicit casting, re-specifying types and sizes, etc.
eyalroz added a commit that referenced this issue Apr 20, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
eyalroz added a commit that referenced this issue Apr 20, 2024
…hould provide the most flexibility in our example programs (and typical user programs) for direct use without explicit casting, re-specifying types and sizes, etc.
eyalroz added a commit that referenced this issue Apr 29, 2024
* Added a `unique_region` class - non-templated
* `unique_region`'s "decay" into `cuda::memory::region_t`'s - so there's no need to reimplement half the world for them
* Added a missing variant of `cuda::memory::copy()`
* Added an example program based on vectorAdd, which uses unique_regions (I would have replaced vectorAdd with it - had it not requirted to lines of source more than before...)
* `region_t`'s now have an `as_span` method, as well as an `operator span()`
* Removed some commented-out unique-pointer-related code
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