Skip to content

Commit

Permalink
handle deprecation warnings uniformly
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj committed Oct 28, 2023
1 parent d9bd299 commit 534e3fb
Show file tree
Hide file tree
Showing 32 changed files with 229 additions and 374 deletions.
17 changes: 2 additions & 15 deletions core/reorder/rcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,7 @@ void rcm_reorder(matrix::SparsityCsr<ValueType, IndexType>* mtx,
}


#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 5211, 4973, 4974)
#endif
GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS


template <typename ValueType, typename IndexType>
Expand Down Expand Up @@ -164,12 +156,7 @@ Rcm<ValueType, IndexType>::Rcm(const Factory* factory,
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_RCM);


#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
GKO_END_DISABLE_DEPRECATION_WARNINGS


} // namespace reorder
Expand Down
22 changes: 6 additions & 16 deletions core/test/log/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************<GINKGO LICENSE>*******************************/

#include <ginkgo/core/log/logger.hpp>

// force-top: on
#include <ginkgo/core/base/types.hpp>
GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS
// force-top: off

#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 5211, 4973, 4974)
#endif
#include <ginkgo/core/log/logger.hpp>


#include <memory>
Expand Down Expand Up @@ -362,9 +357,4 @@ TEST(IterationCompleteOverload, CanLogCurrent)
} // namespace


#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
GKO_END_DISABLE_DEPRECATION_WARNINGS
10 changes: 1 addition & 9 deletions core/test/preconditioner/ic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/preconditioner/ic.hpp>


#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 5211, 4973, 4974)
#endif
GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS


#include <memory>
Expand Down
10 changes: 1 addition & 9 deletions core/test/preconditioner/ilu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/preconditioner/ilu.hpp>


#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 5211, 4973, 4974)
#endif
GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS


#include <memory>
Expand Down
10 changes: 1 addition & 9 deletions core/test/reorder/rcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/reorder/rcm.hpp>


#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 5211, 4973, 4974)
#endif
GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS


#include <memory>
Expand Down
17 changes: 2 additions & 15 deletions core/test/reorder/scaled_reordered.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/solver/bicgstab.hpp>


#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 5211, 4973, 4974)
#endif
GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS


namespace {
Expand Down Expand Up @@ -145,9 +137,4 @@ TEST_F(ScaledReorderedFactory, CanSetColScaling)
} // namespace


#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
GKO_END_DISABLE_DEPRECATION_WARNINGS
10 changes: 1 addition & 9 deletions cuda/test/reorder/rcm_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ginkgo/core/reorder/rcm.hpp>


#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

#endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 5211, 4973, 4974)
#endif
GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS


