|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifndef MPIR_INFO_H_INCLUDED
|
|
Packit Service |
c5cf8c |
#define MPIR_INFO_H_INCLUDED
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ------------------------------------------------------------------------- */
|
|
Packit Service |
c5cf8c |
/* Info */
|
|
Packit Service |
c5cf8c |
/*TInfoOverview.tex
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
'MPI_Info' provides a way to create a list of '(key,value)' pairs
|
|
Packit Service |
c5cf8c |
where the 'key' and 'value' are both strings. Because many routines, both
|
|
Packit Service |
c5cf8c |
in the MPI implementation and in related APIs such as the PMI process
|
|
Packit Service |
c5cf8c |
management interface, require 'MPI_Info' arguments, we define a simple
|
|
Packit Service |
c5cf8c |
structure for each 'MPI_Info' element. Elements are allocated by the
|
|
Packit Service |
c5cf8c |
generic object allocator; the head element is always empty (no 'key'
|
|
Packit Service |
c5cf8c |
or 'value' is defined on the head element).
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
For simplicity, we have not abstracted the info data structures;
|
|
Packit Service |
c5cf8c |
routines that want to work with the linked list may do so directly.
|
|
Packit Service |
c5cf8c |
Because the 'MPI_Info' type is a handle and not a pointer, an MPIR
|
|
Packit Service |
c5cf8c |
routine is provided to handle the
|
|
Packit Service |
c5cf8c |
deallocation of 'MPIR_Info' elements. See the implementation of
|
|
Packit Service |
c5cf8c |
'MPI_Info_create' for how an Info type is allocated.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Thread Safety:
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
The info interface itself is not thread-robust. In particular, the routines
|
|
Packit Service |
c5cf8c |
'MPI_INFO_GET_NKEYS' and 'MPI_INFO_GET_NTHKEY' assume that no other
|
|
Packit Service |
c5cf8c |
thread modifies the info key. (If the info routines had the concept
|
|
Packit Service |
c5cf8c |
of a next value, they would not be thread safe. As it stands, a user
|
|
Packit Service |
c5cf8c |
must be careful if several threads have access to the same info object.)
|
|
Packit Service |
c5cf8c |
Further, 'MPI_INFO_DUP', while not
|
|
Packit Service |
c5cf8c |
explicitly advising implementers to be careful of one thread modifying the
|
|
Packit Service |
c5cf8c |
'MPI_Info' structure while 'MPI_INFO_DUP' is copying it, requires that the
|
|
Packit Service |
c5cf8c |
operation take place in a thread-safe manner.
|
|
Packit Service |
c5cf8c |
There isn'' much that we can do about these cases. There are other cases
|
|
Packit Service |
c5cf8c |
that must be handled. In particular, multiple threads are allowed to
|
|
Packit Service |
c5cf8c |
update the same info value. Thus, all of the update routines must be thread
|
|
Packit Service |
c5cf8c |
safe; the simple implementation used in the MPICH implementation uses locks.
|
|
Packit Service |
c5cf8c |
Note that the 'MPI_Info_delete' call does not need a lock; the defintion of
|
|
Packit Service |
c5cf8c |
thread-safety means that any order of the calls functions correctly; since
|
|
Packit Service |
c5cf8c |
it invalid either to delete the same 'MPI_Info' twice or to modify an
|
|
Packit Service |
c5cf8c |
'MPI_Info' that has been deleted, only one thread at a time can call
|
|
Packit Service |
c5cf8c |
'MPI_Info_free' on any particular 'MPI_Info' value.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
T*/
|
|
Packit Service |
c5cf8c |
/*S
|
|
Packit Service |
c5cf8c |
MPIR_Info - Structure of an MPIR info
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Notes:
|
|
Packit Service |
c5cf8c |
There is no reference count because 'MPI_Info' values, unlike other MPI
|
|
Packit Service |
c5cf8c |
objects, may be changed after they are passed to a routine without
|
|
Packit Service |
c5cf8c |
changing the routine''s behavior. In other words, any routine that uses
|
|
Packit Service |
c5cf8c |
an 'MPI_Info' object must make a copy or otherwise act on any info value
|
|
Packit Service |
c5cf8c |
that it needs.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
A linked list is used because the typical 'MPI_Info' list will be short
|
|
Packit Service |
c5cf8c |
and a simple linked list is easy to implement and to maintain. Similarly,
|
|
Packit Service |
c5cf8c |
a single structure rather than separate header and element structures are
|
|
Packit Service |
c5cf8c |
defined for simplicity. No separate thread lock is provided because
|
|
Packit Service |
c5cf8c |
info routines are not performance critical; they may use the single
|
|
Packit Service |
c5cf8c |
critical section lock in the 'MPIR_Process' structure when they need a
|
|
Packit Service |
c5cf8c |
thread lock.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
This particular form of linked list (in particular, with this particular
|
|
Packit Service |
c5cf8c |
choice of the first two members) is used because it allows us to use
|
|
Packit Service |
c5cf8c |
the same routines to manage this list as are used to manage the
|
|
Packit Service |
c5cf8c |
list of free objects (in the file 'src/util/mem/handlemem.c'). In
|
|
Packit Service |
c5cf8c |
particular, if lock-free routines for updating a linked list are
|
|
Packit Service |
c5cf8c |
provided, they can be used for managing the 'MPIR_Info' structure as well.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
The MPI standard requires that keys can be no less that 32 characters and
|
|
Packit Service |
c5cf8c |
no more than 255 characters. There is no mandated limit on the size
|
|
Packit Service |
c5cf8c |
of values.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Module:
|
|
Packit Service |
c5cf8c |
Info-DS
|
|
Packit Service |
c5cf8c |
S*/
|
|
Packit Service |
c5cf8c |
struct MPIR_Info {
|
|
Packit Service |
c5cf8c |
MPIR_OBJECT_HEADER; /* adds handle and ref_count fields */
|
|
Packit Service |
c5cf8c |
struct MPIR_Info *next;
|
|
Packit Service |
c5cf8c |
char *key;
|
|
Packit Service |
c5cf8c |
char *value;
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
extern MPIR_Object_alloc_t MPIR_Info_mem;
|
|
Packit Service |
c5cf8c |
/* Preallocated info objects */
|
|
Packit Service |
c5cf8c |
#define MPIR_INFO_N_BUILTIN 2
|
|
Packit Service |
c5cf8c |
extern MPIR_Info MPIR_Info_builtin[MPIR_INFO_N_BUILTIN];
|
|
Packit Service |
c5cf8c |
extern MPIR_Info MPIR_Info_direct[];
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int MPIR_Info_get_impl(MPIR_Info * info_ptr, const char *key, int valuelen, char *value, int *flag);
|
|
Packit Service |
c5cf8c |
void MPIR_Info_get_nkeys_impl(MPIR_Info * info_ptr, int *nkeys);
|
|
Packit Service |
c5cf8c |
int MPIR_Info_get_nthkey_impl(MPIR_Info * info, int n, char *key);
|
|
Packit Service |
c5cf8c |
void MPIR_Info_get_valuelen_impl(MPIR_Info * info_ptr, const char *key, int *valuelen, int *flag);
|
|
Packit Service |
c5cf8c |
int MPIR_Info_set_impl(MPIR_Info * info_ptr, const char *key, const char *value);
|
|
Packit Service |
c5cf8c |
int MPIR_Info_dup_impl(MPIR_Info * info_ptr, MPIR_Info ** new_info_ptr);
|
|
Packit Service |
c5cf8c |
void MPIR_Info_free(MPIR_Info * info_ptr);
|
|
Packit Service |
c5cf8c |
int MPIR_Info_alloc(MPIR_Info ** info_p_p);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif /* MPIR_INFO_H_INCLUDED */
|