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

Fix append mode double attributes #1302

Merged
merged 17 commits into from
Oct 7, 2022

Conversation

franzpoeschel
Copy link
Contributor

@franzpoeschel franzpoeschel commented Jul 14, 2022

When appending to an existing group/variable-based Series, don't define top-level attributes again (except basePath and openPMD, these are needed internally and ADIOS2 doesn't care as long as they are duplicate but equivalent)
This fixes an Append mode bug that is already present on dev and has a low chance of making CI runs fail.

  • Merge ADIOS2: more fine-grained control for file endings #1218 first
  • Add CHECK_FILE task for other backends too (maybe not for ADIOS1)
  • maybe merge CHECK_FILE and CREATE_FILE tasks, no this would require executing CREATE_FILE very early
  • cleanup
  • Support file creation via Append mode in group-based iteration encoding
  • This seems to trigger an ADIOS2 bug?: I get this on dev already, will need to see what's going on
    append_mode                                                                                                                                                                                                     
    -------------------------------------------------------------------------------                                                                                                                                 
    /home/franzpoeschel/git-repos/openPMD-api/test/SerialIOTest.cpp:6486                                                                                                                                            
    ...............................................................................                                                                                                                                 
                                                                                                                                                                                                                    
    /home/franzpoeschel/git-repos/openPMD-api/test/SerialIOTest.cpp:6486: FAILED:                                                                                                                                   
      {Unknown expression after the reported line}                                                                                                                                                                  
    due to unexpected exception with message:                                                                                                                                                                       
      [Tue Sep 20 14:18:56 2022] [ADIOS2 EXCEPTION] <Engine>                                                                                                                                                        
      <BP5Reader> <ParseMetadataIndex> : Record 5 (id = 115) has invalid length 48.                                                                                                                                 
      We parsed 2195488 bytes for this record      
    

@franzpoeschel franzpoeschel force-pushed the fix-append-mode-double-attributes branch from 719e8db to 2f56ac0 Compare July 15, 2022 13:53
@franzpoeschel franzpoeschel changed the title [WIP] Fix append mode double attributes Fix append mode double attributes Jul 18, 2022
@franzpoeschel franzpoeschel force-pushed the fix-append-mode-double-attributes branch 2 times, most recently from 8315402 to f5e511f Compare July 19, 2022 09:40
franzpoeschel added a commit to franzpoeschel/openPMD-api that referenced this pull request Jul 19, 2022
This reverts commit a39b618.

The test is added in PR openPMD#1302 which fixes the bug
@franzpoeschel franzpoeschel force-pushed the fix-append-mode-double-attributes branch 2 times, most recently from f329c8c to 1b5b053 Compare July 20, 2022 13:19
@franzpoeschel franzpoeschel force-pushed the fix-append-mode-double-attributes branch from a6c67b4 to 22be635 Compare July 29, 2022 09:05
@franzpoeschel franzpoeschel force-pushed the fix-append-mode-double-attributes branch from 22be635 to 0f22a17 Compare August 15, 2022 09:07
@@ -502,15 +502,18 @@ namespace
int padding;
uint64_t iterationIndex;
std::set<int> paddings;
for (auto const &entry : auxiliary::list_directory(directory))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes another subtle bug: Creating a Series via Append mode should be possible. But so far, this routine failed if the directory was not present.

@franzpoeschel franzpoeschel force-pushed the fix-append-mode-double-attributes branch from 0f22a17 to 77215b9 Compare August 16, 2022 14:51
@ax3l ax3l self-requested a review August 16, 2022 17:17
@ax3l ax3l self-assigned this Aug 16, 2022
@franzpoeschel franzpoeschel force-pushed the fix-append-mode-double-attributes branch from ac5504f to 2bc1ac4 Compare August 17, 2022 09:25
@franzpoeschel franzpoeschel force-pushed the fix-append-mode-double-attributes branch from 8972ff0 to 90194ad Compare August 17, 2022 14:30
include/openPMD/Series.hpp Outdated Show resolved Hide resolved
namespace
{
template <typename>
struct MPI_Types;
Copy link
Member

@ax3l ax3l Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future refactoring: since this is an openPMD internal type trait, we should consider renaming this so it does not collide with the MPI_.... prefix used as convention in the MPI C libraries for all its functions.

Suggestions: MPI_Types -> openPMD_MPI_Type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this, I'm asking myself if this code is even correct. If an MPI application runs on a heterogeneous system with differing CPU architectures, there will be undefined behavior, no?
Maybe, we should just use the largest numeric type for those cases? Or is there a better way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends a bit and would require more work, but I think not in the location here.

heterogeneous system with differing CPU architectures

The questions here is not really the CPU (micro) architecture but the data model: https://en.cppreference.com/w/cpp/language/types Essentially all modern systems you would put on an HPC system are LP64.

If you would like to run with MPI on a system with heterogeneous hosts, you would have to compile your binaries for each of them and spawn them with MPI. That's the easy part, the hard part would be if someone ever implemented an MPI that would allow to communicate between LP64 and, let's say ILP32, or LP64 with big and little endian.

Either way, it would not change the local code in this location.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can actually simplify this by using static constexpr MPI_Datatype const value = ...;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably even make this a simpler constexpr function now, which might also benefit compile time.

Copy link
Contributor Author

@franzpoeschel franzpoeschel Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constexpr will probably not work fully since the MPI datatypes are not constexpr in every implementation, but we can still replace the specialized class template with if constexpr, yeah.

If you would like to run with MPI on a system with heterogeneous hosts, you would have to compile your binaries for each of them and spawn them with MPI. That's the easy part, the hard part would be if someone ever implemented an MPI that would allow to communicate between LP64 and, let's say ILP32, or LP64 with big and little endian.

Either way, it would not change the local code in this location.

Fair enough, thanks for clarifying!

Copy link
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splendid, thanks a lot! :)

@ax3l ax3l merged commit 230afdd into openPMD:dev Oct 7, 2022
eschnett added a commit to eschnett/openPMD-api that referenced this pull request Nov 11, 2022
* dev: (70 commits)
  Docs: Recommend Static Build for Superbuilds (openPMD#1325)
  Python 3.11 (openPMD#1323)
  pybind11: v2.10.1+ (openPMD#1322)
  Add Attribute::getOptional<T>() and use to add some more dynamic datatype conversions at read time (openPMD#1278)
  Mapping between ADIOS steps and openPMD iterations (openPMD#949)
  Deprecate shareRaw (openPMD#1229)
  Fix append mode double attributes (openPMD#1302)
  Constant scalars: Don't flush double (openPMD#1315)
  Remove caching cmake vars (openPMD#1313)
  [pre-commit.ci] pre-commit autoupdate (openPMD#1311)
  storeChunk: Add an overload for shared_ptr<T[]> (openPMD#1296)
  Fix `operationAsString` Export (openPMD#1309)
  ADIOS2: more fine-grained control for file endings (openPMD#1218)
  [pre-commit.ci] pre-commit autoupdate (openPMD#1307)
  Fix file existence check in parallel tests (openPMD#1303)
  ADIOS2: Flush to disk within a step (openPMD#1207)
  [pre-commit.ci] pre-commit autoupdate (openPMD#1304)
  [pre-commit.ci] pre-commit autoupdate (openPMD#1295)
  Update catch2 to v2.13.9 (openPMD#1299)
  [pre-commit.ci] pre-commit autoupdate (openPMD#1292)
  ...

# Conflicts:
#	.github/workflows/linux.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants