Skip to content

Commit

Permalink
Merge pull request #4374 from vicentebolea/backport-from-master
Browse files Browse the repository at this point in the history
Backport from master
  • Loading branch information
vicentebolea authored Oct 25, 2024
2 parents 43591d4 + 74698a4 commit cb871e7
Show file tree
Hide file tree
Showing 27 changed files with 426 additions and 197 deletions.
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ If you find ADIOS2 useful, please cite our [SoftwareX paper](https://doi.org/10.
## Releases

* Latest release: [v2.10.1](https://github.com/ornladios/ADIOS2/releases/tag/v2.10.1)

* Previous releases: [https://github.com/ornladios/ADIOS2/releases](https://github.com/ornladios/ADIOS2/releases)

## Packages
Expand Down
4 changes: 0 additions & 4 deletions bindings/CXX11/adios2/cxx11/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ class Engine
auto bufferView = static_cast<AdiosView<U>>(data);
#if defined(ADIOS2_HAVE_KOKKOS) || defined(ADIOS2_HAVE_GPU_SUPPORT)
auto bufferMem = bufferView.memory_space();
auto bufferLayout = bufferView.layout();
variable.SetMemorySpace(bufferMem);
variable.SetArrayLayout(bufferLayout);
#endif
Put(variable, bufferView.data(), launch);
}
Expand Down Expand Up @@ -416,9 +414,7 @@ class Engine
auto bufferView = static_cast<AdiosView<U>>(data);
#if defined(ADIOS2_HAVE_KOKKOS) || defined(ADIOS2_HAVE_GPU_SUPPORT)
auto bufferMem = bufferView.memory_space();
auto bufferLayout = bufferView.layout();
variable.SetMemorySpace(bufferMem);
variable.SetArrayLayout(bufferLayout);
#endif
Get(variable, bufferView.data(), launch);
}
Expand Down
3 changes: 2 additions & 1 deletion bindings/Python/py11Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ std::vector<std::map<std::string, std::string>> Engine::BlocksInfo(std::string &
MinVarInfo *minBlocksInfo = nullptr;

auto Variable = itVariable->second.get();
minBlocksInfo = m_Engine->MinBlocksInfo(*Variable, 0);
size_t s = (m_Engine->m_OpenMode == Mode::ReadRandomAccess ? step : 0);
minBlocksInfo = m_Engine->MinBlocksInfo(*Variable, s);
if (minBlocksInfo)
{
for (auto &info : minBlocksInfo->BlocksInfo)
Expand Down
2 changes: 1 addition & 1 deletion python/adios2/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def _(self, name, content, shape=[], start=[], count=[], operations=None):
if shape != [] and not variable.single_value():
variable.set_shape(shape)

if start != [] and count != []:
if start != [] or count != []:
variable.set_selection([start, count])

if operations:
Expand Down
59 changes: 0 additions & 59 deletions scripts/build_scripts/build-adios2-kokkos-crusher.sh

This file was deleted.

15 changes: 8 additions & 7 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,13 @@ if (ADIOS2_HAVE_Derived_Variable)
target_sources(adios2_core PRIVATE
core/VariableDerived.cpp
toolkit/derived/Expression.cpp
toolkit/derived/Function.cpp toolkit/derived/Function.tcc
toolkit/derived/ExprHelper.h)
toolkit/derived/Function.cpp toolkit/derived/Function.tcc)
set_target_properties(adios2_core PROPERTIES
INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${ADIOS2_SOURCE_DIR}/source/adios2/toolkit/derived/parser>;$<BUILD_INTERFACE:${ADIOS2_BINARY_DIR}/source/adios2>")
find_package(BISON "3.8.2")
find_package(FLEX)

if(NOT BISON_FOUND OR NOT FLEX_FOUND)
if(NOT BISON_FOUND OR NOT FLEX_FOUND OR (NOT BISON_VERSION VERSION_GREATER_EQUAL "3.8.2"))
include(ADIOSBisonFlexSub)
SETUP_ADIOS_BISON_FLEX_SUB()
else()
Expand All @@ -156,13 +155,15 @@ if (ADIOS2_HAVE_Derived_Variable)
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/lexer.h)
ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp PROPERTIES COMPILE_FLAGS -Wno-sign-compare)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/parser.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-but-set-variable)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/parser.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-but-set-variable)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "IntelLLVM")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/parser.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-but-set-variable)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
SET_SOURCE_FILES_PROPERTIES(toolkit/derived/Expression.cpp toolkit/derived/Function.cpp PROPERTIES COMPILE_FLAGS "/wd4005 /wd4065 /wd4267 -DYY_NO_UNISTD_H")
endif()
add_library(adios2_core_derived
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 @@ -31,7 +31,16 @@

@ADIOS2_CONFIG_DEFINES@

#define ADIOS2_FEATURE_LIST @ADIOS2_CONFIG_FEATURE_LIST@
/*
* Constant defines: These are available unconditionally
* in the current version of ADIOS2.
*/

#define ADIOS2_HAVE_BP3
#define ADIOS2_HAVE_BP4
#define ADIOS2_HAVE_BP5

#define ADIOS2_FEATURE_LIST "BP3" "BP4" "BP5" @ADIOS2_CONFIG_FEATURE_LIST@

/* Everything between here and the note above is programatically generated */

Expand Down
13 changes: 13 additions & 0 deletions source/adios2/core/VariableBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ void VariableBase::SetArrayLayout(const ArrayOrdering layout)
UpdateLayout(m_Shape);
UpdateLayout(m_Count);
UpdateLayout(m_Start);
UpdateLayout(m_MemoryStart);
UpdateLayout(m_MemoryCount);
return;
}
if (m_ArrayLayout != layout)
Expand Down Expand Up @@ -101,6 +103,9 @@ MemorySpace VariableBase::GetMemorySpace(const void *ptr)

