Skip to content

Commit

Permalink
Merge branch 'master' into cuda_gpu_aware
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonRuonanWang authored Oct 4, 2021
2 parents f123a6d + f5fae3f commit cb4e903
Show file tree
Hide file tree
Showing 455 changed files with 27,629 additions and 9,535 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ adios_option(CUDA "Enable support for Cuda" AUTO)
adios_option(DataMan "Enable support for DataMan" AUTO)
adios_option(DataSpaces "Enable support for DATASPACES" AUTO)
adios_option(SSC "Enable support for SSC" AUTO)
adios_option(Table "Enable support for Table" AUTO)
adios_option(MHS "Enable support for MHS" AUTO)
adios_option(SST "Enable support for SST" AUTO)
adios_option(BP5 "Enable support for BP5" AUTO)
adios_option(ZeroMQ "Enable support for ZeroMQ" AUTO)
Expand All @@ -175,7 +175,7 @@ if(ADIOS2_HAVE_MPI)
endif()

set(ADIOS2_CONFIG_OPTS
Blosc BZip2 ZFP SZ MGARD PNG MPI DataMan CUDA DAOS Table SSC SST BP5 DataSpaces ZeroMQ HDF5 HDF5_VOL IME Python Fortran SysVShMem Profiling Endian_Reverse LIBPRESSIO
Blosc BZip2 ZFP SZ MGARD PNG MPI DataMan CUDA DAOS MHS SSC SST BP5 DataSpaces ZeroMQ HDF5 HDF5_VOL IME Python Fortran SysVShMem Profiling Endian_Reverse LIBPRESSIO
)
GenerateADIOSHeaderConfig(${ADIOS2_CONFIG_OPTS})
configure_file(
Expand Down
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ For a `cmake` configuration example see [scripts/runconf/runconf.sh](https://git

Once ADIOS2 is installed refer to:

* [Linking ADIO 2](https://adios2.readthedocs.io/en/latest/setting_up/setting_up.html#linking-adios-2)
* [Linking ADIOS2](https://adios2.readthedocs.io/en/latest/setting_up/setting_up.html#linking-adios-2)


## Releases
Expand Down
46 changes: 45 additions & 1 deletion bindings/C/adios2/c/adios2_c_adios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@
extern "C" {
#endif

adios2::ArrayOrdering adios2_ToArrayOrdering(const adios2_arrayordering Corder)
{
adios2::ArrayOrdering order = adios2::ArrayOrdering::Auto;
switch (Corder)
{

case adios2_arrayordering_rowmajor:
order = adios2::ArrayOrdering::RowMajor;
break;

case adios2_arrayordering_columnmajor:
order = adios2::ArrayOrdering::ColumnMajor;
break;

case adios2_arrayordering_auto:
order = adios2::ArrayOrdering::Auto;
break;

default:
break;
}
return order;
}

adios2_adios *adios2_init_config_glue_serial(const char *config_file,
const adios2_debug_mode debug_mode,
const char *host_language)
Expand Down Expand Up @@ -48,7 +72,8 @@ adios2_adios *adios2_init_serial()

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

adios2_io *adios2_declare_io(adios2_adios *adios, const char *name)
Expand All @@ -68,6 +93,25 @@ adios2_io *adios2_declare_io(adios2_adios *adios, const char *name)
return io;
}

adios2_io *adios2_declare_io_order(adios2_adios *adios, const char *name,
adios2_arrayordering order)
{
adios2_io *io = nullptr;
try
{
adios2::helper::CheckForNullptr(
adios, "for adios2_adios, in call to adios2_declare_io");
io = reinterpret_cast<adios2_io *>(
&reinterpret_cast<adios2::core::ADIOS *>(adios)->DeclareIO(
name, adios2_ToArrayOrdering(order)));
}
catch (...)
{
adios2::helper::ExceptionToError("adios2_declare_io");
}
return io;
}

adios2_io *adios2_at_io(adios2_adios *adios, const char *name)
{
adios2_io *io = nullptr;
Expand Down
10 changes: 10 additions & 0 deletions bindings/C/adios2/c/adios2_c_adios.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ adios2_adios *adios2_init_config_serial(const char *config_file);
*/
adios2_io *adios2_declare_io(adios2_adios *adios, const char *name);

/**
* Declares a new io handler with specific array ordering
* @param adios owner the io handler
* @param name unique io identifier within current adios handler
* @param order array ordering
* @return success: handler, failure: NULL
*/
adios2_io *adios2_declare_io_order(adios2_adios *adios, const char *name,
adios2_arrayordering order);

/**
* Retrieves a previously declared io handler by name
* @param adios owner the io handler
Expand Down
1 change: 1 addition & 0 deletions bindings/C/adios2/c/adios2_c_attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ adios2_error adios2_attribute_data(void *data, size_t *size,
char *dataT = reinterpret_cast<char *>(data);
attributeCpp->m_DataSingleValue.copy(
dataT, attributeCpp->m_DataSingleValue.size());
dataT[attributeCpp->m_DataSingleValue.size()] = '\0';
*size = 1;
}
else
Expand Down
148 changes: 148 additions & 0 deletions bindings/C/adios2/c/adios2_c_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,154 @@ adios2_error adios2_lock_reader_selections(adios2_engine *engine)
}
}

adios2_varinfo *adios2_inquire_blockinfo(adios2_engine *engine,
adios2_variable *variable,
const size_t step)
{
auto lf_CopyDims = [](const std::vector<size_t> &dims) -> size_t * {
size_t *a = nullptr;
size_t ndims = dims.size();
if (ndims > 0)
{
a = (size_t *)malloc(dims.size() * sizeof(size_t));
std::memcpy(a, dims.data(), dims.size() * sizeof(size_t));
}
return a;
};

adios2_varinfo *varinfo = NULL;

try
{
adios2::helper::CheckForNullptr(
engine, "for adios2_engine, in call to adios2_inquire_blockinfo");

adios2::core::Engine *engineCpp =
reinterpret_cast<adios2::core::Engine *>(engine);

if (engineCpp->m_EngineType == "NULL")
{
return NULL;
}
adios2::helper::CheckForNullptr(variable,
"for adios2_variable, in call "
"to adios2_get");

adios2::core::VariableBase *variableBase =
reinterpret_cast<adios2::core::VariableBase *>(variable);

const adios2::DataType type(variableBase->m_Type);

const auto minBlocksInfo =
engineCpp->MinBlocksInfo(*variableBase, step);

if (minBlocksInfo)
{
varinfo = (adios2_varinfo *)malloc(sizeof(adios2_varinfo));
varinfo->nblocks = minBlocksInfo->BlocksInfo.size();
varinfo->BlocksInfo = (adios2_blockinfo *)malloc(
varinfo->nblocks * sizeof(adios2_blockinfo));
auto *b = varinfo->BlocksInfo;

varinfo->Dims = minBlocksInfo->Dims;
varinfo->Shape = minBlocksInfo->Shape;
varinfo->IsValue = (int)minBlocksInfo->IsValue;
varinfo->IsReverseDims = (int)minBlocksInfo->IsReverseDims;
for (size_t i = 0; i < varinfo->nblocks; ++i)
{
b[i].WriterID = minBlocksInfo->BlocksInfo[i].WriterID;
b[i].BlockID = minBlocksInfo->BlocksInfo[i].BlockID;
b[i].Start = minBlocksInfo->BlocksInfo[i].Start;
b[i].Count = minBlocksInfo->BlocksInfo[i].Count;
if (minBlocksInfo->IsValue)
{
b[i].Value.uint64 = 0;
// = *((T *)minBlocksInfo->BlocksInfo[i].BufferP);
}
else
{
b[i].MinUnion.uint64 = 0;
// = minBlocksInfo->BlocksInfo[i].MinUnion;
b[i].MaxUnion.uint64 = 0;
// = minBlocksInfo->BlocksInfo[i].MaxUnion;
}
}
delete minBlocksInfo;
return varinfo;
}

/* Call the big gun Engine::BlocksInfo<T> */
if (type == adios2::DataType::Compound)
{
return varinfo;
}
else if (type == adios2::helper::GetDataType<std::string>())
{
const auto blocksInfo = engineCpp->BlocksInfo<std::string>(
*dynamic_cast<adios2::core::Variable<std::string> *>(
variableBase),
step);
varinfo = (adios2_varinfo *)malloc(sizeof(adios2_varinfo));
varinfo->nblocks = blocksInfo.size();
varinfo->BlocksInfo = (adios2_blockinfo *)malloc(
varinfo->nblocks * sizeof(adios2_blockinfo));
auto *b = varinfo->BlocksInfo;

varinfo->Dims = static_cast<int>(blocksInfo[0].Shape.size());
varinfo->Shape = lf_CopyDims(blocksInfo[0].Shape);
varinfo->IsValue = (int)blocksInfo[0].IsValue;
varinfo->IsReverseDims = (int)blocksInfo[0].IsReverseDims;
for (size_t i = 0; i < varinfo->nblocks; ++i)
{
b[i].WriterID = blocksInfo[i].WriterID;
b[i].BlockID = blocksInfo[i].BlockID;
b[i].Start = lf_CopyDims(blocksInfo[i].Start);
b[i].Count = lf_CopyDims(blocksInfo[i].Count);
// minBlocksInfo->BlocksInfo[i].MinUnion;
b[i].MinUnion.uint64 = 0;
// minBlocksInfo->BlocksInfo[i].MaxUnion;
b[i].MaxUnion.uint64 = 0;
b[i].Value.str = (char *)malloc(blocksInfo[i].Value.size() + 1);
std::strcpy(b[i].Value.str, blocksInfo[i].Value.data());
};
}
#define declare_template_instantiation(T) \
else if (type == adios2::helper::GetDataType<T>()) \
{ \
const auto blocksInfo = engineCpp->BlocksInfo<T>( \
*dynamic_cast<adios2::core::Variable<T> *>(variableBase), step); \
varinfo = (adios2_varinfo *)malloc(sizeof(adios2_varinfo)); \
varinfo->nblocks = blocksInfo.size(); \
varinfo->BlocksInfo = (adios2_blockinfo *)malloc( \
varinfo->nblocks * sizeof(adios2_blockinfo)); \
auto *b = varinfo->BlocksInfo; \
\
varinfo->Dims = static_cast<int>(blocksInfo[0].Shape.size()); \
varinfo->Shape = lf_CopyDims(blocksInfo[0].Shape); \
varinfo->IsValue = (int)blocksInfo[0].IsValue; \
varinfo->IsReverseDims = (int)blocksInfo[0].IsReverseDims; \
for (size_t i = 0; i < varinfo->nblocks; ++i) \
{ \
b[i].WriterID = blocksInfo[i].WriterID; \
b[i].BlockID = blocksInfo[i].BlockID; \
b[i].Start = lf_CopyDims(blocksInfo[i].Start); \
b[i].Count = lf_CopyDims(blocksInfo[i].Count); \
b[i].MinUnion.uint64 = 0; \
b[i].MaxUnion.uint64 = 0; \
b[i].Value.uint64 = 0; \
}; \
}
ADIOS2_FOREACH_PRIMITIVE_STDTYPE_1ARG(declare_template_instantiation)
#undef declare_template_instantiation
}
catch (...)
{
adios2::helper::ExceptionToError("adios2_inquire_blockinfo");
return NULL;
}
return varinfo;
}

adios2_error adios2_close_by_index(adios2_engine *engine,
const int transport_index)
{
Expand Down
10 changes: 10 additions & 0 deletions bindings/C/adios2/c/adios2_c_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,16 @@ adios2_error adios2_lock_writer_definitions(adios2_engine *engine);
*/
adios2_error adios2_lock_reader_selections(adios2_engine *engine);

/**
* Get the list of blocks for a variable in a given step.
* In Streaming mode, step is unused, always the current step is processed.
* @return Newly allocated adios2_varinfo structure, nullptr if step does not
* exist. The pointer must be freed by user
*/
adios2_varinfo *adios2_inquire_blockinfo(adios2_engine *engine,
adios2_variable *variable,
const size_t step);

#ifdef __cplusplus
} // end extern C
#endif
Expand Down
54 changes: 54 additions & 0 deletions bindings/C/adios2/c/adios2_c_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,60 @@ adios2_error adios2_remove_all_attributes(adios2_io *io)
}
}

char **adios2_available_variables(adios2_io *io, size_t *size)
{
try
{
adios2::helper::CheckForNullptr(
io, "for adios2_io, in call to adios2_available_variables");
std::map<std::string, std::map<std::string, std::string>> varInfo =
reinterpret_cast<adios2::core::IO *>(io)->GetAvailableVariables();
*size = varInfo.size();
char **names = (char **)malloc(*size * sizeof(char *));

size_t cnt = 0;
for (auto var : varInfo)
{
size_t len = var.first.length();
names[cnt] = (char *)malloc((len + 1) * sizeof(char));
strcpy(names[cnt], var.first.c_str());
cnt++;
}

return names;
}
catch (...)
{
return NULL;
}
}
char **adios2_available_attributes(adios2_io *io, size_t *size)
{
try
{
adios2::helper::CheckForNullptr(
io, "for adios2_io, in call to adios2_available_attributes");
std::map<std::string, std::map<std::string, std::string>> varInfo =
reinterpret_cast<adios2::core::IO *>(io)->GetAvailableAttributes();
*size = varInfo.size();
char **names = (char **)malloc(*size * sizeof(char *));

size_t cnt = 0;
for (auto var : varInfo)
{
size_t len = var.first.length();
names[cnt] = (char *)malloc((len + 1) * sizeof(char));
strcpy(names[cnt], var.first.c_str());
cnt++;
}

return names;
}
catch (...)
{
return NULL;
}
}
adios2_engine *adios2_open(adios2_io *io, const char *name,
const adios2_mode mode)
{
Expand Down
17 changes: 17 additions & 0 deletions bindings/C/adios2/c/adios2_c_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,23 @@ adios2_error adios2_remove_variable(adios2_bool *result, adios2_io *io,
* @return adios2_error 0: success, see enum adios2_error for errors
*/
adios2_error adios2_remove_all_variables(adios2_io *io);
/**
* @brief returns an array or c strings for names of available variables
* Might create dangling pointers
* @param io handler variables io owner
* @param length of array of strings
* @return names of variables as an array of strings
*/
char **adios2_available_variables(adios2_io *io, size_t *size);

/**
* @brief returns an array or c strings for names of available attributes
* Might create dangling pointers
* @param io handler variables io owner
* @param length of array of strings
* @return names of variables as an array of strings
*/
char **adios2_available_attributes(adios2_io *io, size_t *size);

/**
* @brief DANGEROUS! Removes an attribute identified by name. Might create
Expand Down
Loading

0 comments on commit cb4e903

Please sign in to comment.