Exemple #1
0
int get_sems(const char* filename, int num)
{
	CHECK(filename, "Argumented filename pointer is NULL");
	int fileid = creat(filename, 660);
	CHECK(fileid != -1 || (fileid == -1 && errno == EEXIST), "Unexpected error during sharing memory file creation");


	key_t file_key = ftok(filename, 1);
	CHECK(file_key != -1, "Failed to get System V key");
	OUT3("# File key: %d\n# Number: %d\n# Flag: %o\n", file_key, num, IPC_CREAT | 0660);
	int sem_id = semget(file_key, num, IPC_CREAT | 0660);	
	CHECK(sem_id != -1, "Failed to get semaphor id from System V key");
	return sem_id;
}
Exemple #2
0
void wilson_dslash_spproj(double *out0, double *out1, double *out2, double *out3, 
			  double *inf, double sign)
{
  int c;

  for(c=0;c<3;c++){

    /* spin project with [1 + sign * gamma_0] */
    OUT0(0,c,0) = INF(0,c,0) + sign * ( -INF(1,c,3) ); 
    OUT0(1,c,0) = INF(1,c,0) + sign * (  INF(0,c,3) ); 
    
    OUT0(0,c,1) = INF(0,c,1) + sign * ( -INF(1,c,2) ); 
    OUT0(1,c,1) = INF(1,c,1) + sign * (  INF(0,c,2) ); 
    
    /* spin project with [1 + sign * gamma_1] */
    OUT1(0,c,0) = INF(0,c,0) + sign * ( -INF(0,c,3) ); 
    OUT1(1,c,0) = INF(1,c,0) + sign * ( -INF(1,c,3) ); 
    
    OUT1(0,c,1) = INF(0,c,1) + sign * (  INF(0,c,2) ); 
    OUT1(1,c,1) = INF(1,c,1) + sign * (  INF(1,c,2) ); 
    
    /* spin project with [1 + sign * gamma_2] */
    OUT2(0,c,0) = INF(0,c,0) + sign * ( -INF(1,c,2) ); 
    OUT2(1,c,0) = INF(1,c,0) + sign * (  INF(0,c,2) ); 
    
    OUT2(0,c,1) = INF(0,c,1) + sign * (  INF(1,c,3) ); 
    OUT2(1,c,1) = INF(1,c,1) + sign * ( -INF(0,c,3) ); 
    
    /* spin project with [1 + sign * gamma_3] */
    OUT3(0,c,0) = INF(0,c,0) + sign * (  INF(0,c,2) ); 
    OUT3(1,c,0) = INF(1,c,0) + sign * (  INF(1,c,2) ); 
    
    OUT3(0,c,1) = INF(0,c,1) + sign * (  INF(0,c,3) ); 
    OUT3(1,c,1) = INF(1,c,1) + sign * (  INF(1,c,3) ); 
  }

}
Exemple #3
0
/* perform a low temperature anneal on pins */
final_pin_place()
{

    INT i ;               /* counter */
    INT attempts ;        /* number of moves made */
    INT nummoves ;        /* number of moves to do on a cell */
    INT selection ;       /* select a cell with softpins */
    INT nsoftpin_cells ;  /* number of cells with softpins */
    CELLBOXPTR acellptr;  /* current cell with softpins */

    /* don't perform if cost only is specified in input file */
    /* scale data variable is necessary for recursive TimberWolfMC call */
    if( /* cost_onlyG || */ scale_dataG > 1 ){
	return ;
    }

    /* now check to see if we have any soft pins if not return */
    if( (nsoftpin_cells = (int) softPinArrayG[HOWMANY] ) == 0 ){
	return ;
    }

    /* make new site arrays for pins */
    for( i = 1; i <= nsoftpin_cells; i++ ){
	update_sites( softPinArrayG[i] ) ;
    }
    findcost() ;

    /* continue with a low Temp anneal */
    TG = 10.0 ;
    attempts = 0 ;
    if( overpenalG ){  
	/* make pinFactor 1 order more important than wirelength */
	pinFactorG =  10.0 * (DOUBLE) funccostG / (DOUBLE) overpenalG ;
	/* also set softPinArrayG to look at cells with overlap */
    } else {
	/* otherwise use previous pinFactorG */
	/* make 1 order more important */
	pinFactorG *= 10.0 ;
    }

    while( attempts < attmaxG ) {

	/* to make pin moves more efficient, use softPinArrayG */
	/* which keeps track of all softcells which have pins */
	/* which can move. softPinArrayG[0] holds size of array */
	selection = PICK_INT( 1, (int) softPinArrayG[HOWMANY] );
	/* now get cellptr */
	acellptr = softPinArrayG[selection] ;
	/* pick number of pins moves to be attempted */
	/* PIN_MOVE is beginning of sequence.  */
	if( overpenalG && !(doPartitionG) ){  
	    /* if a penalty exists do many moves */
	    nummoves = acellptr->numsoftpins ;
	} else {
	    nummoves = 1 ; /* no penalty try to reduce wirelen */
	}

	/* *********** NOW EVALUATE THE PROPOSED MOVE ********* */
	/* now try softpin moves */
	for( i=1; i<= nummoves; i++ ){
	    selectpin( acellptr ) ;
	}
	/* *********** END OF PROPOSED MOVE  EVALUATION ********* */
	attempts++ ;

	D( "finalpin", checkcost() ) ; /* if debug on check cost after each move */

    } /* ****** END OF ANNEALING LOOP **************** */

    /* verify incremental and current costs after each iteration */
    D( "finalpin", checkcost() ) ;

    /* ----------------------------------------------------------------- 
       now output statistics for this temperature.
    */

    OUT1("\n\nPin place optimizer\n");
    OUT1("\nI     T     funccost  overpen  x pinFact = overfill pinflips\n");
    OUT2("%3d ",iterationG ); 
    OUT2("%4.2le ",TG ); 
    OUT2("%4.2le ",(DOUBLE) funccostG ); 
    OUT2("%4.2le ",(DOUBLE) overpenalG ); 
    OUT2("%4.2le ",(DOUBLE) pinFactorG ); 
    OUT2("%4.2le ",(DOUBLE) overfillG ); 
    OUT3("%3d/%3d\n\n",flippG,attpG ); 
    FLUSHOUT() ;

    return ;
} /* end final_pin_place */