/* This provides a few of the MPI-uni functions that cannot be implemented with C macros */ #include #if !defined(__MPIUNI_H) #error "Wrong mpi.h included! require mpi.h from MPIUNI" #endif #if !defined(PETSC_STDCALL) #define PETSC_STDCALL #endif #include #if defined(PETSC_HAVE_STDLIB_H) #include #endif #define MPI_SUCCESS 0 #define MPI_FAILURE 1 void *MPIUNI_TMP = 0; int MPIUNI_DATASIZE[10] = {sizeof(int),sizeof(float),sizeof(double),2*sizeof(double),sizeof(char),2*sizeof(int),4*sizeof(double),4,8,2*sizeof(double)}; /* With MPI Uni there is only one communicator, which is called 1. */ #define MAX_ATTR 128 typedef struct { void *extra_state; void *attribute_val; int active; MPI_Delete_function *del; } MPI_Attr; static MPI_Attr attr[MAX_ATTR]; static int num_attr = 1,mpi_tag_ub = 100000000; #if defined(__cplusplus) extern "C" { #endif /* To avoid problems with prototypes to the system memcpy() it is duplicated here */ int MPIUNI_Memcpy(void *a,const void* b,int n) { int i; char *aa= (char*)a; char *bb= (char*)b; for (i=0; i= MAX_ATTR) MPI_Abort(MPI_COMM_WORLD,1); attr[num_attr].extra_state = extra_state; attr[num_attr].del = delete_fn; *keyval = num_attr++; return 0; } int MPI_Keyval_free(int *keyval) { attr[*keyval].active = 0; return MPI_SUCCESS; } int MPI_Attr_put(MPI_Comm comm,int keyval,void *attribute_val) { attr[keyval].active = 1; attr[keyval].attribute_val = attribute_val; return MPI_SUCCESS; } int MPI_Attr_delete(MPI_Comm comm,int keyval) { if (attr[keyval].active && attr[keyval].del) { void* save_attribute_val = attr[keyval].attribute_val; attr[keyval].active = 0; attr[keyval].attribute_val = 0; (*(attr[keyval].del))(comm,keyval,save_attribute_val,attr[keyval].extra_state); } return MPI_SUCCESS; } int MPI_Attr_get(MPI_Comm comm,int keyval,void *attribute_val,int *flag) { if (!keyval) Keyval_setup(); *flag = attr[keyval].active; *(void **)attribute_val = attr[keyval].attribute_val; return MPI_SUCCESS; } int MPI_Comm_create(MPI_Comm comm,MPI_Group group,MPI_Comm *newcomm) { *newcomm = comm; return MPI_SUCCESS; } static int dups = 0; int MPI_Comm_dup(MPI_Comm comm,MPI_Comm *out) { *out = comm; dups++; return 0; } int MPI_Comm_free(MPI_Comm *comm) { int i; if (--dups) return MPI_SUCCESS; for (i=0; i