1 /*
2  * Copyright (C) by Argonne National Laboratory
3  *     See COPYRIGHT in top-level directory
4  */
5 
6 #include "ad_testfs.h"
7 #include "adioi.h"
8 
ADIOI_TESTFS_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)9 void ADIOI_TESTFS_WriteContig(ADIO_File fd, const void *buf, int count,
10                               MPI_Datatype datatype, int file_ptr_type,
11                               ADIO_Offset offset, ADIO_Status * status, int
12                               *error_code)
13 {
14     int myrank, nprocs;
15     MPI_Count datatype_size;
16 
17     *error_code = MPI_SUCCESS;
18 
19     MPI_Comm_size(fd->comm, &nprocs);
20     MPI_Comm_rank(fd->comm, &myrank);
21     MPI_Type_size_x(datatype, &datatype_size);
22     FPRINTF(stdout, "[%d/%d] ADIOI_TESTFS_WriteContig called on %s\n", myrank,
23             nprocs, fd->filename);
24     FPRINTF(stdout, "[%d/%d]    writing (buf = %p, loc = %lld, sz = %lld)\n",
25             myrank, nprocs, buf, (long long) offset, (long long) datatype_size * (long long) count);
26 
27     if (file_ptr_type != ADIO_EXPLICIT_OFFSET) {
28         fd->fp_ind += datatype_size * count;
29         fd->fp_sys_posn = fd->fp_ind;
30         FPRINTF(stdout, "[%d/%d]    new file position is %lld\n", myrank,
31                 nprocs, (long long) fd->fp_ind);
32     } else {
33         fd->fp_sys_posn = offset + datatype_size * count;
34     }
35 
36 #ifdef HAVE_STATUS_SET_BYTES
37     MPIR_Status_set_bytes(status, datatype, datatype_size * count);
38 #endif
39 }
40 
ADIOI_TESTFS_WriteStrided(ADIO_File fd,const void * buf,int count,MPI_Datatype datatype,int file_ptr_type,ADIO_Offset offset,ADIO_Status * status,int * error_code)41 void ADIOI_TESTFS_WriteStrided(ADIO_File fd, const void *buf, int count,
42                                MPI_Datatype datatype, int file_ptr_type,
43                                ADIO_Offset offset, ADIO_Status * status, int *error_code)
44 {
45     int myrank, nprocs;
46 
47     *error_code = MPI_SUCCESS;
48 
49     MPI_Comm_size(fd->comm, &nprocs);
50     MPI_Comm_rank(fd->comm, &myrank);
51     FPRINTF(stdout, "[%d/%d] ADIOI_TESTFS_WriteStrided called on %s\n",
52             myrank, nprocs, fd->filename);
53     FPRINTF(stdout, "[%d/%d]    calling ADIOI_GEN_WriteStrided\n", myrank, nprocs);
54 
55     ADIOI_GEN_WriteStrided(fd, buf, count, datatype, file_ptr_type, offset, status, error_code);
56 }
57