diff --git a/docs/api/object.md b/docs/api/object.md index bbde0f11d..62ba199cd 100644 --- a/docs/api/object.md +++ b/docs/api/object.md @@ -55,7 +55,7 @@ class MyHostDeviceObjectClass this->_size = 0; } - static MyHostDeviceObjectClass createDeviceObject(const int size) + [[nodiscard]] static MyHostDeviceObjectClass createDeviceObject(const int size) { MyHostDeviceObjectClass result; @@ -71,7 +71,7 @@ class MyHostDeviceObjectClass device_object._size = 0; } - static MyHostDeviceObjectClass createHostObject(const int size) + [[nodiscard]] static MyHostDeviceObjectClass createHostObject(const int size) { MyHostDeviceObjectClass result; diff --git a/examples/createAndDestroyDeviceObject.cpp b/examples/createAndDestroyDeviceObject.cpp index 90678f488..eebcb2604 100644 --- a/examples/createAndDestroyDeviceObject.cpp +++ b/examples/createAndDestroyDeviceObject.cpp @@ -22,7 +22,7 @@ class Image public: Image() = default; - static Image + [[nodiscard]] static Image createDeviceObject(const stdgpu::index_t width, const stdgpu::index_t height) { Image result; @@ -43,7 +43,7 @@ class Image device_object._height = 0; } - static Image + [[nodiscard]] static Image createHostObject(const stdgpu::index_t width, const stdgpu::index_t height) { Image result; diff --git a/src/stdgpu/atomic.cuh b/src/stdgpu/atomic.cuh index 95e2552bb..76b00d5fa 100644 --- a/src/stdgpu/atomic.cuh +++ b/src/stdgpu/atomic.cuh @@ -112,7 +112,7 @@ public: * \return A newly created object of this class allocated on the GPU (device) * \note The size is implicitly set to 1 (and not needed as a parameter) as the object only manages a single value */ - static atomic + [[nodiscard]] static atomic createDeviceObject(const Allocator& allocator = Allocator()); /** @@ -125,7 +125,7 @@ public: */ template >)> - static atomic + [[nodiscard]] static atomic createDeviceObject(ExecutionPolicy&& policy, const Allocator& allocator = Allocator()); /** diff --git a/src/stdgpu/bitset.cuh b/src/stdgpu/bitset.cuh index e8bd69069..239e0db9d 100644 --- a/src/stdgpu/bitset.cuh +++ b/src/stdgpu/bitset.cuh @@ -161,7 +161,7 @@ public: * \param[in] allocator The allocator instance to use * \return A newly created object of this class allocated on the GPU (device) */ - static bitset + [[nodiscard]] static bitset createDeviceObject(const index_t& size, const Allocator& allocator = Allocator()); /** @@ -174,7 +174,7 @@ public: */ template >)> - static bitset + [[nodiscard]] static bitset createDeviceObject(ExecutionPolicy&& policy, const index_t& size, const Allocator& allocator = Allocator()); /** diff --git a/src/stdgpu/memory.h b/src/stdgpu/memory.h index d2a85431d..286221440 100644 --- a/src/stdgpu/memory.h +++ b/src/stdgpu/memory.h @@ -55,7 +55,7 @@ enum class Initialization * \post get_dynamic_memory_type(result) == dynamic_memory_type::device if count > 0 */ template -T* +[[nodiscard]] T* createDeviceArray(const stdgpu::index64_t count, const T default_value = T()); /** @@ -68,7 +68,7 @@ createDeviceArray(const stdgpu::index64_t count, const T default_value = T()); * \post get_dynamic_memory_type(result) == dynamic_memory_type::device if count > 0 */ template -T* +[[nodiscard]] T* createHostArray(const stdgpu::index64_t count, const T default_value = T()); /** @@ -82,7 +82,7 @@ createHostArray(const stdgpu::index64_t count, const T default_value = T()); * \post get_dynamic_memory_type(result) == dynamic_memory_type::managed if count > 0 */ template -T* +[[nodiscard]] T* createManagedArray(const stdgpu::index64_t count, const T default_value = T(), const Initialization initialize_on = Initialization::DEVICE); @@ -139,7 +139,7 @@ enum class MemoryCopy * \note The source array might also be a managed array */ template -T* +[[nodiscard]] T* copyCreateDevice2HostArray(const T* device_array, const stdgpu::index64_t count, const MemoryCopy check_safety = MemoryCopy::RANGE_CHECK); @@ -155,7 +155,7 @@ copyCreateDevice2HostArray(const T* device_array, * \note The source array might also be a managed array */ template -T* +[[nodiscard]] T* copyCreateHost2DeviceArray(const T* host_array, const stdgpu::index64_t count, const MemoryCopy check_safety = MemoryCopy::RANGE_CHECK); @@ -171,7 +171,7 @@ copyCreateHost2DeviceArray(const T* host_array, * \note The source array might also be a managed array */ template -T* +[[nodiscard]] T* copyCreateHost2HostArray(const T* host_array, const stdgpu::index64_t count, const MemoryCopy check_safety = MemoryCopy::RANGE_CHECK); @@ -187,7 +187,7 @@ copyCreateHost2HostArray(const T* host_array, * \note The source array might also be a managed array */ template -T* +[[nodiscard]] T* copyCreateDevice2DeviceArray(const T* device_array, const stdgpu::index64_t count, const MemoryCopy check_safety = MemoryCopy::RANGE_CHECK); diff --git a/src/stdgpu/mutex.cuh b/src/stdgpu/mutex.cuh index e8d930a0d..62c9a356d 100644 --- a/src/stdgpu/mutex.cuh +++ b/src/stdgpu/mutex.cuh @@ -107,7 +107,7 @@ public: * \param[in] allocator The allocator instance to use * \return A newly created object of this class allocated on the GPU (device) */ - static mutex_array + [[nodiscard]] static mutex_array createDeviceObject(const index_t& size, const Allocator& allocator = Allocator()); /** @@ -120,7 +120,7 @@ public: */ template >)> - static mutex_array + [[nodiscard]] static mutex_array createDeviceObject(ExecutionPolicy&& policy, const index_t& size, const Allocator& allocator = Allocator()); /** diff --git a/src/stdgpu/queue.cuh b/src/stdgpu/queue.cuh index 509344b63..cb3334a04 100644 --- a/src/stdgpu/queue.cuh +++ b/src/stdgpu/queue.cuh @@ -65,7 +65,7 @@ public: * \param[in] size The size of managed array * \return A newly created object of this class allocated on the GPU (device) */ - static queue + [[nodiscard]] static queue createDeviceObject(const index_t& size); /** diff --git a/src/stdgpu/stack.cuh b/src/stdgpu/stack.cuh index 9074eff7e..ac8593ad7 100644 --- a/src/stdgpu/stack.cuh +++ b/src/stdgpu/stack.cuh @@ -65,7 +65,7 @@ public: * \param[in] size The size of managed array * \return A newly created object of this class allocated on the GPU (device) */ - static stack + [[nodiscard]] static stack createDeviceObject(const index_t& size); /** diff --git a/src/stdgpu/unordered_map.cuh b/src/stdgpu/unordered_map.cuh index c27cdf5a4..a019f5ebb 100644 --- a/src/stdgpu/unordered_map.cuh +++ b/src/stdgpu/unordered_map.cuh @@ -103,7 +103,7 @@ public: * \pre capacity > 0 * \return A newly created object of this class allocated on the GPU (device) */ - static unordered_map + [[nodiscard]] static unordered_map createDeviceObject(const index_t& capacity, const Allocator& allocator = Allocator()); /** @@ -116,7 +116,7 @@ public: */ template >)> - static unordered_map + [[nodiscard]] static unordered_map createDeviceObject(ExecutionPolicy&& policy, const index_t& capacity, const Allocator& allocator = Allocator()); /** diff --git a/src/stdgpu/unordered_set.cuh b/src/stdgpu/unordered_set.cuh index ac345e678..5a2277f77 100644 --- a/src/stdgpu/unordered_set.cuh +++ b/src/stdgpu/unordered_set.cuh @@ -92,7 +92,7 @@ public: * \pre capacity > 0 * \return A newly created object of this class allocated on the GPU (device) */ - static unordered_set + [[nodiscard]] static unordered_set createDeviceObject(const index_t& capacity, const Allocator& allocator = Allocator()); /** @@ -105,7 +105,7 @@ public: */ template >)> - static unordered_set + [[nodiscard]] static unordered_set createDeviceObject(ExecutionPolicy&& policy, const index_t& capacity, const Allocator& allocator = Allocator()); /** diff --git a/src/stdgpu/vector.cuh b/src/stdgpu/vector.cuh index 0626f2055..71a74c8c8 100644 --- a/src/stdgpu/vector.cuh +++ b/src/stdgpu/vector.cuh @@ -100,7 +100,7 @@ public: * \return A newly created object of this class allocated on the GPU (device) * \pre capacity > 0 */ - static vector + [[nodiscard]] static vector createDeviceObject(const index_t& capacity, const Allocator& allocator = Allocator()); /** @@ -113,7 +113,7 @@ public: */ template >)> - static vector + [[nodiscard]] static vector createDeviceObject(ExecutionPolicy&& policy, const index_t& capacity, const Allocator& allocator = Allocator()); /** diff --git a/tests/stdgpu/memory.inc b/tests/stdgpu/memory.inc index d439041ba..68b87118f 100644 --- a/tests/stdgpu/memory.inc +++ b/tests/stdgpu/memory.inc @@ -1209,7 +1209,7 @@ class TestContainer public: TestContainer() = default; - static TestContainer + [[nodiscard]] static TestContainer createDeviceObject(const stdgpu::index_t size, const Allocator& allocator = Allocator()) { TestContainer result; @@ -1225,7 +1225,7 @@ public: template >)> - static TestContainer + [[nodiscard]] static TestContainer createDeviceObject([[maybe_unused]] ExecutionPolicy&& policy, const stdgpu::index_t size, const Allocator& allocator = Allocator())