*** orig/src/mpi/romio/adio/ad_pvfs2/ad_pvfs2_hints.c Thu Oct 7 00:33:55 2004 --- mod/src/mpi/romio/adio/ad_pvfs2/ad_pvfs2_hints.c Sun May 22 19:44:23 2005 *************** *** 61,68 **** MPI_Info_set(fd->info, "striping_factor", value); } ! ! ADIOI_Free(value); } } /* set the values for collective I/O and data sieving parameters */ --- 61,175 ---- MPI_Info_set(fd->info, "striping_factor", value); } ! ADIOI_Free(value); ! ! /* the striping unit */ ! value = (char *) ADIOI_Malloc( (MPI_MAX_INFO_VAL+1)*sizeof(char)); ! MPI_Info_get(users_info, "striping_unit", ! MPI_MAX_INFO_VAL, value, &flag); ! if (flag) { ! tmp_value = fd->hints->striping_unit = atoi(value); ! MPI_Bcast(&tmp_value, 1, MPI_INT, 0, fd->comm); ! /* --BEGIN ERROR HANDLING-- */ ! if (tmp_value != fd->hints->striping_unit) { ! MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(myname, ! "striping_unit", ! error_code); ! return; ! } ! /* --END ERROR HANDLING-- */ ! MPI_Info_set(fd->info, "striping_unit", value); ! } ! ADIOI_Free(value); ! ! /* the distribution name */ ! char *szDistributionName = (char *)ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char)); ! memset(szDistributionName, '\0', MPI_MAX_INFO_VAL+1); ! MPI_Info_get(users_info, "distribution_name", ! MPI_MAX_INFO_VAL, szDistributionName, &flag); ! ! if (flag) { ! char *szTmpValue = (char *) ADIOI_Malloc( (MPI_MAX_INFO_VAL+1)*sizeof(char)); ! strcpy(szTmpValue, szDistributionName); ! MPI_Bcast(szTmpValue, strlen(szDistributionName) + 1, MPI_CHAR, 0, fd->comm); ! /* --BEGIN ERROR HANDLING-- */ ! if (strcmp(szTmpValue, szDistributionName) != 0) { ! ADIOI_Free(szTmpValue); ! szTmpValue = NULL; ! ADIOI_Free(szDistributionName); ! szDistributionName = NULL; ! MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(myname, ! "distribution_name", ! error_code); ! return; ! } ! /* --END ERROR HANDLING-- */ ! MPI_Info_set(fd->info, "distribution_name", szDistributionName); ! ADIOI_Free(szTmpValue); ! szTmpValue = NULL; ! } ! else ! { ! //default value ! strcpy(szDistributionName, "simple_stripe"); ! MPI_Info_set(fd->info, "distribution_name", szDistributionName); ! } ! //we free szDistributionName later, because we need it: ! ! //get all parameter of distribution "distribution_name" ! int iKeyCount; ! MPI_Info_get_nkeys(users_info, &iKeyCount); ! int ii; ! for (ii = 0; ii < iKeyCount; ii++) ! { ! //get the key name ! char *szKey = (char *)ADIOI_Malloc((MPI_MAX_INFO_KEY+1)*sizeof(char)); ! memset(szKey, '\0', MPI_MAX_INFO_KEY+1); ! MPI_Info_get_nthkey(users_info, ii, szKey); ! //is key relevant to me? ! char *szFound = strstr(szKey, szDistributionName); ! if (szFound == szKey) ! { ! //found distribution_name at the beginning of the key ! //-> seems to be relevant to me ! char *szValue = (char *)ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char)); ! memset(szValue, '\0', MPI_MAX_INFO_VAL+1); ! MPI_Info_get(users_info, szKey, MPI_MAX_INFO_VAL, ! szValue, &flag); ! ! if (flag) { ! char *szTmpValue = (char *) ADIOI_Malloc( (MPI_MAX_INFO_VAL+1)*sizeof(char)); ! strcpy(szTmpValue, szValue); ! MPI_Bcast(szTmpValue, strlen(szValue) + 1, MPI_CHAR, 0, ! fd->comm); ! /* --BEGIN ERROR HANDLING-- */ ! if (strcmp(szTmpValue, szValue) != 0) { ! ADIOI_Free(szTmpValue); ! szTmpValue = NULL; ! ADIOI_Free(szDistributionName); ! szDistributionName = NULL; ! ADIOI_Free(szValue); ! szValue = NULL; ! MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(myname, ! szKey, ! error_code); ! ADIOI_Free(szKey); ! szKey = NULL; ! return; ! } ! /* --END ERROR HANDLING-- */ ! MPI_Info_set(fd->info, szKey, szValue); ! ADIOI_Free(szTmpValue); ! szTmpValue = NULL; ! } ! ADIOI_Free(szValue); ! szValue = NULL; ! } ! ADIOI_Free(szKey); ! szKey = NULL; ! } ! ADIOI_Free(szDistributionName); ! szDistributionName = NULL; } } /* set the values for collective I/O and data sieving parameters */ *** orig/src/mpi/romio/adio/ad_pvfs2/ad_pvfs2_open.c Thu Oct 7 00:33:55 2004 --- mod/src/mpi/romio/adio/ad_pvfs2/ad_pvfs2_open.c Sun May 22 20:16:27 2005 *************** *** 29,36 **** * handle to everyone else in the communicator */ static void fake_an_open(PVFS_fs_id fs_id, char *pvfs_name, int access_mode, ! int nr_datafiles, ADIOI_PVFS2_fs *pvfs2_fs, ! open_status *o_status) { int ret; PVFS_sysresp_lookup resp_lookup; --- 29,37 ---- * handle to everyone else in the communicator */ static void fake_an_open(PVFS_fs_id fs_id, char *pvfs_name, int access_mode, ! int nr_datafiles, PVFS_size striping_unit, ! MPI_Info mpiInfo, ! ADIOI_PVFS2_fs *pvfs2_fs, open_status *o_status) { int ret; PVFS_sysresp_lookup resp_lookup; *************** *** 57,65 **** o_status->error = ret; return; } ret = PVFS_sys_create(resp_getparent.basename, resp_getparent.parent_ref, attribs, ! &(pvfs2_fs->credentials), NULL, &resp_create); if (ret < 0) { /* XXX: should only do this for EEXISTS */ ret = PVFS_sys_lookup(fs_id, pvfs_name, --- 58,286 ---- o_status->error = ret; return; } + //lookup distribution + char *szDistributionName = (char *)ADIOI_Malloc(sizeof(char)*(MPI_MAX_INFO_VAL+1)); + memset(szDistributionName, '\0', MPI_MAX_INFO_VAL+1); + int iFlag; + MPI_Info_get(mpiInfo, "distribution_name", MPI_MAX_INFO_VAL, + szDistributionName, &iFlag); + PVFS_sys_dist *myDist = NULL; + if (iFlag) + { + //get the distribution + myDist = PVFS_sys_dist_lookup(szDistributionName); + if (myDist == NULL) + { + fprintf(stderr, + "Distribution function %s does not exist!\n", + szDistributionName); + o_status->error = -1; + return; + } + //set distribution params + if (strcmp(szDistributionName, "simple_stripe") == 0 && + striping_unit > 0) + { + PVFS_sys_dist_setparam(myDist, "strip_size", &striping_unit); + } + int iKeyCount; + MPI_Info_get_nkeys(mpiInfo, &iKeyCount); + int ii; + for (ii = 0; ii < iKeyCount; ii++) + { + //get the key name + char *szKey = (char *)ADIOI_Malloc((MPI_MAX_INFO_KEY+1)*sizeof(char)); + memset(szKey, '\0', MPI_MAX_INFO_KEY+1); + MPI_Info_get_nthkey(mpiInfo, ii, szKey); + //get value + char *szValue = (char *)ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char)); + memset(szValue, '\0', MPI_MAX_INFO_VAL+1); + MPI_Info_get(mpiInfo, szKey, MPI_MAX_INFO_VAL, + szValue, &iFlag); + if (iFlag) + { + //is key relevant? + char *szDistri = strtok(szKey, ":"); + if (strcmp(szDistri, szDistributionName) == 0) + { + //found distribution_name at the beginning + //of the key + //-> seems to be relevant + //get type + char *szType = strtok(NULL, ":"); + if (szType != NULL) + { + //get name + char *szName = strtok(NULL, ":"); + if (szName != NULL) + { + if (strcmp(szType, "char") == 0) + { + if (strlen(szValue) == 1) + { + char cValue = szValue[0]; + PVFS_sys_dist_setparam(myDist, + szName, + &cValue); + } + else + { + fprintf(stderr, + "Error converting parameter" + " to char (Key: %s:%s:%s, " + "Value: %s)\n", szDistri, + szType, szName, szValue); + //XXX: pick a good error for this + ret = -1; + } + } + if (strcmp(szType, "string") == 0) + { + PVFS_sys_dist_setparam(myDist, szName, + szValue); + } + if (strcmp(szType, "int") == 0) + { + char *pEnd; + long int lValue = strtol(szValue, &pEnd, + 10); + if (*pEnd != '\0' || errno == ERANGE) + { + fprintf(stderr, + "Error converting parameter" + " to int (Key: %s:%s:%s, " + "Value: %s)\n", szDistri, + szType, szName, szValue); + //XXX: pick a good error for this + ret = -1; + } + else + { + PVFS_sys_dist_setparam(myDist, + szName, + &lValue); + } + + } + if (strcmp(szType, "unsigned int") == 0) + { + char *pEnd; + unsigned long int ulValue = + strtoul(szValue, &pEnd, 10); + if (*pEnd != '\0' || errno == ERANGE) + { + fprintf(stderr, + "Error converting parameter" + " to unsigned int (Key: " + "%s:%s:%s, Value: %s)\n", + szDistri, + szType, szName, szValue); + //XXX: pick a good error for this + ret = -1; + } + else + { + PVFS_sys_dist_setparam(myDist, + szName, + &ulValue); + } + } + if (strcmp(szType, "int64") == 0) + { + char *pEnd; + long long int llValue = + strtoll(szValue, &pEnd, 10); + if (*pEnd != '\0' || errno == ERANGE) + { + fprintf(stderr, + "Error converting parameter" + " to int64 (Key: " + "%s:%s:%s, Value: %s)\n", + szDistri, szType, szName, + szValue); + //XXX: pick a good error for this + ret = -1; + } + else + { + PVFS_sys_dist_setparam(myDist, + szName, + &llValue); + } + } + if (strcmp(szType, "unsigned int64") == 0) + { + char *pEnd; + unsigned long long int ullValue = + strtoull(szValue, &pEnd, 10); + if (*pEnd != '\0' || errno == ERANGE) + { + fprintf(stderr, + "Error converting parameter" + " to unsigned int64 " + "(Key: %s:%s:%s, Value: %s)" + "\n", szDistri, szType, + szName, szValue); + //XXX: pick a good error for this + ret = -1; + } + else + { + PVFS_sys_dist_setparam(myDist, + szName, + &ullValue); + } + } + if (strcmp(szType, "double") == 0) + { + char *pEnd; + double dValue = strtod(szValue, &pEnd); + if (*pEnd != '\0' || errno == ERANGE) + { + fprintf(stderr, + "Error converting parameter" + " to double (Key: %s:%s:%s," + " Value: %s)\n", szDistri, + szType, szName, szValue); + //XXX: pick a good error for this + ret = -1; + } + else + { + PVFS_sys_dist_setparam(myDist, + szName, + &dValue); + } + } + } + } + } + } + ADIOI_Free(szKey); + szKey = NULL; + ADIOI_Free(szValue); + szValue = NULL; + } + } + else + { + myDist = PVFS_sys_dist_lookup("simple_stripe"); + if (striping_unit > 0) + { + PVFS_sys_dist_setparam(myDist, "strip_size", &striping_unit); + } + } + ADIOI_Free(szDistributionName); + szDistributionName = NULL; + if (ret < 0) + { + o_status->error = ret; + return; + } ret = PVFS_sys_create(resp_getparent.basename, resp_getparent.parent_ref, attribs, ! &(pvfs2_fs->credentials), myDist, &resp_create); ! PVFS_sys_dist_free(myDist); if (ret < 0) { /* XXX: should only do this for EEXISTS */ ret = PVFS_sys_lookup(fs_id, pvfs_name, *************** *** 152,158 **** o_status.error = -1; } else { fake_an_open(cur_fs, pvfs_path, ! fd->access_mode, fd->hints->striping_factor, pvfs2_fs, &o_status); } } --- 373,380 ---- o_status.error = -1; } else { fake_an_open(cur_fs, pvfs_path, ! fd->access_mode, fd->hints->striping_factor, ! fd->hints->striping_unit, fd->info, pvfs2_fs, &o_status); } }