Debian Codegraph @

src/mpi/romio/mpi-io/glue/openmpi/mpio_file.c

raw
1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #include "mpioimpl.h"
7
8 #include "adio_extern.h"
9
10 /* Hooks for allocation of MPI_File handles.
11 *
12 * Three functions are used in ROMIO for allocation/deallocation
13 * of MPI_File structures:
14 * - MPIO_File_create(size)
15 * - MPIO_File_resolve(mpi_fh)
16 * - MPIO_File_free(mpi_fh)
17 *
18 */
19
20 MPI_File MPIO_File_create(int size)
21 {
22 MPI_File mpi_fh;
23
24 mpi_fh = (MPI_File) ADIOI_Calloc(size, 1);
25 return mpi_fh;
26 }
27
28 ADIO_File MPIO_File_resolve(MPI_File mpi_fh)
29 {
30 return mpi_fh;
31 }
32
33 void MPIO_File_free(MPI_File * mpi_fh)
34 {
35 ADIOI_Free(*mpi_fh);
36 *mpi_fh = MPI_FILE_NULL;
37 }
38
39 /* these functions aren't needed with the way Open MPI uses ROMIO */
40 #if 0
41
42
43 MPI_File MPIO_File_f2c(MPI_Fint fh)
44 {
45 #ifndef INT_LT_POINTER
46 return (MPI_File) ((void *) fh);
47 /* the extra cast is to get rid of a compiler warning on Exemplar.
48 * The warning is because MPI_File points to a structure containing
49 * longlongs, which may be 8-byte aligned. But MPI_Fint itself
50 * may not be 8-byte aligned. */
51 #else
52 if (!fh)
53 return MPI_FILE_NULL;
54 if ((fh < 0) || (fh > ADIOI_Ftable_ptr)) {
55 FPRINTF(stderr, "MPI_File_f2c: Invalid file handle\n");
56 MPI_Abort(MPI_COMM_WORLD, 1);
57 }
58 return ADIOI_Ftable[fh];
59 #endif
60 }
61
62 MPI_Fint MPIO_File_c2f(MPI_File fh)
63 {
64 #ifndef INT_LT_POINTER
65 return (MPI_Fint) fh;
66 #else
67 int i;
68
69 if ((fh == MPI_FILE_NULL) || (fh->cookie != ADIOI_FILE_COOKIE))
70 return (MPI_Fint) 0;
71 if (!ADIOI_Ftable) {
72 ADIOI_Ftable_max = 1024;
73 ADIOI_Ftable = (MPI_File *)
74 ADIOI_Malloc(ADIOI_Ftable_max * sizeof(MPI_File));
75 ADIOI_Ftable_ptr = 0; /* 0 can't be used though, because
76 * MPI_FILE_NULL=0 */
77 for (i = 0; i < ADIOI_Ftable_max; i++)
78 ADIOI_Ftable[i] = MPI_FILE_NULL;
79 }
80 if (ADIOI_Ftable_ptr == ADIOI_Ftable_max - 1) {
81 ADIOI_Ftable = (MPI_File *) ADIOI_Realloc(ADIOI_Ftable,
82 (ADIOI_Ftable_max + 1024) * sizeof(MPI_File));
83 for (i = ADIOI_Ftable_max; i < ADIOI_Ftable_max + 1024; i++)
84 ADIOI_Ftable[i] = MPI_FILE_NULL;
85 ADIOI_Ftable_max += 1024;
86 }
87 ADIOI_Ftable_ptr++;
88 ADIOI_Ftable[ADIOI_Ftable_ptr] = fh;
89 return (MPI_Fint) ADIOI_Ftable_ptr;
90 #endif
91 }
92
93 #endif /* #if 0 */