void VariableBase::SetMemorySpace(const MemorySpace mem)
{
#if defined(ADIOS2_HAVE_KOKKOS) || defined(ADIOS2_HAVE_GPU_SUPPORT)
ArrayOrdering layout = m_BaseLayout;
#endif
#ifdef ADIOS2_HAVE_GPU_SUPPORT
if (m_MemSpace != MemorySpace::Detect && m_MemSpace != mem)
{
Expand All @@ -115,6 +120,14 @@ void VariableBase::SetMemorySpace(const MemorySpace mem)
ExistingMemSpace + " and cannot received a " +
NewMemSpace + " buffer");
}
if (mem == MemorySpace::GPU)
layout = ArrayOrdering::ColumnMajor;
#endif
#if defined(ADIOS2_HAVE_KOKKOS) || defined(ADIOS2_HAVE_GPU_SUPPORT)
// set the layout based on the buffer memory space
// skipping throwing an exception for a mismatch
if (m_ArrayLayout == ArrayOrdering::Auto)
SetArrayLayout(layout);
#endif
m_MemSpace = mem;
}
Expand Down
2 changes: 0 additions & 2 deletions source/adios2/core/VariableDerived.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#ifndef ADIOS2_CORE_VARIABLE_DERIVED_H_
#define ADIOS2_CORE_VARIABLE_DERIVED_H_

#include "adios2/common/ADIOSTypes.h"
#include "adios2/core/VariableBase.h"
#include "adios2/helper/adiosType.h"
#include "adios2/toolkit/derived/Expression.h"

namespace adios2
Expand Down
1 change: 1 addition & 0 deletions source/adios2/engine/campaign/CampaignData.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifndef ADIOS2_ENGINE_CAMPAIGNDATA_H_
#define ADIOS2_ENGINE_CAMPAIGNDATA_H_

#include <cstdint>
#include <fstream>
#include <iostream>
#include <map>
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/helper/kokkos/adiosKokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool IsGPUbuffer(const void *ptr)
hipError_t ret;
hipPointerAttribute_t attr;
ret = hipPointerGetAttributes(&attr, ptr);
#if defined(ROCM_VERSION_MAJOR) && ROCM_VERSION_MAJOR < 6
#if defined(HIP_VERSION_MAJOR) && HIP_VERSION_MAJOR < 6
if (ret == hipSuccess && attr.memoryType == hipMemoryTypeDevice)
#else
if (ret == hipSuccess && attr.type == hipMemoryTypeDevice)
Expand Down
5 changes: 4 additions & 1 deletion source/adios2/operator/compress/CompressMGARD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,13 @@ size_t CompressMGARD::Operate(const char *dataIn, const Dims &blockStart, const
return 0;
}

mgard_x::Config config;
config.lossless = mgard_x::lossless_type::Huffman_Zstd;

