Skip to content

Commit

Permalink
Merge pull request #4128 from vicentebolea/backports-from-master
Browse files Browse the repository at this point in the history
Backports from master
  • Loading branch information
vicentebolea authored Apr 3, 2024
2 parents 1f50ea2 + 1218457 commit 1b41921
Show file tree
Hide file tree
Showing 259 changed files with 12,154 additions and 6,674 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/everything.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ jobs:
- name: Build
run: gha/scripts/ci/gh-actions/run.sh build
- name: Print ccache statistics
run: ccache -s
run: ccache -s | tee $GITHUB_STEP_SUMMARY
- name: Save cache
uses: actions/cache/save@v3
if: ${{ github.ref_name == 'master' && steps.restore-cache.outputs.cache-hit != 'true' }}
Expand Down
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ adios_option(Profiling "Enable support for profiling" AUTO)
adios_option(Endian_Reverse "Enable support for Little/Big Endian Interoperability" AUTO)
adios_option(Sodium "Enable support for Sodium for encryption" AUTO)
adios_option(Catalyst "Enable support for in situ visualization plugin using ParaView Catalyst" AUTO)
adios_option(Campaign "Enable support for Campaigns (requires SQLite3 and ZLIB)" OFF)
adios_option(Campaign "Enable support for Campaigns (requires SQLite3 and ZLIB)" AUTO)
adios_option(AWSSDK "Enable support for S3 compatible storage using AWS SDK's S3 module" OFF)
adios_option(Derived_Variable "Enable support for derived variables" OFF)
adios_option(PIP "Enable support for pip packaging" OFF)
Expand Down Expand Up @@ -443,9 +443,21 @@ foreach(opt IN LISTS ADIOS2_CONFIG_OPTS)
endif()
endforeach()

if (ADIOS2_HAVE_SST AND (ADIOS2_SST_HAVE_LIBFABRIC OR ADIOS2_SST_HAVE_UCX))
message(" RDMA Transport for Staging: Available")
set (HPCDataPlaneList "")
if (ADIOS2_HAVE_SST)
if (ADIOS2_SST_HAVE_LIBFABRIC)
set (HPCDataPlaneList "${HPCDataPlaneList} fabric")
endif()
if (ADIOS2_SST_HAVE_UCX)
set (HPCDataPlaneList "${HPCDataPlaneList} UCX")
endif()
if (ADIOS2_SST_HAVE_MPI_DP)
set (HPCDataPlaneList "${HPCDataPlaneList} MPI")
endif()
endif()
if ({HPCDataPlaneList} STREQUAL "")
message(" Possible RDMA DataPlanes for SST: <none>")
else()
message(" RDMA Transport for Staging: Unconfigured")
message(" Possible RDMA DataPlanes for SST: ${HPCDataPlaneList}")
endif()

37 changes: 37 additions & 0 deletions bindings/C/adios2/c/adios2_c_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,43 @@ adios2_error adios2_set_transport_parameter(adios2_io *io, const size_t transpor
}
}

#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
adios2_derived_variable *adios2_define_derived_variable(adios2_io *io, const char *name,
const char *expression,
const adios2_derived_var_type type)
{
adios2_derived_variable *variable = nullptr;

try
{
adios2::helper::CheckForNullptr(io, "for adios2_io, in call to adios2_define_variable");
adios2::core::IO &ioCpp = *reinterpret_cast<adios2::core::IO *>(io);
adios2::DerivedVarType typeCpp = adios2::DerivedVarType::MetadataOnly;
switch (type)
{
case adios2_derived_var_type_metadata_only:
typeCpp = adios2::DerivedVarType::MetadataOnly;
break;
case adios2_derived_var_type_expression_string:
typeCpp = adios2::DerivedVarType::ExpressionString;
break;
case adios2_derived_var_type_store_data:
typeCpp = adios2::DerivedVarType::StoreData;
break;
}
adios2::core::VariableDerived *variableCpp = nullptr;
variableCpp = &ioCpp.DefineDerivedVariable(name, expression, typeCpp);
variable = reinterpret_cast<adios2_derived_variable *>(variableCpp);
}
catch (...)
{

adios2::helper::ExceptionToError("adios2_define_variable");
}
return variable;
}
#endif

