1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#include "adio.h"
#include "adio_extern.h"
#include "ad_ime.h"
#include "ad_ime_common.h"
#include <stdint.h>
#define IME_READ 0
#define IME_WRITE 1
static void IME_IOContig(ADIO_File fd,
void *buf,
int count,
MPI_Datatype datatype,
int file_ptr_type,
ADIO_Offset offset, ADIO_Status * status, int io_flag, int *error_code)
{
ssize_t ret;
MPI_Count datatype_size;
size_t mem_len;
uint64_t file_offset = offset;
static char myname[] = "ADIOI_IME_IOCONTIG";
if (count == 0) {
ret = 0;
goto fn_exit;
}
MPI_Type_size_x(datatype, &datatype_size);
mem_len = datatype_size * count;
if (file_ptr_type == ADIO_INDIVIDUAL)
file_offset = fd->fp_ind;
switch (io_flag) {
case IME_READ:
ret = ime_native_pread(fd->fd_sys, buf, mem_len, offset);
break;
case IME_WRITE:
ret = ime_native_pwrite(fd->fd_sys, buf, mem_len, offset);
break;
default:
*error_code = MPIO_Err_create_code(MPI_SUCCESS,
MPIR_ERR_RECOVERABLE,
myname, __LINE__, MPI_ERR_IO, "Unknown flag", 0);
goto exit;
break;
};
/* Let the application decide how to fail */
if (ret < 0) {
*error_code = MPI_SUCCESS;
goto exit;
}
if (file_ptr_type == ADIO_INDIVIDUAL)
fd->fp_ind += ret;
fd->fp_sys_posn = file_offset + ret;
fn_exit:
#ifdef HAVE_STATUS_SET_BYTES
if (status)
MPIR_Status_set_bytes(status, datatype, ret);
#endif
*error_code = MPI_SUCCESS;
exit:
return;
}
void ADIOI_IME_ReadContig(ADIO_File fd,
void *buf,
int count,
MPI_Datatype datatype,
int file_ptr_type,
ADIO_Offset offset, ADIO_Status * status, int *error_code)
{
IME_IOContig(fd, buf, count, datatype, file_ptr_type, offset, status, IME_READ, error_code);
}
void ADIOI_IME_WriteContig(ADIO_File fd,
const void *buf,
int count,
MPI_Datatype datatype,
int file_ptr_type,
ADIO_Offset offset, ADIO_Status * status, int *error_code)
{
IME_IOContig(fd,
(void *) buf,
count, datatype, file_ptr_type, offset, status, IME_WRITE, error_code);
}
|