Issuing I/O operations

Once initialized, ABT-IO can be used to issue I/O operations as follows.

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <abt-io.h>

int main(int argc, char** argv)
{
    // Argobots must be initialized, either with ABT_init
    // or with margo_init, thallium::engine, or thallium::abt.
    ABT_init(argc, argv);

    // abt_io_init takes the number of ES to create as a parameter.
    abt_io_instance_id abtio = abt_io_init(2);

    // open a file
    int fd = abt_io_open(abtio, "test.txt", O_WRONLY | O_APPEND | O_CREAT, 0600);

    // write to the file
    abt_io_pwrite(abtio, fd, "This is a test", 14, 0);

    // close the file
    abt_io_close(abtio, fd);

    // ABT-IO must be finalized before Argobots it finalized.
    abt_io_finalize(abtio);

    ABT_finalize();

    return 0;
}

The list of available I/O operations is the following.

ABT-IO function

Corresponding POSIX function

abt_io_open

open

abt_io_write

write

abt_io_pwrite

pwrite

abt_io_read

read

abt_io_pread

pread

abt_io_mkostemp

mkostemp

abt_io_unlink

unlink

abt_io_close

close

abt_io_ftruncate

ftruncate

abt_io_truncate

truncate

abt_io_lseek

lseek

abt_io_fdatasync

fdatasync

abt_io_fallocate

fallocate

abt_io_stat

stat

abt_io_statfs

statfs

Important

We highly recommend using the pwrite and pread wrappers rather than the write, read, and lseek wrappers. The former functions include explicit offsets with each operation, while the latter rely on implicit file positioning which will be unreliable and unpredictable if current I/O operations are in flight. ABT-IO inherently does not serialize or otherwise enforce ordering among concurrent operations.