adios2_variable *adios2_define_variable(adios2_io *io, const char *name, const adios2_type type,
const size_t ndims, const size_t *shape,
const size_t *start, const size_t *count,
Expand Down
20 changes: 20 additions & 0 deletions bindings/C/adios2/c/adios2_c_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,26 @@ adios2_variable *adios2_define_variable(adios2_io *io, const char *name, const a
const size_t *start, const size_t *count,
const adios2_constant_dims constant_dims);

#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
/**
* @brief Define a derived variable within io
* @param io handler that owns the variable
* @param name unique variable identifier
* @param type primitive type from enum adios2_type in adios2_c_types.h
* @param ndims number of dimensions
* @param shape global dimension
* @param start local offset
* @param count local dimension
* @param constant_dims adios2_constant_dims_true:: shape, start, count
* won't change; adios2_constant_dims_false: shape, start, count will change
* after definition
* @return success: handler, failure: NULL
*/
adios2_derived_variable *adios2_define_derived_variable(adios2_io *io, const char *name,
const char *expression,
const adios2_derived_var_type type);
#endif

/**
* @brief Retrieve a variable handler within current io handler
* @param io handler to variable io owner
Expand Down
20 changes: 20 additions & 0 deletions bindings/C/adios2/c/adios2_c_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extern "C" {
typedef struct adios2_adios adios2_adios;
typedef struct adios2_io adios2_io;
typedef struct adios2_variable adios2_variable;
typedef struct adios2_derived_variable adios2_derived_variable;
typedef struct adios2_attribute adios2_attribute;
typedef struct adios2_engine adios2_engine;
typedef struct adios2_operator adios2_operator;
Expand Down Expand Up @@ -139,6 +140,16 @@ typedef enum
adios2_arrayordering_auto
} adios2_arrayordering;

#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
/** Type of derived variables */
typedef enum
{
adios2_derived_var_type_metadata_only = 0,
adios2_derived_var_type_expression_string = 1,
adios2_derived_var_type_store_data = 2
} adios2_derived_var_type;
#endif

static const size_t adios2_string_array_element_max_size = 4096;

static const size_t adios2_local_value_dim = SIZE_MAX - 2;
Expand All @@ -159,6 +170,15 @@ union adios2_PrimitiveStdtypeUnion
char *str;
};

typedef enum
{
adios2_memory_space_detect = 0,
adios2_memory_space_host = 1,
#ifdef ADIOS2_HAVE_GPU_SUPPORT
adios2_memory_space_gpu = 2,
#endif
} adios2_memory_space;

typedef struct
{
int WriterID;
Expand Down
90 changes: 88 additions & 2 deletions bindings/C/adios2/c/adios2_c_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,82 @@ adios2_error adios2_set_shape(adios2_variable *variable, const size_t ndims, con
}
}

adios2::MemorySpace adios2_ToMemorySpace(const adios2_memory_space Cmem)
{
adios2::MemorySpace mem = adios2::MemorySpace::Detect;
switch (Cmem)
{

case adios2_memory_space_host:
mem = adios2::MemorySpace::Host;
break;

#ifdef ADIOS2_HAVE_GPU_SUPPORT
case adios2_memory_space_gpu:
mem = adios2::MemorySpace::GPU;
break;
#endif
default:
break;
}
return mem;
}

adios2_memory_space adios2_FromMemorySpace(const adios2::MemorySpace mem)
{
adios2_memory_space Cmem = adios2_memory_space_detect;
switch (mem)
{

case adios2::MemorySpace::Host:
Cmem = adios2_memory_space_host;
break;

#ifdef ADIOS2_HAVE_GPU_SUPPORT
case adios2::MemorySpace::GPU:
Cmem = adios2_memory_space_gpu;
break;
#endif
default:
break;
}
return Cmem;
}

adios2_error adios2_set_memory_space(adios2_variable *variable, const adios2_memory_space mem)
{
try
{
adios2::core::VariableBase *variableBase =
reinterpret_cast<adios2::core::VariableBase *>(variable);
variableBase->SetMemorySpace(adios2_ToMemorySpace(mem));

return adios2_error_none;
}
catch (...)
{
return static_cast<adios2_error>(
adios2::helper::ExceptionToError("adios2_set_memory_space"));
}
}

adios2_error adios2_get_memory_space(adios2_memory_space *mem, adios2_variable *variable)
{
try
{
adios2::core::VariableBase *variableBase =
reinterpret_cast<adios2::core::VariableBase *>(variable);
*mem = adios2_FromMemorySpace(variableBase->m_MemSpace);

return adios2_error_none;
}
catch (...)
{
return static_cast<adios2_error>(
adios2::helper::ExceptionToError("adios2_set_memory_space"));
}
}

adios2_error adios2_set_block_selection(adios2_variable *variable, const size_t block_id)
{
try
Expand Down Expand Up @@ -274,7 +350,8 @@ adios2_error adios2_variable_ndims(size_t *ndims, const adios2_variable *variabl
}
}

