ADIOS2.jl

ADIOS2.jl is a Julia interface to the ADIOS2, the Adaptable Input Output System version 2.

Installation

julia>]
pkg> add ADIOS2

ADIOS2 binaries are downloaded by default using the ADIOS2_jll package

Using a custom or system provided ADIOS2 library

Set the environment variable JULIA_ADIOS2_PATH to the top-level installation directory for ADIOS2, i.e. the libadios2_c and libadios2_c_mpi (if using MPI-enabled ADIOS2) libraries should be located under $JULIA_ADIOS2_PATH/lib or $JULIA_ADIOS2_PATH/lib64. Then run import Pkg; Pkg.build("ADIOS2"). This is preferred in high-performance computing (HPC) systems for system-wide installations for libraries built against vendor MPI implementations. It is highly recommended that MPIPreferences points at the system MPI implementation used to build ADIOS2.

Example:

$ export JULIA_ADIOS2_PATH=/opt/adios2/2.8.3

Then in Julia, run:

pkg> build

Basic API

Types

ADIOS2.ErrorType
@enum Error begin
    error_none
    error_invalid_argument
    error_system_error
    error_runtime_error
    error_exception
end

Error return types for all ADIOS2 functions

Based on the library C++ standardized exceptions. Each error will issue a more detailed description in the standard error output, stderr

source
ADIOS2.AdiosTypeType
const AdiosType = Union{AbstractString,
                        Float32,Float64,
                        Complex{Float32},Complex{Float64},
                        Int8,Int16,Int32,Int64,
                        UInt8,UInt16,UInt32,UInt64}

A Union of all scalar types supported in ADIOS files.

source
ADIOS2.ModeType
@enum Mode begin
    mode_undefined
    mode_write
    mode_read
    mode_append
    mode_readRandomAccess

    mode_deferred
    mode_sync
end

Mode specifies for various functions. write, read, append, and readRandomAccess are used for file operations. deferred and sync are used for get and put operations.

source
ADIOS2.StepStatusType
@enum StepStatus begin
    step_status_other_error
    step_status_ok
    step_status_not_ready
    step_status_end_of_stream
end
source
ADIOS2.ShapeIdType
@enum ShapeId begin
    shapeid_unknown
    shapeid_global_value
    shapeid_global_array
    shapeid_joined_array
    shapeid_local_value
    shapeid_local_array
end
source

Adios functions

ADIOS2.AdiosType
mutable struct Adios

Holds a C pointer adios2_adios *.

This value is finalized automatically. It can also be explicitly finalized by calling finalize(adios).

source
ADIOS2.adios_init_mpiFunction
adios = adios_init_mpi(comm::MPI.Comm)
adios = adios_init_mpi(config_file::AbstractString, comm::MPI.Comm)
adios::Union{Adios,Nothing}

Starting point for MPI apps. Creates an ADIOS handler. MPI collective and it calls MPI_Comm_dup.

source
ADIOS2.adios_init_serialFunction
adios = adios_init_serial()
adios = adios_init_serial(config_file::AbstractString)
adios::Union{Adios,Nothing}

Initialize an Adios struct in a serial, non-MPI application. Doesn’t require a runtime config file.

See also the ADIOS2 documentation.

source
ADIOS2.adios_finalizeFunction
err = adios_finalize(adios::Adios)
err::Error

Finalize the ADIOS context adios. It is usually not necessary to call this function.

Instead of calling this function, one can also call the finalizer via finalize(adios). This finalizer is also called automatically when the Adios object is garbage collected.

See also the ADIOS2 documentation

source

IO functions

ADIOS2.define_variableFunction
variable = define_variable(io::AIO, name::AbstractString, type::Type,
                     shape::Union{Nothing,NTuple{N,Int} where N,CartesianIndex}=nothing,
                     start::Union{Nothing,NTuple{N,Int} where N,CartesianIndex}=nothing,
                     count::Union{Nothing,NTuple{N,Int} where N,CartesianIndex}=nothing,
                     constant_dims::Bool=false)
variable::Union{Nothing,Variable}

Define a variable within io.

Arguments

  • io: handler that owns the variable
  • name: unique variable identifier
  • type: primitive type
  • ndims: number of dimensions
  • shape: global dimension
  • start: local offset
  • count: local dimension
  • constant_dims: true: shape, start, count won't change; false: shape, start, count will change after definition
source
ADIOS2.inquire_variableFunction
variable = inquire_variable(io::AIO, name::AbstractString)
variable::Union{Nothing,Variable}

Retrieve a variable handler within current io handler.

Arguments

  • io: handler to variable io owner
  • name: unique variable identifier within io handler
