File: MPE_GetTags.4

package info (click to toggle)
mpich 1.1.0-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 22,116 kB
  • ctags: 27,349
  • sloc: ansic: 193,435; sh: 11,172; fortran: 6,545; makefile: 5,801; cpp: 5,020; tcl: 3,548; asm: 3,536; csh: 1,079; java: 614; perl: 183; awk: 168; sed: 70; f90: 62
file content (149 lines) | stat: -rw-r--r-- 3,028 bytes parent folder | download | duplicates (2)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
.TH MPE_GetTags 4 "5/28/1996" " " "MPE"
.SH NAME
MPE_GetTags \-  Returns tags that can be used in communication with a  communicator 
.SH SYNOPSIS
.nf
#include <stdio.h>
#include "mpe.h"
int MPE_GetTags( comm_in, ntags, comm_out, first_tag )
MPI_Comm comm_in, *comm_out;
int      ntags, *first_tag;
.fi
.SH INPUT PARAMETERS
.PD 0
.TP
.B comm_in 
- Input communicator
.PD 1
.PD 0
.TP
.B ntags   
- Number of tags
.PD 1

.SH OUTPUT PARAMETERS
.PD 0
.TP
.B comm_out 
- Output communicator.  May be 'comm_in'.
.PD 1
.PD 0
.TP
.B first_tag 
- First tag available
.PD 1

.SH RETURNS
MPI_SUCCESS on success, MPI error class on failure.

.SH NOTES
This routine returns the requested number of tags, with the tags being
'first_tag', 'first_tag+1', ..., 'first_tag+ntags-1'.

These tags are guarenteed to be unique within 'comm_out'.

.SH SEE ALSO
MPE_ReturnTags
.br
@*/
int MPE_GetTags( comm_in, ntags, comm_out, first_tag )
MPI_Comm comm_in, *comm_out;
int      ntags, *first_tag;
{
int mpe_errno = MPI_SUCCESS;
int *tagvalp, *maxval, flag;

if (MPE_Tag_keyval == MPI_KEYVAL_INVALID) {
MPI_Keyval_create( MPI_NULL_COPY_FN, MPE_DelTag,
&MPE_Tag_keyval, (void *)0 );
}

if ((mpe_errno = MPI_Attr_get( comm_in, MPE_Tag_keyval, &tagvalp, &flag )))
return mpe_errno;

if (!flag) {
/* This communicator is not yet known to this system, so we
dup it and setup the first value */
MPI_Comm_dup( comm_in, comm_out );
comm_in = *comm_out;
MPI_Attr_get( MPI_COMM_WORLD, MPI_TAG_UB, &maxval, &flag );
tagvalp = (int *)malloc( 2 * sizeof(int) );
if (!tagvalp) return MPI_ERR_OTHER;
*tagvalp   = *maxval;
*first_tag = *tagvalp - ntags;
*tagvalp   = *first_tag;
MPI_Attr_put( comm_in, MPE_Tag_keyval, tagvalp );
return MPI_SUCCESS;
}
*comm_out = comm_in;

if (*tagvalp < ntags) {
/* Error, out of tags.  Another solution would be to
do an MPI_Comm_dup. */
return MPI_ERR_INTERN;
}
*first_tag = *tagvalp - ntags;
*tagvalp   = *first_tag;

return MPI_SUCCESS;
}

/*
This is a simple implementation that will lose track of tags that are
not returned in a stack fashion.
*/

/*@
MPE_ReturnTags - Returns tags allocated with MPE_GetTags.

.SH INPUT PARAMETERS
.PD 0
.TP
.B comm 
- Communicator to return tags to
.PD 1
.PD 0
.TP
.B first_tag 
- First of the tags to return
.PD 1
.PD 0
.TP
.B ntags 
- Number of tags to return.
.PD 1

.SH SEE ALSO
MPE_GetTags
.br
@*/
int MPE_ReturnTags( comm, first_tag, ntags )
MPI_Comm comm;
int      first_tag, ntags;
{
int *tagvalp, flag, mpe_errno;

if ((mpe_errno = MPI_Attr_get( comm, MPE_Tag_keyval, &tagvalp, &flag )))
return mpe_errno;

if (!flag) {
/* Error, attribute does not exist in this communicator */
return MPI_ERR_OTHER;
}
if (*tagvalp == first_tag) {
*tagvalp = first_tag + ntags;
}

return MPI_SUCCESS;
}

/*@
MPE_TagsEnd - Returns the private keyval.

.SH NOTES
This routine is provided to aid in cleaning up all of the allocated
storage in and MPI program.  Normally, this routine does `not` need
to be called.  If it is, it should be called immediately before
'MPI_Finalize'.
.SH LOCATION
privtags.c