adios2_error adios2_variable_shape(size_t *shape, const adios2_variable *variable)
adios2_error adios2_variable_shape_with_memory_space(size_t *shape, const adios2_variable *variable,
adios2_memory_space mem)
{
try
{
Expand All @@ -296,7 +373,11 @@ adios2_error adios2_variable_shape(size_t *shape, const adios2_variable *variabl
{ \
const adios2::core::Variable<T> *variable = \
dynamic_cast<const adios2::core::Variable<T> *>(variableBase); \
const adios2::Dims shapeCpp = variable->Shape(adios2::EngineCurrentStep); \
adios2::Dims shapeCpp; \
if (mem == adios2_memory_space_host) \
shapeCpp = variable->Shape(adios2::EngineCurrentStep); \
else \
shapeCpp = variable->Shape(adios2::EngineCurrentStep, adios2_ToMemorySpace(mem)); \
std::copy(shapeCpp.begin(), shapeCpp.end(), shape); \
}
ADIOS2_FOREACH_STDTYPE_1ARG(declare_template_instantiation)
Expand All @@ -310,6 +391,11 @@ adios2_error adios2_variable_shape(size_t *shape, const adios2_variable *variabl
}
}

adios2_error adios2_variable_shape(size_t *shape, const adios2_variable *variable)
{
return adios2_variable_shape_with_memory_space(shape, variable, adios2_memory_space_host);
}

adios2_error adios2_variable_start(size_t *start, const adios2_variable *variable)
{
try
Expand Down
26 changes: 26 additions & 0 deletions bindings/C/adios2/c/adios2_c_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ extern "C" {
*/
adios2_error adios2_set_shape(adios2_variable *variable, const size_t ndims, const size_t *shape);

/**
* Sets the memory space for all following Puts/Gets
* to either host (default) or device
* @param mem memory space where Put/Get buffers are allocated
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_set_memory_space(adios2_variable *variable, const adios2_memory_space mem);

/**
* Get the memory space that was set by the application for a given variable
* @param memory space output, the variable memory space
* @param variable handler
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_get_memory_space(adios2_memory_space *mem, adios2_variable *variable);

/**
* Read mode only. Required for reading local variables. For Global Arrays it
* will Set
Expand Down Expand Up @@ -140,6 +156,16 @@ adios2_error adios2_variable_ndims(size_t *ndims, const adios2_variable *variabl
*/
adios2_error adios2_variable_shape(size_t *shape, const adios2_variable *variable);

/**
* Retrieve current variable shape for a given memory space
* @param shape output, must be pre-allocated with ndims
* @param variable handler
* @param memory space
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_variable_shape_with_memory_space(size_t *shape, const adios2_variable *variable,
const adios2_memory_space mem);

/**
* Retrieve current variable start
* @param start output, single value
Expand Down
6 changes: 3 additions & 3 deletions bindings/CXX11/adios2/cxx11/Variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ class Variable
explicit operator bool() const noexcept;

/**
* Sets the memory space for all following Puts
* to either host (default) or device (currently only CUDA supported)
* @param mem memory space where Put buffers are allocated
* Sets the memory space for all following Puts/Gets
* to either host (default) or device
* @param mem memory space where Put/Get buffers are allocated
*/
void SetMemorySpace(const MemorySpace mem);

Expand Down
2 changes: 2 additions & 0 deletions bindings/Fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ add_library(adios2_fortran
modules/adios2_io_open_mod.F90
modules/adios2_io_open_serial_smod.F90
modules/adios2_io_define_variable_mod.f90
modules/adios2_io_define_derived_variable_mod.f90
modules/adios2_io_define_attribute_mod.f90
modules/adios2_engine_mod.f90
modules/adios2_engine_begin_step_mod.f90
Expand All @@ -54,6 +55,7 @@ add_library(adios2_fortran
modules/adios2_variable_max_mod.f90
modules/adios2_operator_mod.f90
)

set_property(TARGET adios2_fortran PROPERTY EXPORT_NAME fortran)
set_property(TARGET adios2_fortran PROPERTY OUTPUT_NAME adios2${ADIOS2_LIBRARY_SUFFIX}_fortran)

Expand Down
23 changes: 22 additions & 1 deletion bindings/Fortran/f2c/adios2_f2c_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,27 @@ void FC_GLOBAL(adios2_define_variable_f2c,
}
}

void FC_GLOBAL(adios2_define_derived_variable_f2c,
ADIOS2_DEFINE_DERIVED_VARIABLE_F2C)(adios2_derived_variable **variable,
adios2_io **io, const char *name,
const char *expression, const int *type,
int *ierr)
{
#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
*variable = adios2_define_derived_variable(*io, name, expression,
static_cast<adios2_derived_var_type>(*type));
*ierr = (*variable == NULL) ? static_cast<int>(adios2_error_exception)
: static_cast<int>(adios2_error_none);
#else
std::cout << "ADIOS2 Warning: adios2_define_derived_variable() is not supported in the "
"current ADIOS2 build. The expression "
<< expression << " will be ignored and the variable " << name
<< " will not be produced." << std::endl;
*variable = nullptr;
*ierr = static_cast<int>(adios2_error_exception);
#endif
}

struct cnamelist
{
char **names;
Expand Down Expand Up @@ -267,7 +288,7 @@ void FC_GLOBAL(adios2_retrieve_namelist_f2c,
len = static_cast<size_t>(namelist_len);
}
// copy C string without '\0'
strncpy(fs, info->names[i], len);
memcpy(fs, info->names[i], len);
// pad with spaces
memset(fs + len, ' ', namelist_len - len);
}
Expand Down
Loading

0 comments on commit 1b41921

Please sign in to comment.