source
ADIOS2.inquire_all_variablesFunction
variables = inquire_all_variables(io::AIO)
variables::Union{Nothing,Vector{Variable}}

Returns an array of variable handlers for all variable present in the io group.

Arguments

  • io: handler to variables io owner
source
ADIOS2.inquire_group_variablesFunction
vars = inquire_group_variables(io::AIO, full_prefix::AbstractString)
vars::Vector{String}

List all variables in the group full_prefix.

source
ADIOS2.define_attributeFunction
attribute = define_attribute(io::AIO, name::AbstractString, value)
attribute::Union{Nothing,Attribute}

Define an attribute value inside io.

source
ADIOS2.define_attribute_arrayFunction
attribute = define_attribute_array(io::AIO, name::AbstractString,
                                   values::AbstractVector)
attribute::Union{Nothing,Attribute}

Define an attribute array inside io.

source
ADIOS2.define_variable_attributeFunction
attribute = define_variable_attribute(io::AIO, name::AbstractString, value,
                                      variable_name::AbstractString,
                                      separator::AbstractString="/")
attribute::Union{Nothing,Attribute}

Define an attribute single value associated to an existing variable by its name.

source
ADIOS2.define_variable_attribute_arrayFunction
attribute = define_variable_attribute_array(io::AIO, name::AbstractString,
                                            values::AbstractVector,
                                            variable_name::AbstractString,
                                            separator::AbstractString="/")
attribute::Union{Nothing,Attribute}

Define an attribute array associated to an existing variable by its name.

source
ADIOS2.inquire_attributeFunction
attribute = inquire_attribute(io::AIO, name::AbstractString)
attribute::Union{Nothing,Attribute}

Return a handler to a previously defined attribute by name.

source
ADIOS2.inquire_variable_attributeFunction
attribute = inquire_variable_attribute(io::AIO, name::AbstractString,
                                       variable_name::AbstractString,
                                       separator::AbstractString="/")
attribute::Union{Nothing,Attribute}

Return a handler to a previously defined attribute by name.

source
ADIOS2.inquire_all_attributesFunction
attributes = inquire_all_attributes(io::AIO)
attributes::Union{Nothing,Vector{Attribute}}

Return an array of attribute handlers for all attribute present in the io group.

source
ADIOS2.inquire_group_attributesFunction
vars = inquire_group_attributes(io::AIO, full_prefix::AbstractString)
vars::Vector{String}

List all attributes in the group full_prefix.

source
ADIOS2.inquire_subgroupsFunction
groups = inquire_subgroups(io::AIO, full_prefix::AbstractString)
groups::Vector{String}

List all subgroups in the group full_prefix.

source
Base.openFunction
engine = open(io::AIO, name::AbstractString, mode::Mode)
engine::Union{Nothing,Engine}

Open an Engine to start heavy-weight input/output operations.

In MPI version reuses the communicator from adios_init_mpi. MPI Collective function as it calls MPI_Comm_dup.

Arguments

  • io: engine owner
  • name: unique engine identifier
  • mode: mode_write, mode_read, mode_append (not yet supported)
source
ADIOS2.get_engineFunction
engine = get_engine(io::AIO, name::AbstractString)
engine::Union{Nothing,Engine}
source

Variable functions

ADIOS2.nameMethod
var_name = name(variable::Variable)
var_name::Union{Nothing,String}

Retrieve variable name.

source
ADIOS2.typeMethod
var_type = type(variable::Variable)
var_type::Union{Nothing,Type}

Retrieve variable type.

source
ADIOS2.shapeidMethod
var_shapeid = shapeid(variable::Variable)
var_shapeid::Union{Nothing,ShapeId}

Retrieve variable shapeid.

source
Base.ndimsMethod
var_ndims = ndims(variable::Variable)
var_ndims::Union{Nothing,Int}

Retrieve current variable number of dimensions.

source
ADIOS2.shapeMethod
var_shape = shape(variable::Variable)
var_shape::Union{Nothing,NTuple{N,Int} where N}

Retrieve current variable shape.

source
ADIOS2.startMethod
var_start = start(variable::Variable)
var_start::Union{Nothing,NTuple{N,Int} where N}

Retrieve current variable start.

source
Base.countMethod
var_count = count(variable::Variable)
var_count::Union{Nothing,NTuple{N,Int} where N}

Retrieve current variable count.

source
ADIOS2.steps_startMethod
var_steps_start = steps_start(variable::Variable)
var_steps_start::Union{Nothing,Int}

Read API, get available steps start from available steps count (e.g. in a file for a variable).

This returns the absolute first available step, don't use with adios2_set_step_selection as inputs are relative, use 0 instead.

source
ADIOS2.stepsMethod
var_steps = steps(variable::Variable)
var_steps::Union{Nothing,Int}

