Beispiel #1
0
Datei: notify.c Projekt: rolk/ug
void NotifyInit (void)
{
  /* allocate memory */
  theRouting = (int *) AllocFix(procs*sizeof(int));
  if (theRouting==NULL)
  {
    DDD_PrintError('E', 6301, STR_NOMEM " in NotifyInit");
    HARD_EXIT;
  }


  maxInfos = MAX_INFOS;                 /* TODO maximum value, just for testing */


  /* init local array for all Info records */
  allInfoBuffer = (NOTIFY_INFO *) AllocFix(maxInfos*sizeof(NOTIFY_INFO));
  if (allInfoBuffer==NULL)
  {
    DDD_PrintError('E', 6300, STR_NOMEM " in NotifyInit");
    HARD_EXIT;
  }


  /* allocate array of NOTIFY_DESCs */
  if (procs>1)
  {
    theDescs = (NOTIFY_DESC *) AllocTmp(sizeof(NOTIFY_DESC)*(procs-1));
  }
  else
  {
    theDescs = NULL;
  }
}
Beispiel #2
0
Datei: supp.c Projekt: rolk/ug
END_UGDIM_NAMESPACE

#include "xfer.h"

START_UGDIM_NAMESPACE

#ifdef XferMemFromHeap
void *xfer_AllocHeap (size_t size)
{
  void *buffer;

  if (xferGlobals.useHeap)
  {
    buffer = AllocHeap(size, xferGlobals.theMarkKey);
  }
  else
  {
    buffer = AllocTmp(size);
  }

  return(buffer);
}
Beispiel #3
0
cg_name         CmplxAddr( cg_name real, cg_name imag ) {
//=======================================================

// Pass a complex value to a subprogram.

    tmp_handle  tmp;
    cg_type     typ;
    cg_type     c_type;

    typ = CGType( real );
    if( typ == TY_SINGLE ) {
        c_type = TY_COMPLEX;
    } else if( typ == TY_DOUBLE ) {
        c_type = TY_DCOMPLEX;
    } else {
        c_type = TY_XCOMPLEX;
    }
    tmp = AllocTmp( c_type );
    CGTrash( CGAssign( TmpPtr( tmp, c_type ), real, typ ) );
    CGTrash( CGAssign( ImagPtr( TmpPtr( tmp, c_type ), typ ), imag, typ ) );
    return( TmpPtr( tmp, c_type ) );
}
Beispiel #4
0
Datei: jcmds.c Projekt: rolk/ug
static int PreparePhase3Msgs (JIAddCplPtrArray *arrayAddCpl,
                              JOINMSG3 **theMsgs, size_t *memUsage)
{
    int i, last_i, nMsgs;
    JIAddCpl **itemsAC = JIAddCplPtrArray_GetData(arrayAddCpl);
    int nAC       = JIAddCplPtrArray_GetSize(arrayAddCpl);

#       if DebugJoin<=3
    printf("%4d: PreparePhase3Msgs, nAddCpls=%d\n",
           me, nAC);
    fflush(stdout);
#       endif

    /* init return parameters */
    *theMsgs = NULL;
    *memUsage = 0;


    if (nAC==0)
        /* no messages */
        return(0);


    nMsgs = 0;
    last_i = i = 0;
    do
    {
        JOINMSG3  *jm;
        size_t bufSize;

        /* skip until dest-processor is different */
        while (i<nAC && (itemsAC[i]->dest == itemsAC[last_i]->dest))
            i++;

        /* create new message */
        jm = (JOINMSG3 *) AllocTmp(sizeof(JOINMSG3));
        if (jm==NULL)
        {
            DDD_PrintError('E', 7902, STR_NOMEM " in PreparePhase3Msgs");
            HARD_EXIT;
        }
        jm->nAddCpls = i-last_i;
        jm->arrayAddCpl = &(itemsAC[last_i]);
        jm->dest = itemsAC[last_i]->dest;
        jm->next = *theMsgs;
        *theMsgs = jm;
        nMsgs++;

        /* create new send message */
        jm->msg_h = LC_NewSendMsg(joinGlobals.phase3msg_t, jm->dest);

        /* init table inside message */
        LC_SetTableSize(jm->msg_h, joinGlobals.cpltab_id, jm->nAddCpls);

        /* prepare message for sending away */
        bufSize = LC_MsgPrepareSend(jm->msg_h);
        *memUsage += bufSize;

        if (DDD_GetOption(OPT_INFO_JOIN) & JOIN_SHOW_MEMUSAGE)
        {
            sprintf(cBuffer,
                    "DDD MESG [%03d]: SHOW_MEM "
                    "send msg phase3   dest=%04d size=%010ld\n",
                    me, jm->dest, (long)bufSize);
            DDD_PrintLine(cBuffer);
        }

        last_i = i;

    } while (last_i < nAC);

    return(nMsgs);
}
Beispiel #5
0
Datei: jcmds.c Projekt: rolk/ug
static void UnpackPhase1Msgs (LC_MSGHANDLE *theMsgs, int nRecvMsgs,
                              DDD_HDR *localCplObjs, int nLCO,
                              JIPartner **p_joinObjs, int *p_nJoinObjs)
{
    JIPartner *joinObjs;
    int nJoinObjs = 0;
    int m, jo;

    /* init return values */
    *p_joinObjs  = NULL;
    *p_nJoinObjs = 0;


    for(m=0; m<nRecvMsgs; m++)
    {
        LC_MSGHANDLE jm = theMsgs[m];
        TEJoin *theJoin = (TEJoin *) LC_GetPtr(jm, joinGlobals.jointab_id);
        int nJ       = (int) LC_GetTableLen(jm, joinGlobals.jointab_id);
        int i, j;

        nJoinObjs += nJ;

        for(i=0, j=0; i<nJ; i++)
        {
            while ((j<nLCO) && (OBJ_GID(localCplObjs[j]) < theJoin[i].gid))
                j++;

            if ((j<nLCO) && (OBJ_GID(localCplObjs[j])==theJoin[i].gid))
            {
                COUPLING *cpl;

                /* found local object which is join target */
                /* store shortcut to local object */
                theJoin[i].hdr = localCplObjs[j];

                /* generate phase2-JIAddCpl for this object */
                for(cpl=ObjCplList(localCplObjs[j]); cpl!=NULL; cpl=CPL_NEXT(cpl))
                {
                    JIAddCpl *ji = JIAddCplSet_NewItem(joinGlobals.setJIAddCpl2);
                    ji->dest    = CPL_PROC(cpl);
                    ji->te.gid  = theJoin[i].gid;
                    ji->te.proc = LC_MsgGetProc(jm);
                    ji->te.prio = theJoin[i].prio;

                    if (! JIAddCplSet_ItemOK(joinGlobals.setJIAddCpl2))
                        continue;

#                                       if DebugJoin<=1
                    printf("%4d: Phase1 Join for %08x from %d, "
                           "send AddCpl to %d.\n",
                           me, theJoin[i].gid, ji->te.proc, ji->dest);
#                                       endif

                }

                /* send phase3-JIAddCpl back to Join-proc */
                for(cpl=ObjCplList(localCplObjs[j]); cpl!=NULL; cpl=CPL_NEXT(cpl))
                {
                    JIAddCpl *ji = JIAddCplSet_NewItem(joinGlobals.setJIAddCpl3);
                    ji->dest    = LC_MsgGetProc(jm);
                    ji->te.gid  = OBJ_GID(localCplObjs[j]);
                    ji->te.proc = CPL_PROC(cpl);
                    ji->te.prio = cpl->prio;

                    if (! JIAddCplSet_ItemOK(joinGlobals.setJIAddCpl3))
                        continue;
                }
            }
            else
            {
                sprintf(cBuffer, "no object %08x for join from %d",
                        theJoin[i].gid, LC_MsgGetProc(jm));
                DDD_PrintError('E', 7300, cBuffer);
                HARD_EXIT;
            }
        }
    }


    /* return immediately if no join-objects have been found */
    if (nJoinObjs==0)
        return;


    /* allocate array of objects, which has been contacted by a join */
    joinObjs = (JIPartner *) AllocTmp(sizeof(JIPartner) * nJoinObjs);
    if (joinObjs==NULL)
    {
        DDD_PrintError('E', 7903, STR_NOMEM " in UnpackPhase1Msgs");
        HARD_EXIT;
    }

    /* set return values */
    *p_joinObjs  = joinObjs;
    *p_nJoinObjs = nJoinObjs;


    /* add one local coupling for each Join */
    for(m=0, jo=0; m<nRecvMsgs; m++)
    {
        LC_MSGHANDLE jm = theMsgs[m];
        TEJoin *theJoin = (TEJoin *) LC_GetPtr(jm, joinGlobals.jointab_id);
        int nJ       = (int) LC_GetTableLen(jm, joinGlobals.jointab_id);
        int i;

        for(i=0; i<nJ; i++)
        {
            AddCoupling(theJoin[i].hdr, LC_MsgGetProc(jm), theJoin[i].prio);

            /* send one phase3-JIAddCpl for symmetric connection */
            {
                JIAddCpl *ji = JIAddCplSet_NewItem(joinGlobals.setJIAddCpl3);
                ji->dest    = LC_MsgGetProc(jm);
                ji->te.gid  = OBJ_GID(theJoin[i].hdr);
                ji->te.proc = me;
                ji->te.prio = OBJ_PRIO(theJoin[i].hdr);

                JIAddCplSet_ItemOK(joinGlobals.setJIAddCpl3);
            }

            joinObjs[jo].hdr  = theJoin[i].hdr;
            joinObjs[jo].proc = LC_MsgGetProc(jm);
            jo++;
        }
    }


    /* sort joinObjs-array according to gid */
    if (nJoinObjs>1)
        qsort(joinObjs, nJoinObjs, sizeof(JIPartner), sort_Gid);
}
Beispiel #6
0
Datei: jcmds.c Projekt: rolk/ug
static int PreparePhase1Msgs (JIJoinPtrArray *arrayJoin,
                              JOINMSG1 **theMsgs, size_t *memUsage)
{
    int i, last_i, nMsgs;
    JIJoin   **itemsJ = JIJoinPtrArray_GetData(arrayJoin);
    int nJ       = JIJoinPtrArray_GetSize(arrayJoin);

#       if DebugJoin<=3
    printf("%4d: PreparePhase1Msgs, nJoins=%d\n",
           me, nJ);
    fflush(stdout);
#       endif

    /* init return parameters */
    *theMsgs = NULL;
    *memUsage = 0;


    if (nJ==0)
        /* no messages */
        return(0);


    /* check whether Join objects are really local (without copies) */
    /* and set local GID to invalid (will be set to new value lateron) */
    for(i=0; i<nJ; i++)
    {
        if (ObjHasCpl(itemsJ[i]->hdr))
        {
            sprintf(cBuffer, "cannot join %08x, object already distributed",
                    OBJ_GID(itemsJ[i]->hdr));
            DDD_PrintError('E', 7006, cBuffer);
            HARD_EXIT;
        }

        OBJ_GID(itemsJ[i]->hdr) = GID_INVALID;
    }


    /* set local GID to new value */
    for(i=0; i<nJ; i++)
    {
        DDD_GID local_gid = OBJ_GID(itemsJ[i]->hdr);

        /* check for double Joins with different new_gid */
        if (local_gid!=GID_INVALID && local_gid!=itemsJ[i]->new_gid)
        {
            sprintf(cBuffer,
                    "several (inconsistent) DDD_JoinObj-commands for local object %08x",
                    local_gid);
            DDD_PrintError('E', 7007, cBuffer);
            HARD_EXIT;
        }

        OBJ_GID(itemsJ[i]->hdr) = itemsJ[i]->new_gid;
    }


    nMsgs = 0;
    last_i = i = 0;
    do
    {
        JOINMSG1  *jm;
        size_t bufSize;

        /* skip until dest-processor is different */
        while (i<nJ && (itemsJ[i]->dest == itemsJ[last_i]->dest))
            i++;

        /* create new message */
        jm = (JOINMSG1 *) AllocTmp(sizeof(JOINMSG1));
        if (jm==NULL)
        {
            DDD_PrintError('E', 7900, STR_NOMEM " in PreparePhase1Msgs");
            HARD_EXIT;
        }
        jm->nJoins = i-last_i;
        jm->arrayJoin = &(itemsJ[last_i]);
        jm->dest = itemsJ[last_i]->dest;
        jm->next = *theMsgs;
        *theMsgs = jm;
        nMsgs++;

        /* create new send message */
        jm->msg_h = LC_NewSendMsg(joinGlobals.phase1msg_t, jm->dest);

        /* init table inside message */
        LC_SetTableSize(jm->msg_h, joinGlobals.jointab_id, jm->nJoins);

        /* prepare message for sending away */
        bufSize = LC_MsgPrepareSend(jm->msg_h);
        *memUsage += bufSize;

        if (DDD_GetOption(OPT_INFO_JOIN) & JOIN_SHOW_MEMUSAGE)
        {
            sprintf(cBuffer,
                    "DDD MESG [%03d]: SHOW_MEM "
                    "send msg phase1   dest=%04d size=%010ld\n",
                    me, jm->dest, (long)bufSize);
            DDD_PrintLine(cBuffer);
        }

        last_i = i;

    } while (last_i < nJ);

    return(nMsgs);
}