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.


    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


We highly recommend using the pwrite and pread wrappers rather than the write and read wrappers, especially if you either post I/O operations from multiple ES, or setup ABT-IO to execute I/O operations in multiple ES. abt_io_read and abt_io_write rely on the file descriptor’s internal cursor, and Argobots cannot guarantee the order of I/O operations posted, which may lead to unpredictable reordering.