Read API, get available steps count from available steps count (e.g. in a file for a variable). Not necessarily contiguous.

source
ADIOS2.selection_sizeMethod
var_selection_size = selection_size(variable::Variable)
var_selection_size::Union{Nothing,Int}

Return the minimum required allocation (in number of elements of a certain type, not bytes) for the current selection.

source
Base.minimumMethod
var_min = minimum(variable::Variable)
var_min::Union{Nothing,T}

Read mode only: return the absolute minimum for variable.

source
Base.maximumMethod
var_max = maximum(variable::Variable)
var_max::Union{Nothing,T}

Read mode only: return the absolute maximum for variable.

source

Attribute functions

ADIOS2.nameMethod
attr_name = name(attribute::Attribute)
attr_name::Union{Nothing,String}

Retrieve attribute name.

source
ADIOS2.typeMethod
attr_type = type(attribute::Attribute)
attr_type::Union{Nothing,Type}

Retrieve attribute type.

source
ADIOS2.is_valueMethod
attr_is_value = is_value(attribute::Attribute)
attr_is_value::Union{Nothing,Bool}

Retrieve attribute type.

source
Base.sizeMethod
attr_size = size(attribute::Attribute)
attr_size::Union{Nothing,Int}

Retrieve attribute size.

source
ADIOS2.dataMethod
attr_data = data(attribute::Attribute)
attr_data::Union{Nothing,AdiosType,Vector{<:AdiosType}}

Retrieve attribute Data.

source

Engine functions

ADIOS2.nameFunction
var_name = name(variable::Variable)
var_name::Union{Nothing,String}

Retrieve variable name.

source
attr_name = name(attribute::Attribute)
attr_name::Union{Nothing,String}

Retrieve attribute name.

source
engine_name = name(engine::Engine)
engine_name::Union{Nothing,String}

Retrieve engine name.

source
ADIOS2.typeFunction
var_type = type(variable::Variable)
var_type::Union{Nothing,Type}

Retrieve variable type.

source
attr_type = type(attribute::Attribute)
attr_type::Union{Nothing,Type}

Retrieve attribute type.

source
engine_type = type(engine::Engine)
engine_type::Union{Nothing,String}

Retrieve engine type.

source
ADIOS2.openmodeFunction
engine_openmode = openmode(engine::Engine)
engine_openmode::Union{Nothing,Mode}

Retrieve engine openmode.

source
ADIOS2.begin_stepFunction
status = begin_step(engine::Engine, mode::StepMode,
                    timeout_seconds::Union{Integer,AbstractFloat})
status = begin_step(engine::Engine)
status::Union{Noting,StepStatus}

Begin a logical adios2 step stream.

source
ADIOS2.current_stepFunction
step = current_step(engine::Engine)
step::Union{Noting,Int}

Inspect current logical step.

source
ADIOS2.stepsFunction
var_steps = steps(variable::Variable)
var_steps::Union{Nothing,Int}

Read API, get available steps count from available steps count (e.g. in a file for a variable). Not necessarily contiguous.

source
step = steps(engine::Engine)
step::Union{Noting,Int}

Inspect total number of available steps.

source
Base.put!Function
err = Base.put!(engine::Engine, variable::Variable,
                data::Union{Ref,DenseArray,SubArray,Ptr},
                launch::Mode=mode_deferred)
err = Base.put!(engine::Engine, variable::Variable, data::AdiosType,
                launch::Mode=mode_deferred)
err::Error

Schedule writing a variable to file. The buffer data must be contiguous in memory.

Call perform_puts! to perform the actual write operations.

The reference/array/pointer target must not be modified before perform_puts! is called. It is most efficient to schedule multiple put! operations before calling perform_puts!.

source
Base.getFunction
err = Base.get(engine::Engine, variable::Variable,
               data::Union{Ref,DenseArray,SubArray,Ptr},
               launch::Mode=mode_deferred)
err::Error

Schedule reading a variable from file into the provided buffer data. data must be contiguous in memory.

Call perform_gets to perform the actual read operations.

The reference/array/pointer target must not be modified before perform_gets is called. It is most efficient to schedule multiple get operations before calling perform_gets.

source
Base.flushMethod
flush(engine::Engine)

Flush all buffered data to file. Call this after perform_puts! to ensure data are actually written to file.

source
Base.closeMethod
close(engine::Engine)

Close a file. This implicitly also flushed all buffered data.

source

High-Level API

ADIOS2.adios_open_serialFunction
adios = adios_open_serial(filename::AbstractString, mode::Mode)
adios::AdiosFile

Open an ADIOS file. Use mode = mode_write for writing and mode = mode_read for reading.

