void PhysicsHashSpace::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    //Do not respond to changes that have a Sync origin
    if(origin & ChangedOrigin::Sync)
    {
        return;
    }

    if(whichField & LevelsFieldMask)
    {
	    dHashSpaceSetLevels(_SpaceID, (Int32)getLevels().x(), (Int32)getLevels().y());
    }
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void MultiOtsuThreshold::readFilterParameters(AbstractFilterParametersReader* reader, int index)
{
  reader->openFilterGroup(this, index);
  setSelectedCellArrayPath( reader->readDataArrayPath( "SelectedCellArrayPath", getSelectedCellArrayPath() ) );
  setNewCellArrayName( reader->readString( "NewCellArrayName", getNewCellArrayName() ) );
  setSaveAsNewArray( reader->readValue( "SaveAsNewArray", getSaveAsNewArray() ) );
  setSlice( reader->readValue( "Slice", getSlice() ) );
  setLevels( reader->readValue( "Levels", getLevels() ) );
  reader->closeFilterGroup();
}
Exemplo n.º 3
0
std::string Node::texLine()
{ 
    std::ostringstream result;
    result << f << " & "
           << getLevels()   << " & "
           << getBranches() << " & "
           << getCount()    << "\\\\" 
           << std::endl;
    
    return result.str();
} 
Exemplo n.º 4
0
std::string Node::csvLine()
{
    std::ostringstream result;
    result << f << "," 
           << getLevels()   << "," 
           << getBranches() << "," 
           << getCount()    << std::endl;

    result << generator() << std::endl;
    
    return result.str();
}
Exemplo n.º 5
0
void
ControlFile::ensureComponent(const char *pattern)
{
    // Make sure at least one entry exists matching a pattern, if not,
    // create it. Wildcard patterns cannot be created though!
    ComponentIterator iter(getComponentIterator());
    bool wasSeen = false;
    Component *c;
    while ((c = iter.next()) != NULL) {
        std::unique_ptr<Component> component(c);
        if (c->matches(pattern)) {
            wasSeen = true;
            break;
        }
    }
    if (!wasSeen) {
        (void) getLevels(pattern); // Creates it ((### ugly ###))
    }
}
int DwtHaar1D::setupDwtHaar1D()
{
    // signal length must be power of 2
    signalLength = sampleCommon->roundToPowerOf2<cl_uint>(signalLength);

    unsigned int levels = 0;
    int result = getLevels(signalLength, &levels);
    CHECK_ERROR(result,SDK_SUCCESS, "signalLength > 2 ^ 23 not supported");

    // Allocate and init memory used by host
    inData = (cl_float*)malloc(signalLength * sizeof(cl_float));
    CHECK_ALLOCATION(inData, "Failed to allocate host memory. (inData)");

    for(unsigned int i = 0; i < signalLength; i++)
    {
        inData[i] = (cl_float)(rand() % 10);
    }

    dOutData = (cl_float*) malloc(signalLength * sizeof(cl_float));
    CHECK_ALLOCATION(dOutData, "Failed to allocate host memory. (dOutData)");

    memset(dOutData, 0, signalLength * sizeof(cl_float));

    dPartialOutData = (cl_float*) malloc(signalLength * sizeof(cl_float));
    CHECK_ALLOCATION(dPartialOutData, "Failed to allocate host memory.(dPartialOutData)");

    memset(dPartialOutData, 0, signalLength * sizeof(cl_float));

    hOutData = (cl_float*)malloc(signalLength * sizeof(cl_float));
    CHECK_ALLOCATION(hOutData, "Failed to allocate host memory. (hOutData)");

    memset(hOutData, 0, signalLength * sizeof(cl_float));

    if(!quiet)
    {
        sampleCommon->printArray<cl_float>("Input Signal", inData, 256, 1);
    }
	

    return SDK_SUCCESS;
}
Exemplo n.º 7
0
void CampaignLevelState::init(Game* game)
{
	// important!
	setGame(game);

	// create the menu
	//mCampaignLevelMenu = new Menu("CustemLevelMenu", MOUSE, true, 4, 4);
	mCampaignLevelMenu = new Menu("CustemLevelMenu", MOUSE, VER, 2, true, 4, 4);
	mCampaignLevelMenu->setMenuBackground("none", 700, 450, 256, 350);		// mCampaignLevelMenu->setMenuBackground("misc\\textures\\menu_bkgd.bmp", 700, 450, 256, 350);

	// get the files in the map folder
	std::vector<string> levelList = getLevels();

	// load the campaign progress
	mProgress.loadProgress("levels\\campaign\\campaign_progress.txt");

	// add menu items, each level
	for(int i = 0; i < levelList.size(); i++)
	{
		// remove .txt
		if(levelList[i].find(".txt") != string::npos || levelList[i].find(".TXT") != string::npos)
			levelList[i].erase(levelList[i].end()-4,levelList[i].end()); 

		if(mProgress.getProgress(levelList[i]).playable == 0)	{
			mCampaignLevelMenu->addMenuItem(levelList[i], (char*)GRAY_BUTTON_NORMAL_SOURCE.c_str(), (char*)GRAY_BUTTON_HOOVER_SOURCE.c_str());
			mCampaignLevelMenu->setPressable(levelList[i], false);
		}
		else
			mCampaignLevelMenu->addMenuItem(levelList[i], "misc\\textures\\level_menu_normal.bmp", "misc\\textures\\level_menu_hoover.bmp");
	}

	// build the menu
	mCampaignLevelMenu->buildMenu2();
	mCampaignLevelMenu->connect(&CampaignLevelState::menuHandler, this);

	mBackgroundTexture = gGraphics->loadTexture("misc\\textures\\epic_bkgd.bmp");
}
Exemplo n.º 8
0
////////////////////////////////////////////////////////////////////////////////
//! Perform the wavelet decomposition
////////////////////////////////////////////////////////////////////////////////
int runTest( int argc, char** argv)
{
  int i;
#ifdef HW
  XFcuda xcore;
  int Status;
  Status = XFcuda_Initialize(&xcore, 0);
  if (Status != XST_SUCCESS) {
    printf("Initialization failed %d\r\n", Status);
    return XST_FAILURE;
  }
#endif

  unsigned int slength = 262144;
  // get the number of decompositions necessary to perform a full decomposition
  unsigned int dlevels_complete = 0;
  if (1 != getLevels( slength, &dlevels_complete))
  {
    // error message
    fprintf( stderr, "Signal length not supported.\n");
    return;
  }

  // device in data
  float* d_idata = NULL;
  // device out data
  float* d_odata = NULL;
  // device approx_final data
  float* approx_final = NULL;

  // The very final approximation coefficient has to be written to the output
  // data, all others are reused as input data in the next global step and
  // therefore have to be written to the input data again.
  // The following flag indicates where to copy approx_final data
  //   - 0 is input, 1 is output
  int approx_is_input;

  // allocate device mem
  const unsigned int smem_size = sizeof(float) * slength;
  d_idata = (float*) malloc(smem_size);
  d_odata = (float*) malloc(smem_size);
  approx_final = (float*) malloc(smem_size);

  // copy input data to device
  memcpy(d_idata, signal, smem_size);

  // clear result memory
  float* tmp = (float*) malloc( smem_size);
  for (i = 0; i < slength; ++i)
    tmp[i] = 0.0;
  memcpy(d_odata, tmp, smem_size);
  free(tmp);

  // total number of threads
  // in the first decomposition step always one thread computes the average and
  // detail signal for one pair of adjacent values
  unsigned int num_threads_total_left = slength / 2;
  // decomposition levels performed in the current / next step
  unsigned int  dlevels_step = dlevels_complete;

  // 1D signal so the arrangement of elements is also 1D
  dim3  block_size;
  dim3  grid_size;

  // number of decomposition levels left after one iteration on the device
  unsigned int dlevels_left = dlevels_complete;

  // if less or equal 1k elements, then the data can be processed in one block,
  // this avoids the Wait-For-Idle (WFI) on host side which is necessary if the
  // computation is split accross multiple SM's if enough input data
  if( dlevels_complete <= 10) {
    // decomposition can be performed at once
    block_size.x = num_threads_total_left;
    approx_is_input = 0;
  } else {
    // 512 threads per block
    grid_size.x = (num_threads_total_left / 512);
    block_size.x = 512;

    // 512 threads corresponds to 10 decomposition steps
    dlevels_step = 10;
    dlevels_left -= 10;
    approx_is_input = 1;
  }
  grid_size.y = 1;
  grid_size.z = 1;
  block_size.y = 1;
  block_size.z = 1;

#ifdef HW
  XFcuda_SetGriddim_y(&xcore, grid_size.y);
  //XFcuda_SetGriddim_z(&xcore, grid_size.z);
  //XFcuda_SetBlockdim_y(&xcore, block_size.y);
  //XFcuda_SetBlockdim_z(&xcore, block_size.z);
  XFcuda_SetId_addr(&xcore, (int)d_idata / sizeof(float));
  XFcuda_SetOd_addr(&xcore, (int)d_odata / sizeof(float));
  XFcuda_SetApprox_final_addr(&xcore, (int)approx_final / sizeof(float));
#endif

  while( 0 != num_threads_total_left) {

#ifndef HW
    //PS execution
    dwtHaar1D(d_idata, d_odata, approx_final, dlevels_step, num_threads_total_left, block_size.x, grid_size, block_size, 1, 0);
#else

    XFcuda_SetDlevels(&xcore, dlevels_step);
    XFcuda_SetSlength_step_half(&xcore, num_threads_total_left);
    XFcuda_SetBdim(&xcore, block_size.x);
    XFcuda_SetGriddim_x(&xcore, grid_size.x);
    XFcuda_SetBlockdim_x(&xcore, block_size.x);

    Xil_DCacheFlush();
    XFcuda_SetEn_fcuda1(&xcore, 1);

    XFcuda_Start(&xcore);
    while (!XFcuda_IsDone(&xcore));
#endif

    // Copy approx_final to appropriate location
    if (approx_is_input) {
      memcpy(d_idata, approx_final, grid_size.x*4);
    }
    else {
      memcpy(d_odata, approx_final, grid_size.x*4);
    }

    // update level variables
    if( dlevels_left < 10) {
      // approx_final = d_odata;
      approx_is_input = 0;
    }

    // more global steps necessary
    dlevels_step = (dlevels_left > 10) ? dlevels_left - 10 : dlevels_left;
    dlevels_left -= 10;

    // after each step only half the threads are used any longer
    // therefore after 10 steps 2^10 less threads
    num_threads_total_left = num_threads_total_left >> 10;

    // update block and grid size
    grid_size.x = (num_threads_total_left / 512)
      + (0 != (num_threads_total_left % 512)) ? 1 : 0;
    if( grid_size.x <= 1) {
      block_size.x = num_threads_total_left;
    }
  }

#ifdef VERIFY
  for (i = 0; i < 10; i++)
    printf("index=%d, ref=%f, fpga=%f\n", i, reference[i], d_odata[i]);
  int res = compareData(reference, d_odata, slength, 0.1f);
  printf("%s\n", (1 == res) ? "PASSED." : "FAILED.");
#endif
  free(d_idata);
  free(d_odata);
  free(approx_final);
}
int 
DwtHaar1D::runCLKernels(void)
{

    // Calculate thread-histograms 
    unsigned int levels = 0;
    unsigned int curLevels = 0;
    unsigned int actualLevels = 0;

    int result = getLevels(signalLength, &levels);
    CHECK_ERROR(result, SDK_SUCCESS, "getLevels() failed");

    actualLevels = levels;

    //max levels on device should be decided by kernelWorkGroupSize
    int tempVar = (int)(log((float)kernelInfo.kernelWorkGroupSize) / log((float)2));
    maxLevelsOnDevice = tempVar + 1;

    cl_float* temp = (cl_float*)malloc(signalLength * sizeof(cl_float));
    memcpy(temp, inData, signalLength * sizeof(cl_float));

    levelsDone = 0;
    int one = 1;
    while((unsigned int)levelsDone < actualLevels)
    {
        curLevels = (levels < maxLevelsOnDevice) ? levels : maxLevelsOnDevice;

        // Set the signal length for current iteration
        if(levelsDone == 0)
            curSignalLength = signalLength;
        else
            curSignalLength = (one << levels);

        // Set group size
        groupSize = (1 << curLevels) / 2;

        totalLevels = levels;
        runDwtHaar1DKernel();

        if(levels <= maxLevelsOnDevice)
        {
            dOutData[0] = dPartialOutData[0];
            memcpy(hOutData, dOutData, (one << curLevels) * sizeof(cl_float));
            memcpy(dOutData + (one << curLevels), hOutData + (one << curLevels), (signalLength  - (one << curLevels)) * sizeof(cl_float));
            break;
        }
        else
        {
            levels -= maxLevelsOnDevice;
            memcpy(hOutData, dOutData, curSignalLength * sizeof(cl_float));
            memcpy(inData, dPartialOutData, (one << levels) * sizeof(cl_float));
            levelsDone += (int)maxLevelsOnDevice;
        }

    }

    memcpy(inData, temp, signalLength * sizeof(cl_float));
    free(temp);

	 

    return SDK_SUCCESS;
}
Exemplo n.º 10
0
////////////////////////////////////////////////////////////////////////////////
//! Perform the wavelet decomposition
////////////////////////////////////////////////////////////////////////////////
void runTest( int argc, char** argv)
{
  char* s_fname ;
  char* r_fname ;
  char* r_gold_fname ;
  const char usage[] =
  {
    "\nUsage:\n"
      "  dwtHaar1D --signal=<signal_file> --result=<result_file> --gold=<gold_file>\n\n"
      "  <signal_file> Input file containing the signal\n"
      "  <result_file> Output file storing the result of the wavelet decomposition\n"
      "  <gold_file>   Input file containing the reference result of the wavelet decomposition\n"
      "\nExample:\n"
      "  bin\\win32\\release\\dwtHaar1D\n"
      "       --signal=projects\\dwtHaar1D\\data\\signal.dat\n"
      "       --result=projects\\dwtHaar1D\\data\\regression.dat\n"
      "       --gold=projects\\dwtHaar1D\\data\\regression.gold.dat\n"
  };

  char s_fname_arr[] = "data/signal_2_18.dat";
  char r_gold_fname_arr[] = "data/regression_2_18.gold.dat";

  char r_fname_arr[] = "regression.dat";
  s_fname = s_fname_arr;
  r_fname = r_fname_arr;
  r_gold_fname = r_gold_fname_arr;

  // read in signal
  unsigned int slength = 262144;
  DATATYPE* signal = NULL;
  if (s_fname == 0)
  {
    fprintf(stderr, "Cannot find the file containing the signal.\n%s", usage);
    exit(1);
  }
  if (readFile(s_fname, &signal) == 1) {
    printf("Reading signal from %s\n", s_fname);
  } else {
    exit(1);
  }

  // get the number of decompositions necessary to perform a full decomposition
  unsigned int dlevels_complete = 0;
  if (1 != getLevels( slength, &dlevels_complete))
  {
    // error message
    fprintf( stderr, "Signal length not supported.\n");
    return;
  }

  // device in data
  DATATYPE* d_idata = NULL;
  // device out data
  DATATYPE* d_odata = NULL;
  // device approx_final data
  DATATYPE* approx_final = NULL;

  // The very final approximation coefficient has to be written to the output
  // data, all others are reused as input data in the next global step and
  // therefore have to be written to the input data again.
  // The following flag indicates where to copy approx_final data
  //   - 0 is input, 1 is output
  int approx_is_input;

  // allocate device mem
  const unsigned int smem_size = sizeof(DATATYPE) * slength;
  d_idata = (DATATYPE*) malloc(smem_size);
  d_odata = (DATATYPE*) malloc(smem_size);
  approx_final = (DATATYPE*) malloc(smem_size);
  memcpy(d_idata, signal, smem_size);

  // clear result memory
  DATATYPE* tmp = (DATATYPE*) malloc( smem_size);
  int i;
  for (i = 0; i < slength; ++i)
    tmp[i] = 0.0;
  memcpy(d_odata, tmp, smem_size);
  free( tmp);

  // total number of threads
  // in the first decomposition step always one thread computes the average and
  // detail signal for one pair of adjacent values
  unsigned int num_threads_total_left = slength / 2;
  // decomposition levels performed in the current / next step
  unsigned int  dlevels_step = dlevels_complete;

  // 1D signal so the arrangement of elements is also 1D
  dim3  block_size;
  dim3  grid_size;

  // number of decomposition levels left after one iteration on the device
  unsigned int dlevels_left = dlevels_complete;

  // if less or equal 1k elements, then the data can be processed in one block,
  // this avoids the Wait-For-Idle (WFI) on host side which is necessary if the
  // computation is split accross multiple SM's if enough input data
  if( dlevels_complete <= 10) {
    // decomposition can be performed at once
    block_size.x = num_threads_total_left;
    approx_is_input = 0;
  } else {
    // 512 threads per block
    grid_size.x = (num_threads_total_left / 512);
    block_size.x = 512;

    // 512 threads corresponds to 10 decomposition steps
    dlevels_step = 10;
    dlevels_left -= 10;
    approx_is_input = 1;
  }
  grid_size.y = 1;
  grid_size.z = 1;
  block_size.y = 1;
  block_size.z = 1;

  // do until full decomposition is accomplished
  while( 0 != num_threads_total_left) {
    // run kernel
    dwtHaar1D(d_idata, d_odata, approx_final, dlevels_step, num_threads_total_left, block_size.x, grid_size, block_size, 1, 0);

    // Copy approx_final to appropriate location
    if (approx_is_input) {
      memcpy(d_idata, approx_final, grid_size.x*4);
    } else {
      memcpy(d_odata, approx_final, grid_size.x*4);
    }

    // update level variables
    if( dlevels_left < 10) {
      // approx_final = d_odata;
      approx_is_input = 0;
    }

    // more global steps necessary
    dlevels_step = (dlevels_left > 10) ? dlevels_left - 10 : dlevels_left;
    dlevels_left -= 10;

    // after each step only half the threads are used any longer
    // therefore after 10 steps 2^10 less threads
    num_threads_total_left = num_threads_total_left >> 10;

    // update block and grid size
    grid_size.x = (num_threads_total_left / 512)
      + (0 != (num_threads_total_left % 512)) ? 1 : 0;
    if( grid_size.x <= 1) {
      block_size.x = num_threads_total_left;
    }
  }

  // load the reference solution
  unsigned int len_reference = 262144;
  DATATYPE* reference = NULL;
  if (r_gold_fname == 0) {
    fprintf(stderr, "Cannot read the file containing the reference result of the wavelet decomposition.\n%s", usage);
    //cudaThreadExit();
    exit(1);
  }
  if (readFile(r_gold_fname, &reference) == 1)
    printf("Reading reference result from %s\n", r_gold_fname);
  else {
    exit(1);
  }
  assert(slength == len_reference);

  //compare the computed solution and the reference
  int res = compareData(reference, d_odata, slength, 0.001f);
  printf("%s\n", (1 == res) ? "PASSED." : "FAILED.");
  free(reference);
  free(d_odata);
  free(d_idata);
  free(approx_final);
  free(signal);
}
Exemplo n.º 11
0
TreeNameParser::TreeNameParser(char *filename)//Normal.txt
{
	ifstream inf(filename, ios::in);
	// from the name, get the layer number
	QString fName(filename);
	fName.remove(".out");
	int idx = fName.lastIndexOf("_");
	fName = fName.mid(idx+1,fName.size()-idx);
	int layerNum=fName.toUInt();

	//int bufsize = BUFSIZE * 3;
	char lineBuf[BUFSIZE3], *token, sToken[BUFSIZE3];
	char delim[]=".";  // delimited by space
	int  iToken;

	for(int i=0; i<MAX_LEVEL; i++) resetParCount(i);

	while(inf)
	{
		inf.getline(lineBuf, BUFSIZE3);
		for(int j = 0; j < BUFSIZE3; ++j)sToken[j] = '\0';

		// separate the index and string token
		sscanf(lineBuf, "%d %s", &iToken, sToken);

		// save the length 
		int lev= getLevels(sToken), lc=0, wc=0; 
		// lc: level counter ; wc: word counter
		_lev.push_back(lev); // now everything is 3

		if(lev==1) break; // feature. TODO:..last line.. 

		if(lev==2)
		{	
			char temp[BUFSIZE3];
			int i = 0;
			for(int j = 0; j < BUFSIZE3; ++j)temp[j] = '\0';

			for(; sToken[i] != '.'; ++i)
				temp[i] = sToken[i];
			temp[i] = sToken[i];
			++i;
			for(int j = 0; sToken[j] != '\0'; ++j, ++i)
				temp[i] = sToken[j];
			strcpy(sToken, temp);
			lev++;

		}
		// split by "."
		_tmpToken.clear();
		token = strtok(sToken, delim);

	    if(lev==4)
		{
			// get rid of the first level
		}

		if(lev == layerNum)
		{
			_tmpToken.push_back(token); // keep what it is
			pushbackLp(lc++, token, _tmpToken); // save to _lp1
		}

		while( (token = strtok(NULL, delim))!=NULL )
		{
			_tmpToken.push_back(token);
			pushbackLp(lc++, token, _tmpToken); // save to _lp2, _lp3 and _lp4
		};		
		_names.push_back(_tmpToken); // save the last one
	}; // end while(inf)

	int lcc= GetMaxLevel();
	for(int i=0; i<lcc; i++)
	{
		tmp_lpc[i].push_back(parCount[i]); // save the last one
	}

	inf.close();
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void MultiOtsuThreshold::setupFilterParameters()
{
  FilterParameterVector parameters;
  parameters.push_back(FilterParameter::New("Array to Process", "SelectedCellArrayPath", FilterParameterWidgetType::DataArraySelectionWidget, getSelectedCellArrayPath(), false, ""));
  QStringList linkedProps;
  linkedProps << "NewCellArrayName";
  parameters.push_back(LinkedBooleanFilterParameter::New("Save As New Array", "SaveAsNewArray", getSaveAsNewArray(), linkedProps, false));

  parameters.push_back(FilterParameter::New("Created Array Name", "NewCellArrayName", FilterParameterWidgetType::StringWidget, getNewCellArrayName(), false, ""));
  parameters.push_back(FilterParameter::New("Slice at a Time", "Slice", FilterParameterWidgetType::BooleanWidget, getSlice(), false));
  parameters.push_back(FilterParameter::New("Number of Levels", "Levels", FilterParameterWidgetType::IntWidget, getLevels(), false, ""));
  setFilterParameters(parameters);
}
Exemplo n.º 13
0
unsigned int *
ControlFile::getLevels(const char *name)
{
    // these comments are all wrong...

    // See if there already is some info for name. If not,
    // lock the file, stat it, remap if necessary, scan again,
    // and if still not there, append to it. Return pointer to mapped area.

    // ### call getComponent() instead,
    // ### if it does not exist, create it and return the thing
    // ### get default value from pre-existing levels, or from
    // ### the default level if nothing exists.
    // ### (if default level does not exist, create it?)

    _fileBacking.lock(_mode != READONLY);
    static const char *padSpaces = "   "; // 3 spaces
    char buf[2000];
    if (strcmp(name, "") == 0) {
        name = "default";
    }
    // Leave space for 3 spaces and a full levels string (200 bytes should
    // be enough)
    snprintf(buf, sizeof buf - 200, "\n%s: ", name);

    char *levels = strstr(_mapBase, buf);
    if (levels) {
        _fileBacking.unlock();
        char *addr = levels + strlen(buf);
        addr = alignLevels(addr);
        return reinterpret_cast<unsigned int *>(addr);
    }

    char *inheritLevels =  reinterpret_cast<char *>(defaultLevels());
    const char *chop = strrchr(name, '.');
    if (chop != NULL) {
        char shorterName[2000];
        strncpy(shorterName, name, chop - name);
        shorterName[chop-name] = '\0';
        unsigned int *inherit = getLevels(shorterName);
        if (inherit != NULL) {
            inheritLevels =  reinterpret_cast<char *>(inherit);
        }
    }

    //  Append whatever is in buf, excluding the initial newline, and
    //  up to 3 more spaces to get the entire file length to be aligned.
    int fileLength = _fileBacking.size();
    char *appendedString = buf + 1;
    int newLength = fileLength + strlen(appendedString);
    unsigned int padding = static_cast<unsigned int>(-newLength) & 3u;
    strcat(appendedString, &padSpaces[3 - padding]);

    char *baseAddr = _mapBase + fileLength + strlen(appendedString);

    strncat(appendedString, inheritLevels, Logger::NUM_LOGLEVELS*sizeof(int));
    strcat(appendedString, "\n");

    int len = strlen(appendedString);

    int fd = _fileBacking.fd();
    lseek(fd, (off_t)fileLength, SEEK_SET);
    int wlen = write(_fileBacking.fd(), appendedString, len);
    if (wlen != len) {
        _fileBacking.unlock();
        LOG(error, "Writing to control file '%s' fails (%d/%d bytes): %s",
            _fileName, wlen, len, strerror(errno));
        return reinterpret_cast<unsigned int *>(inheritLevels);
    } else {
        _fileSize += wlen;
    }

    if (fileLength + wlen > _mappedSize) {
        if (!extendMapping()) {
            _fileBacking.unlock(); // just for sure
            LOG(error, "Failed to extend mapping of '%s', losing runtime "
                "configurability of component '%s'", _fileName, name);
            return defaultLevels();
        }
    }

    _fileBacking.unlock();

    return reinterpret_cast<unsigned int *>(baseAddr);
}
Exemplo n.º 14
0
void PhysicsHashSpace::initHashSpace()
{
    setLevels(getLevels());
    initSpace();
}