1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 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);
 }