int
saf_get_count_and_type_for_subset_relation(SAF_ParMode pmode, /* The parallel mode. */
SAF_Rel *rel, /* The relation handle. */
SAF_RelTarget *target, /* Optional relation targeting information. */
size_t *abuf_sz, /* [OUT] The number of items that would be placed in
* the A-buffer by a call to the
* saf_read_subset_relation() function. The caller
* may pass value of NULL for this parameter if this
* value is not desired. */
hid_t *abuf_type, /* [OUT] The type of the items that would be placed in
* the A-buffer by a call to the
* saf_read_subset_relation() function. The caller
* may pass value of NULL for this parameter if this
* value is not desired. */
size_t *bbuf_sz, /* [OUT] The number of items that would be placed in
* the B-buffer by a call to the
* saf_read_subset_relation() function. The caller
* may pass value of NULL for this parameter if this
* value is not desired. */
hid_t *bbuf_type /* [OUT] The type of the items that would be placed in
* the B-buffer by a call to the
* saf_read_subset_relation() function. The caller
* may pass value of NULL for this parameter if this
* value is not desired. */
)
{
SAF_ENTER(saf_get_count_and_type_for_subset_relation, SAF_PRECONDITION_ERROR);
ss_set_t sub; /* Cached subset from the relation */
hid_t ftype=-1; /* File datatype for blobs */
hsize_t size; /* Size of a blob */
ss_collection_t sub_coll; /* Collection on relation's subset */
SAF_REQUIRE(_saf_valid_pmode(pmode), SAF_LOW_CHK_COST, SAF_PRECONDITION_ERROR,
_saf_errmsg("PMODE must be valid"));
if (!_saf_is_participating_proc(pmode)) SAF_RETURN(-1);
SAF_REQUIRE(SS_REL(rel), SAF_LOW_CHK_COST, SAF_PRECONDITION_ERROR,
_saf_errmsg("REL must be a valid relation handle for all participating processes"));
/* ISSUE: Relation targeting is not yet implemented. */
SAF_ASSERT(!target, SAF_LOW_CHK_COST, SAF_NOTIMPL_ERROR, _saf_errmsg("Relation targeting is not yet implemented"));
/* Cache some stuff for convenience */
sub = SS_REL(rel)->sub;
if (NULL==_saf_getCollection_set(&sub, SS_REL_P(rel,sub_cat), &sub_coll))
SAF_ERROR(SAF_FILE_ERROR, _saf_errmsg("required subset collection was not available"));
/* If the collection is of size 1 and the type is SET and represents part of a decomposition then this is the special case
* where we store the relation data in the collection. */
if (SS_COLLECTION(&sub_coll)->count==1 &&
SS_COLLECTION(&sub_coll)->cell_type==SAF_CELLTYPE_SET &&
SS_COLLECTION(&sub_coll)->is_decomp) {
if (abuf_sz) *abuf_sz = 1;
if (abuf_type) *abuf_type = H5Tcopy(H5T_NATIVE_SIZE);
} else {
/* First, dealing with the range to be stored in abuf (indirect_rels or r_blob). There is always an A-buffer... */
if (ss_array_nelmts(SS_REL_P(rel,indirect_rels))>0) {
if (abuf_sz) *abuf_sz = ss_array_nelmts(SS_REL_P(rel,indirect_rels));
if (abuf_type) *abuf_type = H5Tcopy(ss_pers_tm);
} else if (!SS_PERS_ISNULL(SS_REL_P(rel,r_blob))) {
ss_blob_bound_f1(SS_REL_P(rel,r_blob), NULL, NULL, &size, &ftype);
if (abuf_type) *abuf_type = H5Tget_native_type(ftype, H5T_DIR_DEFAULT);
H5Tclose(ftype); ftype=-1;
if (abuf_sz) *abuf_sz = size;
} else {
if (abuf_sz) *abuf_sz = 0;
if (bbuf_sz) *bbuf_sz = 0;
if (abuf_type) *abuf_type = H5I_INVALID_HID;
if (bbuf_type) *bbuf_type = H5I_INVALID_HID;
return SAF_SUCCESS;
}
/* Now to get the info for the B-buffer (domain blob). Note that there may have been no B-buffer. */
if (SS_PERS_ISNULL(SS_REL_P(rel,d_blob))) {
if (bbuf_sz) *bbuf_sz = 0;
if (bbuf_type) *bbuf_type = H5I_INVALID_HID;
} else {
ss_blob_bound_f1(SS_REL_P(rel,d_blob), NULL, NULL, &size, &ftype);
if (bbuf_type) *bbuf_type = H5Tget_native_type(ftype, H5T_DIR_DEFAULT);
H5Tclose(ftype); ftype=-1;
if (bbuf_sz) *bbuf_sz = size;
}
}
SAF_LEAVE(SAF_SUCCESS);
}