PutParameter(bufferOut, bufferOutOffset, true);
void *compressedData = bufferOut + bufferOutOffset;
mgard_x::compress(mgardDim, mgardType, mgardCount, tolerance, s, errorBoundType, dataIn,
compressedData, sizeOut, true);
compressedData, sizeOut, config, true);
bufferOutOffset += sizeOut;

return bufferOutOffset;
Expand Down
18 changes: 18 additions & 0 deletions source/adios2/toolkit/derived/DerivedData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef ADIOS2_DERIVED_Data_H_
#define ADIOS2_DERIVED_Data_H_

#include "adios2/common/ADIOSTypes.h"

namespace adios2
{
namespace derived
{
struct DerivedData
{
void *Data;
Dims Start;
Dims Count;
};
}
}
#endif
63 changes: 0 additions & 63 deletions source/adios2/toolkit/derived/ExprHelper.h

This file was deleted.

47 changes: 46 additions & 1 deletion source/adios2/toolkit/derived/Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,49 @@
#define ADIOS2_DERIVED_Expression_CPP_

#include "Expression.h"
#include "Function.h"
#include "adios2/helper/adiosLog.h"
#include "parser/ASTDriver.h"

namespace adios2
{
namespace detail
{
struct OperatorProperty
{
std::string name;
bool is_associative;
};

const std::map<ExpressionOperator, OperatorProperty> op_property = {
{ExpressionOperator::OP_NULL, {"NULL", false}},
{ExpressionOperator::OP_ALIAS, {"ALIAS", false}}, /* Parser-use only */
{ExpressionOperator::OP_PATH, {"PATH", false}}, /* Parser-use only */
{ExpressionOperator::OP_NUM, {"NUM", false}}, /* Parser-use only */
{ExpressionOperator::OP_INDEX, {"INDEX", false}},
{ExpressionOperator::OP_ADD, {"ADD", true}},
{ExpressionOperator::OP_SQRT, {"SQRT", false}},
{ExpressionOperator::OP_POW, {"POW", false}},
{ExpressionOperator::OP_CURL, {"CURL", false}},
{ExpressionOperator::OP_MAGN, {"MAGNITUDE", false}}};

const std::map<std::string, ExpressionOperator> string_to_op = {
{"ALIAS", ExpressionOperator::OP_ALIAS}, /* Parser-use only */
{"PATH", ExpressionOperator::OP_PATH}, /* Parser-use only */
{"NUM", ExpressionOperator::OP_NUM}, /* Parser-use only */
{"INDEX", ExpressionOperator::OP_INDEX}, {"+", ExpressionOperator::OP_ADD},
{"add", ExpressionOperator::OP_ADD}, {"ADD", ExpressionOperator::OP_ADD},
{"SQRT", ExpressionOperator::OP_SQRT}, {"sqrt", ExpressionOperator::OP_SQRT},
{"POW", ExpressionOperator::OP_POW}, {"^", ExpressionOperator::OP_POW},
{"CURL", ExpressionOperator::OP_CURL}, {"curl", ExpressionOperator::OP_CURL},
{"MAGNITUDE", ExpressionOperator::OP_MAGN}, {"magnitude", ExpressionOperator::OP_MAGN}};

inline std::string get_op_name(ExpressionOperator op) { return op_property.at(op).name; }

inline ExpressionOperator get_op(std::string op) { return string_to_op.at(op); }

// helper function
adios2::detail::ExpressionOperator convert_op(std::string opname)
ExpressionOperator convert_op(std::string opname)
{
adios2::detail::ExpressionOperator op;
try
Expand Down Expand Up @@ -77,6 +112,16 @@ adios2::derived::ExpressionTree ASTNode_to_ExpressionTree(adios2::detail::ASTNod

namespace derived
{
struct OperatorFunctions
{
std::function<DerivedData(std::vector<DerivedData>, DataType)> ComputeFct;
std::function<Dims(std::vector<Dims>)> DimsFct;
};

std::map<adios2::detail::ExpressionOperator, OperatorFunctions> OpFunctions = {
{adios2::detail::ExpressionOperator::OP_ADD, {AddFunc, SameDimsFunc}},
{adios2::detail::ExpressionOperator::OP_CURL, {Curl3DFunc, CurlDimsFunc}},
{adios2::detail::ExpressionOperator::OP_MAGN, {MagnitudeFunc, SameDimsFunc}}};

Expression::Expression(std::string string_exp)
: m_Shape({0}), m_Start({0}), m_Count({0}), ExprString(string_exp)
Expand Down
Loading

0 comments on commit cb871e7

Please sign in to comment.