Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When reading with different order (column <-> row order), do not reve… #3315

Merged
merged 1 commit into from Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions source/adios2/toolkit/format/bp5/BP5Deserializer.cpp
Expand Up @@ -404,13 +404,13 @@ BP5Deserializer::ControlInfo *BP5Deserializer::BuildControl(FMFormat Format)
return ret;
}

void BP5Deserializer::ReverseDimensions(size_t *Dimensions, int count,
int times)
void BP5Deserializer::ReverseDimensions(size_t *Dimensions, size_t count,
size_t times)
{
int Offset = 0;
for (int j = 0; j < times; j++)
size_t Offset = 0;
for (size_t j = 0; j < times; j++)
{
for (int i = 0; i < count / 2; i++)
for (size_t i = 0; i < count / 2; i++)
{
size_t tmp = Dimensions[Offset + i];
Dimensions[Offset + i] = Dimensions[Offset + count - i - 1];
Expand Down Expand Up @@ -672,11 +672,14 @@ void BP5Deserializer::InstallMetaData(void *MetadataBlock, size_t BlockLen,
{
/* if we're getting data from someone of the other array gender,
* switcheroo */
ReverseDimensions(meta_base->Shape, meta_base->Dims, 1);
ReverseDimensions(meta_base->Count, meta_base->Dims,
BlockCount);
ReverseDimensions(meta_base->Offsets, meta_base->Dims,
BlockCount);
if (ControlFields[i].OrigShapeID == ShapeID::GlobalArray)
{
ReverseDimensions(meta_base->Shape, meta_base->Dims, 1);
ReverseDimensions(meta_base->Offsets, meta_base->Dims,
BlockCount);
}
}
if ((WriterRank == 0) || (VarRec->GlobalDims == NULL))
{
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/toolkit/format/bp5/BP5Deserializer.h
Expand Up @@ -184,7 +184,7 @@ class BP5Deserializer : virtual public BP5Base
BP5VarRec *LookupVarByKey(void *Key) const;
BP5VarRec *LookupVarByName(const char *Name);
BP5VarRec *CreateVarRec(const char *ArrayName);
void ReverseDimensions(size_t *Dimensions, int count, int times);
void ReverseDimensions(size_t *Dimensions, size_t count, size_t times);
void BreakdownVarName(const char *Name, char **base_name_p,
DataType *type_p, int *element_size_p);
void BreakdownFieldType(const char *FieldType, bool &Operator,
Expand Down
115 changes: 92 additions & 23 deletions testing/CMakeLists.txt
@@ -1,11 +1,11 @@
#------------------------------------------------------------------------------#
# ------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
# ------------------------------------------------------------------------------#

if(ADIOS2_HAVE_MPI)
set(MPIEXEC_EXTRA_FLAGS "" CACHE STRING
"Extra flags to set after mpiexec and before the num_procs flag"
"Extra flags to set after mpiexec and before the num_procs flag"
)
mark_as_advanced(MPIEXEC_EXTRA_FLAGS)
separate_arguments(MPIEXEC_EXTRA_FLAGS)
Expand All @@ -17,50 +17,56 @@ if(ADIOS2_HAVE_MPI)
endif()

include(GoogleTest)

# gtest_add_tests_helper:
# Create a wrapper around gtest_add_tests that uses common patterns for test
# names, execurtable names, mpi usage, etc.
#
# Arguments:
# testname - The basename of the test file
# mpi - MPI_ALLOW - build MPI test, execute with mpiexec; also build Serial test
# MPI_NONE - build Serial test only
# MPI_ONLY - build MPI test only, execute with mpiexec
# src_pfx - Source filename prefix, Test${src_pfs}${testname}.cpp
# tst_pfx - Test name prefix to be added to CTest
# tst_sfx - Test name suffix to be added to CTest
# testname - The basename of the test file
# mpi - MPI_ALLOW - build MPI test, execute with mpiexec; also build Serial test
# MPI_NONE - build Serial test only
# MPI_ONLY - build MPI test only, execute with mpiexec
# src_pfx - Source filename prefix, Test${src_pfs}${testname}.cpp
# tst_pfx - Test name prefix to be added to CTest
# tst_sfx - Test name suffix to be added to CTest
# all additional arguments are passed directly to gtest_add_tests
#
# Example:
# You have a gtest file, TestFooThings.cpp that containst Test1 and Test2
# gtest functions that can be called with different sets of arguments.
# You have a gtest file, TestFooThings.cpp that containst Test1 and Test2
# gtest functions that can be called with different sets of arguments.
#
# gtest_add_tests_helper(Things MPI_ALLOW Foo Foo. .Bar EXTRA_ARGS "Bar")
# gtest_add_tests_helper(Things MPI_ALLOW Foo Foo. .Baz EXTRA_ARGS "Baz")
# gtest_add_tests_helper(Things MPI_ALLOW Foo Foo. .Bar EXTRA_ARGS "Bar")
# gtest_add_tests_helper(Things MPI_ALLOW Foo Foo. .Baz EXTRA_ARGS "Baz")
#
# will create the executable Test.Foo.Things and add the tests
# Foo.Things.Test1.Bar.Serial
# Foo.Things.Test1.Bar.MPI
# Foo.Things.Test2.Bar.Serial
# Foo.Things.Test2.Bar.MPI
# Foo.Things.Test1.Baz.Serial
# Foo.Things.Test1.Baz.MPI
# Foo.Things.Test2.Baz.Serial
# Foo.Things.Test2.Baz.MPI
# will create the executable Test.Foo.Things and add the tests
# Foo.Things.Test1.Bar.Serial
# Foo.Things.Test1.Bar.MPI
# Foo.Things.Test2.Bar.Serial
# Foo.Things.Test2.Bar.MPI
# Foo.Things.Test1.Baz.Serial
# Foo.Things.Test1.Baz.MPI
# Foo.Things.Test2.Baz.Serial
# Foo.Things.Test2.Baz.MPI
#
function(gtest_add_tests_helper testname mpi src_pfx tst_pfx tst_sfx)
set(test_targets "")

if(NOT mpi MATCHES "^MPI_(ALLOW|NONE|ONLY)$")
message(FATAL_ERROR "Invalid mpi argument value '${mpi}'.")
endif()

set(all_tests)

if(NOT mpi STREQUAL "MPI_ONLY")
set(tgt Test.${tst_pfx}${testname}.Serial)
list(APPEND test_targets "${tgt}")

if(NOT TARGET ${tgt})
add_executable(${tgt} Test${src_pfx}${testname}.cpp)
target_link_libraries(${tgt} adios2::cxx11 adios2::c adios2_core adios2::thirdparty::gtest)
endif()

gtest_add_tests(TARGET ${tgt}
TEST_PREFIX "${tst_pfx}"
TEST_SUFFIX "${tst_sfx}.Serial"
Expand All @@ -69,13 +75,16 @@ function(gtest_add_tests_helper testname mpi src_pfx tst_pfx tst_sfx)
)
list(APPEND all_tests ${added_tests})
endif()

if(ADIOS2_HAVE_MPI AND NOT mpi STREQUAL "MPI_NONE")
set(tgt Test.${tst_pfx}${testname}.MPI)
list(APPEND test_targets "${tgt}")

if(NOT TARGET ${tgt})
add_executable(${tgt} Test${src_pfx}${testname}.cpp)
target_link_libraries(${tgt} adios2::cxx11_mpi adios2::c_mpi adios2_core_mpi MPI::MPI_C adios2::thirdparty::gtest)
endif()

gtest_add_tests(TARGET ${tgt}
TEST_PREFIX "${tst_pfx}"
TEST_SUFFIX "${tst_sfx}.MPI"
Expand All @@ -86,12 +95,72 @@ function(gtest_add_tests_helper testname mpi src_pfx tst_pfx tst_sfx)
list(APPEND all_tests ${added_tests})
set_tests_properties(${added_tests} PROPERTIES PROCESSORS "${MPIEXEC_MAX_NUMPROCS}")
endif()

set("Test.${tst_pfx}${testname}-TESTS" "${all_tests}" PARENT_SCOPE)
set("Test.${tst_pfx}${testname}-TARGETS" "${test_targets}" PARENT_SCOPE)
endfunction()

if(ADIOS2_HAVE_Fortran)
function(gtest_add_tests_helper_Fortran testname mpi src_pfx tst_pfx tst_sfx wrk_dir extra_args)
set(test_targets "")

# message(STATUS "Add testname=${testname} src_pfx=${src_pfx} tst_pfx=${tst_pfx} tst_sfx=${tst_sfx} wrk_dir=${wrk_dir} extra=${extra_args}")
if(NOT mpi MATCHES "^MPI_(ALLOW|NONE|ONLY)$")
message(FATAL_ERROR "Invalid mpi argument value '${mpi}'.")
endif()

set(all_tests)

if(NOT mpi STREQUAL "MPI_ONLY")
set(tgt Test.${tst_pfx}${testname}.Serial)
list(APPEND test_targets "${tgt}")

if(NOT TARGET ${tgt})
add_executable(${tgt} Test${src_pfx}${testname}.F90)
set_target_properties(${tgt} PROPERTIES LINKER_LANGUAGE Fortran)
target_link_libraries(${tgt} adios2::fortran adios2::thirdparty::gtest)
endif()

add_test(
NAME ${tst_pfx}${src_pfx}${testname}${tst_sfx}.Serial
COMMAND ${tgt} ${extra_args}
WORKING_DIRECTORY ${wrk_dir}
)
list(APPEND all_tests ${added_tests})
endif()

if(ADIOS2_HAVE_MPI AND NOT mpi STREQUAL "MPI_NONE")
set(tgt Test.${tst_pfx}${testname}.MPI)
list(APPEND test_targets "${tgt}")

if(NOT TARGET ${tgt})
add_executable(${tgt} Test${src_pfx}${testname}.F90)
set_target_properties(${tgt} PROPERTIES LINKER_LANGUAGE Fortran)
target_link_libraries(${tgt} adios2::fortran_mpi MPI::MPI_Fortran adios2::thirdparty::gtest)
endif()

set(test_name ${tst_pfx}${src_pfx}${testname}${tst_sfx}.MPI)
add_test(
NAME ${test_name}
COMMAND ${MPIEXEC_COMMAND} $<TARGET_FILE:${tgt}> ${extra_args}
WORKING_DIRECTORY ${wrk_dir}
)
set_tests_properties(${test_name} PROPERTIES
PROCESSORS "${MPIEXEC_MAX_NUMPROCS}"
)
list(APPEND all_tests ${added_tests})
set_tests_properties(${added_tests} PROPERTIES PROCESSORS "${MPIEXEC_MAX_NUMPROCS}")
endif()

# message(STATUS "Creating Fortran tests ${all_tests}")
set("Test.${tst_pfx}${testname}-TESTS" "${all_tests}" PARENT_SCOPE)
set("Test.${tst_pfx}${testname}-TARGETS" "${test_targets}" PARENT_SCOPE)
endfunction()
endif(ADIOS2_HAVE_Fortran)

add_subdirectory(adios2)
add_subdirectory(utils)

if(ADIOS2_RUN_INSTALL_TEST)
add_subdirectory(install)
endif()
Expand Down
71 changes: 55 additions & 16 deletions testing/adios2/engine/bp/CMakeLists.txt
@@ -1,7 +1,8 @@
#------------------------------------------------------------------------------#
# ------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
# ------------------------------------------------------------------------------#
include(ADIOSFunctions)

set(BP3_DIR ${CMAKE_CURRENT_BINARY_DIR}/bp3)
set(BP4_DIR ${CMAKE_CURRENT_BINARY_DIR}/bp4)
Expand Down Expand Up @@ -31,11 +32,12 @@ macro(bp4_bp5_gtest_add_tests_helper testname mpi)
gtest_add_tests_helper(${testname} ${mpi} BP Engine.BP. .BP4
WORKING_DIRECTORY ${BP4_DIR} EXTRA_ARGS "BP4"
)

if(ADIOS2_HAVE_BP5)
gtest_add_tests_helper(${testname} ${mpi} BP Engine.BP. .BP5
WORKING_DIRECTORY ${BP5_DIR} EXTRA_ARGS "BP5"
)
endif()
gtest_add_tests_helper(${testname} ${mpi} BP Engine.BP. .BP5
WORKING_DIRECTORY ${BP5_DIR} EXTRA_ARGS "BP5"
)
endif()
endmacro()

macro(bp_gtest_add_tests_helper testname mpi)
Expand All @@ -45,6 +47,7 @@ macro(bp_gtest_add_tests_helper testname mpi)
gtest_add_tests_helper(${testname} ${mpi} BP Engine.BP. .BP4
WORKING_DIRECTORY ${BP4_DIR} EXTRA_ARGS "BP4"
)

if(ADIOS2_HAVE_BP5)
gtest_add_tests_helper(${testname} ${mpi} BP Engine.BP. .BP5
WORKING_DIRECTORY ${BP5_DIR} EXTRA_ARGS "BP5"
Expand All @@ -69,6 +72,28 @@ macro(async_gtest_add_tests_helper testname mpi)
endif()
endmacro()

if(ADIOS2_HAVE_Fortran)
macro(bp_gtest_add_tests_helper_Fortran testname mpi)
# message(STATUS "Creating Fortran test ${testname} ${mpi}")
gtest_add_tests_helper_Fortran(${testname} ${mpi} BP Engine.BP. .BP3
${BP3_DIR} "BP3"
)
gtest_add_tests_helper_Fortran(${testname} ${mpi} BP Engine.BP. .BP4
${BP4_DIR} "BP4"
)

if(ADIOS2_HAVE_BP5)
gtest_add_tests_helper_Fortran(${testname} ${mpi} BP Engine.BP. .BP5
${BP5_DIR} "BP5"
)
endif()
endmacro()
else()
macro(bp_gtest_add_tests_helper_Fortran testname mpi)
message(STATUS "Skip creating Fortran test ${testname} ${mpi}")
endmacro()
endif()

add_subdirectory(operations)

# These tests should be *very* fast
Expand All @@ -89,13 +114,17 @@ bp_gtest_add_tests_helper(WriteReadMultiblock MPI_ALLOW)
bp_gtest_add_tests_helper(WriteReadVector MPI_ALLOW)
bp_gtest_add_tests_helper(WriteReadAttributesMultirank MPI_ALLOW)
bp_gtest_add_tests_helper(LargeMetadata MPI_ALLOW)

if(ADIOS2_HAVE_BP5)
set (BP5LargeMeta "Engine.BP.BPLargeMetadata.BPWrite1D_LargeMetadata.BP5.Serial")
if (ADIOS2_HAVE_MPI)
list (APPEND BP5LargeMeta "Engine.BP.BPLargeMetadata.BPWrite1D_LargeMetadata.BP5.MPI" "Engine.BP.BPLargeMetadata.ManyLongStrings.BP5.MPI")
endif()
set_tests_properties(${BP5LargeMeta} PROPERTIES RUN_SERIAL TRUE)
set(BP5LargeMeta "Engine.BP.BPLargeMetadata.BPWrite1D_LargeMetadata.BP5.Serial")

if(ADIOS2_HAVE_MPI)
list(APPEND BP5LargeMeta "Engine.BP.BPLargeMetadata.BPWrite1D_LargeMetadata.BP5.MPI" "Engine.BP.BPLargeMetadata.ManyLongStrings.BP5.MPI")
endif()

set_tests_properties(${BP5LargeMeta} PROPERTIES RUN_SERIAL TRUE)
endif()

bp_gtest_add_tests_helper(WriteMemorySelectionRead MPI_ALLOW)
bp_gtest_add_tests_helper(WriteReadLocalVariables MPI_ALLOW)
bp_gtest_add_tests_helper(WriteReadLocalVariablesSel MPI_ALLOW)
Expand All @@ -112,6 +141,14 @@ bp_gtest_add_tests_helper(SelectSteps MPI_ALLOW)
bp_gtest_add_tests_helper(SelectionsOnRowMajorData MPI_NONE)
bp_gtest_add_tests_helper(SelectionsOnColumnMajorData MPI_NONE)

# Fortran writer C++ reader test
if(ADIOS2_HAVE_Fortran)
bp_gtest_add_tests_helper_Fortran(FortranToCppWriter MPI_ONLY)
bp_gtest_add_tests_helper(FortranToCppReader MPI_ONLY)

# SetupTestPipeline(Engine.BP.BPFortranToCPPWriter.BP5.MPI ";Engine.BP.BPFortranToCPPReader.ADIOS2BPFortranToCppRead.BP5.MPI" FALSE)
endif(ADIOS2_HAVE_Fortran)

if(NOT MSVC)
bp_gtest_add_tests_helper(BufferSize MPI_NONE)
endif()
Expand Down Expand Up @@ -142,9 +179,9 @@ gtest_add_tests_helper(WriteNull MPI_ALLOW BP Engine.BP. .BP3
bp4_bp5_gtest_add_tests_helper(WriteAppendReadADIOS2 MPI_ALLOW)

# BP4 only for now
#gtest_add_tests_helper(WriteAppendReadADIOS2 MPI_ALLOW BP Engine.BP. .BP4
# WORKING_DIRECTORY ${BP4_DIR} EXTRA_ARGS "BP4"
#)
# gtest_add_tests_helper(WriteAppendReadADIOS2 MPI_ALLOW BP Engine.BP. .BP4
# WORKING_DIRECTORY ${BP4_DIR} EXTRA_ARGS "BP4"
# )
gtest_add_tests_helper(StepsInSituGlobalArray MPI_ALLOW BP Engine.BP. .BP4
WORKING_DIRECTORY ${BP4_DIR} EXTRA_ARGS "BP4"
)
Expand All @@ -153,10 +190,10 @@ gtest_add_tests_helper(StepsInSituLocalArray MPI_ALLOW BP Engine.BP. .BP4
)

gtest_add_tests_helper(InquireVariableException MPI_ALLOW BP Engine.BP. .BP4
WORKING_DIRECTORY ${BP4_DIR}
WORKING_DIRECTORY ${BP4_DIR}
)
gtest_add_tests_helper(InquireDefine MPI_ALLOW BP Engine.BP. .BP4
WORKING_DIRECTORY ${BP4_DIR}
WORKING_DIRECTORY ${BP4_DIR}
)

# FileStream is BP4 + StreamReader=true
Expand All @@ -174,6 +211,7 @@ if(ADIOS2_HAVE_CUDA)
gtest_add_tests_helper(SelectionsCuda MPI_ALLOW BP Engine.BP. .BP4
WORKING_DIRECTORY ${BP4_DIR} EXTRA_ARGS "BP4"
)

if(ADIOS2_HAVE_BP5)
gtest_add_tests_helper(WriteReadCuda MPI_ALLOW BP Engine.BP. .BP5
WORKING_DIRECTORY ${BP5_DIR} EXTRA_ARGS "BP5"
Expand All @@ -182,6 +220,7 @@ if(ADIOS2_HAVE_CUDA)
WORKING_DIRECTORY ${BP5_DIR} EXTRA_ARGS "BP5"
)
endif()

foreach(tgt ${Test.Engine.BP.WriteReadCuda-TARGETS})
target_sources(${tgt} PRIVATE operations/CudaRoutines.cu)
target_link_libraries(${tgt} CUDA::cudart)
Expand Down