This source file includes following definitions.
- ompi_datatype_get_elements
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include "ompi_config.h"
23 #include <stdio.h>
24 #include <limits.h>
25
26 #include "ompi/runtime/params.h"
27 #include "ompi/datatype/ompi_datatype.h"
28 #include "opal/datatype/opal_datatype_internal.h"
29
30 int ompi_datatype_get_elements (ompi_datatype_t *datatype, size_t ucount, size_t *count)
31 {
32 size_t internal_count, size, total;
33 int rc, i;
34
35 *count = 0;
36 if (OMPI_SUCCESS != (rc = ompi_datatype_type_size (datatype, &size))) {
37 return OMPI_ERR_BAD_PARAM;
38 }
39
40 if (size == 0) {
41
42 return OMPI_SUCCESS;
43 }
44
45 internal_count = ucount / size;
46 size = ucount - internal_count * size;
47
48
49
50 if (!ompi_datatype_is_predefined(datatype)) {
51 if (0 != internal_count) {
52 opal_datatype_compute_ptypes(&datatype->super);
53
54 for (i = OPAL_DATATYPE_FIRST_TYPE, total = 0 ; i < OPAL_DATATYPE_MAX_PREDEFINED ; ++i) {
55 total += datatype->super.ptypes[i];
56 }
57 internal_count = total * internal_count;
58 }
59 if (size > 0) {
60
61
62
63 if (-1 == (i = ompi_datatype_get_element_count (datatype, size))) {
64 return OMPI_ERR_VALUE_OUT_OF_BOUNDS;
65 }
66
67 internal_count += i;
68 }
69 } else if (0 != size) {
70
71 return OMPI_ERR_VALUE_OUT_OF_BOUNDS;
72 }
73
74 *count = internal_count;
75
76 return OMPI_SUCCESS;
77 }