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
|
/*
* Copyright 1998-1999, University of Notre Dame.
* Authors: Brian W. Barrett, Arun F. Rodrigues, Jeffrey M. Squyres,
* and Andrew Lumsdaine
*
* This file is part of XMPI
*
* You should have received a copy of the License Agreement for XMPI
* along with the software; see the file LICENSE. If not, contact
* Office of Research, University of Notre Dame, Notre Dame, IN 46556.
*
* Permission to modify the code and to distribute modified code is
* granted, provided the text of this NOTICE is retained, a notice that
* the code was modified is included with the above COPYRIGHT NOTICE and
* with the COPYRIGHT NOTICE in the LICENSE file, and that the LICENSE
* file is distributed with the modified code.
*
* LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.
* By way of example, but not limitation, Licensor MAKES NO
* REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY
* PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS
* OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS
* OR OTHER RIGHTS.
*
* Additional copyrights may follow.
*
* $Id: mpitr_dtype.c,v 1.3 1999/11/08 06:20:37 bbarrett Exp $
*
* Function: - MPI datatype trace access functions
*/
#include <stdlib.h>
#include <string.h>
#include <mpitrace.h>
#include <portable.h>
#include <terror.h>
#include <typical.h>
#include <t_types.h>
/*
* global functions
*/
int mpitr_dtypeget();
/*
* external functions
*/
extern int lam_rtrget();
/*
* mpitr_dtypeget
*
* Function: - get datatype trace
* Accepts: - process node
* - process pid
* - datatype label
* - ptr trace datatype buffer (returned value)
* Returns: - 0 or LAMERROR
*/
int
mpitr_dtypeget(nodeid, pid, dtlabel, ptrdtype)
int4 nodeid;
int4 pid;
int4 dtlabel;
char **ptrdtype;
{
int trlen; /* trace buffer length */
char *p; /* favourite pointer */
char *trbuf; /* datatype trace buffer */
struct trdtype *ptrdt; /* ptr into datatype trace */
*ptrdtype = 0;
if (dtlabel < 0) {
errno = EINVAL;
return(LAMERROR);
}
if (dtlabel <= TRDTMAX) {
/*
* Allocate datatype description.
*/
trlen = 2 * sizeof(struct trdtype);
*ptrdtype = malloc((unsigned) trlen);
if (*ptrdtype == 0) return(LAMERROR);
ptrdt = (struct trdtype *) *ptrdtype;
ptrdt->trd_dtype = dtlabel;
ptrdt->trd_length = trlen;
ptrdt++;
ptrdt->trd_dtype = dtlabel;
ptrdt->trd_count = 1;
return(0);
}
/*
* It's a constructed datatype, get its trace representation.
*/
trlen = lam_rtrget(nodeid, (int4) TRDTYPE, pid, &trbuf);
if (trlen < 0) return(LAMERROR);
/*
* Locate the datatype buffer with given number.
*/
*ptrdtype = 0;
p = trbuf;
while (trlen > 0) {
ptrdt = (struct trdtype *) (p + sizeof(struct trsrc));
mttoli4((int4 *) ptrdt, sizeof(struct trdtype) / sizeof(int4));
if (ptrdt->trd_dtype == dtlabel) {
*ptrdtype = (char *) ptrdt;
break;
}
trlen -= (ptrdt->trd_length + sizeof(struct trsrc));
p += (ptrdt->trd_length + sizeof(struct trsrc));
}
if (*ptrdtype == 0) {
free((char *) trbuf);
errno = EINVAL;
return(LAMERROR);
}
/*
* Copy datatype record.
*/
*ptrdtype = malloc((unsigned) (ptrdt->trd_length));
if (*ptrdtype == 0) {
free((char *) trbuf);
return(LAMERROR);
}
mttoli4((int4 *) (((char *) ptrdt) + sizeof(struct trdtype)),
(ptrdt->trd_length - sizeof(struct trdtype)) / sizeof(int4));
memcpy(*ptrdtype, (char *) ptrdt, ptrdt->trd_length);
free((char *) trbuf);
return(0);
}
|