Skip to content

Commit

Permalink
Let the debug mode APIs stick around but mark them as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuck Atkins committed Jun 21, 2022
1 parent 08b9229 commit 6d1fb9f
Show file tree
Hide file tree
Showing 21 changed files with 141 additions and 51 deletions.
1 change: 1 addition & 0 deletions CTestCustom.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
"was built for newer macOS version"
"warning generated"
"warnings generated"
"warning: template parameter ... is not used in declaring the parameter types of function template"
)
list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE
".*/thirdparty/.*"
Expand Down
11 changes: 11 additions & 0 deletions bindings/C/adios2/c/adios2_c_adios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,22 @@ adios2_adios *adios2_init_serial()
return adios2_init_config_glue_serial("", "C");
}

adios2_adios *adios2_init_serial_debug(adios2_debug_mode)
{
return adios2_init_serial();
}

adios2_adios *adios2_init_config_serial(const char *config_file)
{
return adios2_init_config_glue_serial(config_file, "C");
}

adios2_adios *adios2_init_config_serial_debug(const char *config_file,
adios2_debug_mode)
{
return adios2_init_config_serial(config_file);
}

adios2_io *adios2_declare_io(adios2_adios *adios, const char *name)
{
adios2_io *io = nullptr;
Expand Down
26 changes: 21 additions & 5 deletions bindings/C/adios2/c/adios2_c_adios.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ extern "C" {
#endif

#if ADIOS2_USE_MPI
#define adios2_init(comm) adios2_init_mpi(comm)
#define adios2_init_config(config_file, comm) \
adios2_init_config_mpi(config_file, comm)
#define adios2_init(comm, debug) adios2_init_mpi_debug(comm, debug)
#define adios2_init_config(config_file, comm, debug) \
adios2_init_config_mpi_debug(config_file, comm, debug)

/**
* Starting point for MPI apps. Creates an ADIOS handler.
Expand All @@ -34,6 +34,9 @@ extern "C" {
*/
adios2_adios *adios2_init_mpi(MPI_Comm comm);

ADIOS2_DEPRECATED
adios2_adios *adios2_init_mpi_debug(MPI_Comm comm, adios2_debug_mode);

/**
* Starting point for MPI apps. Creates an ADIOS handler allowing a runtime
* config file.
Expand All @@ -44,9 +47,15 @@ adios2_adios *adios2_init_mpi(MPI_Comm comm);
* @return success: handler, failure: NULL
*/
adios2_adios *adios2_init_config_mpi(const char *config_file, MPI_Comm comm);

ADIOS2_DEPRECATED
adios2_adios *adios2_init_config_mpi_debug(const char *config_file,
MPI_Comm comm, adios2_debug_mode);

#else
#define adios2_init() adios2_init_serial()
#define adios2_init_config(config_file) adios2_init_config_serial(config_file)
#define adios2_init(debug) adios2_init_serial_debug(debug)
#define adios2_init_config(config_file, debug) \
adios2_init_config_serial_debug(config_file, debug)
#endif

/**
Expand All @@ -56,13 +65,20 @@ adios2_adios *adios2_init_config_mpi(const char *config_file, MPI_Comm comm);
*/
adios2_adios *adios2_init_serial(void);

ADIOS2_DEPRECATED
adios2_adios *adios2_init_serial_debug(adios2_debug_mode);

/**
* Initialize an ADIOS struct pointer handler in a serial, non-MPI application.
* Doesn't require a runtime config file.
* @return success: handler, failure: NULL
*/
adios2_adios *adios2_init_config_serial(const char *config_file);

ADIOS2_DEPRECATED
adios2_adios *adios2_init_config_serial_debug(const char *config_file,
adios2_debug_mode);

/**
* Declares a new io handler
* @param adios owner the io handler
Expand Down
11 changes: 11 additions & 0 deletions bindings/C/adios2/c/adios2_c_adios_mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,20 @@ adios2_adios *adios2_init_mpi(MPI_Comm comm)
return adios2_init_config_glue_mpi("", comm, "C");
}

adios2_adios *adios2_init_mpi_debug(MPI_Comm comm, adios2_debug_mode)
{
return adios2_init_mpi(comm);
}

adios2_adios *adios2_init_config_mpi(const char *config_file, MPI_Comm comm)
{
return adios2_init_config_glue_mpi(config_file, comm, "C");
}

adios2_adios *adios2_init_config_mpi_debug(const char *config_file,
MPI_Comm comm, adios2_debug_mode)
{
return adios2_init_config_mpi(config_file, comm);
}

} // end extern C
7 changes: 7 additions & 0 deletions bindings/C/adios2/c/adios2_c_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ typedef enum
adios2_true = 1,
} adios2_bool;

/* DEPRECATED: Debug mode will be removed in a future release */
typedef enum
{
adios2_debug_mode_off = 0,
adios2_debug_mode_on = 1,
} adios2_debug_mode;

typedef enum
{
adios2_constant_dims_false = 0,
Expand Down
7 changes: 7 additions & 0 deletions bindings/CXX11/adios2.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
#include "adios2/common/ADIOSMacros.h"
#include "adios2/common/ADIOSTypes.h"

// DEPRECATED: Debug mode will be removed in a future release
namespace adios2
{
constexpr bool DebugON = true;
constexpr bool DebugOFF = false;
} // end namespace adios2

#include "adios2/cxx11/ADIOS.h"
#include "adios2/cxx11/Attribute.h"
#include "adios2/cxx11/Engine.h"
Expand Down
2 changes: 0 additions & 2 deletions bindings/CXX11/adios2/cxx11/ADIOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ ADIOS::ADIOS(const std::string &configFile)
{
}

ADIOS::ADIOS(const char *configFile) : ADIOS(std::string(configFile), "C++") {}

ADIOS::ADIOS() : ADIOS("", "C++") {}

ADIOS::ADIOS(const std::string &configFile, const std::string &hostLanguage)
Expand Down
72 changes: 51 additions & 21 deletions bindings/CXX11/adios2/cxx11/ADIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <functional>
#include <memory>
#include <string>
#include <type_traits>

#include "IO.h"
#include "Operator.h"
Expand Down Expand Up @@ -41,6 +42,9 @@ class ADIOS
{

public:
template <class T>
using enable_if_bool = typename std::enable_if<std::is_same<T, bool>::value, bool>::type;

#if ADIOS2_USE_MPI
/**
* Starting point for MPI apps. Creates an ADIOS object.
Expand All @@ -50,6 +54,13 @@ class ADIOS
*/
ADIOS(MPI_Comm comm);

template <typename TDebugMode,
enable_if_bool<TDebugMode> Enable = true>
ADIOS2_DEPRECATED ADIOS(MPI_Comm comm, TDebugMode)
: ADIOS(comm)
{
}

/**
* Starting point for MPI apps. Creates an ADIOS object allowing a
* runtime config file.
Expand All @@ -61,6 +72,14 @@ class ADIOS
*/
ADIOS(const std::string &configFile, MPI_Comm comm);

template <typename TDebugMode,
enable_if_bool<TDebugMode> Enable = true>
ADIOS2_DEPRECATED ADIOS(const std::string &configFile, MPI_Comm comm,
TDebugMode)
: ADIOS(configFile, comm)
{
}

/** extra constructor for R and other languages that use the
* public C++ API but has data in column-major. Pass "" for configfile
* if there is no config file. Last bool argument exist only to
Expand All @@ -72,20 +91,16 @@ class ADIOS
*/
ADIOS(const std::string &configFile, MPI_Comm comm,
const std::string &hostLanguage);
#else
// Client code that does not enable ADIOS2_USE_MPI may accidentally
// try to pass a MPI_Comm instance to our constructor. If the type
// the MPI library uses to implement MPI_Comm happens to be convertible
// to one of the types offered by our serial constructors (e.g. 'bool'),
// the invocation will appear to succeed but will ignore the
// communicator passed. Add explicitly deleted constructors that have
// better conversions for common MPI_Comm types.

// openmpi uses 'ompi_communicator_t*' for MPI_Comm
ADIOS(void *define_ADIOS2_USE_MPI_to_use_MPI_constructor) = delete;

// mpich uses 'int' for MPI_Comm
ADIOS(int define_ADIOS2_USE_MPI_to_use_MPI_constructor) = delete;

template <typename TDebugMode,
enable_if_bool<TDebugMode> Enable = true>
ADIOS2_DEPRECATED ADIOS(const std::string &configFile, MPI_Comm comm,
const std::string &hostLanguage,
TDebugMode)
: ADIOS(configFile, comm, hostLanguage)
{
}

#endif

/**
Expand All @@ -96,20 +111,26 @@ class ADIOS
*/
ADIOS(const std::string &configFile);

/**
* Starting point for non-MPI serial apps. Creates an ADIOS object allowing
* a runtime config file.
* @param configFile runtime config file
* @exception std::invalid_argument if user input is incorrect
*/
ADIOS(const char *configFile);
template <typename TDebugMode,
enable_if_bool<TDebugMode> Enable = true>
ADIOS2_DEPRECATED ADIOS(const std::string &configFile,
TDebugMode)
: ADIOS(configFile)
{
}

/**
* Starting point for non-MPI apps. Creates an ADIOS object
* @exception std::invalid_argument if user input is incorrect
*/
ADIOS();

template <typename TDebugMode,
enable_if_bool<TDebugMode> Enable = true>
ADIOS2_DEPRECATED ADIOS(TDebugMode) : ADIOS()
{
}

/** extra constructor for R and other languages that use the
* public C++ API but has data in column-major. Pass "" for configfile
* if there is no config file. Last bool argument exist only to
Expand All @@ -121,6 +142,15 @@ class ADIOS
*/
ADIOS(const std::string &configFile, const std::string &hostLanguage);

template <typename TDebugMode,
enable_if_bool<TDebugMode> Enable = true>
ADIOS2_DEPRECATED ADIOS(const std::string &configFile,
const std::string &hostLanguage,
TDebugMode)
: ADIOS(configFile, hostLanguage)
{
}

/** object inspection true: valid object, false: invalid object */
explicit operator bool() const noexcept;

Expand Down
4 changes: 2 additions & 2 deletions examples/hello/bpWriter/helloBPWriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ int main(int argc, char *argv[])
}

#if ADIOS2_USE_MPI
adios2_adios *adios = adios2_init(MPI_COMM_WORLD);
adios2_adios *adios = adios2_init_mpi(MPI_COMM_WORLD);
#else
adios2_adios *adios = adios2_init();
adios2_adios *adios = adios2_init_serial();
#endif

check_handler(adios, "adios");
Expand Down
11 changes: 10 additions & 1 deletion source/adios2/common/ADIOSConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#cmakedefine ADIOS2_VERSION_TWEAK @ADIOS2_VERSION_TWEAK@

#define ADIOS2_VERSION (ADIOS2_VERSION_MAJOR* 10000 + ADIOS2_VERSION_MINOR * 100 + ADIOS2_VERSION_PATCH)
#define ADIOS2_DEBUGMODE_REMOVED 1

/*
* ADIOS Build Information:
Expand Down Expand Up @@ -42,4 +41,14 @@
# error "ADIOS2 was not built with MPI enabled."
#endif

#ifndef ADIOS2_DEPRECATED
# if defined(__GNUC__) || defined (__clang__)
# define ADIOS2_DEPRECATED __attribute__((deprecated))
# elif defined(_MSC_VER)
# define ADIOS2_DEPRECATED __declspec(deprecated)
# else
# define ADIOS2_DEPRECATED
# endif
#endif

#endif /* ADIOSCONFIG_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ TEST_F(BPAvailableVariablesAttributes, AvailableVariablesAttributes)
size_t steps = 5;

#if ADIOS2_USE_MPI
adios2_adios *adiosH = adios2_init(MPI_COMM_WORLD);
adios2_adios *adiosH = adios2_init_mpi(MPI_COMM_WORLD);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
#else
adios2_adios *adiosH = adios2_init();
adios2_adios *adiosH = adios2_init_serial();
#endif

// count dims are allocated in stack
Expand Down
4 changes: 2 additions & 2 deletions testing/adios2/bindings/C/TestBPWriteAggregateReadLocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void LocalAggregate1D(const std::string substreams)
std::vector<int32_t> inumbers(NSteps * Nx);
std::vector<float> fnumbers(NSteps * Nx);

adios2_adios *adiosH = adios2_init(MPI_COMM_WORLD);
adios2_adios *adiosH = adios2_init_mpi(MPI_COMM_WORLD);

// writer
{
Expand Down Expand Up @@ -175,7 +175,7 @@ void LocalAggregate1DBlock0(const std::string substreams)
std::vector<int32_t> inumbers(NSteps * Nx);
std::vector<float> fnumbers(NSteps * Nx);

adios2_adios *adiosH = adios2_init(MPI_COMM_WORLD);
adios2_adios *adiosH = adios2_init_mpi(MPI_COMM_WORLD);

// writer
{
Expand Down
4 changes: 2 additions & 2 deletions testing/adios2/bindings/C/TestBPWriteReadMultiblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ TEST_F(BPWriteReadMultiblockCC, ZeroSizeBlocks)
size_t steps = 5;

#if ADIOS2_USE_MPI
adios2_adios *adiosH = adios2_init(MPI_COMM_WORLD);
adios2_adios *adiosH = adios2_init_mpi(MPI_COMM_WORLD);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
#else
adios2_adios *adiosH = adios2_init();
adios2_adios *adiosH = adios2_init_serial();
#endif

// count dims are allocated in stack
Expand Down
4 changes: 2 additions & 2 deletions testing/adios2/bindings/C/TestBPWriteTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class ADIOS2_C_API : public ::testing::Test
ADIOS2_C_API()
{
#if ADIOS2_USE_MPI
adiosH = adios2_init(MPI_COMM_WORLD);
adiosH = adios2_init_mpi(MPI_COMM_WORLD);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
#else
adiosH = adios2_init();
adiosH = adios2_init_serial();
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions testing/adios2/bindings/C/TestNullWriteRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ TEST_F(NullWriteReadTests_C_API, NullWriteRead1D8)
// Write test data using BP

#if ADIOS2_USE_MPI
adios2_adios *adios = adios2_init(MPI_COMM_WORLD);
adios2_adios *adios = adios2_init_mpi(MPI_COMM_WORLD);
#else
adios2_adios *adios = adios2_init();
adios2_adios *adios = adios2_init_serial();
#endif
{
adios2_io *io = adios2_declare_io(adios, "WriteNull");
Expand Down
4 changes: 2 additions & 2 deletions testing/adios2/engine/bp/TestBPWriteReadBlockInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,9 +839,9 @@ TEST_F(BPWriteReadBlockInfo, BPWriteReadBlockInfo1D8_C)

{
#if ADIOS2_USE_MPI
adios2_adios *adiosH = adios2_init(MPI_COMM_WORLD);
adios2_adios *adiosH = adios2_init_mpi(MPI_COMM_WORLD);
#else
adios2_adios *adiosH = adios2_init();
adios2_adios *adiosH = adios2_init_serial();
#endif
adios2_io *ioR = adios2_declare_io(adiosH, "ReadIO");
if (!engineName.empty())
Expand Down
Loading

0 comments on commit 6d1fb9f

Please sign in to comment.