source
ADIOS2.adios_open_mpiFunction
adios = adios_open_mpi(comm::MPI.Comm, filename::AbstractString, mode::Mode)
adios::AdiosFile

Open an ADIOS file for parallel I/O. Use mode = mode_write for writing and mode = mode_read for reading.

source
Base.flushMethod
flush(file::AdiosFile)

Flush an ADIOS file. When writing, flushing or closing a file is necesssary to ensure that data are actually written to the file.

source
Base.closeMethod
close(file::AdiosFile)

Close an ADIOS file. When writing, flushing or closing a file is necesssary to ensure that data are actually written to the file.

source
ADIOS2.adios_subgroup_namesFunction
groups = adios_subgroup_names(file::AdiosFile, groupname::AbstractString)
vars::Vector{String}

List (non-recursively) all subgroups in the group groupname in the file.

source
ADIOS2.adios_define_attributeFunction

adiosdefineattribute(file::AdiosFile, name::AbstractString, value::AdiosType)

Write a scalar attribute.

source
adios_define_attribute(file::AdiosFile, name::AbstractString,
                       value::AbstractArray{<:AdiosType})

Write an array-valued attribute.

source
adios_define_attribute(file::AdiosFile, path::AbstractString,
                       name::AbstractString, value::AdiosType)

Write a scalar attribute into the path path in the file.

source
adios_define_attribute(file::AdiosFile, path::AbstractString,
                       name::AbstractString,
                       value::AbstractArray{<:AdiosType})

Write an array-valued attribute into the path path in the file.

source
ADIOS2.adios_group_attribute_namesFunction
vars = adios_group_attribute_names(file::AdiosFile, groupname::AbstractString)
vars::Vector{String}

List (non-recursively) all attributes in the group groupname in the file.

source
ADIOS2.adios_attribute_dataFunction
attr_data = adios_attribute_data(file::AdiosFile, name::AbstractString)
attr_data::Union{Nothing,AdiosType}

Read an attribute from a file. Return nothing if the attribute is not found.

source
attr_data =  adios_attribute_data(file::AdiosFile, path::AbstractString,
                                  name::AbstractString)
attr_data::Union{Nothing,AdiosType}

Read an attribute from a file in path path. Return nothing if the attribute is not found.

source
ADIOS2.adios_put!Function

adios_put!(file::AdiosFile, name::AbstractString, scalar::AdiosType)

Schedule writing a scalar variable to a file.

The variable is not written until adios_perform_puts! is called and the file is flushed or closed.

source
adios_put!(file::AdiosFile, name::AbstractString,
           array::AbstractArray{<:AdiosType}; make_copy::Bool=false)

Schedule writing an array-valued variable to a file.

make_copy determines whether to make a copy of the array, which is expensive for large arrays. When no copy is made, then the array must not be modified before adios_perform_puts! is called.

The variable is not written until adios_perform_puts! is called and the file is flushed or closed.

source
ADIOS2.adios_perform_puts!Function
adios_perform_puts!(file::AdiosFile)

Execute all scheduled adios_put! operations.

The data might not be in the file yet; they might be buffered. Call adios_flush or adios_close to ensure all data are written to file.

source
ADIOS2.adios_group_variable_namesFunction
vars = adios_group_variable_names(file::AdiosFile, groupname::AbstractString)
vars::Vector{String}

List (non-recursively) all variables in the group groupname in the file.

source
ADIOS2.IORefType
mutable struct IORef{T,D}

A reference to the value of a variable that has been scheduled to be read from disk. This value cannot be accessed bofre the read operations have actually been executed.

Use fetch(ioref::IORef) to access the value. fetch will trigger the actual reading from file if necessary. It is most efficient to schedule multiple read operations at once.

Use adios_perform_gets to trigger reading all currently scheduled variables.

source
Base.isreadyMethod
isready(ioref::IORef)::Bool

Check whether an IORef has already been read from file.

source
Base.fetchMethod
value = fetch(ioref::IORef{T,D}) where {T,D}
value::Array{T,D}

Access an IORef. If necessary, the variable is read from file and then cached. (Each IORef is read at most once.)

Scalars are handled as zero-dimensional arrays. To access the value of a zero-dimensional array, write array[] (i.e. use array indexing, but without any indices).

source
ADIOS2.adios_getFunction
ioref = adios_get(file::AdiosFile, name::AbstractString)
ioref::Union{Nothing,IORef}

Schedule reading a variable from a file.

The variable is not read until adios_perform_gets is called. This happens automatically when the IORef is accessed (via fetch). It is most efficient to first schedule multiple variables for reading, and then executing the reads together.

source
ADIOS2.adios_perform_getsFunction
adios_perform_gets(file::AdiosFile)

Execute all currently scheduled read opertions. This makes all pending IORefs ready.

source