Skip to content

SerialIO ADIOS1 Test: Bool#344

Merged
ax3l merged 4 commits intoopenPMD:devfrom
ax3l:fix-adiosBool
Sep 14, 2018
Merged

SerialIO ADIOS1 Test: Bool#344
ax3l merged 4 commits intoopenPMD:devfrom
ax3l:fix-adiosBool

Conversation

@ax3l
Copy link
Member

@ax3l ax3l commented Sep 13, 2018

ADIOS1 bool testing. Probably needs a fix.

auto ptr = reinterpret_cast< unsigned char* >(values.get());
*ptr = static_cast< unsigned char >(att.get< unsigned char >());
auto ptr = reinterpret_cast< bool* >(values.get());
*ptr = static_cast< bool >(att.get< bool >());
Copy link
Member

@anokfireball anokfireball Sep 13, 2018

Choose a reason for hiding this comment

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

values is a void* that is given to ADIOS, allocated here.
To support bool writing (with the workaround), this will have to be allocated as uint8_t.
The Attribute is passed as bool, so that case needs to be handled manually.

void
CommonADIOS1IOHandlerImpl::flush_attribute(int64_t group, std::string const& name, Attribute const& att)
{
    auto dtype = att.dtype;
    if( dtype == Datatype::BOOL )
        dtype = Datatype::UCHAR;

    switch( dtype ) /* NOTE - workaround dtype */
    /* ... */

    auto values = auxiliary::allocatePtr(dtype, nelems); /* NOTE - workaround dtype */
    switch( att.dtype ) /* NOTE - original dtype */
    {
        case DT::BOOL:
        {
            auto ptr = reinterpret_cast< unsigned char* >(values.get());
            *ptr = static_cast< unsigned char >(att.get< bool >());
            break;
        }
    }
    /* ... */
}

Copy link
Member Author

@ax3l ax3l Sep 13, 2018

Choose a reason for hiding this comment

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

@C0nsultant can you push the change you are suggesting on the PR branch? I am open to any changes here, just needed a demonstrator to show what I saw was causing the crash during write :)

(Was on the plane and road today, sorry for the missing annotations!)

@ax3l ax3l merged commit d3228d7 into openPMD:dev Sep 14, 2018
@ax3l ax3l deleted the fix-adiosBool branch September 14, 2018 06:45
@ax3l
Copy link
Member Author

ax3l commented Sep 14, 2018

@C0nsultant thx! :)

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