Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Memory Resource / View #158

Closed
wants to merge 162 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
e98dad5
Create two macros that flag whether exceptions or RTTI are available,…
wmaxey Jul 20, 2021
47ae762
Add stub memory_resource headers.
jrhemstad Jan 14, 2021
f9d0e0c
Initial memory_resource definition and docs.
jrhemstad Jan 14, 2021
e3b7932
Add intial unique_stream and stream_view classes.
jrhemstad Jan 14, 2021
3ccc32b
Add stream_ordered_memory_resource abstract class.
jrhemstad Jan 14, 2021
3f65584
Fix wonky formatting.
jrhemstad Jan 14, 2021
5d865e5
Internal symbol names.
jrhemstad Jan 19, 2021
04e37c3
Synchronize before (de)allocating.
jrhemstad Jan 19, 2021
80e554f
Doc updates.
jrhemstad Jan 19, 2021
87c3c86
EOF blank lines.
jrhemstad Jan 19, 2021
645cea3
Rename value() to get().
jrhemstad Jan 20, 2021
d2b8077
Remove owning stream wrapper.
jrhemstad Jan 21, 2021
b6f1f6d
Remove stream_view conversion to cudaStream_t.
jrhemstad Jan 21, 2021
bd1a00d
Make stream_view ctor from cudaStream_t implicit.
jrhemstad Jan 21, 2021
a96f150
Remove erroneous template for is_equal.
jrhemstad Jan 21, 2021
97e84fa
Add default implementation of do_is_equal to perform identity compari…
jrhemstad Jan 21, 2021
ee48752
Format.
jrhemstad Jan 21, 2021
b7631f1
Make default alignment to alignof(max_align_t)
jrhemstad Jan 22, 2021
d77f640
Clarify docs about alignment.
jrhemstad Jan 22, 2021
35d0849
Make async private functions virtual.
jrhemstad Jan 22, 2021
da2c650
Sync after allocate in default do_allocate implementation.
jrhemstad Jan 22, 2021
e494129
Rename memory_kind member to kind.
jrhemstad Jan 22, 2021
f8cee68
First draft of execution context in memory_resource.
jrhemstad Jan 22, 2021
b5f6627
Conditionally inherit from std::pmr::memory_resource.
jrhemstad Jan 22, 2021
7a07c90
Clarify memory may still be in use when deallocate_async is called.
jrhemstad Jan 25, 2021
5ba94ed
Move cuda/std/memory_resource to cuda/memory_resource.
jrhemstad Jan 25, 2021
4ca291c
Move cuda/std/stream to cuda/stream.
jrhemstad Jan 25, 2021
6b265e2
Correct comment at endif.
jrhemstad Jan 25, 2021
6378948
Make public stream_view members actually public.
jrhemstad Jan 25, 2021
fdd0a13
Add initial stream_view tests.
jrhemstad Jan 25, 2021
47960cd
Rename test/cuda/stream to test/cuda/stream_view.
jrhemstad Jan 26, 2021
ee116b9
Rename stream header to stream_view.
jrhemstad Jan 26, 2021
2aed9eb
Correct function parameter symbol names.
jrhemstad Jan 26, 2021
23a1d84
Use cuda::std::max_align_t instead of std::max_align_t.
jrhemstad Jan 26, 2021
906a4e9
Add tests for memory_resource members.
jrhemstad Jan 26, 2021
6bde07f
Add test of derived memory_resource.
jrhemstad Jan 26, 2021
520dc78
Add derived stream_ordered_memory_resource tests.
jrhemstad Jan 26, 2021
659ff54
Add cudaexcept header.
jrhemstad Jan 26, 2021
57036ea
Add throw_on_cuda_error function.
jrhemstad Jan 26, 2021
381ef33
Use throw_on_cuda_error in stream_view::synchronize.
jrhemstad Jan 26, 2021
3103f9d
Build CUDA error string in cuda_error ctor.
jrhemstad Jan 26, 2021
80f9907
cudaexcept doesn't need to include cuda_util.
jrhemstad Jan 26, 2021
493c911
Update stream_view::synchronize docs about thrown exception.
jrhemstad Jan 26, 2021
e83b73e
Don't delegate single argument cudaErrot_t ctor.
jrhemstad Jan 26, 2021
a3806af
Add tests for cuda_error.
jrhemstad Jan 26, 2021
42939f1
Verify code in thrown exception.
jrhemstad Jan 27, 2021
1bb6017
Rename cudaexcept header to cuda/exception.
jrhemstad Jan 28, 2021
74758d8
Update include for cuda/exception.
jrhemstad Jan 28, 2021
d26e8b7
Rename cuda_util header to __cuda_util.
jrhemstad Jan 28, 2021
f16fd51
Make memory_resource::do_get_context pure virtual.
jrhemstad Jan 28, 2021
ccbbc23
Make do_get_context in stream resource final.
jrhemstad Jan 28, 2021
36ea9a8
Delegate `get_context` implementation to base class.
jrhemstad Feb 1, 2021
fdf8b37
Add tests for overriding do_get_context.
jrhemstad Feb 1, 2021
0e94d50
Remove cuda::memory_resource inheritiance from std::pmr.
jrhemstad Feb 4, 2021
b6d5c36
Update definition of pmr_adaptor to check for presence of `<memory_re…
jrhemstad Feb 4, 2021
682a68e
Update endif comment.
jrhemstad Feb 4, 2021
de953ea
Need to move the passed Pointer.
jrhemstad Feb 4, 2021
e4ba29c
Fix symbol names in pmr_adaptor.
jrhemstad Feb 4, 2021
1cff649
Move stream_ordered_memory_resource tests to their own directory.
jrhemstad Feb 4, 2021
ac8aa21
Add __pmr_adaptor_base intermediate.
jrhemstad Feb 4, 2021
cc3cad3
Tests for pmr_adaptor.
jrhemstad Feb 5, 2021
5318bbf
Add tests for equality of pmr_adaptor.
jrhemstad Feb 8, 2021
da320e8
Prefix throw_on_cuda_error with double underscore.
jrhemstad Feb 8, 2021
6ba42e8
Add stub memory_resource headers.
jrhemstad Jan 14, 2021
e0c4195
Initial memory_resource definition and docs.
jrhemstad Jan 14, 2021
09e7bb6
Add intial unique_stream and stream_view classes.
jrhemstad Jan 14, 2021
9664913
Add stream_ordered_memory_resource abstract class.
jrhemstad Jan 14, 2021
a04f690
Fix wonky formatting.
jrhemstad Jan 14, 2021
e929d27
Internal symbol names.
jrhemstad Jan 19, 2021
4328b67
Synchronize before (de)allocating.
jrhemstad Jan 19, 2021
eb93da5
Doc updates.
jrhemstad Jan 19, 2021
47c5b8d
EOF blank lines.
jrhemstad Jan 19, 2021
084bd1a
Rename value() to get().
jrhemstad Jan 20, 2021
68becc7
Remove owning stream wrapper.
jrhemstad Jan 21, 2021
39c07a2
Remove stream_view conversion to cudaStream_t.
jrhemstad Jan 21, 2021
3e4e1d2
Make stream_view ctor from cudaStream_t implicit.
jrhemstad Jan 21, 2021
4d022ab
Remove erroneous template for is_equal.
jrhemstad Jan 21, 2021
6364727
Add default implementation of do_is_equal to perform identity compari…
jrhemstad Jan 21, 2021
c33e67d
Format.
jrhemstad Jan 21, 2021
8038d08
Make default alignment to alignof(max_align_t)
jrhemstad Jan 22, 2021
3255270
Clarify docs about alignment.
jrhemstad Jan 22, 2021
04d809b
Make async private functions virtual.
jrhemstad Jan 22, 2021
5071663
Sync after allocate in default do_allocate implementation.
jrhemstad Jan 22, 2021
92c261c
Rename memory_kind member to kind.
jrhemstad Jan 22, 2021
38af784
First draft of execution context in memory_resource.
jrhemstad Jan 22, 2021
4449c30
Conditionally inherit from std::pmr::memory_resource.
jrhemstad Jan 22, 2021
f2d1249
Clarify memory may still be in use when deallocate_async is called.
jrhemstad Jan 25, 2021
6e45682
Move cuda/std/memory_resource to cuda/memory_resource.
jrhemstad Jan 25, 2021
01b2e7e
Move cuda/std/stream to cuda/stream.
jrhemstad Jan 25, 2021
51519c8
Correct comment at endif.
jrhemstad Jan 25, 2021
142b830
Make public stream_view members actually public.
jrhemstad Jan 25, 2021
a8ffe8f
Add initial stream_view tests.
jrhemstad Jan 25, 2021
adc7f8d
Rename test/cuda/stream to test/cuda/stream_view.
jrhemstad Jan 26, 2021
1c2c1f3
Rename stream header to stream_view.
jrhemstad Jan 26, 2021
973b1bb
Correct function parameter symbol names.
jrhemstad Jan 26, 2021
2798a5c
Use cuda::std::max_align_t instead of std::max_align_t.
jrhemstad Jan 26, 2021
e813908
Add tests for memory_resource members.
jrhemstad Jan 26, 2021
1d3be3f
Add test of derived memory_resource.
jrhemstad Jan 26, 2021
1dab7fa
Add derived stream_ordered_memory_resource tests.
jrhemstad Jan 26, 2021
fbd1b6e
Add cudaexcept header.
jrhemstad Jan 26, 2021
5d5caac
Add throw_on_cuda_error function.
jrhemstad Jan 26, 2021
8675c03
Build CUDA error string in cuda_error ctor.
jrhemstad Jan 26, 2021
4e41555
cudaexcept doesn't need to include cuda_util.
jrhemstad Jan 26, 2021
7d902cf
Don't delegate single argument cudaErrot_t ctor.
jrhemstad Jan 26, 2021
be60e50
Add tests for cuda_error.
jrhemstad Jan 26, 2021
c0f313c
Verify code in thrown exception.
jrhemstad Jan 27, 2021
373dc57
Rename cudaexcept header to cuda/exception.
jrhemstad Jan 28, 2021
fc38d9a
Update include for cuda/exception.
jrhemstad Jan 28, 2021
f87f7f6
Rename cuda_util header to __cuda_util.
jrhemstad Jan 28, 2021
e277a85
Make memory_resource::do_get_context pure virtual.
jrhemstad Jan 28, 2021
9ac28c9
Make do_get_context in stream resource final.
jrhemstad Jan 28, 2021
9fea2e4
Delegate `get_context` implementation to base class.
jrhemstad Feb 1, 2021
bb2719f
Remove cuda::memory_resource inheritiance from std::pmr.
jrhemstad Feb 4, 2021
652af93
Update definition of pmr_adaptor to check for presence of `<memory_re…
jrhemstad Feb 4, 2021
31d66ac
Update endif comment.
jrhemstad Feb 4, 2021
5629299
Need to move the passed Pointer.
jrhemstad Feb 4, 2021
a18cb23
Fix symbol names in pmr_adaptor.
jrhemstad Feb 4, 2021
158feee
Move stream_ordered_memory_resource tests to their own directory.
jrhemstad Feb 4, 2021
fcc283d
Add __pmr_adaptor_base intermediate.
jrhemstad Feb 4, 2021
8712779
Enable pmr_adaptor for any host accessible memory kind.
jrhemstad Feb 16, 2021
98a8858
Remove comment.
jrhemstad Feb 16, 2021
348fabb
Add missing template parameter.
jrhemstad Feb 19, 2021
8c14994
Clarify throw docs.
jrhemstad Mar 1, 2021
a735037
Further info on stream-ordered memory allocation.
jrhemstad Mar 1, 2021
c9b53da
Update doxygen block style.
jrhemstad Mar 1, 2021
3c71f2a
Update Doxygen tag style.
jrhemstad Mar 1, 2021
6e1882f
More doxygen tag style.
jrhemstad Mar 1, 2021
d83934f
Add links to string_view and span to stream_view.
jrhemstad Mar 1, 2021
ebc7ddc
Make stream_view default ctor noexcept.
jrhemstad Mar 1, 2021
260caba
Document implicit conversion from cudaStream-t.
jrhemstad Mar 1, 2021
419f29b
Document implicit conversion in comparison operators.
jrhemstad Mar 1, 2021
d92fdc1
Add value_type member alias in stream_view for cudaStream_t.
jrhemstad Mar 1, 2021
e13c6ba
Add test for stream_view::value_type.
jrhemstad Mar 1, 2021
3b8b97a
Use fully qualified name for cudaStream-t.
jrhemstad Mar 1, 2021
00a5fe4
Use value_type alias.
jrhemstad Mar 1, 2021
ac90a7f
Use fully qualified named for cudaStreamSynchronize.
jrhemstad Mar 1, 2021
3f40bcc
Use fully qualified cuda names.
jrhemstad Mar 1, 2021
9a8d144
Rename `synchronize` to `wait`.
jrhemstad Mar 1, 2021
d3a4006
Add test for stream_view::wait.
jrhemstad Mar 1, 2021
a07b740
Add stream_view::ready function.
jrhemstad Mar 1, 2021
0419a42
Add destruction of stream in stream_view::wait test.
jrhemstad Mar 1, 2021
16103ce
Add test for stream_view::ready.
jrhemstad Mar 1, 2021
025d184
Refactoring for resource/view model
mzient Apr 24, 2021
720ae7e
Fix problems with resource view. Add tests for resource_view.
mzient Apr 26, 2021
91b7abc
Add a test checking that the interface of the resource pointer is
mzient Apr 27, 2021
698a502
Review issues + comparison
mzient Jun 7, 2021
696be93
Fix pmr wrapper.
mzient Jun 17, 2021
fda1658
Fix clang build warnings.
mzient Jul 1, 2021
c8dbdf8
Fix comparison - step 1.
mzient Jul 20, 2021
b43ce65
Workaround dynamic cast for private bases.
mzient Jul 21, 2021
af7bd53
* Allow comparing views of null resources
mzient Aug 4, 2021
377a1e6
Add missing `inline` and visibility specifiers to `__throw_on_cuda_er…
mzient Aug 5, 2021
2285a65
Add missing inline.
mzient Aug 30, 2021
64728e0
Fix C++17 build without PMR headers.
mzient Oct 13, 2021
45aeec4
Enable comparison between resource_views and memory_resource pointers.
mzient Oct 20, 2021
484c23d
Remove compatibility check from view comparison.
mzient Oct 26, 2021
03ee4f8
Add memory_resource reference comparison.
mzient Oct 27, 2021
67624c5
Remove context.
mzient Nov 10, 2021
0a6b39e
Remove unused typedefs.
mzient Nov 12, 2021
545d87b
Add property_list.
mzient Dec 7, 2021
199d584
Rename resource_view to resource_ptr.
mzient Dec 7, 2021
64f087f
Move memory resource to namespace pmr. Drop 'memory' from stream_orde…
mzient Dec 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions include/cuda/memory_resource
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,44 @@ bool __is_type(const ::std::type_info *__ti1, const void *__fallback_ti1) {
template <typename _ResourcePointer, typename... _Properties>
class basic_resource_view;

template <typename... _Properties>
struct properties;


namespace detail {
template <typename... _Properties>
struct __kind_from_properties_helper {
using type = void;
};

template <typename... _Properties>
using __kind_from_properties_helper_t = typename __kind_from_properties_helper<_Properties...>::type;

template <typename _Kind, typename... _Tail>
struct __kind_from_properties_helper<is_kind<_Kind>, _Tail...> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code does not compile for me anymore after this latest change -- is_kind is not defined until later in the file.

deps/libcudacxx-src/include/cuda/memory_resource:129:40: error: 'is_kind' was not declared in this scope
  129 |   struct __kind_from_properties_helper<is_kind<_Kind>, _Tail...> {
      |                                        ^~~~~~~
_deps/libcudacxx-src/include/cuda/memory_resource:129:53: error: template argument 1 is invalid
  129 |   struct __kind_from_properties_helper<is_kind<_Kind>, _Tail...> {
      |                                                     ^
_deps/libcudacxx-src/include/cuda/memory_resource:149:3: error: wrong number of template arguments (2, should be 3)
  149 |   >;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix for this appears to be to move the struct is_kind definition above this.

using type = _Kind;
};

template <typename _FirstProp, typename... _Tail>
struct __kind_from_properties_helper<_FirstProp, _Tail...> {
using type = __kind_from_properties_helper_t<_Tail...>;
};
}


/*!
* \brief Evaluaes to the a memory kind tag form _Properties (if listed as is_kind)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* \brief Evaluaes to the a memory kind tag form _Properties (if listed as is_kind)
* \brief Evaluates to the a memory kind tag from _Properties (if listed as is_kind)

* or to a list of properties otherwise.
*/
template <typename... _Properties>
struct kind_from_properties {
using type = _CUDA_VSTD::conditional_t<
_CUDA_VSTD::is_same<detail::__kind_from_properties_helper_t<_Properties...>, void>,
detail::__kind_from_properties_helper_t<_Properties...>
>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this is supposed to compile. conditional_t takes 3 template parameters, not two, and the first one is a non-type parameter (so use is_same_v). Unfortunately I don't know what the T parameter for conditional_t should be (the case where the properties list is void). Should it be void as well?:

Suggested change
struct kind_from_properties {
using type = _CUDA_VSTD::conditional_t<
_CUDA_VSTD::is_same<detail::__kind_from_properties_helper_t<_Properties...>, void>,
detail::__kind_from_properties_helper_t<_Properties...>
>;
struct kind_from_properties {
using type = _CUDA_VSTD::conditional_t<
_CUDA_VSTD::is_same_v<detail::__kind_from_properties_helper_t<_Properties...>, void>,
void,
detail::__kind_from_properties_helper_t<_Properties...>
>;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It compiles if I write it as above, but I'm not sure if it's correct.

};


/*!
* \brief Groups the tag types denoting the execution environment in which the memory can be accessed
*
Expand Down Expand Up @@ -815,8 +853,6 @@ public:

template <typename _Ptr2, typename... _Props2>
bool operator==(const cuda::basic_resource_view<_Ptr2, _Props2...> &__v2) const noexcept {
using __view1_t = basic_resource_view;
using __view2_t = basic_resource_view<_Ptr2, _Props2...>;
if (__pointer == nullptr || __v2.__pointer == nullptr)
return __pointer == nullptr && __v2.__pointer == nullptr;
return static_cast<const detail::memory_resource_base*>(__pointer)->is_equal(*__v2.__pointer);
harrism marked this conversation as resolved.
Show resolved Hide resolved
Expand Down