Commit bdc46c7e authored by Rob Latham's avatar Rob Latham
Browse files

tweak hint inspection approach



Recent changes to MPI_INFO_GET will report a hard error if the info
value passed in is too short.  If we want to determine if a key is set
or not, and don't care what it is, we'll use MPI_INFO_GET_VALUELEN.
Took the opportunity to add a system-hints test to the ROMIO tests
Signed-off-by: default avatarPaul Coffman <pkcoff@us.ibm.com>
Signed-off-by: default avatarWei-keng Liao <wkliao@ece.northwestern.edu>
parent c895bd9c
......@@ -38,8 +38,8 @@
void ADIOI_Info_print_keyvals(MPI_Info info)
{
int i, nkeys, flag;
char key[MPI_MAX_INFO_KEY];
char value[MPI_MAX_INFO_VAL];
char key[MPI_MAX_INFO_KEY+1];
char value[MPI_MAX_INFO_VAL+1];
if (info == MPI_INFO_NULL)
return;
......@@ -48,7 +48,7 @@ void ADIOI_Info_print_keyvals(MPI_Info info)
for (i=0; i<nkeys; i++) {
MPI_Info_get_nthkey(info, i, key);
ADIOI_Info_get(info, key, MPI_MAX_INFO_VAL-1, value, &flag);
ADIOI_Info_get(info, key, MPI_MAX_INFO_VAL, value, &flag);
printf("key = %-25s value = %-10s\n", key, value);
}
return;
......@@ -91,7 +91,7 @@ static int file_to_info_all(int fd, MPI_Info info, int rank, MPI_Comm comm)
char *pos1=NULL, *pos2=NULL;
int flag;
ssize_t ret;
char dummy;
int valuelen;
/* assumption: config files will be small */
#define HINTFILE_MAX_SIZE 1024*4
......@@ -128,7 +128,7 @@ static int file_to_info_all(int fd, MPI_Info info, int rank, MPI_Comm comm)
#endif
/* don't actually care what the value is. only want to know if key
* exists: we leave it alone if so*/
ADIOI_Info_get(info, key, 1, &dummy, &flag);
ADIOI_Info_get_valuelen(info, key, &valuelen, &flag);
if (flag == 1) continue;
ADIOI_Info_set(info, key, val);
} while ((token = strtok_r(NULL, "\n", &pos1)) != NULL);
......@@ -159,9 +159,10 @@ void ADIOI_incorporate_system_hints(MPI_Info info,
MPI_Info sysinfo,
MPI_Info *new_info)
{
int i, nkeys_sysinfo, flag=0; /* must initialize flag to 0 */
int i, nkeys_sysinfo, nkeys_info=0, flag=0; /* must initialize flag to 0 */
int valuelen;
char val[MPI_MAX_INFO_VAL], key[MPI_MAX_INFO_KEY];
char val[MPI_MAX_INFO_VAL+1], key[MPI_MAX_INFO_KEY+1];
if (sysinfo == MPI_INFO_NULL)
nkeys_sysinfo = 0;
......@@ -176,15 +177,21 @@ void ADIOI_incorporate_system_hints(MPI_Info info,
if (info == MPI_INFO_NULL)
MPI_Info_create(new_info);
else
else {
/* tiny optimization: if 'info' has no keys, we can skip the check if a
* hint is set: no keys means nothing has been set, and there's nothing
* we might step on */
MPI_Info_get_nkeys(info, &nkeys_info);
MPI_Info_dup(info, new_info);
}
for (i=0; i<nkeys_sysinfo; i++) {
MPI_Info_get_nthkey(sysinfo, i, key);
/* don't care about the value, just want to know if hint set already*/
if (info != MPI_INFO_NULL) ADIOI_Info_get(info, key, 1, val, &flag);
if (info != MPI_INFO_NULL && nkeys_info)
ADIOI_Info_get_valuelen(info, key, &valuelen, &flag);
if (flag == 1) continue; /* skip any hints already set by user */
ADIOI_Info_get(sysinfo, key, MPI_MAX_INFO_VAL-1, val, &flag);
ADIOI_Info_get(sysinfo, key, MPI_MAX_INFO_VAL, val, &flag);
ADIOI_Info_set(*new_info, key, val);
flag = 0;
}
......
......@@ -25,7 +25,7 @@ AM_FFLAGS = $(USER_FFLAGS)
CTESTS = simple perf async coll_test coll_perf misc file_info excl large_array \
atomicity noncontig i_noncontig noncontig_coll split_coll shared_fp \
large_file psimple error status noncontig_coll2 aggregation1 aggregation2 \
async-multiple ordered_fp hindexed external32 types_with_zeros darray_read
async-multiple ordered_fp hindexed external32 types_with_zeros darray_read syshints
FTESTS = fcoll_test fperf fmisc pfcoll_test
......
......@@ -386,6 +386,11 @@ MakeExe darray_read
echo '**** Testing darray_read ****'
$mpirun -np 4 ./darray_read $FILENAME
CleanExe darray_read
MakeExe syshints
echo '**** Testing syshints ****'
$mpirun -np 1 ./syshints $srcdir/test_hintfile
CleanExe syshints
#
if [ @NOF77@ = 0 ] ; then
echo ""
......
#include <mpi.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
static void handle_error(int errcode, const char *str)
{
char msg[MPI_MAX_ERROR_STRING];
int resultlen;
MPI_Error_string(errcode, msg, &resultlen);
fprintf(stderr, "%s: %s\n", str, msg);
MPI_Abort(MPI_COMM_WORLD, 1);
}
#define CHECK(fn) {int errcode; errcode = (fn); if (errcode != MPI_SUCCESS) handle_error(errcode, #fn); }
static int hint_check(MPI_Info info_used, char * key, char *expected) {
char value[MPI_MAX_INFO_VAL+1];
int flag;
CHECK(MPI_Info_get(info_used, key, MPI_MAX_INFO_VAL, value, &flag));
if (strcmp(expected, value) ){
fprintf(stderr, "expected value \"%s\" for key \"%s\" got \"%s\"\n",
expected, key, value);
return 1;
}
return 0;
}
int main(int argc, char ** argv)
{
setenv("ROMIO_HINTS", argv[1], 1);
MPI_File fh;
MPI_Info info_used, info_mine;
int nr_errors=0;
MPI_Init(&argc, &argv);
MPI_Info_create(&info_mine);
MPI_Info_set(info_mine, "romio_cb_read", "disable");
CHECK(MPI_File_open(MPI_COMM_WORLD, argv[1], MPI_MODE_RDONLY, info_mine, &fh));
CHECK(MPI_File_get_info(fh, &info_used));
nr_errors += hint_check(info_used, "ind_rd_buffer_size", "49");
nr_errors += hint_check(info_used, "romio_no_indep_rw", "true");
if (nr_errors == 0) printf(" No Errors\n");
CHECK(MPI_Info_free(&info_mine));
CHECK(MPI_Info_free(&info_used));
CHECK(MPI_File_close(&fh));
MPI_Finalize();
return nr_errors;
}
romio_cb_read enable
# multiple info keys are strage but not an error. Note only the first one will
# be processed
ind_rd_buffer_size 49
ind_rd_buffer_size 60
romio_no_indep_rw true
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment