/* Generated from "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod" by precompile.pike running Pike v8.1 release 13
 *
 * Do NOT edit this file.
 */

#undef PRECOMPILE_API_VERSION
#define PRECOMPILE_API_VERSION 6



#undef cmod___CMOD__
#define cmod___CMOD__ 1
#line 1 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#line 1 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#line 1 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#line 3488 "/Users/hww3/devel/pike/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike"







#line 3495 "/Users/hww3/devel/pike/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike"
#line 1 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#line 1 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
/* -*- c -*-
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
*/
#include "object.h"
#include "interpret.h"
#include "program.h"
#include "pike_error.h"
#include "builtin_functions.h"
#include "threads.h"

#include <mpi.h>

#include "module_support.h"

/*
 * TODO:
 * communicators
 * all kinds of send/recv
 * reduce
 * all_reduce (reduced result present everywhere)
 * reduce_scatter
 * gather
 * scatter
 * scan etc?
 */

struct mpi_info {
    unsigned int length;
    unsigned int type_size;
    unsigned int shift;
    void * data;
    MPI_Datatype type;
    unsigned char clone;
};



#ifndef PIKE_UNUSED_ATTRIBUTE
#define PIKE_UNUSED_ATTRIBUTE
#endif
#define CMOD_MAP_PROGRAM_IDS_DEFINED 1
static int ___cmod_map_program_ids(int id) PIKE_UNUSED_ATTRIBUTE;
#ifndef TYPEOF
/* Compat with older Pikes. */
#define TYPEOF(SVAL)	((SVAL).type)
#define SUBTYPEOF(SVAL)	((SVAL).subtype)
#define SET_SVAL_TYPE(SVAL, TYPE)	(TYPEOF(SVAL) = TYPE)
#define SET_SVAL_SUBTYPE(SVAL, TYPE)	(SUBTYPEOF(SVAL) = TYPE)
#define SET_SVAL(SVAL, TYPE, SUBTYPE, FIELD, EXPR) do {	\
    /* Set the type afterwards to avoid a clobbered	\
     * svalue in case EXPR throws. */			\
    (SVAL).u.FIELD = (EXPR);				\
    SET_SVAL_TYPE((SVAL), (TYPE));			\
    SET_SVAL_SUBTYPE((SVAL), (SUBTYPE));		\
  } while(0)
#endif /* !TYPEOF */
#ifndef PIKE_UNUSED
/* Compat with Pike 7.8 and earlier. */
/* NB: Not strictly correct; PIKE_UNUSED was added the
 *     day after set_program_id_to_id(), but good enough.
 */
#ifndef UNUSED
#define UNUSED(X)	X
#endif
#ifndef set_program_id_to_id
/* NB: Recent Pike 7.8 has a #define that conflicts with
 *     the following declaration.
 */
static void set_program_id_to_id(void*UNUSED(id)){}
#endif
#else /* */
PMOD_EXPORT void set_program_id_to_id( int (*to)(int) );
#endif /* !PIKE_UNUSED */
#if !defined(string_has_null) && !defined(STRING_CONTENT_CHECKED)
/* This symbol was added as a macro in Pike 7.7.20, and is an
 * inline function in Pike 7.9.4 and later, at which time the
 * flag STRING_CONTENT_CHECKED was added.
 */
#define string_has_null(X) (strlen((X)->str)!=(size_t)(X)->len)
#endif


#ifndef DEFAULT_CMOD_STORAGE
#define CMOD_COND_USED
#define DEFAULT_CMOD_STORAGE static
#endif
#define module_strings_declared
static struct pike_string *module_strings[2] = {
  NULL,
  NULL,
};
#ifndef CMOD_COND_USED
# define Comm_f_Comm_Bcast_fun_num_used 1
# define Comm_f_Comm_Send_fun_num_used 1
# define Comm_program_fun_num_used 1
# define FloatArray_program_fun_num_used 1
# define IntArray_program_fun_num_used 1
# define Op_program_fun_num_used 1
# define Pointer_f_Pointer_cq__backtick_28_29_fun_num_used 1
# define Pointer_program_fun_num_used 1
# define Sentinel_program_fun_num_used 1
# define SingleArray_program_fun_num_used 1
# define Status_program_fun_num_used 1
# define f_Comm_Abort_fun_num_used 1
# define f_Comm_Allreduce_fun_num_used 1
# define f_Comm_Barrier_fun_num_used 1
# define f_Comm_Bcast_1_fun_num_used 1
# define f_Comm_Bcast_2_fun_num_used 1
# define f_Comm_Exscan_fun_num_used 1
# define f_Comm_Gather_fun_num_used 1
# define f_Comm_Gatherv_fun_num_used 1
# define f_Comm_Recv_fun_num_used 1
# define f_Comm_Reduce_fun_num_used 1
# define f_Comm_Scan_fun_num_used 1
# define f_Comm_Scatter_fun_num_used 1
# define f_Comm_Scatterv_fun_num_used 1
# define f_Comm_Send_1_fun_num_used 1
# define f_Comm_Send_2_fun_num_used 1
# define f_Comm_cq__backtickrank_fun_num_used 1
# define f_Comm_cq__backticksize_fun_num_used 1
# define f_Comm_dup_fun_num_used 1
# define f_Finalize_fun_num_used 1
# define f_FloatArray_assign_fun_num_used 1
# define f_FloatArray_cast_fun_num_used 1
# define f_FloatArray_clear_fun_num_used 1
# define f_FloatArray_cq__backtick_5B_5D_eq_fun_num_used 1
# define f_FloatArray_cq__backtick_5B_5D_fun_num_used 1
# define f_FloatArray_cq__sizeof_fun_num_used 1
# define f_FloatArray_cq__values_fun_num_used 1
# define f_FloatArray_create_fun_num_used 1
# define f_FloatArray_sum_fun_num_used 1
# define f_Init_fun_num_used 1
# define f_IntArray_assign_fun_num_used 1
# define f_IntArray_cast_fun_num_used 1
# define f_IntArray_clear_fun_num_used 1
# define f_IntArray_cq__backtick_5B_5D_eq_fun_num_used 1
# define f_IntArray_cq__backtick_5B_5D_fun_num_used 1
# define f_IntArray_cq__sizeof_fun_num_used 1
# define f_IntArray_cq__values_fun_num_used 1
# define f_IntArray_create_fun_num_used 1
# define f_IntArray_sum_fun_num_used 1
# define f_Op_create_fun_num_used 1
# define f_Pointer_cq__backtick_28_29_1_fun_num_used 1
# define f_Pointer_cq__backtick_28_29_2_fun_num_used 1
# define f_Pointer_create_fun_num_used 1
# define f_SingleArray_assign_fun_num_used 1
# define f_SingleArray_cast_fun_num_used 1
# define f_SingleArray_clear_fun_num_used 1
# define f_SingleArray_cq__backtick_5B_5D_eq_fun_num_used 1
# define f_SingleArray_cq__backtick_5B_5D_fun_num_used 1
# define f_SingleArray_cq__sizeof_fun_num_used 1
# define f_SingleArray_cq__values_fun_num_used 1
# define f_SingleArray_create_fun_num_used 1
# define f_SingleArray_sum_fun_num_used 1
# define f_Status_cq__backtickSOURCE_fun_num_used 1
# define f_Status_cq__backtickTAG_fun_num_used 1
#else /* !CMOD_COND_USED */
# undef Comm_f_Comm_Bcast_fun_num_used
# undef Comm_f_Comm_Send_fun_num_used
# undef Comm_program_fun_num_used
# undef FloatArray_program_fun_num_used
# undef IntArray_program_fun_num_used
# undef Op_program_fun_num_used
# undef Pointer_f_Pointer_cq__backtick_28_29_fun_num_used
# undef Pointer_program_fun_num_used
# undef Sentinel_program_fun_num_used
# undef SingleArray_program_fun_num_used
# undef Status_program_fun_num_used
# undef f_Comm_Abort_fun_num_used
# undef f_Comm_Allreduce_fun_num_used
# undef f_Comm_Barrier_fun_num_used
# undef f_Comm_Bcast_1_fun_num_used
# undef f_Comm_Bcast_2_fun_num_used
# undef f_Comm_Exscan_fun_num_used
# undef f_Comm_Gather_fun_num_used
# undef f_Comm_Gatherv_fun_num_used
# undef f_Comm_Recv_fun_num_used
# undef f_Comm_Reduce_fun_num_used
# undef f_Comm_Scan_fun_num_used
# undef f_Comm_Scatter_fun_num_used
# undef f_Comm_Scatterv_fun_num_used
# undef f_Comm_Send_1_fun_num_used
# undef f_Comm_Send_2_fun_num_used
# undef f_Comm_cq__backtickrank_fun_num_used
# undef f_Comm_cq__backticksize_fun_num_used
# undef f_Comm_dup_fun_num_used
# undef f_Finalize_fun_num_used
# undef f_FloatArray_assign_fun_num_used
# undef f_FloatArray_cast_fun_num_used
# undef f_FloatArray_clear_fun_num_used
# undef f_FloatArray_cq__backtick_5B_5D_eq_fun_num_used
# undef f_FloatArray_cq__backtick_5B_5D_fun_num_used
# undef f_FloatArray_cq__sizeof_fun_num_used
# undef f_FloatArray_cq__values_fun_num_used
# undef f_FloatArray_create_fun_num_used
# undef f_FloatArray_sum_fun_num_used
# undef f_Init_fun_num_used
# undef f_IntArray_assign_fun_num_used
# undef f_IntArray_cast_fun_num_used
# undef f_IntArray_clear_fun_num_used
# undef f_IntArray_cq__backtick_5B_5D_eq_fun_num_used
# undef f_IntArray_cq__backtick_5B_5D_fun_num_used
# undef f_IntArray_cq__sizeof_fun_num_used
# undef f_IntArray_cq__values_fun_num_used
# undef f_IntArray_create_fun_num_used
# undef f_IntArray_sum_fun_num_used
# undef f_Op_create_fun_num_used
# undef f_Pointer_cq__backtick_28_29_1_fun_num_used
# undef f_Pointer_cq__backtick_28_29_2_fun_num_used
# undef f_Pointer_create_fun_num_used
# undef f_SingleArray_assign_fun_num_used
# undef f_SingleArray_cast_fun_num_used
# undef f_SingleArray_clear_fun_num_used
# undef f_SingleArray_cq__backtick_5B_5D_eq_fun_num_used
# undef f_SingleArray_cq__backtick_5B_5D_fun_num_used
# undef f_SingleArray_cq__sizeof_fun_num_used
# undef f_SingleArray_cq__values_fun_num_used
# undef f_SingleArray_create_fun_num_used
# undef f_SingleArray_sum_fun_num_used
# undef f_Status_cq__backtickSOURCE_fun_num_used
# undef f_Status_cq__backtickTAG_fun_num_used
#endif /* !CMOD_COND_USED */

#ifdef f_IntArray_create_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_IntArray_create_fun_num = -1;

#endif /* f_IntArray_create_fun_num_used */

#ifdef f_IntArray_clear_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_IntArray_clear_fun_num = -1;

#endif /* f_IntArray_clear_fun_num_used */

#ifdef f_IntArray_assign_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_IntArray_assign_fun_num = -1;

#endif /* f_IntArray_assign_fun_num_used */

#ifdef f_IntArray_cq__backtick_5B_5D_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_IntArray_cq__backtick_5B_5D_fun_num = -1;

#endif /* f_IntArray_cq__backtick_5B_5D_fun_num_used */

#ifdef f_IntArray_cq__backtick_5B_5D_eq_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_IntArray_cq__backtick_5B_5D_eq_fun_num = -1;

#endif /* f_IntArray_cq__backtick_5B_5D_eq_fun_num_used */

#ifdef f_IntArray_sum_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_IntArray_sum_fun_num = -1;

#endif /* f_IntArray_sum_fun_num_used */

#ifdef f_IntArray_cq__sizeof_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_IntArray_cq__sizeof_fun_num = -1;

#endif /* f_IntArray_cq__sizeof_fun_num_used */

#ifdef f_IntArray_cq__values_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_IntArray_cq__values_fun_num = -1;

#endif /* f_IntArray_cq__values_fun_num_used */

#ifdef f_IntArray_cast_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_IntArray_cast_fun_num = -1;

#endif /* f_IntArray_cast_fun_num_used */
DEFAULT_CMOD_STORAGE struct program *IntArray_program=NULL;

#ifdef IntArray_program_fun_num_used
DEFAULT_CMOD_STORAGE int IntArray_program_fun_num=-1;
#endif /* IntArray_program_fun_num_used */

#ifdef f_FloatArray_create_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_FloatArray_create_fun_num = -1;

#endif /* f_FloatArray_create_fun_num_used */

#ifdef f_FloatArray_clear_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_FloatArray_clear_fun_num = -1;

#endif /* f_FloatArray_clear_fun_num_used */

#ifdef f_FloatArray_assign_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_FloatArray_assign_fun_num = -1;

#endif /* f_FloatArray_assign_fun_num_used */

#ifdef f_FloatArray_cq__backtick_5B_5D_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_FloatArray_cq__backtick_5B_5D_fun_num = -1;

#endif /* f_FloatArray_cq__backtick_5B_5D_fun_num_used */

#ifdef f_FloatArray_cq__backtick_5B_5D_eq_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_FloatArray_cq__backtick_5B_5D_eq_fun_num = -1;

#endif /* f_FloatArray_cq__backtick_5B_5D_eq_fun_num_used */

#ifdef f_FloatArray_sum_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_FloatArray_sum_fun_num = -1;

#endif /* f_FloatArray_sum_fun_num_used */

#ifdef f_FloatArray_cq__sizeof_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_FloatArray_cq__sizeof_fun_num = -1;

#endif /* f_FloatArray_cq__sizeof_fun_num_used */

#ifdef f_FloatArray_cq__values_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_FloatArray_cq__values_fun_num = -1;

#endif /* f_FloatArray_cq__values_fun_num_used */

#ifdef f_FloatArray_cast_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_FloatArray_cast_fun_num = -1;

#endif /* f_FloatArray_cast_fun_num_used */
DEFAULT_CMOD_STORAGE struct program *FloatArray_program=NULL;

#ifdef FloatArray_program_fun_num_used
DEFAULT_CMOD_STORAGE int FloatArray_program_fun_num=-1;
#endif /* FloatArray_program_fun_num_used */

#ifdef f_SingleArray_create_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_SingleArray_create_fun_num = -1;

#endif /* f_SingleArray_create_fun_num_used */

#ifdef f_SingleArray_clear_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_SingleArray_clear_fun_num = -1;

#endif /* f_SingleArray_clear_fun_num_used */

#ifdef f_SingleArray_assign_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_SingleArray_assign_fun_num = -1;

#endif /* f_SingleArray_assign_fun_num_used */

#ifdef f_SingleArray_cq__backtick_5B_5D_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_SingleArray_cq__backtick_5B_5D_fun_num = -1;

#endif /* f_SingleArray_cq__backtick_5B_5D_fun_num_used */

#ifdef f_SingleArray_cq__backtick_5B_5D_eq_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_SingleArray_cq__backtick_5B_5D_eq_fun_num = -1;

#endif /* f_SingleArray_cq__backtick_5B_5D_eq_fun_num_used */

#ifdef f_SingleArray_sum_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_SingleArray_sum_fun_num = -1;

#endif /* f_SingleArray_sum_fun_num_used */

#ifdef f_SingleArray_cq__sizeof_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_SingleArray_cq__sizeof_fun_num = -1;

#endif /* f_SingleArray_cq__sizeof_fun_num_used */

#ifdef f_SingleArray_cq__values_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_SingleArray_cq__values_fun_num = -1;

#endif /* f_SingleArray_cq__values_fun_num_used */

#ifdef f_SingleArray_cast_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_SingleArray_cast_fun_num = -1;

#endif /* f_SingleArray_cast_fun_num_used */
DEFAULT_CMOD_STORAGE struct program *SingleArray_program=NULL;

#ifdef SingleArray_program_fun_num_used
DEFAULT_CMOD_STORAGE int SingleArray_program_fun_num=-1;
#endif /* SingleArray_program_fun_num_used */

#ifdef f_Status_cq__backtickSOURCE_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Status_cq__backtickSOURCE_fun_num = -1;

#endif /* f_Status_cq__backtickSOURCE_fun_num_used */

#ifdef f_Status_cq__backtickTAG_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Status_cq__backtickTAG_fun_num = -1;

#endif /* f_Status_cq__backtickTAG_fun_num_used */
DEFAULT_CMOD_STORAGE struct program *Status_program=NULL;

#ifdef Status_program_fun_num_used
DEFAULT_CMOD_STORAGE int Status_program_fun_num=-1;
#endif /* Status_program_fun_num_used */
DEFAULT_CMOD_STORAGE struct program *Sentinel_program=NULL;

#ifdef Sentinel_program_fun_num_used
DEFAULT_CMOD_STORAGE int Sentinel_program_fun_num=-1;
#endif /* Sentinel_program_fun_num_used */
DEFAULT_CMOD_STORAGE struct program *Op_program=NULL;

#ifdef Op_program_fun_num_used
DEFAULT_CMOD_STORAGE int Op_program_fun_num=-1;
#endif /* Op_program_fun_num_used */

#ifdef f_Pointer_create_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Pointer_create_fun_num = -1;

#endif /* f_Pointer_create_fun_num_used */

#ifdef f_Pointer_cq__backtick_28_29_1_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Pointer_cq__backtick_28_29_1_fun_num = -1;

#endif /* f_Pointer_cq__backtick_28_29_1_fun_num_used */

#ifdef f_Pointer_cq__backtick_28_29_2_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Pointer_cq__backtick_28_29_2_fun_num = -1;

#endif /* f_Pointer_cq__backtick_28_29_2_fun_num_used */

#ifdef Pointer_f_Pointer_cq__backtick_28_29_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t Pointer_f_Pointer_cq__backtick_28_29_fun_num = -1;

#endif /* Pointer_f_Pointer_cq__backtick_28_29_fun_num_used */
DEFAULT_CMOD_STORAGE struct program *Pointer_program=NULL;

#ifdef Pointer_program_fun_num_used
DEFAULT_CMOD_STORAGE int Pointer_program_fun_num=-1;
#endif /* Pointer_program_fun_num_used */

#ifdef f_Comm_Send_1_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Send_1_fun_num = -1;

#endif /* f_Comm_Send_1_fun_num_used */

#ifdef f_Comm_Send_2_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Send_2_fun_num = -1;

#endif /* f_Comm_Send_2_fun_num_used */

#ifdef Comm_f_Comm_Send_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t Comm_f_Comm_Send_fun_num = -1;

#endif /* Comm_f_Comm_Send_fun_num_used */

#ifdef f_Comm_Recv_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Recv_fun_num = -1;

#endif /* f_Comm_Recv_fun_num_used */

#ifdef f_Comm_Bcast_1_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Bcast_1_fun_num = -1;

#endif /* f_Comm_Bcast_1_fun_num_used */

#ifdef f_Comm_Bcast_2_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Bcast_2_fun_num = -1;

#endif /* f_Comm_Bcast_2_fun_num_used */

#ifdef Comm_f_Comm_Bcast_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t Comm_f_Comm_Bcast_fun_num = -1;

#endif /* Comm_f_Comm_Bcast_fun_num_used */

#ifdef f_Comm_Reduce_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Reduce_fun_num = -1;

#endif /* f_Comm_Reduce_fun_num_used */

#ifdef f_Comm_Allreduce_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Allreduce_fun_num = -1;

#endif /* f_Comm_Allreduce_fun_num_used */

#ifdef f_Comm_Scan_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Scan_fun_num = -1;

#endif /* f_Comm_Scan_fun_num_used */

#ifdef f_Comm_Exscan_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Exscan_fun_num = -1;

#endif /* f_Comm_Exscan_fun_num_used */

#ifdef f_Comm_Scatter_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Scatter_fun_num = -1;

#endif /* f_Comm_Scatter_fun_num_used */

#ifdef f_Comm_Gather_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Gather_fun_num = -1;

#endif /* f_Comm_Gather_fun_num_used */

#ifdef f_Comm_Scatterv_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Scatterv_fun_num = -1;

#endif /* f_Comm_Scatterv_fun_num_used */

#ifdef f_Comm_Gatherv_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Gatherv_fun_num = -1;

#endif /* f_Comm_Gatherv_fun_num_used */

#ifdef f_Comm_Abort_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Abort_fun_num = -1;

#endif /* f_Comm_Abort_fun_num_used */

#ifdef f_Comm_Barrier_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_Barrier_fun_num = -1;

#endif /* f_Comm_Barrier_fun_num_used */

#ifdef f_Comm_cq__backtickrank_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_cq__backtickrank_fun_num = -1;

#endif /* f_Comm_cq__backtickrank_fun_num_used */

#ifdef f_Comm_cq__backticksize_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_cq__backticksize_fun_num = -1;

#endif /* f_Comm_cq__backticksize_fun_num_used */

#ifdef f_Comm_dup_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Comm_dup_fun_num = -1;

#endif /* f_Comm_dup_fun_num_used */
DEFAULT_CMOD_STORAGE struct program *Comm_program=NULL;

#ifdef Comm_program_fun_num_used
DEFAULT_CMOD_STORAGE int Comm_program_fun_num=-1;
#endif /* Comm_program_fun_num_used */

#ifdef f_Init_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Init_fun_num = -1;

#endif /* f_Init_fun_num_used */

#ifdef f_Finalize_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Finalize_fun_num = -1;

#endif /* f_Finalize_fun_num_used */

#ifdef f_Op_create_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Op_create_fun_num = -1;

#endif /* f_Op_create_fun_num_used */
/*! @module MPI */

#line 42 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#define mpi_INITIALIZED	1
#define mpi_FINALIZED	2
static unsigned char mpi_status = 0;

static void initialize_mpi(const char * name) {
    if (mpi_status != mpi_FINALIZED) {
	int provided;

	mpi_status = mpi_INITIALIZED;
	/* MPI specification expects &argc, &argv as first arguments,
	 * but does not operate them in any way. The implmenentations
	 * that I have encountered operate fine with NULL, NULL. */
	MPI_Init_thread(NULL, NULL, MPI_THREAD_MULTIPLE, &provided);
	if (provided != MPI_THREAD_MULTIPLE)
	    Pike_fatal("MPI cannot deliver: %d vs %d.\n",
		       MPI_THREAD_MULTIPLE, provided);
    } else
	Pike_error("%s: Operation not possible because MPI has already been finalized.\n",
		   name);
}

static inline void using_mpi(const char *name) {
    if (mpi_status != mpi_INITIALIZED)
	initialize_mpi(name);
}

#define IS_SENTINEL(x) ((x) && (-1 != low_get_storage((x)->prog,	\
					      MPI_IntArray_program)	\
			|| -1 != low_get_storage((x)->prog,		\
						 MPI_FloatArray_program)\
			|| -1 != low_get_storage((x)->prog,		\
						 MPI_Sentinel_program)))

#define IS_SENTINEL_OR_PTR(x) (IS_SENTINEL(x) || -1 			\
			       != low_get_storage((x)->prog,		\
						  MPI_Pointer_program))

#define ENSURE_SENTINEL(x, fun, argnum) do { if (!IS_SENTINEL(x))	\
      SIMPLE_ARG_TYPE_ERROR(fun, argnum, "inherits(MPI.IntArray)|"      \
			 "inherits(MPI.FloatArray)|"			\
			 "inherits(MPI.Sentinel)");			\
} while (0)
#define ENSURE_SENTINEL_OR_NULL(x, fun, argnum) do {			\
    if ((x) && !IS_SENTINEL(x))						\
	SIMPLE_ARG_TYPE_ERROR(fun, argnum, "inherits(MPI.IntArray)|"	\
			     "inherits(MPI.FloatArray)|"		\
			     "inherits(MPI.Sentinel)|void");		\
} while (0)

#define FAIL_SENTINEL_OR_PTR(fun, argnum) do {				\
    SIMPLE_ARG_TYPE_ERROR(fun, argnum, "inherits(MPI.IntArray)|"        \
			 "inherits(MPI.FloatArray)|"			\
			 "inherits(MPI.Sentinel)|string");		\
} while (0)

#define ENSURE_SENTINEL_OR_PTR(x, fun, argnum) do {			\
    if (!(IS_SENTINEL_OR_PTR(x)))					\
	FAIL_SENTINEL_OR_PTR(fun, argnum);				\
} while (0)

/*! @class IntArray
 *! This class implements an array of 32 bit integers.
 */

#undef class_IntArray_defined
#define class_IntArray_defined
#line 117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#line 1 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"





    
#undef var_i_IntArray_defined
#define var_i_IntArray_defined

#undef THIS
#define THIS ((struct IntArray_struct *)(Pike_interpreter.frame_pointer->current_storage + IntArray_storage_offset))

#undef THIS_INTARRAY
#define THIS_INTARRAY ((struct IntArray_struct *)(Pike_interpreter.frame_pointer->current_storage + IntArray_storage_offset))

#undef OBJ2_INTARRAY
#define OBJ2_INTARRAY(o) ((struct IntArray_struct *)(o->storage+IntArray_storage_offset+IntArray_program->inherits[0].storage_offset))

#undef GET_INTARRAY_STORAGE
#define GET_INTARRAY_STORAGE(o) ((struct IntArray_struct *)(o->storage+IntArray_storage_offset+IntArray_program->inherits[0].storage_offset))
static ptrdiff_t IntArray_storage_offset;
struct IntArray_struct {

#ifdef var_i_IntArray_defined
#line 6 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
struct mpi_info i;
#endif /* var_i_IntArray_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct IntArray_struct *IntArray_gdb_dummy_ptr;
#endif
/*! @decl void create(int(0..) size) */
    #define f_IntArray_create_defined
DEFAULT_CMOD_STORAGE void f_IntArray_create(INT32 args) {
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
INT_TYPE size;
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("create",args,1);
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if((TYPEOF(Pike_sp[0-1]) != PIKE_T_INT) || (Pike_sp[0-1].u.integer < 0)) SIMPLE_ARG_TYPE_ERROR("create",1,"int(31bit)");
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
size=Pike_sp[0-1].u.integer;
#line 11 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if (THIS->i.data) Pike_error("create() called twice.\n");
	THIS->i.length = size;
	if (size) THIS->i.data = xalloc(size * THIS->i.type_size);
	/* memset(THIS->p, 0, size * sizeof(*THIS->p)); */
	/* NOTE: This may point to formerly used memory and give access to
	 * the (old) content of that memory.
	 * Make sure to never hand out "partially filled" IntArrays to users
	 * in full.
	 */
    }

}
/*! @decl void clear()
 *! Sets all elements of the MPI_IntArray  to 0.
*/
    #define f_IntArray_clear_defined
DEFAULT_CMOD_STORAGE void f_IntArray_clear(INT32 args) {
#line 26 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("clear",args,0);
{
	if (!THIS->i.length) return;
	memset(THIS->i.data, 0, THIS->i.length * THIS->i.type_size);
    }

}
/*! @decl void assign(MPI_IntArray  other)
 *! Assigns the first @expr{sizeof(other)@} entries from @expr{other@} to the
 *! respective entries in the current array.
 *!
 *! @throws
 *! 	If @expr{sizeof(other) > sizeof(this)@}
 */
    #define f_IntArray_assign_defined
DEFAULT_CMOD_STORAGE void f_IntArray_assign(INT32 args) {
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
struct object * other;
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
int other_inh_num;
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("assign",args,1);
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("assign",1,"object");
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
debug_malloc_pass(other=Pike_sp[0-1].u.object);
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
other_inh_num = SUBTYPEOF(Pike_sp[0-1]);
{
	if (!other || -1 == low_get_storage(other->prog, MPI_IntArray_program ))
	    SIMPLE_BAD_ARG_ERROR("`+", 1, "inherits(MPI."  "Int"  "Array)");
	if (THIS->i.length < OBJ2_MPI_INTARRAY(other)->i.length)
	    Pike_error("Cannot assign from MPI."  "Int"  "Array of size %d to "  "Int"  "Array of size %d.\n",
		       OBJ2_MPI_INTARRAY(other)->i.length, THIS->i.length);

	memcpy(THIS->i.data, OBJ2_MPI_INTARRAY(other)->i.data, OBJ2_MPI_INTARRAY(other)->i.length * THIS->i.type_size);
	pop_n_elems(args);
    }

}
/*! @decl int `[](int idx)
 *! Gives the @expr{idx@}ths element of the MPI_IntArray .
*/
    #define f_IntArray_cq__backtick_5B_5D_defined
DEFAULT_CMOD_STORAGE void f_IntArray_cq__backtick_5B_5D(INT32 args) {
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
INT_TYPE idx;
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("`[]",args,1);
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if((TYPEOF(Pike_sp[0-1]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("`[]",1,"int");
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
idx=Pike_sp[0-1].u.integer;
#line 56 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	int r;

	if ((unsigned int)idx >= THIS->i.length || idx < 0)
	    Pike_error("Invalid index %d in MPI."  "Int"  "Array of size %u.\n",
		       idx, THIS->i.length);

	r = ((int*)THIS->i.data)[idx];
	pop_n_elems(args);
	push_int(r);
    }

}
/*! @decl int `[]=(int idx, int val)
 *! Sets the @expr{idx@}ths element of the MPI_IntArray  to
 *! @expr{val@}.
*/
    #define f_IntArray_cq__backtick_5B_5D_eq_defined
DEFAULT_CMOD_STORAGE void f_IntArray_cq__backtick_5B_5D_eq(INT32 args) {
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
INT_TYPE idx;
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
INT_TYPE val;
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 2) wrong_number_of_args_error("`[]=",args,2);
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if((TYPEOF(Pike_sp[0-2]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("`[]=",1,"int");
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
idx=Pike_sp[0-2].u.integer;
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if((TYPEOF(Pike_sp[1-2]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("`[]=",2,"int");
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
val=Pike_sp[1-2].u.integer;
#line 74 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if ((unsigned int)idx >= THIS->i.length || idx < 0)
	    Pike_error("Invalid index %d in MPI."  "Int"  "Array of size %u.\n",
		       idx, THIS->i.length);

	((int*)THIS->i.data)[idx] = val;
	stack_swap();
	pop_n_elems(1);
    }

}
#line 84 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
/* Why did i put this in here? sum()? seriously? */
    #define f_IntArray_sum_defined
DEFAULT_CMOD_STORAGE void f_IntArray_sum(INT32 args) {
#line 85 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("sum",args,0);
{
	unsigned int i;
	int r = 0;

	if (!THIS->i.length) {
	    push_int(0);
	    return;
	}

	for (i = 0; i < THIS->i.length; i++) {
	    r += ((int*)THIS->i.data)[i];
	}

	push_int(r);
    }

}
/*! @decl int _sizeof()
 *! @returns
 *! 	The number of entries in this MPI_IntArray .
*/
    #define f_IntArray_cq__sizeof_defined
DEFAULT_CMOD_STORAGE void f_IntArray_cq__sizeof(INT32 args) {
#line 106 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("_sizeof",args,0);
#line 108 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	push_int(THIS->i.length);
    }

}
/*! @decl array(int) _values()
 *! @returns
 *! 	A Pike array copy of this array.
 *! @example
 *! array pike_array = values(typed_array);
*/
    #define f_IntArray_cq__values_defined
DEFAULT_CMOD_STORAGE void f_IntArray_cq__values(INT32 args) {
#line 118 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("_values",args,0);
#line 120 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	struct array *a;
	unsigned int i;
	struct svalue sv;

	push_int(THIS->i.length);
	f_allocate(1);

	a = Pike_sp[-1].u.array;

	for (i = 0; i < THIS->i.length; i++) {
	    SET_SVAL((*(ITEM(a)+i)), PIKE_T_INT, NUMBER_NUMBER, integer,
		     ((int*)THIS->i.data)[i]);
	}
    }

}
/*! @decl mixed cast(string type)
 *! Supports casting (by copy) this MPI_IntArray  to a Pike array.
 *!
 *! @example
 *! array pike_array = (array)typed_array;
*/
    #define f_IntArray_cast_defined
DEFAULT_CMOD_STORAGE void f_IntArray_cast(INT32 args) {
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
struct pike_string * type;
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("cast",args,1);
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("cast",1,"string");
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
debug_malloc_pass(type=Pike_sp[0-1].u.string);
#line 144 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if (type == module_strings[0] /* "array" */) {
	    pop_n_elems(args);
	    apply_current(f_MPI_IntArray_cq__values_fun_num , 0);
	} else if (type == module_strings[1] /* "object" */) {
	    pop_n_elems(args);
	    ref_push_object(Pike_fp->current_object);
	} else
	    Pike_error("Cannot cast to %o.\n", Pike_sp-1);
    }

    }

#undef internal_init_IntArray_defined
#define internal_init_IntArray_defined

#undef IntArray_event_handler_defined
#define IntArray_event_handler_defined
static void init_IntArray_struct(void)
#line 156 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	THIS->i.type = MPI_INT;
	THIS->i.type_size = sizeof(int);
	THIS->i.shift = (1<<3);
    }

    
#undef IntArray_gc_live_obj
#define IntArray_gc_live_obj

#undef internal_exit_IntArray_defined
#define internal_exit_IntArray_defined

#undef IntArray_event_handler_defined
#define IntArray_event_handler_defined
static void exit_IntArray_struct(void)
#line 163 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if (THIS->i.data) {
	    if (!THIS->i.clone) free(THIS->i.data);
	    THIS->i.data = NULL;
	    THIS->i.length = 0;
	}
    }












#line 117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"


#ifdef IntArray_event_handler_defined
static void IntArray_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_IntArray_defined
  case PROG_EVENT_INIT: init_IntArray_struct(); break;

#endif /* internal_init_IntArray_defined */

#ifdef internal_exit_IntArray_defined
  case PROG_EVENT_EXIT: exit_IntArray_struct(); break;

#endif /* internal_exit_IntArray_defined */
  default: break; 
  }
}

#endif /* IntArray_event_handler_defined */

#ifdef THIS_

#undef THIS
#define THIS THIS_

#endif /* THIS_ */
/*! @endclass */

/*! @class FloatArray
 *! This class implements an array of double precision floats.
 *!
 *! @note
 *! 	Values will be converted to and from the Pike float type,
 *! 	which may introduce rounding errors if the types don't match in
 *! 	your installation.
 */

#undef class_FloatArray_defined
#define class_FloatArray_defined
#line 141 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#line 1 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"





    
#undef var_i_FloatArray_defined
#define var_i_FloatArray_defined

#undef THIS
#define THIS ((struct FloatArray_struct *)(Pike_interpreter.frame_pointer->current_storage + FloatArray_storage_offset))

#undef THIS_FLOATARRAY
#define THIS_FLOATARRAY ((struct FloatArray_struct *)(Pike_interpreter.frame_pointer->current_storage + FloatArray_storage_offset))

#undef OBJ2_FLOATARRAY
#define OBJ2_FLOATARRAY(o) ((struct FloatArray_struct *)(o->storage+FloatArray_storage_offset+FloatArray_program->inherits[0].storage_offset))

#undef GET_FLOATARRAY_STORAGE
#define GET_FLOATARRAY_STORAGE(o) ((struct FloatArray_struct *)(o->storage+FloatArray_storage_offset+FloatArray_program->inherits[0].storage_offset))
static ptrdiff_t FloatArray_storage_offset;
struct FloatArray_struct {

#ifdef var_i_FloatArray_defined
#line 6 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
struct mpi_info i;
#endif /* var_i_FloatArray_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct FloatArray_struct *FloatArray_gdb_dummy_ptr;
#endif
/*! @decl void create(int(0..) size) */
    #define f_FloatArray_create_defined
DEFAULT_CMOD_STORAGE void f_FloatArray_create(INT32 args) {
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
INT_TYPE size;
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("create",args,1);
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if((TYPEOF(Pike_sp[0-1]) != PIKE_T_INT) || (Pike_sp[0-1].u.integer < 0)) SIMPLE_ARG_TYPE_ERROR("create",1,"int(31bit)");
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
size=Pike_sp[0-1].u.integer;
#line 11 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if (THIS->i.data) Pike_error("create() called twice.\n");
	THIS->i.length = size;
	if (size) THIS->i.data = xalloc(size * THIS->i.type_size);
	/* memset(THIS->p, 0, size * sizeof(*THIS->p)); */
	/* NOTE: This may point to formerly used memory and give access to
	 * the (old) content of that memory.
	 * Make sure to never hand out "partially filled" IntArrays to users
	 * in full.
	 */
    }

}
/*! @decl void clear()
 *! Sets all elements of the MPI_FloatArray  to 0.
*/
    #define f_FloatArray_clear_defined
DEFAULT_CMOD_STORAGE void f_FloatArray_clear(INT32 args) {
#line 26 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("clear",args,0);
{
	if (!THIS->i.length) return;
	memset(THIS->i.data, 0, THIS->i.length * THIS->i.type_size);
    }

}
/*! @decl void assign(MPI_FloatArray  other)
 *! Assigns the first @expr{sizeof(other)@} entries from @expr{other@} to the
 *! respective entries in the current array.
 *!
 *! @throws
 *! 	If @expr{sizeof(other) > sizeof(this)@}
 */
    #define f_FloatArray_assign_defined
DEFAULT_CMOD_STORAGE void f_FloatArray_assign(INT32 args) {
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
struct object * other;
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
int other_inh_num;
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("assign",args,1);
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("assign",1,"object");
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
debug_malloc_pass(other=Pike_sp[0-1].u.object);
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
other_inh_num = SUBTYPEOF(Pike_sp[0-1]);
{
	if (!other || -1 == low_get_storage(other->prog, MPI_FloatArray_program ))
	    SIMPLE_BAD_ARG_ERROR("`+", 1, "inherits(MPI."  "Float"  "Array)");
	if (THIS->i.length < OBJ2_MPI_FLOATARRAY(other)->i.length)
	    Pike_error("Cannot assign from MPI."  "Float"  "Array of size %d to "  "Float"  "Array of size %d.\n",
		       OBJ2_MPI_FLOATARRAY(other)->i.length, THIS->i.length);

	memcpy(THIS->i.data, OBJ2_MPI_FLOATARRAY(other)->i.data, OBJ2_MPI_FLOATARRAY(other)->i.length * THIS->i.type_size);
	pop_n_elems(args);
    }

}
/*! @decl float `[](int idx)
 *! Gives the @expr{idx@}ths element of the MPI_FloatArray .
*/
    #define f_FloatArray_cq__backtick_5B_5D_defined
DEFAULT_CMOD_STORAGE void f_FloatArray_cq__backtick_5B_5D(INT32 args) {
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
INT_TYPE idx;
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("`[]",args,1);
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if((TYPEOF(Pike_sp[0-1]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("`[]",1,"int");
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
idx=Pike_sp[0-1].u.integer;
#line 56 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	double r;

	if ((unsigned int)idx >= THIS->i.length || idx < 0)
	    Pike_error("Invalid index %d in MPI."  "Float"  "Array of size %u.\n",
		       idx, THIS->i.length);

	r = ((double*)THIS->i.data)[idx];
	pop_n_elems(args);
	push_float(r);
    }

}
/*! @decl float `[]=(int idx, float val)
 *! Sets the @expr{idx@}ths element of the MPI_FloatArray  to
 *! @expr{val@}.
*/
    #define f_FloatArray_cq__backtick_5B_5D_eq_defined
DEFAULT_CMOD_STORAGE void f_FloatArray_cq__backtick_5B_5D_eq(INT32 args) {
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
INT_TYPE idx;
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
FLOAT_TYPE val;
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 2) wrong_number_of_args_error("`[]=",args,2);
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if((TYPEOF(Pike_sp[0-2]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("`[]=",1,"int");
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
idx=Pike_sp[0-2].u.integer;
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(TYPEOF(Pike_sp[1-2]) != PIKE_T_FLOAT) SIMPLE_ARG_TYPE_ERROR("`[]=",2,"float");
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
val=Pike_sp[1-2].u.float_number;
#line 74 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if ((unsigned int)idx >= THIS->i.length || idx < 0)
	    Pike_error("Invalid index %d in MPI."  "Float"  "Array of size %u.\n",
		       idx, THIS->i.length);

	((double*)THIS->i.data)[idx] = val;
	stack_swap();
	pop_n_elems(1);
    }

}
#line 84 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
/* Why did i put this in here? sum()? seriously? */
    #define f_FloatArray_sum_defined
DEFAULT_CMOD_STORAGE void f_FloatArray_sum(INT32 args) {
#line 85 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("sum",args,0);
{
	unsigned int i;
	double r = 0;

	if (!THIS->i.length) {
	    push_float(0);
	    return;
	}

	for (i = 0; i < THIS->i.length; i++) {
	    r += ((double*)THIS->i.data)[i];
	}

	push_float(r);
    }

}
/*! @decl int _sizeof()
 *! @returns
 *! 	The number of entries in this MPI_FloatArray .
*/
    #define f_FloatArray_cq__sizeof_defined
DEFAULT_CMOD_STORAGE void f_FloatArray_cq__sizeof(INT32 args) {
#line 106 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("_sizeof",args,0);
#line 108 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	push_int(THIS->i.length);
    }

}
/*! @decl array(float) _values()
 *! @returns
 *! 	A Pike array copy of this array.
 *! @example
 *! array pike_array = values(typed_array);
*/
    #define f_FloatArray_cq__values_defined
DEFAULT_CMOD_STORAGE void f_FloatArray_cq__values(INT32 args) {
#line 118 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("_values",args,0);
#line 120 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	struct array *a;
	unsigned int i;
	struct svalue sv;

	push_int(THIS->i.length);
	f_allocate(1);

	a = Pike_sp[-1].u.array;

	for (i = 0; i < THIS->i.length; i++) {
	    SET_SVAL((*(ITEM(a)+i)), T_FLOAT, 0, float_number,
		     ((double*)THIS->i.data)[i]);
	}
    }

}
/*! @decl mixed cast(string type)
 *! Supports casting (by copy) this MPI_FloatArray  to a Pike array.
 *!
 *! @example
 *! array pike_array = (array)typed_array;
*/
    #define f_FloatArray_cast_defined
DEFAULT_CMOD_STORAGE void f_FloatArray_cast(INT32 args) {
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
struct pike_string * type;
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("cast",args,1);
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("cast",1,"string");
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
debug_malloc_pass(type=Pike_sp[0-1].u.string);
#line 144 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if (type == module_strings[0] /* "array" */) {
	    pop_n_elems(args);
	    apply_current(f_MPI_FloatArray_cq__values_fun_num , 0);
	} else if (type == module_strings[1] /* "object" */) {
	    pop_n_elems(args);
	    ref_push_object(Pike_fp->current_object);
	} else
	    Pike_error("Cannot cast to %o.\n", Pike_sp-1);
    }

    }

#undef internal_init_FloatArray_defined
#define internal_init_FloatArray_defined

#undef FloatArray_event_handler_defined
#define FloatArray_event_handler_defined
static void init_FloatArray_struct(void)
#line 156 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	THIS->i.type = MPI_DOUBLE;
	THIS->i.type_size = sizeof(double);
	THIS->i.shift = (2<<3);
    }

    
#undef FloatArray_gc_live_obj
#define FloatArray_gc_live_obj

#undef internal_exit_FloatArray_defined
#define internal_exit_FloatArray_defined

#undef FloatArray_event_handler_defined
#define FloatArray_event_handler_defined
static void exit_FloatArray_struct(void)
#line 163 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if (THIS->i.data) {
	    if (!THIS->i.clone) free(THIS->i.data);
	    THIS->i.data = NULL;
	    THIS->i.length = 0;
	}
    }












#line 141 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"


#ifdef FloatArray_event_handler_defined
static void FloatArray_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_FloatArray_defined
  case PROG_EVENT_INIT: init_FloatArray_struct(); break;

#endif /* internal_init_FloatArray_defined */

#ifdef internal_exit_FloatArray_defined
  case PROG_EVENT_EXIT: exit_FloatArray_struct(); break;

#endif /* internal_exit_FloatArray_defined */
  default: break; 
  }
}

#endif /* FloatArray_event_handler_defined */

#ifdef THIS_

#undef THIS
#define THIS THIS_

#endif /* THIS_ */
/*! @endclass */

/*! @class SingleArray
 *! This class implements an array of single precision floats.
 *!
 *! @note
 *! 	Values will be converted to and from the Pike float type,
 *! 	which may introduce rounding errors if the types don't match in
 *! 	your installation.
 */

#undef class_SingleArray_defined
#define class_SingleArray_defined
#line 165 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#line 1 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"





    
#undef var_i_SingleArray_defined
#define var_i_SingleArray_defined

#undef THIS
#define THIS ((struct SingleArray_struct *)(Pike_interpreter.frame_pointer->current_storage + SingleArray_storage_offset))

#undef THIS_SINGLEARRAY
#define THIS_SINGLEARRAY ((struct SingleArray_struct *)(Pike_interpreter.frame_pointer->current_storage + SingleArray_storage_offset))

#undef OBJ2_SINGLEARRAY
#define OBJ2_SINGLEARRAY(o) ((struct SingleArray_struct *)(o->storage+SingleArray_storage_offset+SingleArray_program->inherits[0].storage_offset))

#undef GET_SINGLEARRAY_STORAGE
#define GET_SINGLEARRAY_STORAGE(o) ((struct SingleArray_struct *)(o->storage+SingleArray_storage_offset+SingleArray_program->inherits[0].storage_offset))
static ptrdiff_t SingleArray_storage_offset;
struct SingleArray_struct {

#ifdef var_i_SingleArray_defined
#line 6 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
struct mpi_info i;
#endif /* var_i_SingleArray_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct SingleArray_struct *SingleArray_gdb_dummy_ptr;
#endif
/*! @decl void create(int(0..) size) */
    #define f_SingleArray_create_defined
DEFAULT_CMOD_STORAGE void f_SingleArray_create(INT32 args) {
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
INT_TYPE size;
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("create",args,1);
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if((TYPEOF(Pike_sp[0-1]) != PIKE_T_INT) || (Pike_sp[0-1].u.integer < 0)) SIMPLE_ARG_TYPE_ERROR("create",1,"int(31bit)");
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
size=Pike_sp[0-1].u.integer;
#line 11 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if (THIS->i.data) Pike_error("create() called twice.\n");
	THIS->i.length = size;
	if (size) THIS->i.data = xalloc(size * THIS->i.type_size);
	/* memset(THIS->p, 0, size * sizeof(*THIS->p)); */
	/* NOTE: This may point to formerly used memory and give access to
	 * the (old) content of that memory.
	 * Make sure to never hand out "partially filled" IntArrays to users
	 * in full.
	 */
    }

}
/*! @decl void clear()
 *! Sets all elements of the MPI_SingleArray  to 0.
*/
    #define f_SingleArray_clear_defined
DEFAULT_CMOD_STORAGE void f_SingleArray_clear(INT32 args) {
#line 26 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("clear",args,0);
{
	if (!THIS->i.length) return;
	memset(THIS->i.data, 0, THIS->i.length * THIS->i.type_size);
    }

}
/*! @decl void assign(MPI_SingleArray  other)
 *! Assigns the first @expr{sizeof(other)@} entries from @expr{other@} to the
 *! respective entries in the current array.
 *!
 *! @throws
 *! 	If @expr{sizeof(other) > sizeof(this)@}
 */
    #define f_SingleArray_assign_defined
DEFAULT_CMOD_STORAGE void f_SingleArray_assign(INT32 args) {
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
struct object * other;
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
int other_inh_num;
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("assign",args,1);
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("assign",1,"object");
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
debug_malloc_pass(other=Pike_sp[0-1].u.object);
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
other_inh_num = SUBTYPEOF(Pike_sp[0-1]);
{
	if (!other || -1 == low_get_storage(other->prog, MPI_SingleArray_program ))
	    SIMPLE_BAD_ARG_ERROR("`+", 1, "inherits(MPI."  "Single"  "Array)");
	if (THIS->i.length < OBJ2_MPI_SINGLEARRAY(other)->i.length)
	    Pike_error("Cannot assign from MPI."  "Single"  "Array of size %d to "  "Single"  "Array of size %d.\n",
		       OBJ2_MPI_SINGLEARRAY(other)->i.length, THIS->i.length);

	memcpy(THIS->i.data, OBJ2_MPI_SINGLEARRAY(other)->i.data, OBJ2_MPI_SINGLEARRAY(other)->i.length * THIS->i.type_size);
	pop_n_elems(args);
    }

}
/*! @decl float `[](int idx)
 *! Gives the @expr{idx@}ths element of the MPI_SingleArray .
*/
    #define f_SingleArray_cq__backtick_5B_5D_defined
DEFAULT_CMOD_STORAGE void f_SingleArray_cq__backtick_5B_5D(INT32 args) {
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
INT_TYPE idx;
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("`[]",args,1);
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if((TYPEOF(Pike_sp[0-1]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("`[]",1,"int");
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
idx=Pike_sp[0-1].u.integer;
#line 56 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	float r;

	if ((unsigned int)idx >= THIS->i.length || idx < 0)
	    Pike_error("Invalid index %d in MPI."  "Single"  "Array of size %u.\n",
		       idx, THIS->i.length);

	r = ((float*)THIS->i.data)[idx];
	pop_n_elems(args);
	push_float(r);
    }

}
/*! @decl float `[]=(int idx, float val)
 *! Sets the @expr{idx@}ths element of the MPI_SingleArray  to
 *! @expr{val@}.
*/
    #define f_SingleArray_cq__backtick_5B_5D_eq_defined
DEFAULT_CMOD_STORAGE void f_SingleArray_cq__backtick_5B_5D_eq(INT32 args) {
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
INT_TYPE idx;
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
FLOAT_TYPE val;
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 2) wrong_number_of_args_error("`[]=",args,2);
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if((TYPEOF(Pike_sp[0-2]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("`[]=",1,"int");
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
idx=Pike_sp[0-2].u.integer;
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(TYPEOF(Pike_sp[1-2]) != PIKE_T_FLOAT) SIMPLE_ARG_TYPE_ERROR("`[]=",2,"float");
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
val=Pike_sp[1-2].u.float_number;
#line 74 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if ((unsigned int)idx >= THIS->i.length || idx < 0)
	    Pike_error("Invalid index %d in MPI."  "Single"  "Array of size %u.\n",
		       idx, THIS->i.length);

	((float*)THIS->i.data)[idx] = val;
	stack_swap();
	pop_n_elems(1);
    }

}
#line 84 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
/* Why did i put this in here? sum()? seriously? */
    #define f_SingleArray_sum_defined
DEFAULT_CMOD_STORAGE void f_SingleArray_sum(INT32 args) {
#line 85 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("sum",args,0);
{
	unsigned int i;
	float r = 0;

	if (!THIS->i.length) {
	    push_float(0);
	    return;
	}

	for (i = 0; i < THIS->i.length; i++) {
	    r += ((float*)THIS->i.data)[i];
	}

	push_float(r);
    }

}
/*! @decl int _sizeof()
 *! @returns
 *! 	The number of entries in this MPI_SingleArray .
*/
    #define f_SingleArray_cq__sizeof_defined
DEFAULT_CMOD_STORAGE void f_SingleArray_cq__sizeof(INT32 args) {
#line 106 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("_sizeof",args,0);
#line 108 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	push_int(THIS->i.length);
    }

}
/*! @decl array(float) _values()
 *! @returns
 *! 	A Pike array copy of this array.
 *! @example
 *! array pike_array = values(typed_array);
*/
    #define f_SingleArray_cq__values_defined
DEFAULT_CMOD_STORAGE void f_SingleArray_cq__values(INT32 args) {
#line 118 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 0) wrong_number_of_args_error("_values",args,0);
#line 120 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	struct array *a;
	unsigned int i;
	struct svalue sv;

	push_int(THIS->i.length);
	f_allocate(1);

	a = Pike_sp[-1].u.array;

	for (i = 0; i < THIS->i.length; i++) {
	    SET_SVAL((*(ITEM(a)+i)), T_FLOAT, 0, float_number,
		     ((float*)THIS->i.data)[i]);
	}
    }

}
/*! @decl mixed cast(string type)
 *! Supports casting (by copy) this MPI_SingleArray  to a Pike array.
 *!
 *! @example
 *! array pike_array = (array)typed_array;
*/
    #define f_SingleArray_cast_defined
DEFAULT_CMOD_STORAGE void f_SingleArray_cast(INT32 args) {
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
struct pike_string * type;
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(args != 1) wrong_number_of_args_error("cast",args,1);
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("cast",1,"string");
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
debug_malloc_pass(type=Pike_sp[0-1].u.string);
#line 144 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if (type == module_strings[0] /* "array" */) {
	    pop_n_elems(args);
	    apply_current(f_MPI_SingleArray_cq__values_fun_num , 0);
	} else if (type == module_strings[1] /* "object" */) {
	    pop_n_elems(args);
	    ref_push_object(Pike_fp->current_object);
	} else
	    Pike_error("Cannot cast to %o.\n", Pike_sp-1);
    }

    }

#undef internal_init_SingleArray_defined
#define internal_init_SingleArray_defined

#undef SingleArray_event_handler_defined
#define SingleArray_event_handler_defined
static void init_SingleArray_struct(void)
#line 156 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	THIS->i.type = MPI_FLOAT;
	THIS->i.type_size = sizeof(float);
	THIS->i.shift = (3<<3);
    }

    
#undef SingleArray_gc_live_obj
#define SingleArray_gc_live_obj

#undef internal_exit_SingleArray_defined
#define internal_exit_SingleArray_defined

#undef SingleArray_event_handler_defined
#define SingleArray_event_handler_defined
static void exit_SingleArray_struct(void)
#line 163 "/Users/hww3/devel/pike/src/modules/MPI/typed_array.H"
{
	if (THIS->i.data) {
	    if (!THIS->i.clone) free(THIS->i.data);
	    THIS->i.data = NULL;
	    THIS->i.length = 0;
	}
    }












#line 165 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"


#ifdef SingleArray_event_handler_defined
static void SingleArray_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_SingleArray_defined
  case PROG_EVENT_INIT: init_SingleArray_struct(); break;

#endif /* internal_init_SingleArray_defined */

#ifdef internal_exit_SingleArray_defined
  case PROG_EVENT_EXIT: exit_SingleArray_struct(); break;

#endif /* internal_exit_SingleArray_defined */
  default: break; 
  }
}

#endif /* SingleArray_event_handler_defined */

#ifdef THIS_

#undef THIS
#define THIS THIS_

#endif /* THIS_ */
/*! @endclass */

/*! @class Status
 *! Objects of this class can be passed as the last argument to the receive
 *! operation of @[MPI.Comm] communicators. After the operation has finished,
 *! they will contain information about the sender the message was received
 *! from and the tag used for communication.
 *!
 *! Therefore, Status objects are particularly helpful in combination with
 *! @[MPI.ANY_SOURCE] and @[MPI.ANY_TAG].
 *!
 *! @seealso
 *! 	@[MPI.Comm()->Recv()]
 */

#undef class_Status_defined
#define class_Status_defined

#undef var_status_Status_defined
#define var_status_Status_defined

#undef THIS
#define THIS ((struct Status_struct *)(Pike_interpreter.frame_pointer->current_storage + Status_storage_offset))

#undef THIS_STATUS
#define THIS_STATUS ((struct Status_struct *)(Pike_interpreter.frame_pointer->current_storage + Status_storage_offset))

#undef OBJ2_STATUS
#define OBJ2_STATUS(o) ((struct Status_struct *)(o->storage+Status_storage_offset+Status_program->inherits[0].storage_offset))

#undef GET_STATUS_STORAGE
#define GET_STATUS_STORAGE(o) ((struct Status_struct *)(o->storage+Status_storage_offset+Status_program->inherits[0].storage_offset))
static ptrdiff_t Status_storage_offset;
struct Status_struct {

#ifdef var_status_Status_defined
#line 182 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
MPI_Status status;
#endif /* var_status_Status_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Status_struct *Status_gdb_dummy_ptr;
#endif
/*! @decl int SOURCE
     *! Contains the source that the message was received from.
     *!
     *! @example
     *!int main() {
     *!	if (MPI.world->rank) {
     *!		sleep(random(MPI.world->size)/10.0);
     *!		MPI.world->Send(gethostname(), MPI.world->rank), 0);
     *!	} else {
     *!		MPI.Status status;
     *!		MPI.Pointer p;
     *!
     *!		for (int i = 0; i < MPI.world->size; i++) {
     *!			MPI.world->Recv(p, MPI.ANY_SOURCE, 0, status);
     *!			write("Rank %d has hostname %s.\n", status->SOURCE, p());
     *!		}
     *!	}
     *!
     *!	return 0;
     *!}
     *!
     *! @seealso
     *! 	@[MPI.Comm()->Recv()]
     */
    #define f_Status_cq__backtickSOURCE_defined
DEFAULT_CMOD_STORAGE void f_Status_cq__backtickSOURCE(INT32 args) {
#line 208 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 0) wrong_number_of_args_error("`SOURCE",args,0);
{
	push_int(THIS->status.MPI_SOURCE);
    }

    }
/*! @decl int TAG
     *! Contains the tag that was used in the @[MPI.Comm()->Recv] operation.
     *!
     *! @seealso
     *! 	@[MPI.Comm()->Recv()]
     */
    #define f_Status_cq__backtickTAG_defined
DEFAULT_CMOD_STORAGE void f_Status_cq__backtickTAG(INT32 args) {
#line 219 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 0) wrong_number_of_args_error("`TAG",args,0);
{
	push_int(THIS->status.MPI_TAG);
    }
}

#ifdef THIS_

#undef THIS
#define THIS THIS_

#endif /* THIS_ */
/*! @endclass */

/*! @class Sentinel
 *! A @[Sentinel] is a kind of handle that can be given out by objects if
 *! they want to allow @[MPI] to send from/receive into the memory areas
 *! pointed to by the Sentinel.
 *!
 *! Other than that, @[Sentinel]s are not that useful from Pike.
 *!
 *! @seealso
 *! 	@[Math.FMatrix()->get_sentinel()], @[Math.FMatrix]
 */

#undef class_Sentinel_defined
#define class_Sentinel_defined

#undef var_i_Sentinel_defined
#define var_i_Sentinel_defined

#undef var_other_Sentinel_defined
#define var_other_Sentinel_defined

#undef THIS
#define THIS ((struct Sentinel_struct *)(Pike_interpreter.frame_pointer->current_storage + Sentinel_storage_offset))

#undef THIS_SENTINEL
#define THIS_SENTINEL ((struct Sentinel_struct *)(Pike_interpreter.frame_pointer->current_storage + Sentinel_storage_offset))

#undef OBJ2_SENTINEL
#define OBJ2_SENTINEL(o) ((struct Sentinel_struct *)(o->storage+Sentinel_storage_offset+Sentinel_program->inherits[0].storage_offset))

#undef GET_SENTINEL_STORAGE
#define GET_SENTINEL_STORAGE(o) ((struct Sentinel_struct *)(o->storage+Sentinel_storage_offset+Sentinel_program->inherits[0].storage_offset))
static ptrdiff_t Sentinel_storage_offset;
struct Sentinel_struct {

#ifdef var_i_Sentinel_defined
#line 237 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct mpi_info i;
#endif /* var_i_Sentinel_defined */

#ifdef var_other_Sentinel_defined
#line 238 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * other;
#endif /* var_other_Sentinel_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Sentinel_struct *Sentinel_gdb_dummy_ptr;
#endif

#undef internal_init_Sentinel_defined
#define internal_init_Sentinel_defined

#undef Sentinel_event_handler_defined
#define Sentinel_event_handler_defined
static void init_Sentinel_struct(void)
#line 240 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	THIS->other = NULL;
    }

    
#undef Sentinel_gc_live_obj
#define Sentinel_gc_live_obj

#undef internal_exit_Sentinel_defined
#define internal_exit_Sentinel_defined

#undef Sentinel_event_handler_defined
#define Sentinel_event_handler_defined
static void exit_Sentinel_struct(void)
#line 244 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	if (THIS->other) {
	    free_object(THIS->other);
	    THIS->other = NULL;
	}
	
    }

#ifdef Sentinel_event_handler_defined
static void Sentinel_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_Sentinel_defined
  case PROG_EVENT_INIT: init_Sentinel_struct(); break;

#endif /* internal_init_Sentinel_defined */

#ifdef internal_exit_Sentinel_defined
  case PROG_EVENT_EXIT: exit_Sentinel_struct(); break;

#endif /* internal_exit_Sentinel_defined */
  default: break; 
  }
}

#endif /* Sentinel_event_handler_defined */

#ifdef THIS_

#undef THIS
#define THIS THIS_

#endif /* THIS_ */
/*! @endclass */

#line 255 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
PMOD_EXPORT struct object * mpi_clone_sentinel(MPI_Datatype type,
					       unsigned int length,
					       unsigned int type_size,
					       unsigned int shift,
					       void * p,
					       struct object * other) {
    struct object * o = low_clone(MPI_Sentinel_program);

    OBJ2_MPI_SENTINEL(o)->i.length = length;
    OBJ2_MPI_SENTINEL(o)->i.type_size = type_size;
    OBJ2_MPI_SENTINEL(o)->i.shift = shift;
    OBJ2_MPI_SENTINEL(o)->i.type = type;
    OBJ2_MPI_SENTINEL(o)->i.data = p;
    OBJ2_MPI_SENTINEL(o)->other = other;
    add_ref(other);
    return o;
}

PMOD_EXPORT struct op_info {
    struct object *o;
    void **data;
};

/*! @class Op
 *! Objects of this class represent MPI operations used in collective
 *! operations like @[MPI.Comm()->reduce()]. You can use operations
 *! predefined by MPI or create your own.
 *!
 *! Other than that, @[Op]s are not that useful from Pike.
 *!
 *! @seealso
 *! 	@[MPI] constants, @[MPI.Op_create()], @[MPI.Comm->Reduce()].
 */

#undef class_Op_defined
#define class_Op_defined

#undef var_op_Op_defined
#define var_op_Op_defined

#undef var_refcnt_Op_defined
#define var_refcnt_Op_defined

#undef var_ufun_Op_defined
#define var_ufun_Op_defined

#undef var_op_info_Op_defined
#define var_op_info_Op_defined

#undef var_info_Op_defined
#define var_info_Op_defined

#undef var_shift_Op_defined
#define var_shift_Op_defined

#undef THIS
#define THIS ((struct Op_struct *)(Pike_interpreter.frame_pointer->current_storage + Op_storage_offset))

#undef THIS_OP
#define THIS_OP ((struct Op_struct *)(Pike_interpreter.frame_pointer->current_storage + Op_storage_offset))

#undef OBJ2_OP
#define OBJ2_OP(o) ((struct Op_struct *)(o->storage+Op_storage_offset+Op_program->inherits[0].storage_offset))

#undef GET_OP_STORAGE
#define GET_OP_STORAGE(o) ((struct Op_struct *)(o->storage+Op_storage_offset+Op_program->inherits[0].storage_offset))
static ptrdiff_t Op_storage_offset;
struct Op_struct {

#ifdef var_op_Op_defined
#line 290 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
MPI_Op op;
#endif /* var_op_Op_defined */

#ifdef var_refcnt_Op_defined
#line 291 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
unsigned int *refcnt;
#endif /* var_refcnt_Op_defined */

#ifdef var_ufun_Op_defined
#line 292 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct svalue ufun;
#endif /* var_ufun_Op_defined */

#ifdef var_op_info_Op_defined
#line 293 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct op_info (*create)(void *);
#endif /* var_op_info_Op_defined */

#ifdef var_info_Op_defined
#line 294 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
void *info;
#endif /* var_info_Op_defined */

#ifdef var_shift_Op_defined
#line 295 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
unsigned int len, shift;
#endif /* var_shift_Op_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Op_struct *Op_gdb_dummy_ptr;
#endif

#undef Op_gc_live_obj
#define Op_gc_live_obj

#undef internal_exit_Op_defined
#define internal_exit_Op_defined

#undef Op_event_handler_defined
#define Op_event_handler_defined
static void exit_Op_struct(void)
#line 298 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	if (THIS->refcnt) {
	    if (!--*THIS->refcnt) {
		if (mpi_status != mpi_FINALIZED) MPI_Op_free(&THIS->op);
		free(THIS->refcnt);
		if (THIS->info) free(THIS->info);
	    }

	    free_svalue(&THIS->ufun);
	}
    }

#ifdef Op_event_handler_defined
static void Op_event_handler(int ev) {
  switch(ev) {

#ifdef internal_exit_Op_defined
  case PROG_EVENT_EXIT: exit_Op_struct(); break;

#endif /* internal_exit_Op_defined */
  default: break; 
  }
}

#endif /* Op_event_handler_defined */

#ifdef THIS_

#undef THIS
#define THIS THIS_

#endif /* THIS_ */
/*! @endclass */

#line 312 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
PMOD_EXPORT struct object *mpi_clone_op(MPI_Op op, unsigned int *refcnt)
{
    struct object *o = low_clone(MPI_Op_program);

    OBJ2_MPI_OP(o)->op = op;
    OBJ2_MPI_OP(o)->refcnt = refcnt;
    return o;
}

static inline struct object *mpi_clone_array(struct program *prog, unsigned int length, void *data)
{
    struct object *r = low_clone(prog);

    OBJ2_MPI_INTARRAY(r)->i.clone = 1;
    OBJ2_MPI_INTARRAY(r)->i.data = data;
    OBJ2_MPI_INTARRAY(r)->i.length = length;

    return r;
}

/* Any ideas appreciated! */
struct {
    struct svalue ufun;
    struct program *bufprog;
    struct object *op;
} mpi_pike_user_function;

struct mpi_user_function_errstruct {
    struct object *v1;
    struct object *v2;
    void **p1, **p2;
};

static void mpi_user_function_error(struct mpi_user_function_errstruct *v)
{
    INVALIDATE_CURRENT_TIME();

    if (v->p1) *v->p1 = *v->p2 = NULL;

    debug_malloc_touch(v->v1);
    destruct_object(v->v1, DESTRUCT_EXPLICIT);
    debug_malloc_touch(v->v2);
    destruct_object(v->v2, DESTRUCT_EXPLICIT);
    destruct_objects_to_destruct();

    free(v);
}

static void mpi_user_function(void *invec, void *outvec, int *len,
			      MPI_Datatype *type)
{
    ONERROR err;
    struct program *p;
    struct mpi_user_function_errstruct *v
            = ALLOC_STRUCT(mpi_user_function_errstruct);
    struct svalue *old_sp = Pike_sp;


    push_svalue(&mpi_pike_user_function.ufun);


    if (mpi_pike_user_function.bufprog) {
	v->v1 = mpi_clone_array(mpi_pike_user_function.bufprog, *len, invec);
	v->v2 = mpi_clone_array(mpi_pike_user_function.bufprog, *len, outvec);
	v->p1 = v->p2 = NULL;
    } else {
	struct op_info oinfo;
	unsigned int tsize;

	MPI_Type_size(*type, (int*)&tsize);

	/* TODO: can this even happen? i think not, but have to be sure! */
	if (*(unsigned int*)len * tsize
		!= OBJ2_MPI_OP(mpi_pike_user_function.op)->len)
	    Pike_fatal("Pike defined MPI operation with nonmatching length (%d (%d)received vs %d in op).\n",
		       *len * tsize, tsize, OBJ2_MPI_OP(mpi_pike_user_function.op)->len);

	oinfo = OBJ2_MPI_OP(mpi_pike_user_function.op)->create(OBJ2_MPI_OP(mpi_pike_user_function.op)->info);
	v->v1 = oinfo.o;
	*(v->p1 = oinfo.data) = invec;
	oinfo = OBJ2_MPI_OP(mpi_pike_user_function.op)->create(OBJ2_MPI_OP(mpi_pike_user_function.op)->info);
	v->v2 = oinfo.o;
	*(v->p2 = oinfo.data) = outvec;
    }

    ref_push_object(v->v1);
    ref_push_object(v->v2);

    SET_ONERROR(err, mpi_user_function_error, v);
    f_call_function(3);
    UNSET_ONERROR(err);
    INVALIDATE_CURRENT_TIME();

    if (v->p1) *v->p1 = *v->p2 = NULL;

    debug_malloc_touch(v->v1);
    destruct_object(v->v1, DESTRUCT_EXPLICIT);
    debug_malloc_touch(v->v2);
    destruct_object(v->v2, DESTRUCT_EXPLICIT);
    destruct_objects_to_destruct();

    free(v);

#ifndef PIKE_DEBUG
    if (Pike_sp-old_sp > 0)
	pop_n_elems(Pike_sp-old_sp);
#else
    if (Pike_sp-old_sp == 1)
	pop_n_elems(1);
    else if (Pike_sp-old_sp != 0)
	Pike_fatal("MPI: Pike defined operation caused stack malfunction (detection): %d\n",
		   Pike_sp-old_sp);
#endif
}

static inline int mpi_Reduce(struct object *sendbuf, struct object *recvbuf,
	       MPI_Op op, int root, MPI_Comm comm)
{
    unsigned int shift = OBJ2_MPI_INTARRAY(sendbuf)->i.shift,
		 length = OBJ2_MPI_INTARRAY(sendbuf)->i.length;
    int rank;

    MPI_Bcast(&shift, 1, MPI_INT, root, comm);
    MPI_Bcast(&length, 1, MPI_INT, root, comm);

    MPI_Comm_rank(comm, &rank);

    if (OBJ2_MPI_INTARRAY(recvbuf)->i.shift != OBJ2_MPI_INTARRAY(sendbuf)->i.shift)
	Pike_fatal("Reduce: recvbuf and sendbuf differ in shift (%u vs %u).\n",
		   OBJ2_MPI_INTARRAY(recvbuf)->i.shift, OBJ2_MPI_INTARRAY(sendbuf)->i.shift);
    if (OBJ2_MPI_INTARRAY(recvbuf)->i.length != OBJ2_MPI_INTARRAY(sendbuf)->i.length)
	Pike_fatal("Reduce: recvbuf and sendbuf differ in size (%u vs %u).\n",
		   OBJ2_MPI_INTARRAY(recvbuf)->i.length, OBJ2_MPI_INTARRAY(sendbuf)->i.length);

    if (rank != root) {
	if (shift != OBJ2_MPI_INTARRAY(recvbuf)->i.shift)
	    Pike_fatal("Cannot Reduce magic shift %u into buffer of magic shift %u.\n",
		       shift, OBJ2_MPI_INTARRAY(recvbuf)->i.shift);
	if (length > OBJ2_MPI_INTARRAY(recvbuf)->i.length)
	    Pike_fatal("Cannot Reduce magic shift %u and length %d into buffer of length %d.\n",
		       shift, length, OBJ2_MPI_INTARRAY(recvbuf)->i.length);
    }

    INVALIDATE_CURRENT_TIME();

    return MPI_Reduce(OBJ2_MPI_INTARRAY(sendbuf)->i.data,
		      OBJ2_MPI_INTARRAY(recvbuf)->i.data, length,
		      OBJ2_MPI_INTARRAY(sendbuf)->i.type, op,
		      root, comm);
}

#define GEN(_name_) static inline int mpi_ ## _name_(			\
				       struct object *sendbuf,		\
				       struct object *recvbuf,		\
				       MPI_Op op, MPI_Comm comm)	\
{									\
    unsigned int shift = OBJ2_MPI_INTARRAY(sendbuf)->i.shift,		\
		 length = OBJ2_MPI_INTARRAY(sendbuf)->i.length;		\
    int rank;								\
									\
    MPI_Bcast(&shift, 1, MPI_INT, 0, comm);				\
    MPI_Bcast(&length, 1, MPI_INT, 0, comm);				\
									\
    MPI_Comm_rank(comm, &rank);						\
									\
    if (OBJ2_MPI_INTARRAY(recvbuf)->i.shift					\
	    != OBJ2_MPI_INTARRAY(sendbuf)->i.shift)				\
	Pike_fatal(#_name_ ": recvbuf and sendbuf differ in shift (%u vs %u).\n",\
		   OBJ2_MPI_INTARRAY(recvbuf)->i.shift,			\
		   OBJ2_MPI_INTARRAY(sendbuf)->i.shift);			\
    if (OBJ2_MPI_INTARRAY(recvbuf)->i.length				\
	    != OBJ2_MPI_INTARRAY(sendbuf)->i.length)			\
	Pike_fatal(#_name_ ": recvbuf and sendbuf differ in size (%u vs %u).\n",\
		   OBJ2_MPI_INTARRAY(recvbuf)->i.length,			\
		   OBJ2_MPI_INTARRAY(sendbuf)->i.length);			\
									\
    if (rank) {								\
	if (shift != OBJ2_MPI_INTARRAY(recvbuf)->i.shift)			\
	    Pike_fatal("Cannot " #_name_ " magic shift %u into buffer of magic shift %u.\n",\
		       shift, OBJ2_MPI_INTARRAY(recvbuf)->i.shift);	\
	if (length > OBJ2_MPI_INTARRAY(recvbuf)->i.length)			\
	    Pike_fatal("Cannot " #_name_ " magic shift %u and length %d into buffer of length %d.\n",\
		       shift, length,				\
		       OBJ2_MPI_INTARRAY(recvbuf)->i.length);		\
    }									\
									\
    INVALIDATE_CURRENT_TIME();						\
									\
    return MPI_ ## _name_(OBJ2_MPI_INTARRAY(sendbuf)->i.data,		\
		      OBJ2_MPI_INTARRAY(recvbuf)->i.data, length,		\
		      OBJ2_MPI_INTARRAY(sendbuf)->i.type, op,		\
		      comm);						\
}

GEN(Allreduce)
GEN(Scan)
GEN(Exscan)

#undef GEN

static inline int mpi_Recv(struct object *buf, int source, int tag,
			   MPI_Comm comm, MPI_Status *status)
{
    unsigned int shift, length;
    MPI_Status int_status;
    int r;

    if (!status) status = &int_status;

    MPI_Recv(&shift, 1, MPI_INT, source, tag, comm, status);
    MPI_Recv(&length, 1, MPI_INT, status->MPI_SOURCE, status->MPI_TAG, comm, NULL);

    if (shift != OBJ2_MPI_INTARRAY(buf)->i.shift)
	Pike_error("Trying to receive shift %u into buffer of shift %u.\n",
		   shift, OBJ2_MPI_INTARRAY(buf)->i.shift);
    if (OBJ2_MPI_INTARRAY(buf)->i.length < length)
#if 0
	Pike_error("Cannot receive MPI."  "name_prefix"  "Array(%d) into MPI."  "name_prefix"  "Array(%d).\n",
		   length, OBJ2_MPI_INTARRAY(buf)->i.length);
#else
	Pike_error("Cannot receive magic shift %u length %d into length %d.\n",
		   shift, length, OBJ2_MPI_INTARRAY(buf)->i.length);
#endif

    INVALIDATE_CURRENT_TIME();

    return MPI_Recv(OBJ2_MPI_INTARRAY(buf)->i.data, length,
		    OBJ2_MPI_INTARRAY(buf)->i.type, status->MPI_SOURCE,
		    status->MPI_TAG, comm, NULL);
}

static inline int mpi_string_Recv(int source, int tag, MPI_Comm comm,
				  struct pike_string **ps, MPI_Status *status)
{
    unsigned int shift, length;
    MPI_Status int_status;
    struct svalue sval;
    struct string_builder buf;
    int r;
    int x1, x2;

    if (!status) status = &int_status;

    mark_free_svalue(&sval);

    INVALIDATE_CURRENT_TIME();

    THREADS_ALLOW();

    x1=MPI_Recv(&shift, 1, MPI_INT, source, tag, comm, &int_status);
    x2=MPI_Recv(&length, 1, MPI_INT, int_status.MPI_SOURCE, int_status.MPI_TAG, comm,
	     NULL);

    THREADS_DISALLOW();

    if (shift > 2)
	Pike_error("Cannot receive shift %u as a string. (x1, x2: %d, %d)\n", shift, x1, x2);

    init_string_builder_alloc(&buf, length >> shift, shift);

    THREADS_ALLOW();

    r = MPI_Recv(buf.s->str, length, MPI_CHAR, int_status.MPI_SOURCE, int_status.MPI_TAG,
		 comm, NULL);

    buf.s->len = length >> shift;

    THREADS_DISALLOW();

    if (status) *status = int_status;

    *ps = finish_string_builder(&buf);

    return r;
}

static inline int mpi_Bcast(struct object *buf, int root, MPI_Comm comm)
{
    unsigned int length = OBJ2_MPI_INTARRAY(buf)->i.length,
		 shift = OBJ2_MPI_INTARRAY(buf)->i.shift;
    int rank;

    INVALIDATE_CURRENT_TIME();

    MPI_Bcast(&shift, 1, MPI_INT, root, comm);
    MPI_Bcast(&length, 1, MPI_INT, root, comm);

    MPI_Comm_rank(comm, &rank);

    if (rank != root) {
	if (shift != OBJ2_MPI_INTARRAY(buf)->i.shift)
	    Pike_fatal("Cannot (receive) broadcast of shift %u into buffer of shift %u.\n",
		       shift, OBJ2_MPI_INTARRAY(buf)->i.shift);
	if (length > OBJ2_MPI_INTARRAY(buf)->i.length)
	    Pike_fatal("Buffer of shift %u and size %d to small for transmission of size %d.\n",
		       shift, OBJ2_MPI_INTARRAY(buf)->i.length, length);
    }

    return MPI_Bcast(OBJ2_MPI_INTARRAY(buf)->i.data, length,
		     OBJ2_MPI_INTARRAY(buf)->i.type, root, comm);
}

static inline int mpi_string_Bcast(struct pike_string **ps, int root, MPI_Comm comm, PIKE_MUTEX_T *m)
{
    unsigned int shift, length;
    int r, rank;

    INVALIDATE_CURRENT_TIME();

    MPI_Comm_rank(comm, &rank);

    if (rank != root) {
	struct string_builder buf;

	THREADS_ALLOW();
	mt_lock(m);

	MPI_Bcast(&shift, 1, MPI_INT, root, comm);
	MPI_Bcast(&length, 1, MPI_INT, root, comm);

	mt_unlock(m);
	THREADS_DISALLOW();

	if (shift > 2)
	    Pike_error("Cannot receive shift %u as a string.\n", shift);

	init_string_builder_alloc(&buf, length >> shift, shift);

	THREADS_ALLOW();
	mt_lock(m);

	r = MPI_Bcast(buf.s->str, length, MPI_CHAR, root, comm);

	mt_unlock(m);
	THREADS_DISALLOW();

	buf.s->len = length >> shift;

	*ps = finish_string_builder(&buf);
    } else {
	shift = (*ps)->size_shift;
	length = (*ps)->len << ((*ps)->size_shift);

	THREADS_ALLOW();
	mt_lock(m);

	MPI_Bcast(&shift, 1, MPI_INT, root, comm);
	MPI_Bcast(&length, 1, MPI_INT, root, comm);

	r = MPI_Bcast((*ps)->str, length, MPI_CHAR, root, comm);

	mt_unlock(m);
	THREADS_DISALLOW();
    }

    return r;
}


static inline int mpi_Send(struct object *buf, int dest, int tag, MPI_Comm comm)
{
    INVALIDATE_CURRENT_TIME();

    MPI_Send(&OBJ2_MPI_INTARRAY(buf)->i.shift, 1, MPI_INT, dest, tag, comm);
    MPI_Send(&OBJ2_MPI_INTARRAY(buf)->i.length, 1, MPI_INT, dest, tag, comm);
    return MPI_Send(OBJ2_MPI_INTARRAY(buf)->i.data, OBJ2_MPI_INTARRAY(buf)->i.length,
		    OBJ2_MPI_INTARRAY(buf)->i.type, dest, tag, comm);
}

static inline int mpi_Gather(struct object *sendbuf, struct object *recvbuf, int root, MPI_Comm comm)
{
    unsigned int shift, length;
    int rank, size;

    INVALIDATE_CURRENT_TIME();

    MPI_Comm_rank(comm, &rank);
    MPI_Comm_size(comm, &size);

    if (rank == root) {
	if (!IS_SENTINEL(recvbuf))
	    Pike_error("Gather: Rank root (%d) really needs a recvbuf.\n", root);
	shift = OBJ2_MPI_INTARRAY(recvbuf)->i.shift;
	length = OBJ2_MPI_INTARRAY(recvbuf)->i.length / size;
    }

    MPI_Bcast(&shift, 1, MPI_INT, root, comm);
    MPI_Bcast(&length, 1, MPI_INT, root, comm);

    if (shift != OBJ2_MPI_INTARRAY(sendbuf)->i.shift)
	Pike_error("Cannot Gather magic shift %u into buffer of magic shift %u.\n",
		   shift, OBJ2_MPI_INTARRAY(recvbuf)->i.shift);
    if (length > OBJ2_MPI_INTARRAY(sendbuf)->i.length)
	Pike_error("Cannot Gather buffer of magic shift %u, length %u into buffer of length %u.\n",
		   shift, length, OBJ2_MPI_INTARRAY(recvbuf)->i.length);

    return MPI_Gather(OBJ2_MPI_INTARRAY(sendbuf)->i.data, length, OBJ2_MPI_INTARRAY(sendbuf)->i.type,
		      recvbuf ? OBJ2_MPI_INTARRAY(recvbuf)->i.data : NULL, length,
		      recvbuf ? OBJ2_MPI_INTARRAY(recvbuf)->i.type
			      : OBJ2_MPI_INTARRAY(sendbuf)->i.type,
		      root, comm);
}

static inline int mpi_Scatter(struct object *sendbuf, struct object *recvbuf, int root, MPI_Comm comm)
{
    unsigned int shift, length;
    int rank, size;

    MPI_Comm_rank(comm, &rank);
    MPI_Comm_size(comm, &size);

    if (rank == root) {
	if (!IS_SENTINEL(sendbuf))
	    Pike_error("Scatter: Rank root (%d) really needs a sendbuf.\n",
		       root);
	shift = OBJ2_MPI_INTARRAY(sendbuf)->i.shift;
	length = OBJ2_MPI_INTARRAY(sendbuf)->i.length / size;
    }

    INVALIDATE_CURRENT_TIME();

    MPI_Bcast(&shift, 1, MPI_INT, root, comm);
    MPI_Bcast(&length, 1, MPI_INT, root, comm);

    if (shift != OBJ2_MPI_INTARRAY(recvbuf)->i.shift)
	Pike_error("Cannot Scatter magic shift %u into buffer of magic shift %u.\n",
		   shift, OBJ2_MPI_INTARRAY(recvbuf)->i.shift);
    if (length > OBJ2_MPI_INTARRAY(recvbuf)->i.length)
	Pike_error("Cannot Scatter buffer of magic shift %u, length %u into buffer of length %u.\n",
		   shift, length, OBJ2_MPI_INTARRAY(recvbuf)->i.length);

    return MPI_Scatter(sendbuf ? OBJ2_MPI_INTARRAY(sendbuf)->i.data : NULL, length,
		       sendbuf ? OBJ2_MPI_INTARRAY(sendbuf)->i.type
			       : OBJ2_MPI_INTARRAY(recvbuf)->i.type,
		       OBJ2_MPI_INTARRAY(recvbuf)->i.data, length, OBJ2_MPI_INTARRAY(recvbuf)->i.type,
		       root, comm);
}

static inline int mpi_Scatterv(struct object *sendbuf, struct object *counts,
			       struct object *displ, struct object *recvbuf,
			       int root, MPI_Comm comm)
{
    unsigned int shift;
    int rank, size;
    unsigned int count;

    MPI_Comm_rank(comm, &rank);
    MPI_Comm_size(comm, &size);

    if (rank == root) {
	int i;

	if (!IS_SENTINEL(sendbuf))
	    Pike_error("Scatterv: root (%d) really needs a sendbuf.\n",
		       root);
	if (!IS_SENTINEL(counts))
	    Pike_error("Scatterv: root (%d) really needs a counts array.\n",
		       root);
	if (!IS_SENTINEL(displ))
	    Pike_error("Scatterv: root (%d) really needs a displacements array.\n",
		       root);

	shift = OBJ2_MPI_INTARRAY(sendbuf)->i.shift;

	if (OBJ2_MPI_INTARRAY(counts)->i.length != (unsigned int)size)
	    Pike_error("Scatterv: count array of wrong size (%u vs %U).\n",
		       OBJ2_MPI_INTARRAY(counts)->i.length, size);
	if (OBJ2_MPI_INTARRAY(displ)->i.length != (unsigned int)size)
	    Pike_error("Scatterv: displacements array of wrong size (%u vs %u).\n",
		       OBJ2_MPI_INTARRAY(displ)->i.length, size);

	for (i = 0; i < size; i++) {
	    if (((int*)OBJ2_MPI_INTARRAY(counts)->i.data)[i]
		+ ((int*)OBJ2_MPI_INTARRAY(displ)->i.data)[i]
		> (int)OBJ2_MPI_INTARRAY(sendbuf)->i.length
		|| (int)OBJ2_MPI_INTARRAY(sendbuf)->i.length < 0)
		Pike_error("counts[%u]+displ[%<u]<sizeof(sendbuf) (%u).\n",
			   i, OBJ2_MPI_INTARRAY(sendbuf)->i.length);
	}
    }


    INVALIDATE_CURRENT_TIME();

    MPI_Bcast(&shift, 1, MPI_INT, root, comm);
    MPI_Scatter(counts ? OBJ2_MPI_INTARRAY(counts)->i.data : NULL, 1, MPI_INT,
		&count, 1, MPI_INT, root, comm);

    if (shift != OBJ2_MPI_INTARRAY(recvbuf)->i.shift)
	Pike_error("Cannot Scatterv magic shift %u into buffer of magic shift %u.\n",
		   shift, OBJ2_MPI_INTARRAY(recvbuf)->i.shift);
    if (OBJ2_MPI_INTARRAY(recvbuf)->i.length < count)
	Pike_error("Scatterv: to small buffer (%u vs %u) on rank %d.\n",
		   OBJ2_MPI_INTARRAY(recvbuf)->i.length, count, rank);

    return MPI_Scatterv(sendbuf ? OBJ2_MPI_INTARRAY(sendbuf)->i.data : NULL,
			counts ? (int*)OBJ2_MPI_INTARRAY(counts)->i.data : NULL,
			displ ? (int*)OBJ2_MPI_INTARRAY(displ)->i.data : NULL,
			sendbuf ? OBJ2_MPI_INTARRAY(sendbuf)->i.type
				: OBJ2_MPI_INTARRAY(recvbuf)->i.type,
			OBJ2_MPI_INTARRAY(recvbuf)->i.data, count,
			OBJ2_MPI_INTARRAY(recvbuf)->i.type,
			root, comm);
}

static inline int mpi_Gatherv(struct object *sendbuf, struct object *recvbuf,
			      struct object *counts, struct object *displ,
			      int root, MPI_Comm comm)
{
    unsigned int shift;
    int rank, size;
    unsigned int count;

    MPI_Comm_rank(comm, &rank);
    MPI_Comm_size(comm, &size);

    if (rank == root) {
	int i;

	if (!IS_SENTINEL(recvbuf))
	    Pike_error("Gatherv: root (%d) really needs a recvbuf.\n",
		       root);
	if (!IS_SENTINEL(counts))
	    Pike_error("Gatherv: root (%d) really needs a counts array.\n",
		       root);
	if (!IS_SENTINEL(displ))
	    Pike_error("Gatherv: root (%d) really needs a displacements array.\n",
		       root);

	shift = OBJ2_MPI_INTARRAY(recvbuf)->i.shift;

	if (OBJ2_MPI_INTARRAY(counts)->i.length != (unsigned int)size)
	    Pike_error("Gatherv: count array of wrong size (%u vs %U).\n",
		       OBJ2_MPI_INTARRAY(counts)->i.length, size);
	if (OBJ2_MPI_INTARRAY(displ)->i.length != (unsigned int)size)
	    Pike_error("Gatherv: displacements array of wrong size (%u vs %u).\n",
		       OBJ2_MPI_INTARRAY(displ)->i.length, size);

	for (i = 0; i < size; i++) {
	    if (((int*)OBJ2_MPI_INTARRAY(counts)->i.data)[i]
		+ ((int*)OBJ2_MPI_INTARRAY(displ)->i.data)[i]
		> (int)OBJ2_MPI_INTARRAY(recvbuf)->i.length
		|| (int)OBJ2_MPI_INTARRAY(recvbuf)->i.length < 0)
		Pike_error("counts[%u]+displ[%<u]<sizeof(sendbuf) (%u).\n",
			   i, OBJ2_MPI_INTARRAY(sendbuf)->i.length);
	}
    }


    INVALIDATE_CURRENT_TIME();

    MPI_Bcast(&shift, 1, MPI_INT, root, comm);
    MPI_Scatter(counts ? OBJ2_MPI_INTARRAY(counts)->i.data : NULL, 1, MPI_INT,
		&count, 1, MPI_INT, root, comm);

    if (shift != OBJ2_MPI_INTARRAY(sendbuf)->i.shift)
	Pike_error("Cannot Gatherv magic shift %u into buffer of magic shift %u.\n",
		   OBJ2_MPI_INTARRAY(sendbuf)->i.shift, shift);
    if (OBJ2_MPI_INTARRAY(sendbuf)->i.length < count)
	Pike_error("Gatherv: to small buffer (%u vs %u) on rank %d.\n",
		   OBJ2_MPI_INTARRAY(sendbuf)->i.length, count, rank);

    return MPI_Gatherv(OBJ2_MPI_INTARRAY(sendbuf)->i.data,
		       count, OBJ2_MPI_INTARRAY(sendbuf)->i.type,
		       recvbuf ? OBJ2_MPI_INTARRAY(recvbuf)->i.data : NULL,
		       counts ? (int*)OBJ2_MPI_INTARRAY(counts)->i.data : NULL,
		       displ ? (int*)OBJ2_MPI_INTARRAY(displ)->i.data : NULL,
		       recvbuf ? OBJ2_MPI_INTARRAY(recvbuf)->i.type : MPI_INT,
		       root, comm);
}

/*! @class Pointer
 *! A pointer like class. Because @[MPI.Comm->Recv()] et al do not return
 *! "results" but take references/pointers to the target storage, you need to
 *! pass a @[Pointer] to @[MPI.Comm()->recv()] in order to receive the string.
 *!
 *! @example
 *!int main() {
 *!	string s;
 *!	MPI.Pointer p = MPI.Pointer();
 *!
 *!	MPI.Init();
 *!
 *!	if (MPI.world->rank())
 *!		MPI.world->Send(ctime(time(1)), 0);
 *!	else
 *!		for (int i = 1; i < MPI.world->size; i++) {
 *!			MPI.world->Recv(p, i);
 *!			write("Rank %03d says now is %s.\n", p());
 *!		}
 *!
 *!	MPI.Finalize();
 *!	return 0;
 *!}
 */

#undef class_Pointer_defined
#define class_Pointer_defined

#undef var_x_Pointer_defined
#define var_x_Pointer_defined

#undef var_y_Pointer_defined
#define var_y_Pointer_defined

#undef THIS
#define THIS ((struct Pointer_struct *)(Pike_interpreter.frame_pointer->current_storage + Pointer_storage_offset))

#undef THIS_POINTER
#define THIS_POINTER ((struct Pointer_struct *)(Pike_interpreter.frame_pointer->current_storage + Pointer_storage_offset))

#undef OBJ2_POINTER
#define OBJ2_POINTER(o) ((struct Pointer_struct *)(o->storage+Pointer_storage_offset+Pointer_program->inherits[0].storage_offset))

#undef GET_POINTER_STORAGE
#define GET_POINTER_STORAGE(o) ((struct Pointer_struct *)(o->storage+Pointer_storage_offset+Pointer_program->inherits[0].storage_offset))
static ptrdiff_t Pointer_storage_offset;
struct Pointer_struct {

#ifdef var_x_Pointer_defined
#line 909 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct svalue x;
#endif /* var_x_Pointer_defined */

#ifdef var_y_Pointer_defined
#line 910 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int y;
#endif /* var_y_Pointer_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Pointer_struct *Pointer_gdb_dummy_ptr;
#endif
/*! @decl void create()
     *! @decl void create(mixed m)
     *! If @expr{m@} is given, point to @expr{m@}, else point to
     *! @expr{UNDEFINED@}.
     */
    #define f_Pointer_create_defined
DEFAULT_CMOD_STORAGE void f_Pointer_create(INT32 args) {
#line 917 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct svalue * m;
#ifdef PIKE_DEBUG
if(args < 0) Pike_fatal("CMOD function argument negative.\n");
#else
STATIC_ASSUME(args >= 0);
#endif
#line 917 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args > 1) wrong_number_of_args_error("create",args,1);
#line 917 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if ((args > 0) &&
    ((TYPEOF(Pike_sp[0-args]) != PIKE_T_INT) ||
     (SUBTYPEOF(Pike_sp[0-args]) != NUMBER_UNDEFINED))) {
#line 917 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
m=Pike_sp+0-args; dmalloc_touch_svalue(Pike_sp+0-args);
#line 917 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else m = NULL;
#line 919 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	if (m) assign_svalue(&THIS->x, m);
	pop_n_elems(args);
    }

    }
/*! @decl mixed `()()
     *! @decl mixed `()(mixed m)
     *! If called with 0 arguments, returns the pointee. If called with
     *! argument @expr{m@}, now points to @expr{m@}.
     */
    #define f_Pointer_cq__backtick_28_29_1_defined
DEFAULT_CMOD_STORAGE void f_Pointer_cq__backtick_28_29_1(INT32 args) {
#line 929 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 0) wrong_number_of_args_error("`()",args,0);
#line 931 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	push_svalue(&THIS->x);
    }

    }
#define f_Pointer_cq__backtick_28_29_2_defined
DEFAULT_CMOD_STORAGE void f_Pointer_cq__backtick_28_29_2(INT32 args) {
#line 935 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct svalue * m;
#line 935 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 1) wrong_number_of_args_error("`()",args,1);
#line 935 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
m=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
#line 937 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	assign_svalue(&THIS->x, m);
    }

    }

#if defined(f_Pointer_cq__backtick_28_29_1_defined) || defined(f_Pointer_cq__backtick_28_29_2_defined)
#define f_Pointer_cq__backtick_28_29_defined
DEFAULT_CMOD_STORAGE void f_Pointer_cq__backtick_28_29(INT32 args) {
  switch(args) {
   case 0:

#ifdef f_Pointer_cq__backtick_28_29_1_defined
    f_Pointer_cq__backtick_28_29_1(args);
    return;

#endif /* f_Pointer_cq__backtick_28_29_1_defined */
    break;
   case 1:

#ifdef f_Pointer_cq__backtick_28_29_2_defined
    f_Pointer_cq__backtick_28_29_2(args);
    return;

#endif /* f_Pointer_cq__backtick_28_29_2_defined */
    break;
   default:
    wrong_number_of_args_error("`()",args,0);
  }
}

#endif /* f_Pointer_cq__backtick_28_29_1_defined, f_Pointer_cq__backtick_28_29_2_defined */

#undef internal_init_Pointer_defined
#define internal_init_Pointer_defined

#undef Pointer_event_handler_defined
#define Pointer_event_handler_defined
static void init_Pointer_struct(void)
#line 942 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	SET_SVAL(THIS->x, PIKE_T_INT, NUMBER_UNDEFINED, integer, 0);
    }

    
#undef Pointer_gc_live_obj
#define Pointer_gc_live_obj

#undef internal_exit_Pointer_defined
#define internal_exit_Pointer_defined

#undef Pointer_event_handler_defined
#define Pointer_event_handler_defined
static void exit_Pointer_struct(void)
#line 947 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	free_svalue(&THIS->x);
    }

#ifdef Pointer_event_handler_defined
static void Pointer_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_Pointer_defined
  case PROG_EVENT_INIT: init_Pointer_struct(); break;

#endif /* internal_init_Pointer_defined */

#ifdef internal_exit_Pointer_defined
  case PROG_EVENT_EXIT: exit_Pointer_struct(); break;

#endif /* internal_exit_Pointer_defined */
  default: break; 
  }
}

#endif /* Pointer_event_handler_defined */

#ifdef THIS_

#undef THIS
#define THIS THIS_

#endif /* THIS_ */
/*! @endclass */

/*! @class Comm
 *! A communicator object holds a group of processes both relate messages
 *! between those processes as well as perform collective operations,
 *! in which all member processes of the communicator are involved.
 */

#undef class_Comm_defined
#define class_Comm_defined

#undef var_comm_Comm_defined
#define var_comm_Comm_defined

#undef var_bm_Comm_defined
#define var_bm_Comm_defined

#undef THIS
#define THIS ((struct Comm_struct *)(Pike_interpreter.frame_pointer->current_storage + Comm_storage_offset))

#undef THIS_COMM
#define THIS_COMM ((struct Comm_struct *)(Pike_interpreter.frame_pointer->current_storage + Comm_storage_offset))

#undef OBJ2_COMM
#define OBJ2_COMM(o) ((struct Comm_struct *)(o->storage+Comm_storage_offset+Comm_program->inherits[0].storage_offset))

#undef GET_COMM_STORAGE
#define GET_COMM_STORAGE(o) ((struct Comm_struct *)(o->storage+Comm_storage_offset+Comm_program->inherits[0].storage_offset))
static ptrdiff_t Comm_storage_offset;
struct Comm_struct {

#ifdef var_comm_Comm_defined
#line 960 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
MPI_Comm comm;
#endif /* var_comm_Comm_defined */

#ifdef var_bm_Comm_defined
#line 961 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
PIKE_MUTEX_T sm, bm;
#endif /* var_bm_Comm_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Comm_struct *Comm_gdb_dummy_ptr;
#endif
/*! @decl void Send(string buf, int dest, int|void tag)
     *! @decl void Send(MPI.IntArray buf, int dest, int|void tag)
     *! @decl void Send(MPI.FloatArray buf, int dest, int|void tag)
     *! @decl void Send(MPI.SingleArray buf, int dest, int|void tag)
     *! @decl void Send(MPI.Sentinel buf, int dest, int|void tag)
     *! Sends the buffer @expr{buf@} to the process with @[rank] @expr{dest@},
     *! marked with @expr{tag@}.
     *!
     *! @seealso
     *! 	@[MPI.Comm()->Recv()], @[MPI.Comm()->Bcast()], MPI_Send(3).
     */

    
#undef internal_init_Comm_defined
#define internal_init_Comm_defined

#undef Comm_event_handler_defined
#define Comm_event_handler_defined
static void init_Comm_struct(void)
#line 975 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	mt_init(&THIS->sm);
	mt_init(&THIS->bm);
    }

    
#undef Comm_gc_live_obj
#define Comm_gc_live_obj

#undef internal_exit_Comm_defined
#define internal_exit_Comm_defined

#undef Comm_event_handler_defined
#define Comm_event_handler_defined
static void exit_Comm_struct(void)
#line 980 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	mt_destroy(&THIS->sm);
	mt_destroy(&THIS->bm);
	if (mpi_status == mpi_INITIALIZED
		&& THIS->comm != MPI_COMM_WORLD
		&& THIS->comm != MPI_COMM_NULL) {
	    MPI_Comm_free(&THIS->comm);
	}
    }

    #define f_Comm_Send_1_defined
DEFAULT_CMOD_STORAGE void f_Comm_Send_1(INT32 args) {
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct pike_string * buf;
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE dest;
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct svalue * tag;
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args < 2) wrong_number_of_args_error("Send_1",args,2);
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args > 3) wrong_number_of_args_error("Send_1",args,3);
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-args]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("Send",1,"string");
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(buf=Pike_sp[0-args].u.string);
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[1-args]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Send",2,"int");
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
dest=Pike_sp[1-args].u.integer;
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if ((args > 2) &&
    ((TYPEOF(Pike_sp[2-args]) != PIKE_T_INT) ||
     (SUBTYPEOF(Pike_sp[2-args]) != NUMBER_UNDEFINED))) {
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[2-args]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Send",3,"int|void");
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
tag=Pike_sp+2-args; dmalloc_touch_svalue(Pike_sp+2-args);
#line 990 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else tag = NULL;
{
	unsigned int shift = buf->size_shift,
		     length = buf->len << shift;
	MPI_Comm comm = THIS->comm;
	PIKE_MUTEX_T *im = &THIS->sm;

	using_mpi("Send");

	INVALIDATE_CURRENT_TIME();

	if (shift > 2) {
	    Pike_fatal("Sending broken shift %d.\n", shift);
	}

	THREADS_ALLOW();
	mt_lock(im);

	MPI_Send(&shift, 1, MPI_INT, dest, tag ? tag->u.integer : 0, comm);
	MPI_Send(&length, 1, MPI_INT, dest, tag ? tag->u.integer : 0, comm);
	MPI_Send(buf->str, length, MPI_CHAR, dest, tag ? tag->u.integer : 0, comm);

	mt_unlock(im);
	THREADS_DISALLOW();

	pop_n_elems(args);
    }

    }
#define f_Comm_Send_2_defined
DEFAULT_CMOD_STORAGE void f_Comm_Send_2(INT32 args) {
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * buf;
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int buf_inh_num;
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE dest;
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct svalue * tag;
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args < 2) wrong_number_of_args_error("Send_2",args,2);
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args > 3) wrong_number_of_args_error("Send_2",args,3);
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-args]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Send",1,"object");
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(buf=Pike_sp[0-args].u.object);
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
buf_inh_num = SUBTYPEOF(Pike_sp[0-args]);
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[1-args]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Send",2,"int");
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
dest=Pike_sp[1-args].u.integer;
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if ((args > 2) &&
    ((TYPEOF(Pike_sp[2-args]) != PIKE_T_INT) ||
     (SUBTYPEOF(Pike_sp[2-args]) != NUMBER_UNDEFINED))) {
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[2-args]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Send",3,"int|void");
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
tag=Pike_sp+2-args; dmalloc_touch_svalue(Pike_sp+2-args);
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else tag = NULL;
{
	PIKE_MUTEX_T *im = &THIS->sm;

	using_mpi("Send");

	ENSURE_SENTINEL(buf, "Send", 1);
	mt_lock(im);
	mpi_Send(buf, dest, tag ? tag->u.integer : 0, THIS->comm);
	mt_unlock(im);
	pop_n_elems(args);
    }

    }

#if defined(f_Comm_Send_1_defined) || defined(f_Comm_Send_2_defined)
#define f_Comm_Send_defined
DEFAULT_CMOD_STORAGE void f_Comm_Send(INT32 args) {
  if(args < 1) wrong_number_of_args_error("Send",args,2);
  switch(TYPEOF(Pike_sp[0-args])) {
   case PIKE_T_OBJECT:

#ifdef f_Comm_Send_2_defined
    f_Comm_Send_2(args);
    return;

#endif /* f_Comm_Send_2_defined */
    break;
   case PIKE_T_STRING:

#ifdef f_Comm_Send_1_defined
    f_Comm_Send_1(args);
    return;

#endif /* f_Comm_Send_1_defined */
    break;
   default:
    SIMPLE_ARG_TYPE_ERROR("Send",1,"object|string");
  }
}

#endif /* f_Comm_Send_1_defined, f_Comm_Send_2_defined */
/*! @decl void Recv(MPI.Pointer buf, int source, int|void tag, MPI.Status|void status)
     *! @decl void Recv(MPI.IntArray buf, int source, int|void tag, MPI.Status|void status)
     *! @decl void Recv(MPI.FloatArray buf, int source, int|void tag, MPI.Status|void status)
     *! @decl void Recv(MPI.SingleArray buf, int source, int|void tag, MPI.Status|void status)
     *! @decl void Recv(MPI.Sentinel buf, int source, int|void tag, MPI.Status|void status)
     *! Receives a message from @expr{source@} with matching @expr{tag@} into
     *! @expr{buf@}, storing the sender's rank and the tag used into the
     *! optionally given @[MPI.Status].
     *!
     *! @note
     *! 	The type of the buffer of the receiver site has to match the
     *! 	type of the buffer of the sender. @b{Exception:@} If a string
     *! 	is sent, it has to be received into a @[MPI.Pointer].
     *!
     *! @example
     *!int main() {
     *!	MPI.IntArray ia = MPI.IntArray(5);
     *!
     *! MPI.Init();
     *!
     *!	write("This is rank %d, %d processes total.\n", MPI.world->rank,
     *!	      MPI.world->size);
     *!
     *!	if (MPI.world->rank) {
     *!		for (int i = 0; i < sizeof(ia); i++) {
     *!			ia[i] = MPI.world->rank + i;
     *!		}
     *!
     *!		MPI.world->Send(ia, 0); // send to rank 0
     *!	} else {
     *!		for (int i = 0; i < MPI.world->size; i++) {
     *!			MPI.world->Recv(ia, i);
     *!			write("Rank %d sent %O to rank 0.\n", i, (array)ia);
     *!		}
     *!	}
     *!
     *!	MPI.Finalize();
     *!	return 0;
     *!}
     *!
     *!
     *! @seealso
     *! 	@[MPI.Comm->Send()], @[MPI.Comm->Bcast()], @[MPI.ANY_SOURCE],
     *!		@[MPI.ANY_TAG], MPI_Send(3).
     */
    #define f_Comm_Recv_defined
DEFAULT_CMOD_STORAGE void f_Comm_Recv(INT32 args) {
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * buf;
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int buf_inh_num;
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE source;
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct svalue * tag;
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * status;
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int status_inh_num;
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args < 2) wrong_number_of_args_error("Recv",args,2);
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args > 4) wrong_number_of_args_error("Recv",args,4);
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-args]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Recv",1,"object");
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(buf=Pike_sp[0-args].u.object);
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
buf_inh_num = SUBTYPEOF(Pike_sp[0-args]);
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[1-args]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Recv",2,"int");
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
source=Pike_sp[1-args].u.integer;
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if ((args > 2) &&
    ((TYPEOF(Pike_sp[2-args]) != PIKE_T_INT) ||
     (SUBTYPEOF(Pike_sp[2-args]) != NUMBER_UNDEFINED))) {
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[2-args]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Recv",3,"int|void");
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
tag=Pike_sp+2-args; dmalloc_touch_svalue(Pike_sp+2-args);
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else tag = NULL;
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if (args > 3 &&
    (TYPEOF(Pike_sp[3-args]) != PIKE_T_INT ||
     Pike_sp[3-args].u.integer)) {
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[3-args]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Recv",4,"object|void");
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(status=Pike_sp[3-args].u.object);
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
status_inh_num = SUBTYPEOF(Pike_sp[3-args]);
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else status = NULL;
{
	struct pike_string *ps = NULL;

	using_mpi("Recv");

	if (status && -1 == low_get_storage(status->prog, MPI_Status_program)) {
	    SIMPLE_ARG_TYPE_ERROR("Recv", 4, "inherits(MPI.Status)");
	}

	if (IS_SENTINEL(buf)) {
	    mpi_Recv(buf, source, tag ? tag->u.integer : 0, THIS->comm,
		     status ? &OBJ2_MPI_STATUS(status)->status : NULL);
	    pop_n_elems(args);
	} else {
	    if (-1 == low_get_storage(buf->prog, MPI_Pointer_program))
		FAIL_SENTINEL_OR_PTR("Recv", 1);
	    mpi_string_Recv(source, tag ? tag->u.integer : 0, THIS->comm, &ps,
			    status ? &OBJ2_MPI_STATUS(status)->status : NULL);
	    pop_n_elems(args-1);
	    push_string(ps);
	    f_call_function(2);
	    pop_n_elems(1);
	}
    }

    }
#define f_Comm_Bcast_1_defined
DEFAULT_CMOD_STORAGE void f_Comm_Bcast_1(INT32 args) {
#line 1102 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct pike_string * buf;
#line 1102 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE root;
#line 1102 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 2) wrong_number_of_args_error("Bcast",args,2);
#line 1102 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-2]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("Bcast",1,"string");
#line 1102 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(buf=Pike_sp[0-2].u.string);
#line 1102 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[1-2]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Bcast",2,"int");
#line 1102 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
root=Pike_sp[1-2].u.integer;
{
	int rank;

	using_mpi("Bcast");

	MPI_Comm_rank(THIS->comm, &rank);

	if (rank != root)
	    Pike_error("Bcast cannot receive into strings.\n");

	mpi_string_Bcast(&buf, root, THIS->comm, &THIS->bm);
	pop_n_elems(args);
    }

    }
#define f_Comm_Bcast_2_defined
DEFAULT_CMOD_STORAGE void f_Comm_Bcast_2(INT32 args) {
#line 1117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * buf;
#line 1117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int buf_inh_num;
#line 1117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE root;
#line 1117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 2) wrong_number_of_args_error("Bcast",args,2);
#line 1117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-2]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Bcast",1,"object");
#line 1117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(buf=Pike_sp[0-2].u.object);
#line 1117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
buf_inh_num = SUBTYPEOF(Pike_sp[0-2]);
#line 1117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[1-2]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Bcast",2,"int");
#line 1117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
root=Pike_sp[1-2].u.integer;
{
	using_mpi("Bcast");

	if (IS_SENTINEL(buf)) {
	    mpi_Bcast(buf, root, THIS->comm);
	    pop_n_elems(args);
	} else {
	    struct pike_string *ps = NULL;

	    if (-1 == low_get_storage(buf->prog, MPI_Pointer_program))
		FAIL_SENTINEL_OR_PTR("Bcast", 1);

	    mpi_string_Bcast(&ps, root, THIS->comm, &THIS->bm);
	    pop_n_elems(args-1);
	    push_string(ps);
	    f_call_function(2);
	    pop_n_elems(1);
	}

    }

    }

#if defined(f_Comm_Bcast_1_defined) || defined(f_Comm_Bcast_2_defined)
#define f_Comm_Bcast_defined
DEFAULT_CMOD_STORAGE void f_Comm_Bcast(INT32 args) {
  if(args < 1) wrong_number_of_args_error("Bcast",args,2);
  switch(TYPEOF(Pike_sp[0-args])) {
   case PIKE_T_OBJECT:

#ifdef f_Comm_Bcast_2_defined
    f_Comm_Bcast_2(args);
    return;

#endif /* f_Comm_Bcast_2_defined */
    break;
   case PIKE_T_STRING:

#ifdef f_Comm_Bcast_1_defined
    f_Comm_Bcast_1(args);
    return;

#endif /* f_Comm_Bcast_1_defined */
    break;
   default:
    SIMPLE_ARG_TYPE_ERROR("Bcast",1,"object|string");
  }
}

#endif /* f_Comm_Bcast_1_defined, f_Comm_Bcast_2_defined */
#define f_Comm_Reduce_defined
DEFAULT_CMOD_STORAGE void f_Comm_Reduce(INT32 args) {
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * sendbuf;
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int sendbuf_inh_num;
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * recvbuf;
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int recvbuf_inh_num;
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * op;
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int op_inh_num;
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE root;
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 4) wrong_number_of_args_error("Reduce",args,4);
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-4]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Reduce",1,"object");
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(sendbuf=Pike_sp[0-4].u.object);
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
sendbuf_inh_num = SUBTYPEOF(Pike_sp[0-4]);
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[1-4]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Reduce",2,"object");
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(recvbuf=Pike_sp[1-4].u.object);
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
recvbuf_inh_num = SUBTYPEOF(Pike_sp[1-4]);
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[2-4]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Reduce",3,"object");
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(op=Pike_sp[2-4].u.object);
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
op_inh_num = SUBTYPEOF(Pike_sp[2-4]);
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[3-4]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Reduce",4,"int");
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
root=Pike_sp[3-4].u.integer;
{
	using_mpi("Reduce");

	if (-1 == low_get_storage(op->prog, MPI_Op_program))
	    SIMPLE_ARG_TYPE_ERROR("Reduce", 3, "inherits(MPI.Op)");
	ENSURE_SENTINEL(sendbuf, "Reduce", 1);
	ENSURE_SENTINEL(recvbuf, "Reduce", 2);

	if (OBJ2_MPI_OP(op)->refcnt) {
	    assign_svalue_no_free(&mpi_pike_user_function.ufun,
				  &OBJ2_MPI_OP(op)->ufun);
	    sub_ref(mpi_pike_user_function.ufun.u.dummy);
	    if (!OBJ2_MPI_OP(op)->create) {
		/* mpi_Reduce et al. check for the same shift in both buffers
		 * (and fail if those differ). As shifts should differ easier
		 * than programs (i.e. Sentinel_program - lots of shifts, one
		 * program) - we just need to store any one ->prog. */
		mpi_pike_user_function.bufprog = recvbuf->prog;
	    } else {
		if (OBJ2_MPI_OP(op)->len != OBJ2_MPI_SENTINEL(recvbuf)->i.length
			* OBJ2_MPI_SENTINEL(recvbuf)->i.type_size)
		    Pike_fatal("MPI: User defined MPI operation does not match data length with buffers (%d vs %d).\n",
			       OBJ2_MPI_OP(op)->len,
			       OBJ2_MPI_SENTINEL(recvbuf)->i.length
			       * OBJ2_MPI_SENTINEL(recvbuf)->i.type_size);
		if (OBJ2_MPI_OP(op)->shift != OBJ2_MPI_SENTINEL(recvbuf)->i.shift)
		    Pike_fatal("MPI: User defined MPI operation does not match shift with buffers (%d vs %d).\n",
			       OBJ2_MPI_OP(op)->shift,
			       OBJ2_MPI_SENTINEL(recvbuf)->i.shift);
		mpi_pike_user_function.bufprog = NULL;
		mpi_pike_user_function.op = op;
	    }
	}

	mpi_Reduce(sendbuf, recvbuf, OBJ2_MPI_OP(op)->op, root, THIS->comm);
	pop_n_elems(args);
    }





































    }
#define f_Comm_Allreduce_defined
DEFAULT_CMOD_STORAGE void f_Comm_Allreduce(INT32 args) {
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * sendbuf;
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int sendbuf_inh_num;
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * recvbuf;
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int recvbuf_inh_num;
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * op;
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int op_inh_num;
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 3) wrong_number_of_args_error("Allreduce",args,3);
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Allreduce",1,"object");
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(sendbuf=Pike_sp[0-3].u.object);
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
sendbuf_inh_num = SUBTYPEOF(Pike_sp[0-3]);
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[1-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Allreduce",2,"object");
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(recvbuf=Pike_sp[1-3].u.object);
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
recvbuf_inh_num = SUBTYPEOF(Pike_sp[1-3]);
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[2-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Allreduce",3,"object");
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(op=Pike_sp[2-3].u.object);
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
op_inh_num = SUBTYPEOF(Pike_sp[2-3]);
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{										using_mpi( "Allreduce" );							if (-1 == low_get_storage(op->prog, MPI_Op_program))			    SIMPLE_ARG_TYPE_ERROR( "Allreduce" , 3, "inherits(MPI.Op)");		ENSURE_SENTINEL(sendbuf,  "Allreduce" , 1);					ENSURE_SENTINEL(recvbuf,  "Allreduce" , 2);														if (OBJ2_MPI_OP(op)->refcnt) {						    assign_svalue_no_free(&mpi_pike_user_function.ufun,						  &OBJ2_MPI_OP(op)->ufun);				    sub_ref(mpi_pike_user_function.ufun.u.dummy);			    if (!OBJ2_MPI_OP(op)->create) {							mpi_pike_user_function.bufprog = recvbuf->prog;			    } else {									if (OBJ2_MPI_OP(op)->len != OBJ2_MPI_SENTINEL(recvbuf)->i.length			* OBJ2_MPI_SENTINEL(recvbuf)->i.type_size)				    Pike_fatal("MPI: User defined MPI operation does not match data length with buffers (%d vs %d).\n",			       OBJ2_MPI_OP(op)->len,						       OBJ2_MPI_SENTINEL(recvbuf)->i.length					       * OBJ2_MPI_SENTINEL(recvbuf)->i.type_size);			if (OBJ2_MPI_OP(op)->shift								!= OBJ2_MPI_SENTINEL(recvbuf)->i.shift)				    Pike_fatal("MPI: User defined MPI operation does not match shift with buffers (%d vs %d).\n",			       OBJ2_MPI_OP(op)->shift,						       OBJ2_MPI_SENTINEL(recvbuf)->i.shift);			mpi_pike_user_function.bufprog = NULL;					mpi_pike_user_function.op = op;					    }									}																		mpi_Allreduce (sendbuf, recvbuf, OBJ2_MPI_OP(op)->op, THIS->comm);		pop_n_elems(args);						    }
    }
#define f_Comm_Scan_defined
DEFAULT_CMOD_STORAGE void f_Comm_Scan(INT32 args) {
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * sendbuf;
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int sendbuf_inh_num;
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * recvbuf;
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int recvbuf_inh_num;
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * op;
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int op_inh_num;
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 3) wrong_number_of_args_error("Scan",args,3);
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Scan",1,"object");
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(sendbuf=Pike_sp[0-3].u.object);
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
sendbuf_inh_num = SUBTYPEOF(Pike_sp[0-3]);
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[1-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Scan",2,"object");
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(recvbuf=Pike_sp[1-3].u.object);
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
recvbuf_inh_num = SUBTYPEOF(Pike_sp[1-3]);
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[2-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Scan",3,"object");
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(op=Pike_sp[2-3].u.object);
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
op_inh_num = SUBTYPEOF(Pike_sp[2-3]);
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{										using_mpi( "Scan" );							if (-1 == low_get_storage(op->prog, MPI_Op_program))			    SIMPLE_ARG_TYPE_ERROR( "Scan" , 3, "inherits(MPI.Op)");		ENSURE_SENTINEL(sendbuf,  "Scan" , 1);					ENSURE_SENTINEL(recvbuf,  "Scan" , 2);														if (OBJ2_MPI_OP(op)->refcnt) {						    assign_svalue_no_free(&mpi_pike_user_function.ufun,						  &OBJ2_MPI_OP(op)->ufun);				    sub_ref(mpi_pike_user_function.ufun.u.dummy);			    if (!OBJ2_MPI_OP(op)->create) {							mpi_pike_user_function.bufprog = recvbuf->prog;			    } else {									if (OBJ2_MPI_OP(op)->len != OBJ2_MPI_SENTINEL(recvbuf)->i.length			* OBJ2_MPI_SENTINEL(recvbuf)->i.type_size)				    Pike_fatal("MPI: User defined MPI operation does not match data length with buffers (%d vs %d).\n",			       OBJ2_MPI_OP(op)->len,						       OBJ2_MPI_SENTINEL(recvbuf)->i.length					       * OBJ2_MPI_SENTINEL(recvbuf)->i.type_size);			if (OBJ2_MPI_OP(op)->shift								!= OBJ2_MPI_SENTINEL(recvbuf)->i.shift)				    Pike_fatal("MPI: User defined MPI operation does not match shift with buffers (%d vs %d).\n",			       OBJ2_MPI_OP(op)->shift,						       OBJ2_MPI_SENTINEL(recvbuf)->i.shift);			mpi_pike_user_function.bufprog = NULL;					mpi_pike_user_function.op = op;					    }									}																		mpi_Scan (sendbuf, recvbuf, OBJ2_MPI_OP(op)->op, THIS->comm);		pop_n_elems(args);						    }
    }
#define f_Comm_Exscan_defined
DEFAULT_CMOD_STORAGE void f_Comm_Exscan(INT32 args) {
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * sendbuf;
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int sendbuf_inh_num;
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * recvbuf;
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int recvbuf_inh_num;
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * op;
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int op_inh_num;
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 3) wrong_number_of_args_error("Exscan",args,3);
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Exscan",1,"object");
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(sendbuf=Pike_sp[0-3].u.object);
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
sendbuf_inh_num = SUBTYPEOF(Pike_sp[0-3]);
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[1-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Exscan",2,"object");
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(recvbuf=Pike_sp[1-3].u.object);
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
recvbuf_inh_num = SUBTYPEOF(Pike_sp[1-3]);
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[2-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Exscan",3,"object");
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(op=Pike_sp[2-3].u.object);
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
op_inh_num = SUBTYPEOF(Pike_sp[2-3]);
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{										using_mpi( "Exscan" );							if (-1 == low_get_storage(op->prog, MPI_Op_program))			    SIMPLE_ARG_TYPE_ERROR( "Exscan" , 3, "inherits(MPI.Op)");		ENSURE_SENTINEL(sendbuf,  "Exscan" , 1);					ENSURE_SENTINEL(recvbuf,  "Exscan" , 2);														if (OBJ2_MPI_OP(op)->refcnt) {						    assign_svalue_no_free(&mpi_pike_user_function.ufun,						  &OBJ2_MPI_OP(op)->ufun);				    sub_ref(mpi_pike_user_function.ufun.u.dummy);			    if (!OBJ2_MPI_OP(op)->create) {							mpi_pike_user_function.bufprog = recvbuf->prog;			    } else {									if (OBJ2_MPI_OP(op)->len != OBJ2_MPI_SENTINEL(recvbuf)->i.length			* OBJ2_MPI_SENTINEL(recvbuf)->i.type_size)				    Pike_fatal("MPI: User defined MPI operation does not match data length with buffers (%d vs %d).\n",			       OBJ2_MPI_OP(op)->len,						       OBJ2_MPI_SENTINEL(recvbuf)->i.length					       * OBJ2_MPI_SENTINEL(recvbuf)->i.type_size);			if (OBJ2_MPI_OP(op)->shift								!= OBJ2_MPI_SENTINEL(recvbuf)->i.shift)				    Pike_fatal("MPI: User defined MPI operation does not match shift with buffers (%d vs %d).\n",			       OBJ2_MPI_OP(op)->shift,						       OBJ2_MPI_SENTINEL(recvbuf)->i.shift);			mpi_pike_user_function.bufprog = NULL;					mpi_pike_user_function.op = op;					    }									}																		mpi_Exscan (sendbuf, recvbuf, OBJ2_MPI_OP(op)->op, THIS->comm);		pop_n_elems(args);						    }


















    }
#define f_Comm_Scatter_defined
DEFAULT_CMOD_STORAGE void f_Comm_Scatter(INT32 args) {
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * sendbuf;
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int sendbuf_inh_num;
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * recvbuf;
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int recvbuf_inh_num;
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE root;
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 3) wrong_number_of_args_error("Scatter",args,3);
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if (args > 0 &&
    (TYPEOF(Pike_sp[0-3]) != PIKE_T_INT ||
     Pike_sp[0-3].u.integer)) {
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Scatter",1,"object|void");
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(sendbuf=Pike_sp[0-3].u.object);
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
sendbuf_inh_num = SUBTYPEOF(Pike_sp[0-3]);
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else sendbuf = NULL;
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[1-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Scatter",2,"object");
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(recvbuf=Pike_sp[1-3].u.object);
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
recvbuf_inh_num = SUBTYPEOF(Pike_sp[1-3]);
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[2-3]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Scatter",3,"int");
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
root=Pike_sp[2-3].u.integer;
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{										using_mpi( "Scatter" );						ENSURE_SENTINEL_OR_NULL (sendbuf,  "Scatter" , 1); ENSURE_SENTINEL(recvbuf,  "Scatter" , 2);  										mpi_Scatter (sendbuf, recvbuf, root, THIS->comm);			pop_n_elems(args);						    }
    }
#define f_Comm_Gather_defined
DEFAULT_CMOD_STORAGE void f_Comm_Gather(INT32 args) {
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * sendbuf;
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int sendbuf_inh_num;
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * recvbuf;
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int recvbuf_inh_num;
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE root;
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 3) wrong_number_of_args_error("Gather",args,3);
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Gather",1,"object");
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(sendbuf=Pike_sp[0-3].u.object);
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
sendbuf_inh_num = SUBTYPEOF(Pike_sp[0-3]);
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if (args > 1 &&
    (TYPEOF(Pike_sp[1-3]) != PIKE_T_INT ||
     Pike_sp[1-3].u.integer)) {
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[1-3]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Gather",2,"object|void");
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(recvbuf=Pike_sp[1-3].u.object);
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
recvbuf_inh_num = SUBTYPEOF(Pike_sp[1-3]);
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else recvbuf = NULL;
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[2-3]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Gather",3,"int");
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
root=Pike_sp[2-3].u.integer;
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{										using_mpi( "Gather" );						ENSURE_SENTINEL(sendbuf,  "Gather" , 1); ENSURE_SENTINEL_OR_NULL (recvbuf,  "Gather" , 2);  										mpi_Gather (sendbuf, recvbuf, root, THIS->comm);			pop_n_elems(args);						    }





    }
#define f_Comm_Scatterv_defined
DEFAULT_CMOD_STORAGE void f_Comm_Scatterv(INT32 args) {
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * sendbuf;
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int sendbuf_inh_num;
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * counts;
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int counts_inh_num;
struct object * displ;
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int displ_inh_num;
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * recvbuf;
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int recvbuf_inh_num;
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE root;
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 5) wrong_number_of_args_error("Scatterv",args,5);
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if (args > 0 &&
    (TYPEOF(Pike_sp[0-5]) != PIKE_T_INT ||
     Pike_sp[0-5].u.integer)) {
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-5]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Scatterv",1,"object|void");
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(sendbuf=Pike_sp[0-5].u.object);
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
sendbuf_inh_num = SUBTYPEOF(Pike_sp[0-5]);
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else sendbuf = NULL;
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if (args > 1 &&
    (TYPEOF(Pike_sp[1-5]) != PIKE_T_INT ||
     Pike_sp[1-5].u.integer)) {
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[1-5]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Scatterv",2,"object|void");
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(counts=Pike_sp[1-5].u.object);
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
counts_inh_num = SUBTYPEOF(Pike_sp[1-5]);
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else counts = NULL;
if (args > 2 &&
    (TYPEOF(Pike_sp[2-5]) != PIKE_T_INT ||
     Pike_sp[2-5].u.integer)) {
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[2-5]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Scatterv",3,"object|void");
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(displ=Pike_sp[2-5].u.object);
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
displ_inh_num = SUBTYPEOF(Pike_sp[2-5]);
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else displ = NULL;
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[3-5]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Scatterv",4,"object");
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(recvbuf=Pike_sp[3-5].u.object);
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
recvbuf_inh_num = SUBTYPEOF(Pike_sp[3-5]);
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[4-5]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Scatterv",5,"int");
#line 1243 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
root=Pike_sp[4-5].u.integer;
{
	using_mpi("Scatterv");

	ENSURE_SENTINEL_OR_NULL(sendbuf, "Scatterv", 1);
	if (counts && -1 == low_get_storage(counts->prog, MPI_IntArray_program))
	    SIMPLE_ARG_TYPE_ERROR("Scatterv", 2, "inherits(MPI.IntArray)");
	if (displ && -1 == low_get_storage(displ->prog, MPI_IntArray_program))
	    SIMPLE_ARG_TYPE_ERROR("Scatterv", 3, "inherits(MPI.IntArray)");
	ENSURE_SENTINEL(recvbuf, "Scatterv", 4);

	mpi_Scatterv(sendbuf, counts, displ, recvbuf, root, THIS->comm);
	pop_n_elems(args);
    }

    }
#define f_Comm_Gatherv_defined
DEFAULT_CMOD_STORAGE void f_Comm_Gatherv(INT32 args) {
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * sendbuf;
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int sendbuf_inh_num;
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * recvbuf;
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int recvbuf_inh_num;
struct object * counts;
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int counts_inh_num;
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct object * displ;
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
int displ_inh_num;
INT_TYPE root;
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 5) wrong_number_of_args_error("Gatherv",args,5);
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-5]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Gatherv",1,"object");
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(sendbuf=Pike_sp[0-5].u.object);
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
sendbuf_inh_num = SUBTYPEOF(Pike_sp[0-5]);
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if (args > 1 &&
    (TYPEOF(Pike_sp[1-5]) != PIKE_T_INT ||
     Pike_sp[1-5].u.integer)) {
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[1-5]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Gatherv",2,"object|void");
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(recvbuf=Pike_sp[1-5].u.object);
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
recvbuf_inh_num = SUBTYPEOF(Pike_sp[1-5]);
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else recvbuf = NULL;
if (args > 2 &&
    (TYPEOF(Pike_sp[2-5]) != PIKE_T_INT ||
     Pike_sp[2-5].u.integer)) {
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[2-5]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Gatherv",3,"object|void");
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(counts=Pike_sp[2-5].u.object);
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
counts_inh_num = SUBTYPEOF(Pike_sp[2-5]);
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else counts = NULL;
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if (args > 3 &&
    (TYPEOF(Pike_sp[3-5]) != PIKE_T_INT ||
     Pike_sp[3-5].u.integer)) {
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[3-5]) != PIKE_T_OBJECT) SIMPLE_ARG_TYPE_ERROR("Gatherv",4,"object|void");
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
debug_malloc_pass(displ=Pike_sp[3-5].u.object);
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
displ_inh_num = SUBTYPEOF(Pike_sp[3-5]);
#line 1259 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
} else displ = NULL;
if((TYPEOF(Pike_sp[4-5]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Gatherv",5,"int");
#line 1260 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
root=Pike_sp[4-5].u.integer;
{
	using_mpi("Gatherv");
	ENSURE_SENTINEL(sendbuf, "Gatherv", 1);
	ENSURE_SENTINEL_OR_NULL(recvbuf, "Gatherv", 2);
	if (counts && -1 == low_get_storage(counts->prog, MPI_IntArray_program))
	    SIMPLE_ARG_TYPE_ERROR("Gatherv", 3, "inherits(MPI.IntArray)|void");
	if (displ && -1 == low_get_storage(displ->prog, MPI_IntArray_program))
	    SIMPLE_ARG_TYPE_ERROR("Gatherv", 4, "inherits(MPI.IntArray)|void");

	mpi_Gatherv(sendbuf, recvbuf, counts, displ, root, THIS->comm);
	pop_n_elems(args);
    }

    }
#define f_Comm_Abort_defined
DEFAULT_CMOD_STORAGE void f_Comm_Abort(INT32 args) {
#line 1274 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE errorcode;
#line 1274 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 1) wrong_number_of_args_error("Abort",args,1);
#line 1274 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[0-1]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Abort",1,"int");
#line 1274 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
errorcode=Pike_sp[0-1].u.integer;
{
	using_mpi("Abort");
	MPI_Abort(THIS->comm, errorcode);
	pop_n_elems(args);
    }

    }
#define f_Comm_Barrier_defined
DEFAULT_CMOD_STORAGE void f_Comm_Barrier(INT32 args) {
#line 1281 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 0) wrong_number_of_args_error("Barrier",args,0);
{
	using_mpi("Barrier");
	INVALIDATE_CURRENT_TIME();
	MPI_Barrier(THIS->comm);
    }

    }
#define f_Comm_cq__backtickrank_defined
DEFAULT_CMOD_STORAGE void f_Comm_cq__backtickrank(INT32 args) {
#line 1288 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 0) wrong_number_of_args_error("`rank",args,0);
{
	int rank;

	using_mpi("->rank");

	MPI_Comm_rank(THIS->comm, &rank);
	push_int(rank);
    }

    }
#define f_Comm_cq__backticksize_defined
DEFAULT_CMOD_STORAGE void f_Comm_cq__backticksize(INT32 args) {
#line 1298 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 0) wrong_number_of_args_error("`size",args,0);
{
	int size;

	using_mpi("->size");

	MPI_Comm_size(THIS->comm, &size);
	push_int(size);
    }

    }
#define f_Comm_dup_defined
DEFAULT_CMOD_STORAGE void f_Comm_dup(INT32 args) {
#line 1308 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 0) wrong_number_of_args_error("dup",args,0);
#line 1308 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
{
	MPI_Comm comm;
	struct object *o;

	using_mpi("dup");

	o = clone_object(MPI_Comm_program, 0);

	MPI_Comm_dup(THIS->comm, &comm);

	OBJ2_MPI_COMM(o)->comm = comm;

	do { struct object * ret_=(o);  push_object(ret_); return; }while(0);
#line 1321 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
}
}

#ifdef Comm_event_handler_defined
static void Comm_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_Comm_defined
  case PROG_EVENT_INIT: init_Comm_struct(); break;

#endif /* internal_init_Comm_defined */

#ifdef internal_exit_Comm_defined
  case PROG_EVENT_EXIT: exit_Comm_struct(); break;

#endif /* internal_exit_Comm_defined */
  default: break; 
  }
}

#endif /* Comm_event_handler_defined */

#ifdef THIS_

#undef THIS
#define THIS THIS_

#endif /* THIS_ */
/*! @endclass */

#line 1325 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
/* TODO: guard against multiple calls */
/*! @decl void Init()
 *! Initializes @[MPI]. @[MPI] in Pike will auto-initialize once the
 *! first @[MPI]-operation is called. You can call this function to
 *! initialize the parallel @[MPI] at a specific time, since
 *! initialization is a collective operation and will block the process
 *! until all member processes of the parallel program are present.
 *!
 *! @example
 *!int main() {
 *!	MPI.Init();
 *!	write("I am process %d of %d.\n", MPI.world->rank,
 *!	      MPI.world->size);
 *!	MPI.Finalize();
 *!	return 0;
 *!}
 *! @seealso
 *!	@[Finalize()], MPI_Init(3)
 */
#define f_Init_defined
DEFAULT_CMOD_STORAGE void f_Init(INT32 args) {
#line 1344 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 0) wrong_number_of_args_error("Init",args,0);
{
    int provided;

    if (mpi_status == mpi_FINALIZED)
	Pike_error("Cannot initialize MPI after MPI.Finalize()\n");
    else if (mpi_status)
	return;

    mpi_status = mpi_INITIALIZED;
    /* MPI Specification does not use &argc, &argv for anything, nor
     * operate on it in any other way. AFAIK this holds for all
     * implementations, but at least does for OpenMPI. */
    MPI_Init_thread(NULL, NULL, MPI_THREAD_MULTIPLE, &provided);
    if (provided != MPI_THREAD_MULTIPLE)
	Pike_fatal("MPI cannot deliver: %d vs %d.\n", MPI_THREAD_MULTIPLE, provided);
    return;
}


}
/*! @decl void Finalize()
 *! Cleans up the @[MPI] stack. Will be called automatically upon
 *! termination of the Pike program, but can be called explicitly
 *! when it is required that some of the parallel processes continue
 *! running and some terminate.
 *!
 *! @seealso
 *!	@[Init()], MPI_Finalize(3)
 */
#define f_Finalize_defined
DEFAULT_CMOD_STORAGE void f_Finalize(INT32 args) {
#line 1373 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 0) wrong_number_of_args_error("Finalize",args,0);
{
    if (mpi_status == mpi_FINALIZED)
	return;
    mpi_status = mpi_FINALIZED;
    MPI_Finalize();
}

}
/*! @decl Op Op_create(function(object,object:void) ufun, int commute)
 *! Creates a user-defined MPI operation.
 *!
 *! @param ufun
 *!	The function that implements the @[MPI.Op] to be created.
 *!
 *! @param commute
 *!	Set to @expr{1@} if the operation commutes.
 *!
 *! @example
 *!void my_add_fun(object invec, object outvec) {
 *!	for (int i = 0; i < sizeof(outvec); i++) {
 *!	outvec[i] += invec[i];
 *!}
 *!
 *!int main() {
 *!	MPI.Op myadd;
 *!	MPI.IntArray ia = MPI.IntArray(10), results;
 *!
 *!	MPI.Init();
 *!
 *!	myadd = MPI.Op_create(my_add_fun, 1);
 *!
 *!	for (int i = 0; i < sizeof(ia); i++)
 *!		ia[i] = random(1000);
 *!
 *!	if (!MPI.world->rank) results = MPI.IntArray(sizeof(ia));
 *!	MPI.world->Reduce(ia, results, 0);
 *!	if (!MPI.world->rank)
 *!		for (int i; i < sizeof(results); i++)
 *!			write("%02d: %d\n", i, results[i]);
 *!
 *!	MPI.Finalize();
 *!	return 0;
 *!}
 *!
 *! @note
 *!	User-defined MPI operations may @b{not@} call any MPI operations
 *!	themselves.
 *!
 *! @seealso
 *!	@[MPI.Comm->Reduce()], MPI_Op_create(3)
 */
#define f_Op_create_defined
DEFAULT_CMOD_STORAGE void f_Op_create(INT32 args) {
#line 1424 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
struct svalue * ufun;
#line 1424 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
INT_TYPE commute;
#line 1424 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(args != 2) wrong_number_of_args_error("Op_create",args,2);
#line 1424 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if(TYPEOF(Pike_sp[0-2]) != PIKE_T_FUNCTION) SIMPLE_ARG_TYPE_ERROR("Op_create",1,"function");
#line 1424 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
ufun=Pike_sp+0-2; dmalloc_touch_svalue(Pike_sp+0-2);
#line 1424 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
if((TYPEOF(Pike_sp[1-2]) != PIKE_T_INT)) SIMPLE_ARG_TYPE_ERROR("Op_create",2,"int");
#line 1424 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
commute=Pike_sp[1-2].u.integer;
{
    struct object *op;
    MPI_Op mpiop;
    unsigned int *refcnt = xalloc(sizeof(unsigned int));

    *refcnt = 1;

    MPI_Op_create(mpi_user_function, commute, &mpiop);
    op = mpi_clone_op(mpiop, refcnt);
    assign_svalue_no_free(&OBJ2_MPI_OP(op)->ufun, ufun);

    pop_n_elems(args);
    push_object(op);
}

}
#line 1440 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
PMOD_EXPORT struct object *mpi_ex_op(struct op_info (*create)(void *), struct svalue *ufun, int commute, void *info, int shift, int len) {
    struct object *o;
    MPI_Op mpiop;
    unsigned int *refcnt = xalloc(sizeof(unsigned int));

    *refcnt = 1;

    MPI_Op_create(mpi_user_function, commute, &mpiop);
    o = mpi_clone_op(mpiop, refcnt);
    OBJ2_MPI_OP(o)->create = create;
    OBJ2_MPI_OP(o)->info = info;
    OBJ2_MPI_OP(o)->shift = shift;
    OBJ2_MPI_OP(o)->len = len;
    assign_svalue_no_free(&OBJ2_MPI_OP(o)->ufun, ufun);

    return o;
}

PIKE_MODULE_INIT
{
    struct object *co;

    
#ifdef module_strings_declared
module_strings[0] = 
  make_shared_binary_string("array",
                            CONSTANT_STRLEN("array"));
module_strings[1] = 
  make_shared_binary_string("object",
                            CONSTANT_STRLEN("object"));
#endif

#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
set_program_id_to_id( ___cmod_map_program_ids );

#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */

#ifdef class_IntArray_defined

#ifdef PROG_INTARRAY_ID
#line 105 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  START_NEW_PROGRAM_ID(INTARRAY);
#else
#line 105 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  start_new_program();

#endif /* PROG_INTARRAY_ID */
#line 105 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  IntArray_program = Pike_compiler->new_program;

#ifndef tObjImpl_INTARRAY

#undef tObjIs_INTARRAY
#define tObjIs_INTARRAY "\3\1\177\0\0\2"

#undef tObjImpl_INTARRAY
#define tObjImpl_INTARRAY "\3\0\177\0\0\2"

#endif /* tObjImpl_INTARRAY */

#ifdef THIS_INTARRAY
  IntArray_storage_offset = ADD_STORAGE(struct IntArray_struct);
#endif /* THIS_INTARRAY */

#ifdef IntArray_event_handler_defined
  pike_set_prog_event_callback(IntArray_event_handler);

#ifndef IntArray_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* IntArray_gc_live_obj */

#endif /* IntArray_event_handler_defined */

#ifdef f_IntArray_create_defined

#ifdef f_IntArray_create_fun_num_used
  f_IntArray_create_fun_num =
#endif /* f_IntArray_create_fun_num_used */
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("create", f_IntArray_create, tFunc("\10\0\0\0\0\177\377\377\377",tVoid), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_IntArray_create_defined */

#ifdef f_IntArray_clear_defined

#ifdef f_IntArray_clear_fun_num_used
  f_IntArray_clear_fun_num =
#endif /* f_IntArray_clear_fun_num_used */
#line 26 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("clear", f_IntArray_clear, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_IntArray_clear_defined */

#ifdef f_IntArray_assign_defined

#ifdef f_IntArray_assign_fun_num_used
  f_IntArray_assign_fun_num =
#endif /* f_IntArray_assign_fun_num_used */
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("assign", f_IntArray_assign, tFunc(tObj,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_IntArray_assign_defined */

#ifdef f_IntArray_cq__backtick_5B_5D_defined

#ifdef f_IntArray_cq__backtick_5B_5D_fun_num_used
  f_IntArray_cq__backtick_5B_5D_fun_num =
#endif /* f_IntArray_cq__backtick_5B_5D_fun_num_used */
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`[]", f_IntArray_cq__backtick_5B_5D, tFunc("\10\200\0\0\0\177\377\377\377","\10\200\0\0\0\177\377\377\377"), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_IntArray_cq__backtick_5B_5D_defined */

#ifdef f_IntArray_cq__backtick_5B_5D_eq_defined

#ifdef f_IntArray_cq__backtick_5B_5D_eq_fun_num_used
  f_IntArray_cq__backtick_5B_5D_eq_fun_num =
#endif /* f_IntArray_cq__backtick_5B_5D_eq_fun_num_used */
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`[]=", f_IntArray_cq__backtick_5B_5D_eq, tFunc("\10\200\0\0\0\177\377\377\377" "\10\200\0\0\0\177\377\377\377","\10\200\0\0\0\177\377\377\377"), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_IntArray_cq__backtick_5B_5D_eq_defined */

#ifdef f_IntArray_sum_defined

#ifdef f_IntArray_sum_fun_num_used
  f_IntArray_sum_fun_num =
#endif /* f_IntArray_sum_fun_num_used */
#line 85 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("sum", f_IntArray_sum, tFunc(tNone,"\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_IntArray_sum_defined */

#ifdef f_IntArray_cq__sizeof_defined

#ifdef f_IntArray_cq__sizeof_fun_num_used
  f_IntArray_cq__sizeof_fun_num =
#endif /* f_IntArray_cq__sizeof_fun_num_used */
#line 106 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("_sizeof", f_IntArray_cq__sizeof, tFunc(tNone,"\10\200\0\0\0\177\377\377\377"), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_IntArray_cq__sizeof_defined */

#ifdef f_IntArray_cq__values_defined

#ifdef f_IntArray_cq__values_fun_num_used
  f_IntArray_cq__values_fun_num =
#endif /* f_IntArray_cq__values_fun_num_used */
#line 118 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("_values", f_IntArray_cq__values, tFunc(tNone,tArray), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_IntArray_cq__values_defined */

#ifdef f_IntArray_cast_defined

#ifdef f_IntArray_cast_fun_num_used
  f_IntArray_cast_fun_num =
#endif /* f_IntArray_cast_fun_num_used */
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("cast", f_IntArray_cast, tFunc(tStr,tMix), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_IntArray_cast_defined */
#line 105 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  IntArray_program=end_program();
#line 105 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#ifdef IntArray_program_fun_num_used
IntArray_program_fun_num=
#endif
 add_program_constant("IntArray",IntArray_program,0);

#endif /* class_IntArray_defined */

#ifdef class_FloatArray_defined

#ifdef PROG_FLOATARRAY_ID
#line 129 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  START_NEW_PROGRAM_ID(FLOATARRAY);
#else
#line 129 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  start_new_program();

#endif /* PROG_FLOATARRAY_ID */
#line 129 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  FloatArray_program = Pike_compiler->new_program;

#ifndef tObjImpl_FLOATARRAY

#undef tObjIs_FLOATARRAY
#define tObjIs_FLOATARRAY "\3\1\177\0\0\3"

#undef tObjImpl_FLOATARRAY
#define tObjImpl_FLOATARRAY "\3\0\177\0\0\3"

#endif /* tObjImpl_FLOATARRAY */

#ifdef THIS_FLOATARRAY
  FloatArray_storage_offset = ADD_STORAGE(struct FloatArray_struct);
#endif /* THIS_FLOATARRAY */

#ifdef FloatArray_event_handler_defined
  pike_set_prog_event_callback(FloatArray_event_handler);

#ifndef FloatArray_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* FloatArray_gc_live_obj */

#endif /* FloatArray_event_handler_defined */

#ifdef f_FloatArray_create_defined

#ifdef f_FloatArray_create_fun_num_used
  f_FloatArray_create_fun_num =
#endif /* f_FloatArray_create_fun_num_used */
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("create", f_FloatArray_create, tFunc("\10\0\0\0\0\177\377\377\377",tVoid), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_FloatArray_create_defined */

#ifdef f_FloatArray_clear_defined

#ifdef f_FloatArray_clear_fun_num_used
  f_FloatArray_clear_fun_num =
#endif /* f_FloatArray_clear_fun_num_used */
#line 26 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("clear", f_FloatArray_clear, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_FloatArray_clear_defined */

#ifdef f_FloatArray_assign_defined

#ifdef f_FloatArray_assign_fun_num_used
  f_FloatArray_assign_fun_num =
#endif /* f_FloatArray_assign_fun_num_used */
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("assign", f_FloatArray_assign, tFunc(tObj,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_FloatArray_assign_defined */

#ifdef f_FloatArray_cq__backtick_5B_5D_defined

#ifdef f_FloatArray_cq__backtick_5B_5D_fun_num_used
  f_FloatArray_cq__backtick_5B_5D_fun_num =
#endif /* f_FloatArray_cq__backtick_5B_5D_fun_num_used */
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`[]", f_FloatArray_cq__backtick_5B_5D, tFunc("\10\200\0\0\0\177\377\377\377",tFloat), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_FloatArray_cq__backtick_5B_5D_defined */

#ifdef f_FloatArray_cq__backtick_5B_5D_eq_defined

#ifdef f_FloatArray_cq__backtick_5B_5D_eq_fun_num_used
  f_FloatArray_cq__backtick_5B_5D_eq_fun_num =
#endif /* f_FloatArray_cq__backtick_5B_5D_eq_fun_num_used */
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`[]=", f_FloatArray_cq__backtick_5B_5D_eq, tFunc("\10\200\0\0\0\177\377\377\377" tFloat,tFloat), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_FloatArray_cq__backtick_5B_5D_eq_defined */

#ifdef f_FloatArray_sum_defined

#ifdef f_FloatArray_sum_fun_num_used
  f_FloatArray_sum_fun_num =
#endif /* f_FloatArray_sum_fun_num_used */
#line 85 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("sum", f_FloatArray_sum, tFunc(tNone,tFloat), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_FloatArray_sum_defined */

#ifdef f_FloatArray_cq__sizeof_defined

#ifdef f_FloatArray_cq__sizeof_fun_num_used
  f_FloatArray_cq__sizeof_fun_num =
#endif /* f_FloatArray_cq__sizeof_fun_num_used */
#line 106 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("_sizeof", f_FloatArray_cq__sizeof, tFunc(tNone,"\10\200\0\0\0\177\377\377\377"), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_FloatArray_cq__sizeof_defined */

#ifdef f_FloatArray_cq__values_defined

#ifdef f_FloatArray_cq__values_fun_num_used
  f_FloatArray_cq__values_fun_num =
#endif /* f_FloatArray_cq__values_fun_num_used */
#line 118 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("_values", f_FloatArray_cq__values, tFunc(tNone,tArray), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_FloatArray_cq__values_defined */

#ifdef f_FloatArray_cast_defined

#ifdef f_FloatArray_cast_fun_num_used
  f_FloatArray_cast_fun_num =
#endif /* f_FloatArray_cast_fun_num_used */
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("cast", f_FloatArray_cast, tFunc(tStr,tMix), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_FloatArray_cast_defined */
#line 129 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  FloatArray_program=end_program();
#line 129 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#ifdef FloatArray_program_fun_num_used
FloatArray_program_fun_num=
#endif
 add_program_constant("FloatArray",FloatArray_program,0);

#endif /* class_FloatArray_defined */

#ifdef class_SingleArray_defined

#ifdef PROG_SINGLEARRAY_ID
#line 153 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  START_NEW_PROGRAM_ID(SINGLEARRAY);
#else
#line 153 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  start_new_program();

#endif /* PROG_SINGLEARRAY_ID */
#line 153 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  SingleArray_program = Pike_compiler->new_program;

#ifndef tObjImpl_SINGLEARRAY

#undef tObjIs_SINGLEARRAY
#define tObjIs_SINGLEARRAY "\3\1\177\0\0\4"

#undef tObjImpl_SINGLEARRAY
#define tObjImpl_SINGLEARRAY "\3\0\177\0\0\4"

#endif /* tObjImpl_SINGLEARRAY */

#ifdef THIS_SINGLEARRAY
  SingleArray_storage_offset = ADD_STORAGE(struct SingleArray_struct);
#endif /* THIS_SINGLEARRAY */

#ifdef SingleArray_event_handler_defined
  pike_set_prog_event_callback(SingleArray_event_handler);

#ifndef SingleArray_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* SingleArray_gc_live_obj */

#endif /* SingleArray_event_handler_defined */

#ifdef f_SingleArray_create_defined

#ifdef f_SingleArray_create_fun_num_used
  f_SingleArray_create_fun_num =
#endif /* f_SingleArray_create_fun_num_used */
#line 9 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("create", f_SingleArray_create, tFunc("\10\0\0\0\0\177\377\377\377",tVoid), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_SingleArray_create_defined */

#ifdef f_SingleArray_clear_defined

#ifdef f_SingleArray_clear_fun_num_used
  f_SingleArray_clear_fun_num =
#endif /* f_SingleArray_clear_fun_num_used */
#line 26 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("clear", f_SingleArray_clear, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_SingleArray_clear_defined */

#ifdef f_SingleArray_assign_defined

#ifdef f_SingleArray_assign_fun_num_used
  f_SingleArray_assign_fun_num =
#endif /* f_SingleArray_assign_fun_num_used */
#line 39 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("assign", f_SingleArray_assign, tFunc(tObj,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_SingleArray_assign_defined */

#ifdef f_SingleArray_cq__backtick_5B_5D_defined

#ifdef f_SingleArray_cq__backtick_5B_5D_fun_num_used
  f_SingleArray_cq__backtick_5B_5D_fun_num =
#endif /* f_SingleArray_cq__backtick_5B_5D_fun_num_used */
#line 54 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`[]", f_SingleArray_cq__backtick_5B_5D, tFunc("\10\200\0\0\0\177\377\377\377",tFloat), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_SingleArray_cq__backtick_5B_5D_defined */

#ifdef f_SingleArray_cq__backtick_5B_5D_eq_defined

#ifdef f_SingleArray_cq__backtick_5B_5D_eq_fun_num_used
  f_SingleArray_cq__backtick_5B_5D_eq_fun_num =
#endif /* f_SingleArray_cq__backtick_5B_5D_eq_fun_num_used */
#line 72 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`[]=", f_SingleArray_cq__backtick_5B_5D_eq, tFunc("\10\200\0\0\0\177\377\377\377" tFloat,tFloat), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_SingleArray_cq__backtick_5B_5D_eq_defined */

#ifdef f_SingleArray_sum_defined

#ifdef f_SingleArray_sum_fun_num_used
  f_SingleArray_sum_fun_num =
#endif /* f_SingleArray_sum_fun_num_used */
#line 85 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("sum", f_SingleArray_sum, tFunc(tNone,tFloat), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_SingleArray_sum_defined */

#ifdef f_SingleArray_cq__sizeof_defined

#ifdef f_SingleArray_cq__sizeof_fun_num_used
  f_SingleArray_cq__sizeof_fun_num =
#endif /* f_SingleArray_cq__sizeof_fun_num_used */
#line 106 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("_sizeof", f_SingleArray_cq__sizeof, tFunc(tNone,"\10\200\0\0\0\177\377\377\377"), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_SingleArray_cq__sizeof_defined */

#ifdef f_SingleArray_cq__values_defined

#ifdef f_SingleArray_cq__values_fun_num_used
  f_SingleArray_cq__values_fun_num =
#endif /* f_SingleArray_cq__values_fun_num_used */
#line 118 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("_values", f_SingleArray_cq__values, tFunc(tNone,tArray), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_SingleArray_cq__values_defined */

#ifdef f_SingleArray_cast_defined

#ifdef f_SingleArray_cast_fun_num_used
  f_SingleArray_cast_fun_num =
#endif /* f_SingleArray_cast_fun_num_used */
#line 142 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("cast", f_SingleArray_cast, tFunc(tStr,tMix), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_SingleArray_cast_defined */
#line 153 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  SingleArray_program=end_program();
#line 153 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#ifdef SingleArray_program_fun_num_used
SingleArray_program_fun_num=
#endif
 add_program_constant("SingleArray",SingleArray_program,0);

#endif /* class_SingleArray_defined */

#ifdef class_Status_defined

#ifdef PROG_STATUS_ID
#line 181 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  START_NEW_PROGRAM_ID(STATUS);
#else
#line 181 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  start_new_program();

#endif /* PROG_STATUS_ID */
#line 181 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  Status_program = Pike_compiler->new_program;

#ifndef tObjImpl_STATUS

#undef tObjIs_STATUS
#define tObjIs_STATUS "\3\1\177\0\0\5"

#undef tObjImpl_STATUS
#define tObjImpl_STATUS "\3\0\177\0\0\5"

#endif /* tObjImpl_STATUS */

#ifdef THIS_STATUS
  Status_storage_offset = ADD_STORAGE(struct Status_struct);
#endif /* THIS_STATUS */

#ifdef f_Status_cq__backtickSOURCE_defined

#ifdef f_Status_cq__backtickSOURCE_fun_num_used
  f_Status_cq__backtickSOURCE_fun_num =
#endif /* f_Status_cq__backtickSOURCE_fun_num_used */
#line 208 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`SOURCE", f_Status_cq__backtickSOURCE, tFunc(tNone,"\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Status_cq__backtickSOURCE_defined */

#ifdef f_Status_cq__backtickTAG_defined

#ifdef f_Status_cq__backtickTAG_fun_num_used
  f_Status_cq__backtickTAG_fun_num =
#endif /* f_Status_cq__backtickTAG_fun_num_used */
#line 219 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`TAG", f_Status_cq__backtickTAG, tFunc(tNone,"\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Status_cq__backtickTAG_defined */
#line 181 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  Status_program=end_program();
#line 181 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#ifdef Status_program_fun_num_used
Status_program_fun_num=
#endif
 add_program_constant("Status",Status_program,0);

#endif /* class_Status_defined */

#ifdef class_Sentinel_defined

#ifdef PROG_SENTINEL_ID
#line 236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  START_NEW_PROGRAM_ID(SENTINEL);
#else
#line 236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  start_new_program();

#endif /* PROG_SENTINEL_ID */
#line 236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  Sentinel_program = Pike_compiler->new_program;

#ifndef tObjImpl_SENTINEL

#undef tObjIs_SENTINEL
#define tObjIs_SENTINEL "\3\1\177\0\0\6"

#undef tObjImpl_SENTINEL
#define tObjImpl_SENTINEL "\3\0\177\0\0\6"

#endif /* tObjImpl_SENTINEL */

#ifdef THIS_SENTINEL
  Sentinel_storage_offset = ADD_STORAGE(struct Sentinel_struct);
#endif /* THIS_SENTINEL */

#ifdef Sentinel_event_handler_defined
  pike_set_prog_event_callback(Sentinel_event_handler);

#ifndef Sentinel_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Sentinel_gc_live_obj */

#endif /* Sentinel_event_handler_defined */
#line 236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  Sentinel_program=end_program();
#line 236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#ifdef Sentinel_program_fun_num_used
Sentinel_program_fun_num=
#endif
 add_program_constant("Sentinel",Sentinel_program,0);

#endif /* class_Sentinel_defined */

#ifdef class_Op_defined

#ifdef PROG_OP_ID
#line 288 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  START_NEW_PROGRAM_ID(OP);
#else
#line 288 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  start_new_program();

#endif /* PROG_OP_ID */
#line 288 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  Op_program = Pike_compiler->new_program;

#ifndef tObjImpl_OP

#undef tObjIs_OP
#define tObjIs_OP "\3\1\177\0\0\a"

#undef tObjImpl_OP
#define tObjImpl_OP "\3\0\177\0\0\a"

#endif /* tObjImpl_OP */

#ifdef THIS_OP
  Op_storage_offset = ADD_STORAGE(struct Op_struct);
#endif /* THIS_OP */

#ifdef Op_event_handler_defined
  pike_set_prog_event_callback(Op_event_handler);

#ifndef Op_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Op_gc_live_obj */

#endif /* Op_event_handler_defined */
#line 288 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  Op_program=end_program();
#line 288 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#ifdef Op_program_fun_num_used
Op_program_fun_num=
#endif
 add_program_constant("Op",Op_program,0);

#endif /* class_Op_defined */

#ifdef class_Pointer_defined

#ifdef PROG_POINTER_ID
#line 907 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  START_NEW_PROGRAM_ID(POINTER);
#else
#line 907 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  start_new_program();

#endif /* PROG_POINTER_ID */
#line 907 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  Pointer_program = Pike_compiler->new_program;

#ifndef tObjImpl_POINTER

#undef tObjIs_POINTER
#define tObjIs_POINTER "\3\1\177\0\0\b"

#undef tObjImpl_POINTER
#define tObjImpl_POINTER "\3\0\177\0\0\b"

#endif /* tObjImpl_POINTER */

#ifdef THIS_POINTER
  Pointer_storage_offset = ADD_STORAGE(struct Pointer_struct);
#endif /* THIS_POINTER */

#ifdef Pointer_event_handler_defined
  pike_set_prog_event_callback(Pointer_event_handler);

#ifndef Pointer_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Pointer_gc_live_obj */

#endif /* Pointer_event_handler_defined */

#ifdef f_Pointer_create_defined

#ifdef f_Pointer_create_fun_num_used
  f_Pointer_create_fun_num =
#endif /* f_Pointer_create_fun_num_used */
#line 917 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("create", f_Pointer_create, tFunc(tOr(tMix,tVoid),tVoid), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Pointer_create_defined */

#ifdef f_Pointer_cq__backtick_28_29_defined

#ifdef Pointer_f_Pointer_cq__backtick_28_29_fun_num_used
  Pointer_f_Pointer_cq__backtick_28_29_fun_num =
#endif /* Pointer_f_Pointer_cq__backtick_28_29_fun_num_used */
#line 935 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`()", f_Pointer_cq__backtick_28_29, tOr(tFunc(tNone,tMix),tFunc(tMix,tMix)), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Pointer_cq__backtick_28_29_defined */
#line 907 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  Pointer_program=end_program();
#line 907 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#ifdef Pointer_program_fun_num_used
Pointer_program_fun_num=
#endif
 add_program_constant("Pointer",Pointer_program,0);

#endif /* class_Pointer_defined */

#ifdef class_Comm_defined

#ifdef PROG_COMM_ID
#line 958 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  START_NEW_PROGRAM_ID(COMM);
#else
#line 958 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  start_new_program();

#endif /* PROG_COMM_ID */
#line 958 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  Comm_program = Pike_compiler->new_program;

#ifndef tObjImpl_COMM

#undef tObjIs_COMM
#define tObjIs_COMM "\3\1\177\0\0\t"

#undef tObjImpl_COMM
#define tObjImpl_COMM "\3\0\177\0\0\t"

#endif /* tObjImpl_COMM */

#ifdef THIS_COMM
  Comm_storage_offset = ADD_STORAGE(struct Comm_struct);
#endif /* THIS_COMM */

#ifdef Comm_event_handler_defined
  pike_set_prog_event_callback(Comm_event_handler);

#ifndef Comm_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Comm_gc_live_obj */

#endif /* Comm_event_handler_defined */

#ifdef f_Comm_Send_defined

#ifdef Comm_f_Comm_Send_fun_num_used
  Comm_f_Comm_Send_fun_num =
#endif /* Comm_f_Comm_Send_fun_num_used */
#line 1018 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Send", f_Comm_Send, tOr(tFunc(tStr "\10\200\0\0\0\177\377\377\377" tOr("\10\200\0\0\0\177\377\377\377",tVoid),tVoid),tFunc(tObj "\10\200\0\0\0\177\377\377\377" tOr("\10\200\0\0\0\177\377\377\377",tVoid),tVoid)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Send_defined */

#ifdef f_Comm_Recv_defined

#ifdef f_Comm_Recv_fun_num_used
  f_Comm_Recv_fun_num =
#endif /* f_Comm_Recv_fun_num_used */
#line 1076 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Recv", f_Comm_Recv, tFunc(tObj "\10\200\0\0\0\177\377\377\377" tOr("\10\200\0\0\0\177\377\377\377",tVoid) tOr(tObj,tVoid),tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Recv_defined */

#ifdef f_Comm_Bcast_defined

#ifdef Comm_f_Comm_Bcast_fun_num_used
  Comm_f_Comm_Bcast_fun_num =
#endif /* Comm_f_Comm_Bcast_fun_num_used */
#line 1117 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Bcast", f_Comm_Bcast, tOr(tFunc(tStr "\10\200\0\0\0\177\377\377\377",tVoid),tFunc(tObj "\10\200\0\0\0\177\377\377\377",tVoid)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Bcast_defined */

#ifdef f_Comm_Reduce_defined

#ifdef f_Comm_Reduce_fun_num_used
  f_Comm_Reduce_fun_num =
#endif /* f_Comm_Reduce_fun_num_used */
#line 1139 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Reduce", f_Comm_Reduce, tFunc(tObj tObj tObj "\10\200\0\0\0\177\377\377\377",tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Reduce_defined */

#ifdef f_Comm_Allreduce_defined

#ifdef f_Comm_Allreduce_fun_num_used
  f_Comm_Allreduce_fun_num =
#endif /* f_Comm_Allreduce_fun_num_used */
#line 1214 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Allreduce", f_Comm_Allreduce, tFunc(tObj tObj tObj,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Allreduce_defined */

#ifdef f_Comm_Scan_defined

#ifdef f_Comm_Scan_fun_num_used
  f_Comm_Scan_fun_num =
#endif /* f_Comm_Scan_fun_num_used */
#line 1215 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Scan", f_Comm_Scan, tFunc(tObj tObj tObj,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Scan_defined */

#ifdef f_Comm_Exscan_defined

#ifdef f_Comm_Exscan_fun_num_used
  f_Comm_Exscan_fun_num =
#endif /* f_Comm_Exscan_fun_num_used */
#line 1216 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Exscan", f_Comm_Exscan, tFunc(tObj tObj tObj,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Exscan_defined */

#ifdef f_Comm_Scatter_defined

#ifdef f_Comm_Scatter_fun_num_used
  f_Comm_Scatter_fun_num =
#endif /* f_Comm_Scatter_fun_num_used */
#line 1235 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Scatter", f_Comm_Scatter, tFunc(tOr(tObj,tVoid) tObj "\10\200\0\0\0\177\377\377\377",tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Scatter_defined */

#ifdef f_Comm_Gather_defined

#ifdef f_Comm_Gather_fun_num_used
  f_Comm_Gather_fun_num =
#endif /* f_Comm_Gather_fun_num_used */
#line 1236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Gather", f_Comm_Gather, tFunc(tObj tOr(tObj,tVoid) "\10\200\0\0\0\177\377\377\377",tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Gather_defined */

#ifdef f_Comm_Scatterv_defined

#ifdef f_Comm_Scatterv_fun_num_used
  f_Comm_Scatterv_fun_num =
#endif /* f_Comm_Scatterv_fun_num_used */
#line 1242 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Scatterv", f_Comm_Scatterv, tFunc(tOr(tObj,tVoid) tOr(tObj,tVoid) tOr(tObj,tVoid) tObj "\10\200\0\0\0\177\377\377\377",tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Scatterv_defined */

#ifdef f_Comm_Gatherv_defined

#ifdef f_Comm_Gatherv_fun_num_used
  f_Comm_Gatherv_fun_num =
#endif /* f_Comm_Gatherv_fun_num_used */
#line 1258 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Gatherv", f_Comm_Gatherv, tFunc(tObj tOr(tObj,tVoid) tOr(tObj,tVoid) tOr(tObj,tVoid) "\10\200\0\0\0\177\377\377\377",tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Gatherv_defined */

#ifdef f_Comm_Abort_defined

#ifdef f_Comm_Abort_fun_num_used
  f_Comm_Abort_fun_num =
#endif /* f_Comm_Abort_fun_num_used */
#line 1274 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Abort", f_Comm_Abort, tFunc("\10\200\0\0\0\177\377\377\377",tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Abort_defined */

#ifdef f_Comm_Barrier_defined

#ifdef f_Comm_Barrier_fun_num_used
  f_Comm_Barrier_fun_num =
#endif /* f_Comm_Barrier_fun_num_used */
#line 1281 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Barrier", f_Comm_Barrier, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_Barrier_defined */

#ifdef f_Comm_cq__backtickrank_defined

#ifdef f_Comm_cq__backtickrank_fun_num_used
  f_Comm_cq__backtickrank_fun_num =
#endif /* f_Comm_cq__backtickrank_fun_num_used */
#line 1288 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`rank", f_Comm_cq__backtickrank, tFunc(tNone,"\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_cq__backtickrank_defined */

#ifdef f_Comm_cq__backticksize_defined

#ifdef f_Comm_cq__backticksize_fun_num_used
  f_Comm_cq__backticksize_fun_num =
#endif /* f_Comm_cq__backticksize_fun_num_used */
#line 1298 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("`size", f_Comm_cq__backticksize, tFunc(tNone,"\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_cq__backticksize_defined */

#ifdef f_Comm_dup_defined

#ifdef f_Comm_dup_fun_num_used
  f_Comm_dup_fun_num =
#endif /* f_Comm_dup_fun_num_used */
#line 1308 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("dup", f_Comm_dup, tFunc(tNone,tObj), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Comm_dup_defined */
#line 958 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
  Comm_program=end_program();
#line 958 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
#ifdef Comm_program_fun_num_used
Comm_program_fun_num=
#endif
 add_program_constant("Comm",Comm_program,0);

#endif /* class_Comm_defined */

#ifdef f_Init_defined

#ifdef f_Init_fun_num_used
  f_Init_fun_num =
#endif /* f_Init_fun_num_used */
#line 1344 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Init", f_Init, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Init_defined */

#ifdef f_Finalize_defined

#ifdef f_Finalize_fun_num_used
  f_Finalize_fun_num =
#endif /* f_Finalize_fun_num_used */
#line 1373 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Finalize", f_Finalize, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Finalize_defined */

#ifdef f_Op_create_defined

#ifdef f_Op_create_fun_num_used
  f_Op_create_fun_num =
#endif /* f_Op_create_fun_num_used */
#line 1424 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    ADD_FUNCTION2("Op_create", f_Op_create, tFunc(tFuncV(tNone,tMix,tAny) "\10\200\0\0\0\177\377\377\377",tObj), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Op_create_defined */

#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
set_program_id_to_id( 0 );
#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */
#line 1462 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
;

    ADD_INT_CONSTANT("ANY_SOURCE", MPI_ANY_SOURCE, 0);
    ADD_INT_CONSTANT("ANY_TAG", MPI_ANY_TAG, 0);
    add_object_constant("world", co = clone_object(MPI_Comm_program, 0), 0);
    OBJ2_MPI_COMM(co)->comm = MPI_COMM_WORLD;

#define EXPORT_OP(_op_) add_object_constant(		\
	#_op_, mpi_clone_op(MPI_ ## _op_, NULL), 0);
    EXPORT_OP(MAX)
    EXPORT_OP(MIN)
    EXPORT_OP(SUM)
    EXPORT_OP(PROD)
    EXPORT_OP(LAND)
    EXPORT_OP(BAND)
    EXPORT_OP(LOR)
    EXPORT_OP(BOR)
    EXPORT_OP(LXOR)
    EXPORT_OP(BXOR)
    EXPORT_OP(MAXLOC)
    EXPORT_OP(MINLOC)
#undef EXPORT_OP
}

PIKE_MODULE_EXIT
{
    
#ifdef class_IntArray_defined
  if(IntArray_program) {
#line 105 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    free_program(IntArray_program);
    IntArray_program=0;
  }

#endif /* class_IntArray_defined */

#ifdef class_FloatArray_defined
  if(FloatArray_program) {
#line 129 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    free_program(FloatArray_program);
    FloatArray_program=0;
  }

#endif /* class_FloatArray_defined */

#ifdef class_SingleArray_defined
  if(SingleArray_program) {
#line 153 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    free_program(SingleArray_program);
    SingleArray_program=0;
  }

#endif /* class_SingleArray_defined */

#ifdef class_Status_defined
  if(Status_program) {
#line 181 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    free_program(Status_program);
    Status_program=0;
  }

#endif /* class_Status_defined */

#ifdef class_Sentinel_defined
  if(Sentinel_program) {
#line 236 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    free_program(Sentinel_program);
    Sentinel_program=0;
  }

#endif /* class_Sentinel_defined */

#ifdef class_Op_defined
  if(Op_program) {
#line 288 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    free_program(Op_program);
    Op_program=0;
  }

#endif /* class_Op_defined */

#ifdef class_Pointer_defined
  if(Pointer_program) {
#line 907 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    free_program(Pointer_program);
    Pointer_program=0;
  }

#endif /* class_Pointer_defined */

#ifdef class_Comm_defined
  if(Comm_program) {
#line 958 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
    free_program(Comm_program);
    Comm_program=0;
  }

#endif /* class_Comm_defined */

#ifdef module_strings_declared
{
  int i;
  for(i=0; i < 2; i++) {
    if (module_strings[i]) free_string(module_strings[i]);
    module_strings[i] = NULL;
  }
}
#endif
#line 1488 "/Users/hww3/devel/pike/src/modules/MPI/mpi.cmod"
;

    if (mpi_status == mpi_INITIALIZED) {
	mpi_status = mpi_FINALIZED;
	MPI_Finalize();
    }
} 

/*! @endmodule */


#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
static int ___cmod_map_program_ids(int id)
{
  if( (id&0x7f000000) != 0x7f000000 ) return id;
  id = id&0x00ffffff;
  switch(id) {
#ifdef class_IntArray_defined
  case 2:
    return IntArray_program->id;
    break;
#endif
#ifdef class_FloatArray_defined
  case 3:
    return FloatArray_program->id;
    break;
#endif
#ifdef class_SingleArray_defined
  case 4:
    return SingleArray_program->id;
    break;
#endif
#ifdef class_Status_defined
  case 5:
    return Status_program->id;
    break;
#endif
#ifdef class_Sentinel_defined
  case 6:
    return Sentinel_program->id;
    break;
#endif
#ifdef class_Op_defined
  case 7:
    return Op_program->id;
    break;
#endif
#ifdef class_Pointer_defined
  case 8:
    return Pointer_program->id;
    break;
#endif
#ifdef class_Comm_defined
  case 9:
    return Comm_program->id;
    break;
#endif
  };

  return 0;
}
#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */
