From 4f568221a29e4f0f747db1228e95be9931abf69d Mon Sep 17 00:00:00 2001 From: Duncan McBain Date: Tue, 15 Oct 2019 17:04:04 +0100 Subject: [PATCH 1/3] Update default-ctor proposal Feedback has been gathered from internal prototyping and we have used this to inform the proposal. --- .../default-constructed-buffers.md | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/default-constructed-buffers/default-constructed-buffers.md b/default-constructed-buffers/default-constructed-buffers.md index 073ee9d..ca31031 100644 --- a/default-constructed-buffers/default-constructed-buffers.md +++ b/default-constructed-buffers/default-constructed-buffers.md @@ -7,7 +7,7 @@ Date of Creation | 2019-08-20 Target | SYCL 1.2.1 Status | _Draft_ Author | Duncan McBain [Duncan McBain](mailto:duncan@codeplay.com) -Contributors | Duncan McBain, [Gordon Brown](mailto:gordon@codeplay.com) +Contributors | Duncan McBain, [Gordon Brown](mailto:gordon@codeplay.com), [Ruyman Reyes](mailto:ruyman@codeplay.com) ## Description @@ -34,7 +34,8 @@ aid their use in this style of generic interface. ## Proposal The `cl::sycl::buffer` class should be augmented with an additional constructor -that takes no arguments, which initialises the buffer with a zero-size range. +that takes no arguments, which default-constructs the buffer in an +implementation-defined manner. ```c++ namespace cl { namespace sycl { @@ -43,7 +44,7 @@ typename AllocatorT = cl::sycl::buffer_allocator> class buffer { buffer(); - bool is_valid() const noexcept; + bool has_storage() const noexcept; explicit operator bool() const noexcept; }; @@ -53,18 +54,21 @@ class buffer { The template arguments should remain the same, so that the argument can be rebound to a new `buffer` instance later using the copy constructor. -The `is_valid()` call would allow the programmer to query whether or not -the buffer can be used, i.e. whether or not it was constructed with a range of -size zero. The explicit conversion operator would call this same function but -allow its use in `if` statements. +The `has_storage()` call would allow the programmer to query whether or not +the buffer can be used, i.e. whether or not it was default-constructed. The +explicit conversion operator would call this same function but allow its use +in `if` statements. Requesting access from a default-constructed buffer should throw an exception. -It is not meaningful to use a zero-sized allocation on-device. Since there is -no allocation associated with the `buffer`, `cl::sycl::buffer::set_final_data` -and `cl::sycl::buffer::set_write_back` should behave as if the `buffer` had a -final pointer of `nullptr` at all times. The other functions in the `buffer` -API should behave as though the buffer were constructed with a `range` of size -zero and otherwise behave normally. +It is not meaningful to use a default-constructed buffer on-device. Since there +is no allocation associated with a default-constructed `buffer`, +`cl::sycl::buffer::set_final_data` and `cl::sycl::buffer::set_write_back` +should behave as if the `buffer` had a final pointer of `nullptr` at all times. +The other functions in the `buffer` API should behave as though the buffer were +constructed with a `range` of size zero and otherwise behave normally. + +Explicitly constructing a buffer with a range of zero is not allowed. This does +not correspond to a valid device allocation. ## Sample code From f6027bebd734cf49f1de5b33af860b6491558908 Mon Sep 17 00:00:00 2001 From: Duncan McBain Date: Thu, 17 Oct 2019 12:10:25 +0100 Subject: [PATCH 2/3] Remove unnecessary hyphen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Peter Žužek --- default-constructed-buffers/default-constructed-buffers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-constructed-buffers/default-constructed-buffers.md b/default-constructed-buffers/default-constructed-buffers.md index ca31031..6547b4d 100644 --- a/default-constructed-buffers/default-constructed-buffers.md +++ b/default-constructed-buffers/default-constructed-buffers.md @@ -60,7 +60,7 @@ explicit conversion operator would call this same function but allow its use in `if` statements. Requesting access from a default-constructed buffer should throw an exception. -It is not meaningful to use a default-constructed buffer on-device. Since there +It is not meaningful to use a default-constructed buffer on device. Since there is no allocation associated with a default-constructed `buffer`, `cl::sycl::buffer::set_final_data` and `cl::sycl::buffer::set_write_back` should behave as if the `buffer` had a final pointer of `nullptr` at all times. From 5e1db84c3eac34faae5e312cd6483f19fc793850 Mon Sep 17 00:00:00 2001 From: Duncan McBain Date: Mon, 18 Nov 2019 13:40:32 +0000 Subject: [PATCH 3/3] Slightly generalise wording around validity --- default-constructed-buffers/default-constructed-buffers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default-constructed-buffers/default-constructed-buffers.md b/default-constructed-buffers/default-constructed-buffers.md index 6547b4d..ab52a75 100644 --- a/default-constructed-buffers/default-constructed-buffers.md +++ b/default-constructed-buffers/default-constructed-buffers.md @@ -60,7 +60,7 @@ explicit conversion operator would call this same function but allow its use in `if` statements. Requesting access from a default-constructed buffer should throw an exception. -It is not meaningful to use a default-constructed buffer on device. Since there +It is not meaningful to use a default-constructed buffer. Since there is no allocation associated with a default-constructed `buffer`, `cl::sycl::buffer::set_final_data` and `cl::sycl::buffer::set_write_back` should behave as if the `buffer` had a final pointer of `nullptr` at all times. @@ -68,7 +68,7 @@ The other functions in the `buffer` API should behave as though the buffer were constructed with a `range` of size zero and otherwise behave normally. Explicitly constructing a buffer with a range of zero is not allowed. This does -not correspond to a valid device allocation. +not correspond to a valid allocation. ## Sample code