Beispiel #1
0
/*
*********************************************************************************************************
*                                          App_TaskStart()
*
* Description : This is an example of a startup task.  As mentioned in the book's text, you MUST
*               initialize the ticker only once multitasking has started.
*
* Argument(s) : p_arg   is the argument passed to 'App_TaskStart()' by 'OSTaskCreateExt()'.
*
* Return(s)   : none.
*
* Caller(s)   : This is a task.
*
* Notes       : (1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*********************************************************************************************************
*/
static  void  App_TaskStart (void *p_arg)
{   
    (void)p_arg;                                                /* See Note #1                                              */

    BSP_Init();                                                 /* Initialize BSP functions                                 */

    OS_CPU_SysTickInit();                                       /* Initialize the SysTick                                   */

#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                               /* Determine CPU capacity                                   */
#endif

    MEM_Init();

    End_Init();

    GUI_Init(); 

    TIME_Init();

    MENU_Init();

    App_EventCreate();                                          /* Create application events                                */

    App_TaskCreate();                                           /* Create application tasks                                 */
        
    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop            */
        beep();

        OSTimeDlyHMSM(0, 0, 0, 50);
    }
}
Beispiel #2
0
/*
 *  ======== RMM_init ========
 */
bool RMM_init(void)
{
	bool retVal = true;

	DBC_Require(cRefs >= 0);

	if (cRefs == 0) {
		DBC_Assert(!RMM_debugMask.flags);
		GT_create(&RMM_debugMask, "RM");	/* "RM" for RMm */

		retVal = MEM_Init();

		if (!retVal)
			MEM_Exit();

	}

	if (retVal)
		cRefs++;

	GT_1trace(RMM_debugMask, GT_5CLASS,
		 "RMM_init(), ref count:  0x%x\n",
		 cRefs);

	DBC_Ensure((retVal && (cRefs > 0)) || (!retVal && (cRefs >= 0)));

	return retVal;
}
Beispiel #3
0
/*
 *  ======== DBLL_init ========
 */
bool DBLL_init(void)
{
	bool retVal = true;

	DBC_Require(cRefs >= 0);

	if (cRefs == 0) {
		DBC_Assert(!DBLL_debugMask.flags);
		GT_create(&DBLL_debugMask, "DL"); 	/* "DL" for dbDL */
		GH_init();
		retVal = MEM_Init();
		if (!retVal)
			MEM_Exit();

	}

	if (retVal)
		cRefs++;


	GT_1trace(DBLL_debugMask, GT_5CLASS, "DBLL_init(), ref count:  0x%x\n",
		 cRefs);

	DBC_Ensure((retVal && (cRefs > 0)) || (!retVal && (cRefs >= 0)));

	return retVal;
}
Beispiel #4
0
/*
 *  ======== GS_init ========
 *  purpose:
 *      Initializes the GS module.
 */
void GS_init(void)
{
	static bool curInit;

	if (curInit == false) {
		curInit = MEM_Init(); /* which can't fail currently. */
	}
}
Beispiel #5
0
/*
 *  ======== GS_init ========
 *  purpose:
 *      Initializes the GS module.
 */
void GS_init(void)
{
	static bool curInit;

	if (curInit == false) {
		curInit = true;

		MEM_Init();
	}
}
Beispiel #6
0
/* levels: number of skip levels
 * compare: item key comparison (NULL implies pointer comparison)
 * return: skip list or NULL when out of memory;
 * create skip list */
LIST* LIST_Create (int levels, LIST_Compare compare)
{
  LIST *list;

  if (!(list = malloc (sizeof (LIST)))) return NULL;
  MEM_Init (&list->mem, sizeof (ITEM) + levels * sizeof (ITEM*), CHUNK);
  list->maxlevel = levels - 1;
  list->level = 0;
  list->size = 0;

  if (!(list->header.forward = MEM_CALLOC (levels * sizeof (ITEM*)))) return NULL;
  if (!(list->update = malloc (levels * sizeof (ITEM*)))) return NULL;

  list->compare = compare;

  return list;
}
/*
 *  ======== SERVICES_Init ========
 *  Purpose:
 *      Initializes SERVICES modules.
 */
