Beispiel #1
0
/*
	Function for setting up and running the fluid simulation kernels
*/
void solveFluid(struct Configuration* config) { 
	// Jacobi settings
	float alpha = -1.0f;
	// Should use alpha -1 here, but this gives nicer results
	//float alpha = -(1.0f/invhalfgridscale);
	float rbeta = 0.25;
	int iterations = 100;

	// grid scaling. this is currently not used
    if(rank == 0){
        float gridscale = 1.0f;
        float invgridscale = 1.0f/gridscale;
        float invhalfgridscale = 0.5f/gridscale; 

        // Timstep value
        float timestep = 0.05f;

        // Emitter settings
        float amount = 2.0f;
        float radius = 0.5*config->N/10.0f;
        float emitterposx = config->N/2;
        float emitterposy = config->N/3;

        // buoyancy settings
        float bdiry = 1.0f;
        float bdirx = 0.0f;
        float bstrength = 0.1f;

        // advection settings
        float veldamp = 0.01f;	


        // Velocity advection
        float *tmp = config->velx0; config->velx0 = config->velx; config->velx = tmp;
        float *tmp1 = config->vely0; config->vely0 = config->vely; config->vely = tmp1;
        advect(config->N, config->velx, config->velx0, config->velx0, config->vely0, timestep, veldamp, 1);
        advect(config->N, config->vely, config->vely0, config->velx0, config->vely0, timestep, veldamp, 2);

        // Density advection
        float *tmp2 = config->dens0; config->dens0 = config->dens; config->dens = tmp2;
        advect(config->N, config->dens, config->dens0, config->velx, config->vely, timestep, 0.0f, 0);

        // Add density and density buoyancy
        addDensity(config->N, config->dens, timestep, emitterposx, emitterposy, radius, amount);
        addDensityBuoyancy(config->N, config->velx, config->vely, config->dens, bdirx, bdiry, bstrength, timestep);

        // Divergence calculation
        divergence(config->N, config->velx, config->vely, config->div);	

        // Pressure jacobi calculation. First set pres array to zero as initial guess
        setMem(config->N, config->pres);
    }

	jacobi(iterations);
	
    if(rank == 0){
        // Calculate projection
        projection(config->N, config->velx, config->vely, config->pres);	
    }
}
auto V30MZ::opExchangeMemReg(Size size) {
  wait(2);
  modRM();
  auto mem = getMem(size);
  auto reg = getReg(size);
  setMem(size, reg);
  setReg(size, mem);
}
Beispiel #3
0
/*initialization of the grid*/
int init(CPU * grid){
    int i = 0;
    while (i < NB_CPU){
        setMem(&grid[i]);
        setReg(&grid[i]);
        i++;
    }
    return 0;
}
Beispiel #4
0
    void BindArgDataHolder::ArgBinder::operator()( MYSQL_BIND &arg, const bool &value )
    {
        boost::shared_array<char> data( reinterpret_cast<char *>( new char ) );
        m_argMem.push_back( data );

        setMem( arg, MYSQL_TYPE_TINY );
        arg.buffer = data.get();
        arg.is_null = NULL;
    }
void DSVector::setMax(int newmax)
{
   int siz = size();
   int len = ((newmax < siz) ? siz : newmax) + 1;

   spx_realloc(theelem, len);
   setMem (len, theelem);
   set_size( siz );
}
int RobotMemory::findPath(int x, int y)
{
	int value = 0;

	pathstart = owner->getPosition();
	pathstop.x = x;
	pathstop.y = y;

	for (int i=0; i<columns; i++)
		for(int j=0; j<rows; j++)
			map2[i][j] = -1;

	setMem(pathstart->x,pathstart->y,value);
	writeMap();
	while(!endofmap)
	{
		endofmap = true;
		value++;
		for(int i=0; i<columns; i++)
		{
			for(int j=0; j<rows; j++)
			{
				if(map2[i][j] == value - 1)
				{
					endofmap = false;
					if((i == pathstop.x) && (j == pathstop.y))
					{	
						//writeMap();
						setPath(i,j);
						writeMap();
						return 0;
					}
					setMem(i,j+1,value);
					setMem(i,j-1,value);
					setMem(i+1,j,value);
					setMem(i-1,j,value);
				}
			}
		}

	}
	TRACE("Sciezka nie odnaleziona\n");
	return 1;
}
Beispiel #7
0
    void BindArgDataHolder::ArgBinder::operator()( MYSQL_BIND &arg, const std::string &value )
    {
        boost::shared_array<char> data( new char[stringBufferSize] );
        m_argMem.push_back( data );

        setMem( arg, MYSQL_TYPE_STRING );
        arg.buffer = data.get();
        arg.buffer_length = stringBufferSize;
        *arg.is_null = 0;
    }
Beispiel #8
0
 void BindArgDataHolder::ArgBinder::operator()( MYSQL_BIND &arg, const boost::posix_time::ptime &datetime )
 {
     boost::shared_array<char> buf( new char[sizeof(MYSQL_TIME)/sizeof(char)] );
     m_argMem.push_back( buf );
     
     setMem( arg, MYSQL_TYPE_TIMESTAMP );
     arg.buffer = buf.get();
     *arg.is_null = 0;
     *arg.length = 0;
 }
Beispiel #9
0
    void BindArgDataHolder::ArgBinder::operator()( MYSQL_BIND &arg, const boost::int64_t &value )
    {
        boost::shared_array<char> data( reinterpret_cast<char *>( new boost::int64_t ) );
        m_argMem.push_back( data );

        setMem( arg, MYSQL_TYPE_LONGLONG );
        arg.buffer = data.get();
        arg.is_unsigned = 0;
        *arg.is_null = 0;
    }
/*测试 _db_t_object_queue 插入和弹出操作*/
VOID testQueue()
{
    _DB_RET ret;
    WORD i;
    DWORD j;
    initDb(1024);
    _db_t_object_queue queue;
    _db_t_object_handle dbObjectHandle;
    for (i = 0; i < 2; ++i)
    {
        setMem();
        _db_queue_init(dbHandle, &queue, 20, i);
        for(j=0;j<1000000;j++)
        {
            ret = _db_queue_add(dbHandle,&queue,&dbObjectHandle);
            if(ret != _DB_SUCCESS)
            {
                printf("_db_queue_add fail, ret =%x, j=%x\n", ret,j);
                break;
            }
        }
        getUsedMem();
        printf("testQueue add ok, j=%d\n", j);
        for(j=0;j<1000000;j++)
        {
           ret = _db_queue_pop(dbHandle,&queue,&dbObjectHandle);
           if(ret != _DB_SUCCESS)
           {
               printf("_db_queue_pop fail, ret =%x, j=%x\n", ret,j);
               break;
           }
        }
        getUsedMem();
        printf("testQueue pop ok! j=%d\n", j);
    }

    _db_queue_destroy(dbHandle,&queue);
    getUsedMem();

}
/*测试 _db_t_object_array 写入和读出测试*/
VOID testArray()
{
    _DB_RET ret;
    DWORD i;
    DWORD *item;
    initDb(1024);
    _db_t_object_array array;
    _db_array_init(dbHandle, sizeof(DWORD), &array);
    setMem();
    for (i = 0; i < 1000000; ++i)
    {
        printf("testArray: write  %d\n",i);
        ret = _db_array_get(dbHandle, &array, i, (VOID**)&item);
        if (ret != _DB_SUCCESS)
        {
            break;
        }
        *item = i;
    }

    printf("test read write, i=%d, ret =%x\n", i, ret);

    for (i = 0; i < 1000000; ++i)
    {
        printf("testArray: read %d\n",i);
        ret = _db_array_get(dbHandle, &array, i, (VOID**)&item);
        if (ret != _DB_SUCCESS || *item != i)
        {
            printf("%d,testArray fail, ret =0x%x, i=%d, *item=%d\n", ret, i, *item);
            break;
        }
    }
    printf("test read ok, i=%d, ret =%x\n", i, ret);
    getUsedMem();
    _db_array_destroy(dbHandle, &array);
    getUsedMem();
    dropDb();
}
Beispiel #12
0
int main(int argc, char *argv[])
{
  //int ret;
  int c;
  unsigned short i=0, ac;
  unsigned short rom_adr, startAdr=i8086_BEGINADR;  /* Mem-Viewer Startadresse  */
  char str[6];
  char cfgStr[i8086_CFG_MAX_VALUE_LEN];
  unsigned short adr;
  codeView cv;                             /* Code-Viewer Data */

  if (argc<2)
  {
                    printf("i8086emu "VERSION_NUMBER);
                    printf("\nUsage: %s [OPTIONS] FILENAME\n", argv[0]);
                    printf("\nOptions:");
                    printf("\n -c\t\t\tCodeViewer deaktivieren");
                    printf("\n -o XXXXh\t\tStartadresse");
                    printf("\n -r XXXXh\t\tStartadresse ROM-File");
                    printf("\n -d file\t\tDUMP-File");
                    printf("\n --version\t\tshow version information");
                    printf("\n --help\t\t\tthis help information");
                    printf("\n");

    exit(1);
  }
  
  
  signal(SIGTERM, resetAll);
  signal(SIGINT, resetAll);
  signal(SIGQUIT, resetAll);
  signal(SIGSEGV, resetAll);
  
  i8086clearLog(); /* Log-File leeren. */
  i8086init(); /* Prozessor initialisieren. */
  oldPortHandler = i8086SetMsgFunc(i8086_SIG_PORT_OUT, portSignalHandler);

  /* Config-File laden */
  if (i8086ReadStrConfig(cfgStr, CONFIG_FILE, "ROMFILE")!=0)
  {
    rom_adr = i8086ReadHexConfig(CONFIG_FILE, "ROMSTARTADR", 0xc000);
    LoadRomFile(cfgStr, rom_adr);
  }
  else /* Wenn ROM -> kein Core-Dump */
    if (i8086ReadStrConfig(cfgStr, CONFIG_FILE, "COREDUMP")!=0)
      LoadCoreDumpFile(cfgStr);
  startAdr = i8086ReadHexConfig(CONFIG_FILE, "PROGSTARTADR", 0x0100);
    
  for (ac=1; ac<argc; ac++) /* Programmargumente auswerten und speichern */
  {
    char *str;
    
    if(strcmp(argv[ac],"--version")==0)
    {
                    printf("i8086emu "VERSION_NUMBER"\n"
                    "Copyright (C) 2004 JMH, RD, FB, CST\n"
                    "i8086emu comes with NO WARRANTY,\n"
                    "to the extent permitted by law.\n"
                    "You may redistribute copies of i8086emu\n"
                    "under the terms of the GNU General Public License.\n");
                    exit(1);
    }
    if(strcmp(argv[ac],"--help")==0)
    {
                    printf("i8086emu "VERSION_NUMBER);
                    printf("\nUsage: %s [OPTIONS] FILENAME\n", argv[0]);
                    printf("\nOptions:");
                    printf("\n -c\t\t\tCodeViewer deaktivieren");
                    printf("\n -o XXXXh\t\tStartadresse");
                    printf("\n -r XXXXh\t\tStartadresse ROM-File");
                    printf("\n -d file\t\tDUMP-File");
                    printf("\n --version\t\tshow version information");
                    printf("\n --help\t\t\tthis help information");
                    printf("\n");

    exit(1);
    }          
    if (strcmp(argv[ac], "-c")==0)          /* CodeViewer deaktivieren */
      args |= HIDE_CODE_VIEWER;
    if ((str=strstr(argv[ac], "-o"))!=NULL) /* Startadresse des Programmes setzen */
    {
      str = strtok(str, "-o");
      if (str!=NULL)
        startAdr = strtoul(str, NULL, 16);
    }
    if ((str=strstr(argv[ac], "-r"))!=NULL) /* ROM laden */
    {
      //int adr;
      if (argc<ac+2)
      {
        printf("\n -r XXXXh file -> Startadresse ROM-File");
        exit(1);
      }
      rom_adr = strtoul(argv[ac+1], NULL, 16);
      LoadRomFile(argv[ac+2], rom_adr);
    }
    if ((str=strstr(argv[ac], "-d"))!=NULL) /* Core-Dump laden */
    {
      if (argc<ac+1)
      {
        printf("\n -d file -> DUMP-File");
        exit(1);
      }       
      LoadCoreDumpFile(argv[ac+1]);
    }
  }

  if (i8086loadBinFile(core, argv[argc-1], startAdr)!=i8086_SUC_FILELOAD)
  {
    i8086error(argv[argc-1], i8086_ERR_STR_FILENF);    
  }
  if (args & LOAD_ROM) /* ROM verarbeiten */
    startAdr = rom_adr;
  core->pc = startAdr;
    
  initscr();
  clear();
  refresh();
  createWin();

  printReg();
  printFlags();
  printLeds(0);
  printSwitches();
  printDisplay();
  printMem(startAdr);
  cv.startAdr = 0;//i8086_BEGINADR;
  cv.endAdr = 0;

  printCode(core, commands, &cv);
  //i8086PushMsg(1, 1);

  noecho();     /* getch echo aus */
  curs_set(0);  /* Cursor ausschalten */

  keypad(stdscr,1);
  //while (/*c=='g' ||*/ (c=getch/*ar*/())!='q')

  //sendepuffer ist leer
  //core->ports.x[0xD2]=3;

  while ((c==ERR && i%50000!=0) || (c=getch/*ar*/())!='q') //automode nur aller 50000 takte abbrechbar, reicht aber aus, sonst wars zu langsam
  {
    i++;
    if (c==KEY_F(9))
      nodelay(stdscr,TRUE);
    else if (c=='n')
      nodelay(stdscr,FALSE);
    else if (c==KEY_F(8))
    {
    	adr=i8086GetSegRegister_fast(core,i8086_REG_CS, 1)+core->pc;
    	stepover=adr+commands[core->mem[adr]]->size;
	if (commands[core->mem[adr]]->hasMod!=0)
		stepover+=getAdditionalCmdLength(core, core->mem[adr], core->mem[adr+1]);
    	nodelay(stdscr,TRUE);
    }

    if (c==ERR||c=='n') /* next Opcode */
      if (i8086execCommand(core, commands)==i8086_ERR_ILGOPCODE)
      {
        sprintf(str, "%hd", core->mem[core->pc + i8086GetSegRegister_fast(core, i8086_REG_CS, 1)]);
        i8086error(i8086_ERR_STR_ILGOPCODE, str);
        //resetAll(0);
      }

    if (i8086GetSegRegister_fast(core,i8086_REG_CS, 1)+core->pc==breakpoint || i8086GetSegRegister_fast(core,i8086_REG_CS, 1)+core->pc==stepover)
    {
    	i=0;
    	nodelay(stdscr,FALSE);
	    c=0;
    }

    if (c=='r') /* set Registervalue */
      setReg();
    else if (c==KEY_F(1)) /* Print Help */
      printHelp();
    else if (c==KEY_F(2)) //Breakpoint setzen
      {
      	setBreakpoint();
	c=0;
      }
    else if (c=='m') /* Anfangsadresse von Speicherviewer setzen */
      startAdr=readMem();
    else if (c=='w') /* Wert von Speicherzelle setzen */
      setMem();
    else if (c==KEY_F(3)) /* CoreDump */
      coreDump();
    else if ((c>='0')&&(c<='7')) /* Schalter An/Aus */
    {
      unsigned char dual[] = {1,2,4,8,16,32,64,128};
      core->ports.x[0] = core->ports.x[0] ^ dual[atoi((char*)&c)];
    }
    else if (c==KEY_F(12))	//Reset Taste
    {
    	i=0;
    	core->pc=0x0c000;
	i8086SetSegRegister(core,i8086_REG_CS,0xc00);
	i8086SetRegister(core,i8086_REG_AX,1,0);
	//i8086SetRegister(core,i8086_REG_BX,1,0);
	//i8086SetRegister(core,i8086_REG_CX,1,0);
	//i8086SetRegister(core,i8086_REG_DX,1,0);
	//nodelay(stdscr,TRUE);
    }

    handleKeyboard(core,c);

    if (c!=ERR)
    {
      printReg();
      printFlags();
      printSwitches();
      printDisplay();
      printMem(startAdr);
      printCode(core, commands, &cv);
    //printLeds();
    }
  }

  resetAll(0);

  return EXIT_SUCCESS;
}
/* 测试大对象 ,loop小于 500000*/
VOID testBig(WORD page, WORD field, DWORD loop)
{
    _DB_RET ret;
    _db_tuple_no tupleNo;
    DWORD mem, time;
    _db_t_object_handle objectHandle;

    initDb(page);
    ret = initTable(field);
    if (_DB_SUCCESS != ret)
    {
        printf("%d, init initTable error ret= %x\n", __LINE__, ret);
        dropDb();
        return;
    }

    /* test new */
    setClock();
    setMem();
    for (tupleNo = 0; tupleNo < loop; ++tupleNo)
    {
        ret = _db_put_tuple(tranHandle, dbHandle, tableHandle, (BYTE*) record);
        if (ret != _DB_SUCCESS)
        {
            printf("_db_put_tuple error ret= %x\n", ret);
            break;
        }
    }
    time = getUsedTimes();
    mem = getUsedMem();
    writeLog("testNew: ", page, field, tupleNo, mem >> 10, time);

    /*delete given no object */
    setClock();
    for (tupleNo = 0; tupleNo < loop; ++tupleNo)
    {
        ret = _db_delete_tuple_by_tupleno(tranHandle, dbHandle, tableHandle, tupleNo);
        if (ret != _DB_SUCCESS)
        {
            printf("_db_delete_tuple_by_tupleno= %x\n", ret);
            break;
        }
    }
    time = getUsedTimes();
    mem = getUsedMem();
    writeLog("testDelGiven: ", page, field, tupleNo, mem >> 10, time);

    /*test new given */
    setClock();
    setMem();
    for (tupleNo = 0; tupleNo < loop; ++tupleNo)
    {
        ret = _db_put_tuple_by_tupleno(tranHandle, dbHandle, tableHandle, (BYTE*) record, tupleNo);
        if (ret != _DB_SUCCESS)
        {
            printf("_db_put_tuple_by_tupleno error ret= %x\n", ret);
            break;
        }
    }
    time = getUsedTimes();
    mem = getUsedMem();
    writeLog("testNewGiven: ", page, field, tupleNo, mem >> 10, time);

    /* get given no object */
    setClock();
    for (tupleNo = 0; tupleNo < loop; ++tupleNo)
    {
        ret = _db_get_tuplehandle_by_tupleno(dbHandle, tableHandle, tupleNo, &objectHandle);
        if (ret != _DB_FOUND)
        {
            printf("_db_get_tuplehandle_by_tupleno error ret= %x, objectNo=%d\n", ret, tupleNo);
            break;
        }
    }
    time = getUsedTimes();
    writeLog("testGetGiven: ", page, field, tupleNo, mem >> 10, time);

    dropDb();
}
/*随机测试  概率:20% 随机插入 , 40% 按记录号删除  40% 按记录号插入*/
VOID testTreeRandom()
{
    _DB_RET ret;
    _db_t_object_handle objectHandle;
    _db_t_mem_tree tree;
    VOID *pObjectAddr;
    WORD opType;
    DWORD objectNo = 0xabcd0000;
    DWORD i, loop, sum = 0;
    loop = 100000000;

    initDb(1024);
    _db_init_mem_tree(dbHandle, &tree, 12);
    setMem();
    for (i = 0; i < loop; i++)
    {
        srand(i);
        opType = rand() % 5;
        switch (opType)
        {
            case 0:
                ret = _db_mem_tree_new_object(dbHandle, &tree, &objectHandle, &pObjectAddr);
                if (ret != _DB_SUCCESS)
                {
                    printf("%s,%d:_db_mem_tree_new_object fail,i= %d, ret =%d\n", __FILE__,__LINE__, i, ret);
                }
                ++sum;
                break;
            case 1:
            case 2:
                srand(objectNo);
                objectNo = rand() & 0x0fffffff;
                ret = _db_mem_tree_delete_object_byNO(dbHandle, &tree, objectNo);
                if (ret != _DB_SUCCESS)
                {
                    printf("%s,%d:_db_mem_tree_delete_given_no_object fail,i=%d, objectNo=%d,ret =%d\n", __FILE__,__LINE__,
                           i, objectNo, ret);
                }
                else
                {
                    --sum;
                }
                break;
            default:
                srand(objectNo);
                objectNo = rand();
                ret = _db_mem_tree_new_object_byNO(dbHandle, &tree, objectNo, &objectHandle, &pObjectAddr);
                if (ret == _DB_SUCCESS)
                {
                    ++sum;
                }
                else if (ret == _DB_E_MEM_OBJECT_EXIST)
                {
                    printf("%s,%d: object exist,i=%d, objectNo=%d \n", __FILE__,__LINE__, i, objectNo);
                }
                else
                {
                    printf("%s,%d:_db_mem_tree_new_given_no_object fail,i=%d, objectNo=%d,ret =%d\n", __FILE__,__LINE__, i,
                           objectNo, ret);
                }
        }
    }
    printf("tree.level=%d\n", tree.level);
    _db_mem_tree_destroy(dbHandle, &tree);
    dropDb();
}
auto V30MZ::opMoveMemReg(Size size) {
  modRM();
  setMem(size, getReg(size));
}
Beispiel #16
0
void DSVector::allocMem(int len)
{
   spx_alloc(theelem, len);
   setMem(len, theelem);
}
//8c  mov memw,seg
auto V30MZ::opMoveMemSeg() {
  modRM();
  setMem(Word, getSeg());
  state.poll = false;
}
auto V30MZ::opMoveMemImm(Size size) {
  modRM();
  setMem(size, fetch(size));
}