00001
00002
00003
00004
00005
00006
00007
00008 #include "adio.h"
00009 #include "converse.h"
00010
00011 CtvDeclare(ADIOI_Flatlist_node*, ADIOI_Flatlist);
00012 CtvDeclare(ADIOI_Datarep *, ADIOI_Datarep_head);
00013
00014
00015
00016 CtvDeclare(ADIO_File *, ADIOI_Ftable);
00017 CtvDeclare(int, ADIOI_Ftable_ptr);
00018 CtvDeclare(int, ADIOI_Ftable_max);
00019 CtvDeclare(ADIO_Request *, ADIOI_Reqtable);
00020 CtvDeclare(int, ADIOI_Reqtable_ptr);
00021 CtvDeclare(int, ADIOI_Reqtable_max);
00022 #ifndef HAVE_MPI_INFO
00023 MPI_Info *MPIR_Infotable = NULL;
00024 int MPIR_Infotable_ptr = 0, MPIR_Infotable_max = 0;
00025 #endif
00026
00027 CtvDeclare(MPI_Info, ADIOI_syshints);
00028
00029 CtvDeclare(MPI_Op, ADIO_same_amode);
00030
00031 #if defined(ROMIO_XFS) || defined(ROMIO_LUSTRE)
00032 int ADIOI_Direct_read = 0, ADIOI_Direct_write = 0;
00033 #endif
00034
00035 CtvDeclare(int, ADIO_Init_keyval);
00036
00037 CtvDeclare(MPI_Errhandler, ADIOI_DFLT_ERR_HANDLER);
00038
00039
00040 static void my_consensus(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype)
00041 {
00042 int i, *in, *inout;
00043 in = (int*)invec;
00044 inout = (int*)inoutvec;
00045
00046 for (i=0; i< *len; i++) {
00047 if (in[i] != inout[i])
00048 inout[i] = ADIO_AMODE_NOMATCH;
00049 }
00050 return;
00051 }
00052
00053 void ADIO_Init(int *argc, char ***argv, int *error_code)
00054 {
00055 #if defined(ROMIO_XFS) || defined(ROMIO_LUSTRE)
00056 char *c;
00057 #endif
00058
00059 ADIOI_UNREFERENCED_ARG(argc);
00060 ADIOI_UNREFERENCED_ARG(argv);
00061
00062 CtvInitialize(ADIOI_Flatlist_node*, ADIOI_Flatlist);
00063 CtvInitialize(ADIOI_Datarep *, ADIOI_Datarep_head);
00064 CtvInitialize(ADIO_File *, ADIOI_Ftable);
00065 CtvInitialize(int, ADIOI_Ftable_ptr);
00066 CtvInitialize(int, ADIOI_Ftable_max);
00067 CtvInitialize(ADIO_Request *, ADIOI_Reqtable);
00068 CtvInitialize(int, ADIOI_Reqtable_ptr);
00069 CtvInitialize(int, ADIOI_Reqtable_max);
00070 CtvInitialize(MPI_Info, ADIOI_syshints);
00071 CtvInitialize(MPI_Op, ADIO_same_amode);
00072 CtvInitialize(int, ADIO_Init_keyval);
00073 CtvInitialize(MPI_Errhandler, ADIOI_DFLT_ERR_HANDLER);
00074
00075 CtvAccess(ADIOI_Flatlist) = NULL;
00076 CtvAccess(ADIOI_Datarep_head) = NULL;
00077 CtvAccess(ADIOI_Ftable) = NULL;
00078 CtvAccess(ADIOI_Ftable_ptr) = 0;
00079 CtvAccess(ADIOI_Ftable_max) = 0;
00080 CtvAccess(ADIOI_Reqtable) = NULL;
00081 CtvAccess(ADIOI_Reqtable_ptr) = 0;
00082 CtvAccess(ADIOI_Reqtable_max) = 0;
00083 CtvAccess(ADIOI_syshints) = MPI_INFO_NULL;
00084 CtvAccess(ADIO_same_amode) = MPI_OP_NULL;
00085 CtvAccess(ADIO_Init_keyval) = MPI_KEYVAL_INVALID;
00086 CtvAccess(ADIOI_DFLT_ERR_HANDLER) = MPI_ERRORS_RETURN;
00087
00088
00089 CtvAccess(ADIOI_Flatlist) = (ADIOI_Flatlist_node *) ADIOI_Malloc(sizeof(ADIOI_Flatlist_node));
00090 CtvAccess(ADIOI_Flatlist)->type = MPI_DATATYPE_NULL;
00091 CtvAccess(ADIOI_Flatlist)->next = NULL;
00092 CtvAccess(ADIOI_Flatlist)->blocklens = NULL;
00093 CtvAccess(ADIOI_Flatlist)->indices = NULL;
00094
00095 #if defined(ROMIO_XFS) || defined(ROMIO_LUSTRE)
00096 c = getenv("MPIO_DIRECT_READ");
00097 if (c && (!strcmp(c, "true") || !strcmp(c, "TRUE")))
00098 ADIOI_Direct_read = 1;
00099 else ADIOI_Direct_read = 0;
00100 c = getenv("MPIO_DIRECT_WRITE");
00101 if (c && (!strcmp(c, "true") || !strcmp(c, "TRUE")))
00102 ADIOI_Direct_write = 1;
00103 else ADIOI_Direct_write = 0;
00104 #endif
00105
00106
00107
00108
00109 MPI_Info_create(&CtvAccess(ADIOI_syshints));
00110 ADIOI_process_system_hints(CtvAccess(ADIOI_syshints));
00111
00112 #ifdef ADIOI_MPE_LOGGING
00113 {
00114 MPE_Log_get_state_eventIDs( &ADIOI_MPE_open_a, &ADIOI_MPE_open_b );
00115 MPE_Log_get_state_eventIDs( &ADIOI_MPE_read_a, &ADIOI_MPE_read_b );
00116 MPE_Log_get_state_eventIDs( &ADIOI_MPE_write_a, &ADIOI_MPE_write_b );
00117 MPE_Log_get_state_eventIDs( &ADIOI_MPE_lseek_a, &ADIOI_MPE_lseek_b );
00118 MPE_Log_get_state_eventIDs( &ADIOI_MPE_close_a, &ADIOI_MPE_close_b );
00119 MPE_Log_get_state_eventIDs( &ADIOI_MPE_writelock_a,
00120 &ADIOI_MPE_writelock_b );
00121 MPE_Log_get_state_eventIDs( &ADIOI_MPE_readlock_a,
00122 &ADIOI_MPE_readlock_b );
00123 MPE_Log_get_state_eventIDs( &ADIOI_MPE_unlock_a, &ADIOI_MPE_unlock_b );
00124 MPE_Log_get_state_eventIDs( &ADIOI_MPE_postwrite_a,
00125 &ADIOI_MPE_postwrite_b );
00126 MPE_Log_get_state_eventIDs( &ADIOI_MPE_openinternal_a,
00127 &ADIOI_MPE_openinternal_b);
00128 MPE_Log_get_state_eventIDs( &ADIOI_MPE_stat_a, &ADIOI_MPE_stat_b);
00129 MPE_Log_get_state_eventIDs( &ADIOI_MPE_iread_a, &ADIOI_MPE_iread_b);
00130 MPE_Log_get_state_eventIDs( &ADIOI_MPE_iwrite_a, &ADIOI_MPE_iwrite_b);
00131
00132 int comm_world_rank;
00133 MPI_Comm_rank( MPI_COMM_WORLD, &comm_world_rank );
00134
00135 if ( comm_world_rank == 0 ) {
00136 MPE_Describe_state( ADIOI_MPE_open_a, ADIOI_MPE_open_b,
00137 "open", "orange" );
00138 MPE_Describe_state( ADIOI_MPE_read_a, ADIOI_MPE_read_b,
00139 "read", "green" );
00140 MPE_Describe_state( ADIOI_MPE_write_a, ADIOI_MPE_write_b,
00141 "write", "blue" );
00142 MPE_Describe_state( ADIOI_MPE_lseek_a, ADIOI_MPE_lseek_b,
00143 "lseek", "red" );
00144 MPE_Describe_state( ADIOI_MPE_close_a, ADIOI_MPE_close_b,
00145 "close", "grey" );
00146 MPE_Describe_state( ADIOI_MPE_writelock_a, ADIOI_MPE_writelock_b,
00147 "writelock", "plum" );
00148 MPE_Describe_state( ADIOI_MPE_readlock_a, ADIOI_MPE_readlock_b,
00149 "readlock", "magenta" );
00150 MPE_Describe_state( ADIOI_MPE_unlock_a, ADIOI_MPE_unlock_b,
00151 "unlock", "purple" );
00152 MPE_Describe_state( ADIOI_MPE_postwrite_a, ADIOI_MPE_postwrite_b,
00153 "postwrite", "ivory" );
00154 MPE_Describe_state( ADIOI_MPE_openinternal_a, ADIOI_MPE_openinternal_b, "open system", "blue");
00155 MPE_Describe_state( ADIOI_MPE_stat_a, ADIOI_MPE_stat_b, "stat", "purple");
00156 MPE_Describe_state( ADIOI_MPE_iread_a, ADIOI_MPE_iread_b, "iread", "purple");
00157 MPE_Describe_state( ADIOI_MPE_iwrite_a, ADIOI_MPE_iwrite_b, "iwrite", "purple");
00158 }
00159 }
00160 #endif
00161
00162 *error_code = MPI_SUCCESS;
00163 MPI_Op_create(my_consensus, 1, &CtvAccess(ADIO_same_amode));
00164 }