#include <gtest/gtest.h>
Expand Down
4 changes: 2 additions & 2 deletions include/ginkgo/core/base/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class const_array_view {


template <typename ValueType>
using ConstArrayView [[deprecated("please use const_array_view")]] =
using ConstArrayView GKO_DEPRECATED("please use const_array_view") =
const_array_view<ValueType>;


Expand Down Expand Up @@ -714,7 +714,7 @@ class array {


template <typename ValueType>
using Array [[deprecated("please use array")]] = array<ValueType>;
using Array GKO_DEPRECATED("please use array") = array<ValueType>;


/**
Expand Down
45 changes: 21 additions & 24 deletions include/ginkgo/core/base/executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,24 +1307,20 @@ class EnableDeviceReset {
*
* @param device_reset whether to allow a device reset or not
*/
[[deprecated(
GKO_DEPRECATED(
"device_reset is no longer supported, call "
"cudaDeviceReset/hipDeviceReset manually")]] void
set_device_reset(bool device_reset)
{}
"cudaDeviceReset/hipDeviceReset manually")
void set_device_reset(bool device_reset) {}

/**
* Returns the current status of the device reset boolean for this executor.
*
* @return the current status of the device reset boolean for this executor.
*/
[[deprecated(
GKO_DEPRECATED(
"device_reset is no longer supported, call "
"cudaDeviceReset/hipDeviceReset manually")]] bool
get_device_reset()
{
return false;
}
"cudaDeviceReset/hipDeviceReset manually")
bool get_device_reset() { return false; }

protected:
/**
Expand All @@ -1334,11 +1330,10 @@ class EnableDeviceReset {
*/
EnableDeviceReset() {}

[[deprecated(
GKO_DEPRECATED(
"device_reset is no longer supported, call "
"cudaDeviceReset/hipDeviceReset manually")]] EnableDeviceReset(bool
device_reset)
{}
"cudaDeviceReset/hipDeviceReset manually")
EnableDeviceReset(bool device_reset) {}
};


Expand Down Expand Up @@ -1530,13 +1525,14 @@ class CudaExecutor : public detail::ExecutorBase<CudaExecutor>,
* on. See @allocation_mode for more details
* @param stream the stream to execute operations on.
*/
[[deprecated(
GKO_DEPRECATED(
"device_reset is deprecated entirely, call cudaDeviceReset directly. "
"alloc_mode was replaced by the Allocator type "
"hierarchy.")]] static std::shared_ptr<CudaExecutor>
create(int device_id, std::shared_ptr<Executor> master, bool device_reset,
allocation_mode alloc_mode = default_cuda_alloc_mode,
CUstream_st* stream = nullptr);
"hierarchy.")
static std::shared_ptr<CudaExecutor> create(
int device_id, std::shared_ptr<Executor> master, bool device_reset,
allocation_mode alloc_mode = default_cuda_alloc_mode,
CUstream_st* stream = nullptr);

/**
* Creates a new CudaExecutor with a custom allocator and device stream.
Expand Down Expand Up @@ -1743,13 +1739,14 @@ class HipExecutor : public detail::ExecutorBase<HipExecutor>,
* @param alloc_mode the allocation mode that the executor should operate
* on. See @allocation_mode for more details
*/
[[deprecated(
GKO_DEPRECATED(
"device_reset is deprecated entirely, call hipDeviceReset directly. "
"alloc_mode was replaced by the Allocator type "
"hierarchy.")]] static std::shared_ptr<HipExecutor>
create(int device_id, std::shared_ptr<Executor> master, bool device_reset,
allocation_mode alloc_mode = default_hip_alloc_mode,
GKO_HIP_STREAM_STRUCT* stream = nullptr);
"hierarchy.")
static std::shared_ptr<HipExecutor> create(
int device_id, std::shared_ptr<Executor> master, bool device_reset,
allocation_mode alloc_mode = default_hip_alloc_mode,
GKO_HIP_STREAM_STRUCT* stream = nullptr);

static std::shared_ptr<HipExecutor> create(
int device_id, std::shared_ptr<Executor> master,
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/base/machine_topology.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class machine_topology {
};


using MachineTopology [[deprecated("please use machine_topology")]] =
using MachineTopology GKO_DEPRECATED("please use machine_topology") =
machine_topology;


Expand Down
22 changes: 10 additions & 12 deletions include/ginkgo/core/base/polymorphic_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,13 @@ class PolymorphicObject : public log::EnableLogging<PolymorphicObject> {
* @tparam Deleter the deleter of the unique_ptr parameter
*/
template <typename Derived, typename Deleter>
[[deprecated(
GKO_DEPRECATED(
"This function will be removed in a future release, the replacement "
"will copy instead of move. If a move is intended, use move_from "
"instead.")]] std::
enable_if_t<
std::is_base_of<PolymorphicObject, std::decay_t<Derived>>::value,
PolymorphicObject>*
copy_from(std::unique_ptr<Derived, Deleter>&& other)
"instead.")
std::enable_if_t<
std::is_base_of<PolymorphicObject, std::decay_t<Derived>>::value,
PolymorphicObject>* copy_from(std::unique_ptr<Derived, Deleter>&& other)
{
this->template log<log::Logger::polymorphic_object_move_started>(
exec_.get(), other.get(), this);
Expand Down Expand Up @@ -409,14 +408,13 @@ class EnableAbstractPolymorphicObject : public PolymorphicBase {
}

template <typename Derived>
[[deprecated(
GKO_DEPRECATED(
"This function will be removed in a future release, the replacement "
"will copy instead of move. If a move in intended, use move_to "
"instead.")]] std::
enable_if_t<
std::is_base_of<PolymorphicObject, std::decay_t<Derived>>::value,
AbstractObject>*
copy_from(std::unique_ptr<Derived>&& other)
"instead.")
std::enable_if_t<
std::is_base_of<PolymorphicObject, std::decay_t<Derived>>::value,
AbstractObject>* copy_from(std::unique_ptr<Derived>&& other)
{
return static_cast<AbstractObject*>(
this->PolymorphicBase::copy_from(std::move(other)));
Expand Down
7 changes: 3 additions & 4 deletions include/ginkgo/core/base/range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,8 @@ struct implement_binary_operation<operation_kind::range_by_scalar,
_operation_name) \
namespace accessor { \
template <typename Operand> \
struct [[deprecated( \
"Please use " #_operation_name)]] _operation_deprecated_name \
: _operation_name<Operand>{}; \
struct GKO_DEPRECATED("Please use " #_operation_name) \
_operation_deprecated_name : _operation_name<Operand> {}; \
} \
static_assert(true, \
"This assert is used to counter the false positive extra " \
Expand Down Expand Up @@ -864,7 +863,7 @@ GKO_BIND_UNARY_RANGE_OPERATION_TO_OPERATOR(transpose_operation, transpose);


#define GKO_DEPRECATED_SIMPLE_BINARY_OPERATION(_deprecated_name, _name) \
struct [[deprecated("Please use " #_name)]] _deprecated_name : _name {}
struct GKO_DEPRECATED("Please use " #_name) _deprecated_name : _name {}

#define GKO_DEFINE_SIMPLE_BINARY_OPERATION(_name, ...) \
struct _name { \
Expand Down
23 changes: 19 additions & 4 deletions include/ginkgo/core/base/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


// Handle deprecated notices correctly on different systems
#if defined(_WIN32) || defined(__CYGWIN__)
#define GKO_DEPRECATED(msg) __declspec(deprecated(msg))
// clang-format off
#define GKO_DEPRECATED(_msg) [[deprecated(_msg)]]
#ifdef __NVCOMPILER
#define GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS _Pragma("diag_suppress 1445")
#define GKO_END_DISABLE_DEPRECATION_WARNINGS _Pragma("diag_warning 1445")
#elif defined(__GNUC__) || defined(__clang__)
#define GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#define GKO_END_DISABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic pop")
#elif defined(_MSC_VER)
#define GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS \
_Pragma("warning(push)") \
_Pragma("warning(disable : 5211 4973 4974 4996)")
#define GKO_END_DISABLE_DEPRECATION_WARNINGS _Pragma("warning(pop)")
#else
#define GKO_DEPRECATED(msg) __attribute__((deprecated(msg)))
#endif // defined(_WIN32) || defined(__CYGWIN__)
#define GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS
#define GKO_END_DISABLE_DEPRECATION_WARNINGS
#endif
// clang-format on


namespace gko {
Expand Down
12 changes: 6 additions & 6 deletions include/ginkgo/core/base/utils_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ inline typename std::remove_reference<OwningPointer>::type&& give(
* same as calling .get() on the smart pointer.
*/
template <typename Pointer>
[[deprecated("no longer necessary, just pass the object without lend")]] inline
typename std::enable_if<detail::have_ownership_s<Pointer>::value,
detail::pointee<Pointer>*>::type
GKO_DEPRECATED("no longer necessary, just pass the object without lend")
inline typename std::enable_if<detail::have_ownership_s<Pointer>::value,
detail::pointee<Pointer>*>::type
lend(const Pointer& p)
{
return p.get();
Expand All @@ -313,9 +313,9 @@ template <typename Pointer>
* returns `p`.
*/
template <typename Pointer>
[[deprecated("no longer necessary, just pass the object without lend")]] inline
typename std::enable_if<!detail::have_ownership_s<Pointer>::value,
detail::pointee<Pointer>*>::type
GKO_DEPRECATED("no longer necessary, just pass the object without lend")
inline typename std::enable_if<!detail::have_ownership_s<Pointer>::value,
detail::pointee<Pointer>*>::type
lend(const Pointer& p)
{
return p;
Expand Down
Loading

0 comments on commit 534e3fb

Please sign in to comment.