From ba373d77699ed16ce4285425b9081eb464cad57f Mon Sep 17 00:00:00 2001 From: Hugh Bird Date: Fri, 7 Jul 2023 16:14:58 +0100 Subject: [PATCH 1/3] [oneMKL] dft::descriptor copy and move (#487) * Relates to https://github.com/oneapi-src/oneAPI-spec/issues/487 * Adds move constructor/assignment to descriptor class * Otherwise implicitly deleted. * Add explicit copy constructor/assignment to descriptor class * Otherwise ambigiuous * Notes that copy operation is by value. --- .../oneMKL/source/domains/dft/descriptor.rst | 88 ++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/source/elements/oneMKL/source/domains/dft/descriptor.rst b/source/elements/oneMKL/source/domains/dft/descriptor.rst index 58beb77f7d..f28280cce1 100644 --- a/source/elements/oneMKL/source/domains/dft/descriptor.rst +++ b/source/elements/oneMKL/source/domains/dft/descriptor.rst @@ -39,7 +39,15 @@ The descriptor class lives in the ``oneapi::mkl::dft`` namespace. // Syntax for d-dimensional DFT descriptor(std::vector dimensions); - + + descriptor(const descriptor&); + + descriptor(descriptor&&); + + descriptor& descriptor::operator=(const descriptor&); + + descriptor& descriptor::operator=(descriptor&&); + ~descriptor(); @@ -78,6 +86,8 @@ The descriptor class lives in the ``oneapi::mkl::dft`` namespace. - Description * - :ref:`constructors` - Initialize descriptor for 1-dimensional or N-dimensional transformations + * - :ref:`assignment operators` + - Assignment operator. * - :ref:`onemkl_dft_descriptor_set_value` - Sets one particular configuration parameter with the specified configuration value. * - :ref:`onemkl_dft_descriptor_get_value` @@ -104,6 +114,8 @@ factors. The function :ref:`onemkl_dft_descriptor_commit` does this work after use of the function :ref:`onemkl_dft_descriptor_set_value` to set values of all necessary parameters. +The copy constructor copies by value. + .. rubric:: Syntax (one-dimensional transform) .. code-block:: cpp @@ -127,6 +139,28 @@ of all necessary parameters. } +.. rubric:: Copy constructor + +.. code-block:: cpp + + namespace oneapi::mkl::dft { + + template + descriptor(const descriptor& other); + + } + +.. rubric:: Move constructor + +.. code-block:: cpp + + namespace oneapi::mkl::dft { + + template + descriptor(descriptor&& other); + + } + .. container:: section @@ -138,6 +172,9 @@ of all necessary parameters. dimensions vector of :math:`d\geq 0` dimensions(lengths) of data for a d-dimensional transform. + other + another descriptor of the same type to copy or move + .. container:: section .. rubric:: Throws @@ -154,6 +191,55 @@ of all necessary parameters. **Descriptor class member table:** :ref:`onemkl_dft_descriptor_member_table` +.. _onemkl_dft_descriptor_assignment_operator: + +Descriptor class assignment operators ++++++++++++++++++++++++++++++++++++++ + +The assignment operators allow assignment operations. +The copy assignment operator results in a copy by value. + +.. rubric:: Copy assignment + +.. code-block:: cpp + + namespace oneapi::mkl::dft { + + template + descriptor& descriptor::operator=(const descriptor& other); + + } + +.. rubric:: Move assignment + +.. code-block:: cpp + + namespace oneapi::mkl::dft { + + template + descriptor& descriptor::operator=(descriptor&& other); + + } + + +.. container:: section + + .. rubric:: Input Parameters + + other + The descriptor to copy or move from. + +.. container:: section + + .. rubric:: Throws + + The assignment opererator shall throw the following exceptions if the associated condition is detected. An implementation may throw additional implementation-specific exception(s) in case of error conditions not covered here: + + :ref:`oneapi::mkl::host_bad_alloc()` + If any memory allocations on host have failed, for instance due to insufficient memory. + + +**Descriptor class member table:** :ref:`onemkl_dft_descriptor_member_table` .. _onemkl_dft_descriptor_set_value: From 9f9053386a24e589f26254ba79f7157a693803aa Mon Sep 17 00:00:00 2001 From: Hugh Bird Date: Mon, 10 Jul 2023 11:22:28 +0100 Subject: [PATCH 2/3] Correct assignment signatures; Clarify copy by value to deep-copy --- source/elements/oneMKL/source/domains/dft/descriptor.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/elements/oneMKL/source/domains/dft/descriptor.rst b/source/elements/oneMKL/source/domains/dft/descriptor.rst index f28280cce1..546a121410 100644 --- a/source/elements/oneMKL/source/domains/dft/descriptor.rst +++ b/source/elements/oneMKL/source/domains/dft/descriptor.rst @@ -44,9 +44,9 @@ The descriptor class lives in the ``oneapi::mkl::dft`` namespace. descriptor(descriptor&&); - descriptor& descriptor::operator=(const descriptor&); + descriptor& operator=(const descriptor&); - descriptor& descriptor::operator=(descriptor&&); + descriptor& operator=(descriptor&&); ~descriptor(); @@ -114,7 +114,7 @@ factors. The function :ref:`onemkl_dft_descriptor_commit` does this work after use of the function :ref:`onemkl_dft_descriptor_set_value` to set values of all necessary parameters. -The copy constructor copies by value. +The copy constructor is a deep copy of the constructor. .. rubric:: Syntax (one-dimensional transform) @@ -196,8 +196,7 @@ The copy constructor copies by value. Descriptor class assignment operators +++++++++++++++++++++++++++++++++++++ -The assignment operators allow assignment operations. -The copy assignment operator results in a copy by value. +The copy assignment operator results in a deep copy. .. rubric:: Copy assignment From 656553a9ad30eca75734b147fb3c1094b692fbf9 Mon Sep 17 00:00:00 2001 From: HJA Bird <9040797+hjabird@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:58:00 +0100 Subject: [PATCH 3/3] Reword (Suggestion FMarno) Co-authored-by: Finlay --- source/elements/oneMKL/source/domains/dft/descriptor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/elements/oneMKL/source/domains/dft/descriptor.rst b/source/elements/oneMKL/source/domains/dft/descriptor.rst index 546a121410..ea3defe88a 100644 --- a/source/elements/oneMKL/source/domains/dft/descriptor.rst +++ b/source/elements/oneMKL/source/domains/dft/descriptor.rst @@ -114,7 +114,7 @@ factors. The function :ref:`onemkl_dft_descriptor_commit` does this work after use of the function :ref:`onemkl_dft_descriptor_set_value` to set values of all necessary parameters. -The copy constructor is a deep copy of the constructor. +The copy constructor performs a deep copy of the descriptor. .. rubric:: Syntax (one-dimensional transform)