bool SERVICES_Init(void)
{
	bool fInit = true;
	bool fCFG, fDBG, fMEM;
	bool fREG, fSYNC, fCLK, fNTFY;

	GT_init();
	GT_create(&SERVICES_debugMask, "OS");	/* OS for OSal */

	/* Perform required initialization of SERVICES modules. */
	fMEM = MEM_Init();
	fSYNC = SYNC_Init();
	fREG = REG_Init();
	fCFG = CFG_Init();
	fDBG = DBG_Init();
	fCLK  = CLK_Init();
	fNTFY = NTFY_Init();

	fInit = fCFG && fDBG && fMEM && fREG && fSYNC && fCLK;

	if (!fInit) {
		if (fNTFY)
			NTFY_Exit();

		if (fSYNC)
			SYNC_Exit();

		if (fCLK)
			CLK_Exit();

		if (fREG)
			REG_Exit();

		if (fDBG)
			DBG_Exit();

		if (fCFG)
			CFG_Exit();

		if (fMEM)
			MEM_Exit();

	}

	return fInit;
}
Beispiel #8
0
/*
*********************************************************************************************************
*                                          STARTUP TASK
*
* Description : This is an example of a startup task.  As mentioned in the book's text, you MUST
*               initialize the ticker only once multitasking has started.
*
* Arguments   : p_arg   is the argument passed to 'AppTaskStart()' by 'OSTaskCreate()'.
*
* Returns     : none
*
* Notes       : 1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                  used.  The compiler should not generate any code for this statement.
*********************************************************************************************************
*/
static  void  AppTaskStart (void *p_arg)
{
    OS_ERR  err;

   (void)p_arg;

    BSP_Init();                                                 /* Initialize BSP functions                             */
    BSP_Tick_Init();                                            /* Initialize Tick Services.                            */
    App_OS_SetAllHooks();
    
    MEM_Init();
    DR_Init();

#if OS_CFG_STAT_TASK_EN > 0u
    OSStatTaskCPUUsageInit(&err);                               /* Compute CPU capacity with no task running            */
#endif

#ifdef CPU_CFG_INT_DIS_MEAS_EN
    CPU_IntDisMeasMaxCurReset();
#endif

    DR_LED_Off(0u);                                            /* Turn Off LEDs after initialization                   */

    APP_TRACE_DBG(("Creating Application Kernel Objects\n\r"));
    AppObjCreate();                                             /* Create Applicaiton kernel objects                    */

    APP_TRACE_DBG(("Creating Application Tasks\n\r"));
    AppDataAcqCreate();                                            /* Create Application tasks                             */


    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop.       */
        DR_LED_On(1u);
        OSTimeDlyHMSM(0u, 0u, 0u, 10u,
                      OS_OPT_TIME_HMSM_STRICT,
                      &err);
        DR_LED_Off(1u);
        OSTimeDlyHMSM(0u, 0u, 1u, 0u,
                      OS_OPT_TIME_HMSM_STRICT,
                      &err);
    }
}
Beispiel #9
0
void vDos_Init(void)
	{
	hideWinTill = GetTickCount()+2500;												// Auto hidden till first keyboard check, parachute at 2.5 secs

	LOG_MSG("vDos version: %s", vDosVersion);

#ifndef WITHIRQ1
	// Wil have been called earlier in starup if WITHIRQ1 is defined
	vDos_LoadConfig();
#endif

	GUI_StartUp();
	IO_Init();
	PAGING_Init();
	MEM_Init();
	CALLBACK_Init();
	PIC_Init();
	PROGRAMS_Init();
	TIMER_Init();
//	CMOS_Init();
	VGA_Init();
	CPU_Init();
	KEYBOARD_Init();
	BIOS_Init();
	INT10_Init();
	MOUSE_Init();
	SERIAL_Init();
	PARALLEL_Init();
	printTimeout = ConfGetBool("timeout");
	DOS_Init();
	XMS_Init();
	EMS_Init();
	if (errorMess[0])
		MessageBox(NULL, errorMess+1, "vDos: CONFIG.TXT has unresolved items", MB_OK|MB_ICONWARNING);
	SHELL_Init();																	// Start up main machine
	}
Beispiel #10
0
/* create rank coloring using adjacency graph between processors derived from the W graph */
static int* processor_coloring (GAUSS_SEIDEL *gs, LOCDYN *ldy)
{
  int i, n, m, ncpu, rank, *color, *size, *disp, *adj;
  SET *adjcpu, *item;
  MEM setmem;
  DIAB *dia;
  OFFB *blk;
  CON *con;

  adjcpu = NULL;
  rank = ldy->dom->rank;
  ncpu = ldy->dom->ncpu;
  MEM_Init (&setmem, sizeof (SET), 128);
  ERRMEM (color = MEM_CALLOC (ncpu * sizeof (int)));
  ERRMEM (disp = malloc (sizeof (int [ncpu + 1])));
  ERRMEM (size = malloc (sizeof (int [ncpu])));

  /* collaps W adjacency into processor adjacency */
  for (dia = ldy->dia; dia; dia = dia->n)
  {
    for (blk = dia->adjext; blk; blk = blk->n)
    {
      con = (CON*) blk->dia;
      SET_Insert (&setmem, &adjcpu, (void*) (long) con->rank, NULL);
    }
  }

  n = SET_Size (adjcpu);
  MPI_Allgather (&n, 1, MPI_INT, size, 1, MPI_INT, MPI_COMM_WORLD);

  for (i = disp [0] = 0; i < ncpu - 1; i ++) disp [i+1] = disp [i] + size [i];
  for (i = 0, item = SET_First (adjcpu); item; i ++, item = SET_Next (item)) color [i] = (int) (long) item->data;

  m = disp [ncpu] = (disp [ncpu-1] + size [ncpu-1]);
  ERRMEM (adj = malloc (sizeof (int [m])));

  MPI_Allgatherv (color, n, MPI_INT, adj, size, disp, MPI_INT, MPI_COMM_WORLD); /* gather graph adjacency */

  for (i = 0; i < ncpu; i ++) color [i] = 0; /* zero colors */

  for (i = 0; i < ncpu; i ++) /* simple BFS coloring */
  {
    int *j, *k;

    do
    {
      color [i] ++; /* start from first color */

      for (j = &adj[disp[i]], k = &adj[disp[i+1]]; j < k; j ++) /* for each adjacent vertex */
      {
	if (color [*j] == color [i]) break; /* see whether the trial color exists in the adjacency */
      }
    }
    while (j < k); /* if so try next color */
  }

  for (m = i = 0; i < ncpu; i ++) m = MAX (m, color [i]); /* compute number of colors */
  gs->colors = m; /* record number of colors */

  if (rank == 0 && ldy->dom->verbose && gs->verbose)
  {
#if DEBUG
  for (i = 0; i < ncpu; i ++)
  {
    int *j, *k;

    printf ("GAUSS_SEIDEL: RANK %d [%d] ADJCPU:", i, color [i]);
    for (j = &adj[disp[i]], k = &adj[disp[i+1]]; j < k; j ++) printf (" %d [%d]", *j, color [*j]);
    printf ("\n");
  }
#endif
    printf ("GAUSS_SEIDEL: PROCESSOR COLORS = %d\n", m);
  }

  MEM_Release (&setmem);
  free (size);
  free (disp);
  free (adj);

  return color;
}
int main(int argc, char** argv)
{
	struct file_ops_t *fo1;
	struct file_ops_t *fo2;
	struct memory_t *mem1;
	struct memory_t *mem2;

	uint16_t chunk = 128;

	char *filename;

	uint32_t max;

	if (argc < 2) {
		printf("too few arguments\n");
		printf("%s [type:]filename [[type:]filename]\n", argv[0]);
		printf(" type is either HEX or BIN, case insensitive\n\n");
		printf(" If second file is present both files are printed and compared\n");
		printf("  else only first file is printed\n");
		exit(-1);
	}

	if (argc > 1) {
		if (argv[1][0] == 'C') {
			chunk = atoi(&argv[1][1]);

			/* hack */
			argc--;
			argv++;
		}
	}

	if (argc > 1) {
		mem1 = MEM_Init(chunk, 1);

		parse_file(argv[1], &fo1, &filename);
		max = fo1->ReadFile(filename, mem1);

		printf("Filename: %s\n", filename);
		MEM_Print(mem1);
	}

	if (argc > 2) {
		mem2 = MEM_Init(chunk, 1);

		parse_file(argv[2], &fo2, &filename);
		max = fo2->ReadFile(filename, mem2);

		printf("\n\nFilename: %s\n", filename);
		MEM_Print(mem2);

		printf("\nComparing files...\n");
		if (MEM_Compare(mem1, mem2)) {
			// mem_compare is verbose enough ;)
			//printf("Differ\n");
		} else {
			printf("Same\n");
		}

		MEM_Destroy(mem2);
	}

	MEM_Destroy(mem1);
}
Beispiel #12
0
/* create mesh from a vector of nodes, element list in format =>
 * {nuber of nodes, node0, node1, ..., material}, {REPEAT}, ..., 0 (end of list); and surface colors in format =>
 * global surface, {number of nodes, node0, node1, ..., surface}, {REPEAT}, ..., 0 (end of list); */
MESH_DATA* MESH_Create (REAL (*nodes) [3], int *elements, int *surfaces)
{
  int maximal_node,
      minimal_node,
      elements_count,
      faces_count,
      temp, *eleptr, n;
  REAL (*node) [3];
  MEM *elemem,
      facmem,
      mapmem;
  ELEMENT *ele, *enx, *elist;
  FACE *fac, *cac, *gac, *flist;
  MAP *faces, *smap;
  MESH_DATA *msh;
  
  maximal_node = 0;
  minimal_node = INT_MAX;
  elements_count = 0;
  faces_count = 0;

  /* create mesh storage */
  ERRMEM (msh = static_cast<MESH_DATA*>(MEM_CALLOC (sizeof (MESH_DATA))));
  elemem = &msh->elemem;
 
  /* calculate elements */ 
  for (eleptr = elements; eleptr [0]; eleptr += (eleptr [0]+2)) elements_count ++;

  MEM_Init (elemem, sizeof (ELEMENT), elements_count);
  MEM_Init (&facmem, sizeof (FACE), MEMCHUNK);
  MEM_Init (&mapmem, sizeof (MAP), MEMCHUNK);
  MEM_Init (&msh->mapmem, sizeof (MAP), MIN (elements_count, MEMCHUNK));

  elist = NULL;
  flist = NULL;
  faces = NULL;

  /* create elements list & face adjacency map */
  for (eleptr = elements; eleptr [0]; eleptr += (eleptr [0]+2))
  {
    ASSERT (
      eleptr [0] == 4 || /* tetrahedron */
      eleptr [0] == 5 || /* pyramid */
      eleptr [0] == 6 || /* wedge */
      eleptr [0] == 8,   /* hexahedron */
      "ERROR: unsupported element type");

    ele = create_element (elemem, eleptr);
    flist = create_faces (&facmem, &mapmem, &faces, ele, flist);
    ele->next = elist;
    elist = ele;

    /* node number extrema */
    temp = maximal (eleptr);
    if (temp > maximal_node)
      maximal_node = temp;
    temp = minimal (eleptr);
    if (temp < minimal_node)
      minimal_node = temp;
  }

  /* calculate faces */
  for (fac = flist; fac; fac = fac->next)
    if (fac->ele) faces_count ++;

  /* alocate additional storage */
  MEM_Init (&msh->facmem, sizeof (FACE), faces_count);
  msh->nodes_count = (maximal_node - minimal_node + 1);
  ERRMEM (msh->nodes = static_cast<REAL(*)[3]>(malloc (sizeof (REAL [3]) * (msh->nodes_count))));
  msh->surfeles_count = msh->bulkeles_count = 0;
  msh->surfeles = msh->bulkeles = NULL;

  /* set up elements */
  for (ele = elist; ele; ele = enx)
  {
    enx = ele->next;

    if (minimal_node > 0) /* impose 0-based indexing */
    {
      for (temp = 0; temp < ele->type; temp ++)
	ele->nodes [temp] -= minimal_node;
    }

    ele->prev = NULL;
   
    if (ele->neighs < neighs (ele->type)) /* surface element */
    {
      msh->surfeles_count ++;
      ele->next = msh->surfeles;
      if (msh->surfeles) msh->surfeles->prev = ele;
      msh->surfeles = ele;
    }
    else /* bulk element */
    {
      msh->bulkeles_count ++;
      ele->next = msh->bulkeles;
      if (msh->bulkeles) msh->bulkeles->prev = ele;
      msh->bulkeles = ele;
    }
  }

  /* create surfaces map => skip first element of 'surfaces' == the global surface kind */
  for (eleptr = (surfaces + 1), smap = NULL, temp = 0;
    eleptr [0]; eleptr += (eleptr [0]+2), temp ++)
  {
    fac = static_cast<FACE*>(MEM_Alloc (&facmem));
    
    ASSERT (
      eleptr [0] == 3 || /* triangle */
      eleptr [0] == 4,   /* quad */
      "ERROR: unsupported face type");

    fac->type = eleptr [0];
    for (n = 0; n < eleptr [0]; n ++)
      fac->nodes [n] = eleptr [n+1];
    sort (fac->nodes, fac->nodes+fac->type-1);

    fac->color = eleptr [eleptr [0] + 1];
    MAP_Insert (&mapmem, &smap, fac, /* map by the type/nodes key */
      fac, face_compare);
  }

  /* set up nodes */
  for (temp = minimal_node,
       node = msh->nodes;
       temp <= maximal_node;
       temp ++, node ++)
  {
    COPY (nodes [temp], *node);
  }

  /* set up faces */
  for (fac = flist; fac; fac = fac->next)
  {
    if (fac->ele) /* see (***) */
    {
      ele = fac->ele;

      cac = static_cast<FACE*>(MEM_Alloc (&msh->facmem));
      setup_face (ele, fac->index, cac, 0); /* setup face nodes without sorting them */
      cac->index = fac->index;
      cac->ele = fac->ele;
      setup_normal (msh->nodes, cac); /* calculate outer spatial normal */
      cac->next = ele->faces; /* append element face list */
      ele->faces = cac;

      /* set the mapped surface kind if possible => otherwise the global one */
      gac = static_cast<FACE*>(MAP_Find (smap, fac, face_compare));
      cac->color = (gac ? gac->color : surfaces [0]);
    }
  }

  /* create mesh face list */
  for (ele = msh->surfeles; ele; ele = ele->next)
  {
    for (fac = ele->faces; fac; fac = fac->next)
    {
      fac->n = msh->faces;
      msh->faces = fac;
    }
  }

  /* clean up */
  MEM_Release (&facmem);
  MEM_Release (&mapmem);

  return msh;
}
Beispiel #13
0
void   
test_0(UNSIGNED argc, VOID *argv)
{
    STATUS    status;
        int     ch;
        int     i=0, j, k;
        U32     padr;
        U32 *ptr;
        int bus_num = 0;

    /* Access argc and argv just to avoid compilation warnings.  */
    status =  (STATUS) argc + (STATUS) argv;
        
        
        print_help();
        for(;;){
                if ( ttyA_poll() == 0) {
                        ch = ttyA_in();
                        switch(ch){
                        case 'i':
                        case 'I':
                                /* Initialize Memory */
                                MEM_Init();
                                /* Initialize the dev structure */
                                init_devptr();
                                /* Initialize the device */
                                DEV_Init_Devices(device, 1);
                                dev_ptr = DEV_Get_Dev_By_Name("de0");
                                break;
                        case 'p':
                        case 'P':
                                printf("Devices Found on the PCI Bus 0\n\r");
                                probe_pci_devs(0);
                                break;
#ifdef  INCLUDE_ODYSSEY
                        case 'l':
                        case 'L':
                                printf("Devices Found on the Local Bus \n\r");
                                probe_pci_devs(PCI_E_BUSNUM);
                                break;
                        case 'x':
                        case 'X':
                                if ( dev_ptr != NU_NULL) {
                                        DEC21143_XDATA          *dec_data;
                                        DEC21143_DESCRIPTOR             *desc;
                                        dec_data = (DEC21143_XDATA *) dev_ptr->user_defined_1;
                                        
                                        desc = dec_data->DEC21143_First_TX_Descriptor;
                                        printf("\n\r");
                                        while(desc) {
                                                desc = (DEC21143_DESCRIPTOR *)((U32)(desc) | 0xA0000000);
                                                printf("Control :%08X,   ", desc->control_count);
                                                printf("Status  :%08X,   ", desc->status);
                                                printf("Buffer  :%08X\n\r", desc->buffer);
                                        
                                                desc = desc->next_descriptor;
                                        }
                                } else {
                                        printf("Device not Initialized\n\r");
                                }
                                break;
#endif
                        case 'T':
                        case 't':
                                if ( dev_ptr != NU_NULL) {
                                        send_flag ^= 1;
                                } else {
                                        printf("Device not Initialized\n\r");
                                }
                                break;
                        case 'e':
                        case 'E':
                                if ( dev_ptr != NU_NULL) {
                                        DEC21143_Printcounters (dev_ptr);
                                } else {
                                        printf("Device not Initialized\n\r");
                                }
                                break;
                        case 'c':
                        case 'C':
                                print_flag ^= 1;
                                break;
                        case 'd':
                        case 'D':
                                print_data_flag ^= 1;
                                break;
                        case 'r':
                        case 'R':
                                tx_count = 0;
                                rx_count = 0;
                                break;
                        case '+':
                                if ( dev_ptr != NU_NULL) {
                                        maddr[5] = multi_add_byte;
                                        Ether_Add_Multi(dev_ptr, maddr);
                                        multi_add_byte++;
                                        DEC21143_Ioctl(dev_ptr, DEV_ADDMULTI, d_req);
                                } else {
                                        printf("Device not Initialized\n\r");
                                }
                                break;
                        case '-':
                                if ( dev_ptr != NU_NULL) {
                                        maddr[5] = multi_del_byte;
                                        if (Ether_Del_Multi(dev_ptr, maddr) == NU_SUCCESS)
                                                multi_del_byte++;
                                        DEC21143_Ioctl(dev_ptr, DEV_DELMULTI, d_req);
                                } else {
                                        printf("Device not Initialized\n\r");
                                }
                                break;
                        case ' ':
                                print_help();
                                break;
                        default:
                                printf("%c", ch);
                                break;
                        }
                }
                
                NU_Sleep(10);
        }
}
Beispiel #14
0
/* communicate objects using point to point communication */
int COMOBJS (MPI_Comm comm, int tag,
	     OBJ_Pack pack,
	     void *data,
	     OBJ_Unpack unpack,
             COMOBJ *send, int nsend,
	     COMOBJ **recv, int *nrecv) /* recv is contiguous => free (*recv) releases all memory */
{
  COMDATA *send_data,
	  *recv_data,
	  *cd, *cc;
  int recv_count,
      i, n,
      ret;
  COMOBJ *co;
  MAP *map;
  MEM mem;

  ERRMEM (send_data = malloc (nsend * sizeof (COMDATA)));
  MEM_Init (&mem, sizeof (MAP), MAX (nsend, 64));

  /* pack objects */
  for (i = 0, cd = send_data, co = send, map = NULL; i < nsend; i ++, cd ++, co ++)
  {
    int isize = 0,
	dsize = 0;

    cd->rank = co->rank;

    if ((cc = MAP_Find (map, co->o, NULL))) /* same object was already packed */
    {
      cd->ints = cc->ints;
      cd->doubles = cc->doubles;
      cd->i = cc->i;
      cd->d = cc->d;
    }
    else
    {
      cd->ints = 0;
      cd->doubles = 0;
      cd->i = NULL;
      cd->d = NULL;

      pack (co->o, &dsize, &cd->d, &cd->doubles, &isize, &cd->i, &cd->ints);

      MAP_Insert (&mem, &map, co->o, cd, NULL);
    }
  }

  /* send and receive packed data */
  if (tag == INT_MIN) ret = COMALL (comm, send_data, nsend, &recv_data, &recv_count); /* all to all */
  else ret = COM (comm, tag, send_data, nsend, &recv_data, &recv_count); /* point to point */

#if PARDEBUG
  {
    int debug_send_count, *ip, *jp, ii [2], jj [2];
    COMDATA *debug_send_data;
    double *qq, *pp;

    /* send backwards */
    if (tag == INT_MIN) COMALL (comm, recv_data, recv_count, &debug_send_data, &debug_send_count);
    else COM (comm, tag, recv_data, recv_count, &debug_send_data, &debug_send_count);

    ii[0] = 0, ii[1] = 0;
    jj[0] = 0, jj[1] = 0;
    do
    {
      ip = next_int (send_data, nsend, ii);
      jp = next_int (debug_send_data, debug_send_count, jj);
      if (ip && jp)
      {
	ASSERT_DEBUG (*ip == *jp, "Integer values mismatch");
      }
      else
      {
	ASSERT_DEBUG (!ip && !jp, "Integer count mismatch");
      }
    }
    while (ip && jp);

    ii[0] = 0, ii[1] = 0;
    jj[0] = 0, jj[1] = 0;
    do
    {
      qq = next_double (send_data, nsend, ii);
      pp = next_double (debug_send_data, debug_send_count, jj);
      if (qq && pp)
      {
	ASSERT_DEBUG (*qq == *pp, "Double values mismatch");
      }
      else
      {
	ASSERT_DEBUG (!qq && !pp, "Double count mismatch");
      }
    }
    while (qq && pp);

    free (debug_send_data);
  }
#endif

  if (recv_count)
  {
    *nrecv = recv_count;
    ERRMEM (*recv = malloc ((*nrecv) * sizeof (COMOBJ)));

    /* unpack received objects */
    for (n = i = 0, cd = recv_data, co = *recv; i < recv_count; i ++, cd ++)
    {
      int ipos = 0,
	  dpos = 0;

      do
      {
	if (n == *nrecv)
	{
	  *nrecv *= 2; /* resize the receive buffer */
	  ERRMEM (*recv = realloc (*recv, (*nrecv) * sizeof (COMOBJ)));
	  co = *recv + n; /* and reset the current pointer */
	}

	co->rank = cd->rank;
	co->o = unpack (data, &dpos, cd->d, cd->doubles, &ipos, cd->i, cd->ints);

	co ++;
	n ++;

      } while (ipos < cd->ints || dpos < cd->doubles); /* while something is left to unpack */
    }

    /* truncate output */
    if (n) ERRMEM (*recv = realloc (*recv, n * sizeof (COMOBJ)));
    *nrecv = n;
  }
  else
  {
    *recv = NULL;
    *nrecv = 0;
  }

  /* cleanup */
  for (MAP *item = MAP_First (map); item; item = MAP_Next (item))
  { cd = item->data; free (cd->i); free (cd->d); }
  MEM_Release (&mem);
  free (send_data);
  free (recv_data); /* contiguous */

  return ret;
}
Beispiel #15
0
void setupMEM( void )
{
	MEM_Init();
}
Beispiel #16
0
static MESH* psc_read_mesh (FILE *f)
{
  ELEMENT *ele, **tab, *tail;
  MESH *msh;
  int i, j;

  ERRMEM (msh = MEM_CALLOC (sizeof (MESH)));
  MEM_Init (&msh->elemem, sizeof (ELEMENT), 128);
  MEM_Init (&msh->facmem, sizeof (FACE), 128);
  MEM_Init (&msh->mapmem, sizeof (MAP), 128);

  fread (&msh->nodes_count, sizeof (int), 1, f);

  ERRMEM (msh->ref_nodes = malloc (2 * msh->nodes_count * sizeof (double [3])));
  msh->cur_nodes = msh->ref_nodes + msh->nodes_count;

  fread (msh->ref_nodes, sizeof (double [3]), msh->nodes_count, f);
  fread (msh->cur_nodes, sizeof (double [3]), msh->nodes_count, f);

  fread (&msh->surfeles_count, sizeof (int), 1, f);
  fread (&msh->bulkeles_count, sizeof (int), 1, f);

  ERRMEM (tab = malloc ((msh->surfeles_count + msh->bulkeles_count) * sizeof (ELEMENT*)));

  for (i = 0, tail = NULL; i < msh->surfeles_count; i ++)
  {
    ele = psc_read_element (&msh->elemem, &msh->facmem, f);
    ele->flag = i;

    if (tail) ele->prev = tail, tail->next = ele;
    else msh->surfeles = ele;
    tail = ele;
    tab [i] = ele;
  }

  for (tail = NULL; i < msh->surfeles_count + msh->bulkeles_count; i ++)
  {
    ele = psc_read_element (&msh->elemem, &msh->facmem, f);
    ele->flag = i;

    if (tail) ele->prev = tail, tail->next = ele;
    else msh->bulkeles = ele;
    tail = ele;
    tab [i] = ele;
  }

  for (i = 0; i < msh->surfeles_count + msh->bulkeles_count; i ++)
  {
    ele = tab [i];

    for (j = 0; j < ele->neighs; j ++)
    {
      int idx = (long) (void*) ele->adj[j];
      ASSERT_TEXT (idx >= 0 && idx < msh->surfeles_count + msh->bulkeles_count, "INCONSITENT ELEMENT INDEXING");
      ele->adj[j] = tab [idx];
    }
  }

  free (tab);

  return msh;
}
Beispiel #17
0
/*
 *  ======== SERVICES_Init ========
 *  Purpose:
 *      Initializes SERVICES modules.
 */
bool SERVICES_Init(void)
{
	bool fInit = true;
	bool fCFG, fCSL, fDBG, fDPC, fKFILE, fLST, fMEM;
	bool fREG, fSYNC, fCLK, fNTFY;

	DBC_Require(cRefs >= 0);

	if (cRefs == 0) {

		GT_init();
		GT_create(&SERVICES_debugMask, "OS");	/* OS for OSal */

		GT_0trace(SERVICES_debugMask, GT_ENTER,
			 "SERVICES_Init: entered\n");

		/* Perform required initialization of SERVICES modules. */
		fMEM = MEM_Init();
		fREG = REG_Init();
		fCFG = CFG_Init();
		fCSL = CSL_Init();
		fDBG = DBG_Init();
		fDPC = DPC_Init();
		fKFILE = KFILE_Init();
		fLST = LST_Init();
		fSYNC = SYNC_Init();
		fCLK  = CLK_Init();
		fNTFY = NTFY_Init();

		fInit = fCFG && fCSL && fDBG && fDPC && fKFILE &&
			fLST && fMEM && fREG && fSYNC && fCLK;

		if (!fInit) {
			if (fNTFY)
				NTFY_Exit();

			if (fSYNC)
				SYNC_Exit();

			if (fCLK)
				CLK_Exit();

			if (fREG)
				REG_Exit();

			if (fLST)
				LST_Exit();

			if (fKFILE)
				KFILE_Exit();

			if (fDPC)
				DPC_Exit();

			if (fDBG)
				DBG_Exit();

			if (fCSL)
				CSL_Exit();

			if (fCFG)
				CFG_Exit();

			if (fMEM)
				MEM_Exit();

		}
	}

	if (fInit)
		cRefs++;

	GT_1trace(SERVICES_debugMask, GT_5CLASS, "SERVICES_Init: cRefs 0x%x\n",
		 cRefs);

	DBC_Ensure((fInit && (cRefs > 0)) || (!fInit && (cRefs >= 0)));

	return fInit;
}