Exemplo n.º 1
0
void startThreads() {
	stopThreads();
	cleanMemory();
	threadStop = 0;
	files = calloc(numThreads, sizeof(FILE));
	threads = calloc(numThreads, sizeof(pthread_t));
	thread_args = calloc(numThreads, sizeof(uint32_t));
	pixelListHeads = calloc(numThreads, sizeof(pixelHead));
	tiles = calloc(numThreads*numThreads, sizeof(screenTiles));
	
	int32_t numSplit=numThreads;
	int32_t offSetY=0;
	int32_t dY = sizeY / numSplit;
	int32_t rest = sizeY % numSplit;
	int num = 0;
	for (int32_t y = 0; y<numSplit; y++) {
		tiles[num].fromX = 0;
		tiles[num].toX = sizeX;
		tiles[num].fromY = offSetY;
		tiles[num].toY = offSetY+dY;
		// Wenn ein Teilungsrest da ist, muss der aufaddiert werden, sonst fehlt was vom Bild
		if(y == numSplit-1) {
			tiles[num].toY += rest;
		}
		offSetY+=dY;
		num++;
	}
	
	for (int i=0; i<numThreads; i++) {
		thread_args[i] = i;
		printf("Erstelle Thread %d\n", i);
		pthread_create(&threads[i], NULL, ThreadCode, (void *) &thread_args[i]);
	}
	
}
Exemplo n.º 2
0
void freeMem() {
	stopThreads();
	mpf_clear(mandelRange.minRe);
	mpf_clear(mandelRange.maxRe);
	mpf_clear(mandelRange.minIm);
	mpf_clear(mandelRange.maxIm);
	cleanMemory();
}
	void parseFileAndModifyValueForKey(File * file , char * aKey , char * newValue ,
			Bool (*anIgnoreLineCriteria)(char *),
			void (*modifyKeysAndValuesCriteria)(char * , char * , void * , File * ),
			void * storageObject){


		char lineBuffer[SYSTEM_FILE_LINE_LENGTH];
		cleanMemory(lineBuffer,SYSTEM_FILE_LINE_LENGTH);
		while(fgets(lineBuffer , SYSTEM_FILE_LINE_LENGTH , file)){
			char * line = trim(lineBuffer);

			if(anIgnoreLineCriteria == NULL || !anIgnoreLineCriteria(line)){
				char * key = getKey(line);
				char * value = getValue(line);

				if(key != NULL && value != NULL){

					if(equalsStrings(key , aKey)){

						/*
						 * Inicializamos la posicion donde fue encontrada la linea en cuestion
						 * mediante la posicion actual del archivo menos la suma del largo de la linea mas
						 * un caracter '\n' de fin de linea.
						 */
						long int currentPossition = ftell(file);
						long int fileStartLinePossition = currentPossition - (strlen(value) + 1);

						/*
						 * Pocisionamos el cursor del archivo en la posicion correspondiente
						 * para realizar la escritura
						 */
						fseek(file , fileStartLinePossition , SEEK_SET);

						//escritura...
						modifyKeysAndValuesCriteria(value , newValue, storageObject , file);

						/*
						 * volvemos a posicionarnos donde estabamos
						 */
						fseek(file , currentPossition , SEEK_SET);
					}
				}
			}
		}
		cleanMemory(lineBuffer, SYSTEM_FILE_LINE_LENGTH);
	}
Exemplo n.º 4
0
CleanMemoryState::CleanMemoryState(QString displayBuffer):
    LevelState(displayBuffer)
{
    guardedTransition = new CleanMemoryTransition();
    this->addTransition(guardedTransition);
    QObject::connect(this,
                     SIGNAL(entered()),
                     this,
                     SLOT(cleanMemory())
                     );
}
	void parseKeyAndValueFile(File * file ,
			Bool (*anIgnoreLineCriteria)(char *),
			void (*processKeysAndValuesCriteria)(char * , char * , void *),
			void * storageObject){


		char lineBuffer[SYSTEM_FILE_LINE_LENGTH];
		cleanMemory(lineBuffer,SYSTEM_FILE_LINE_LENGTH);
		while(fgets(lineBuffer , SYSTEM_FILE_LINE_LENGTH , file)){
			char * line = trim(lineBuffer);

			if(anIgnoreLineCriteria == NULL || !anIgnoreLineCriteria(line)){
				char * key = getKey(line);
				char * value = getValue(line);

				if(key != NULL && value != NULL)
					processKeysAndValuesCriteria(key , value , storageObject);
			}
		}
		cleanMemory(lineBuffer, SYSTEM_FILE_LINE_LENGTH);
	}
Exemplo n.º 6
0
	char * concatAll(int n , ...){

		char buffer[SYSTEM_STRING_CONCATENATION_SIZE];
		cleanMemory(buffer , SYSTEM_STRING_CONCATENATION_SIZE);

		va_list ap;
		va_start(ap, n);
		int i; for(i=0 ; i<n ; i++){
			strcat(buffer, va_arg(ap, char*));
		}
		va_end(ap);

		return trim(buffer);
	}
Exemplo n.º 7
0
DoubleList cleanMemory(DoubleList list)
{
	if (list.start == 0)
	{
		printf("\n[CLEAN MEMORY] List is empty!");
		return list;
	}
	else
	{
		Node* temp = list.start;
		temp = cleanMemory(temp);

		list.start = 0;
		list.end = 0;
	}
}
Exemplo n.º 8
0
void clean() {

    cleanMemory();
    freeFileName();
    cmdFree();
    conFree();

#ifndef NO_GUI

    colourSpectrumClear();
    timerFree();

    if (video.sdlStarted) {
        TTF_Quit();
        SDL_Quit();
    }

#endif

}
Exemplo n.º 9
0
Node* cleanMemory(Node* list)
{
	if (list == 0)
		return 0;
	
	Node* temp = list->right;

	if (list->info.clientName != 0)
		free(list->info.clientName);
	if (list->info.adress != 0)
		free(list->info.adress);
	if (list->info.telNo != 0)
		free(list->info.telNo);

	free(list);

	temp = cleanMemory(temp);

	return list;
}
Exemplo n.º 10
0
void exploitShortReadPairs(Graph * argGraph,
			   ReadSet * reads,
			   boolean * dubious,
			   boolean * shadows,
			   boolean force_jumps)
{
	boolean modified = true;

	graph = argGraph;

	if (!readStartsAreActivated(graph))
		return;

	velvetLog("Starting pebble resolution...\n");

	resetNodeStatus(graph);

	// Prepare scaffold
	buildScaffold(graph, reads, dubious, shadows);

	// Prepare graph
	prepareGraphForLocalCorrections(graph);

	// Prepare local scaffold 
	localScaffold =
	    callocOrExit(2 * nodeCount(graph) + 1, MiniConnection);

	// Loop until convergence
	while (modified)
		modified = expandLongNodes(force_jumps);

	// Clean up memory
	cleanMemory();
	deactivateLocalCorrectionSettings();

	sortGapMarkers(graph);

	velvetLog("Pebble done.\n");
}
Exemplo n.º 11
0
bool ReadsLayout::load(istream& in_bin, ReadsStorage*r) {
    
  
    unsigned int crcCheck;
    Crc32 CRC;
    
    
    cleanMemory();
    unsigned int tabsize;

    in_bin.read((char*) &crcCheck, sizeof (unsigned int));
    
    in_bin.read((char*) &tabsize, sizeof (unsigned int));

    init(r, tabsize);

    in_bin.read((char*) lastIdentical, sizeof (unsigned int) *tabSize);
    in_bin.read((char*) next, sizeof (unsigned int) *tabSize);
    in_bin.read((char*) previous, sizeof (unsigned int) *tabSize);
    in_bin.read((char*) nodeId, sizeof (unsigned int) *tabSize);
    in_bin.read((char*) position, sizeof (int) *tabSize);
    in_bin.read((char*) flags, sizeof (unsigned char) *tabSize);
    
    CRC.AddData((uint8_t*) & tabSize, sizeof (unsigned int));
    CRC.AddData((uint8_t*) lastIdentical, sizeof (unsigned int) *tabSize);
    CRC.AddData((uint8_t*) next, sizeof (unsigned int) *tabSize);
    CRC.AddData((uint8_t*) previous, sizeof (unsigned int) *tabSize);
    CRC.AddData((uint8_t*) nodeId, sizeof (unsigned int) *tabSize);
    CRC.AddData((uint8_t*) position, sizeof (int) *tabSize);
    CRC.AddData((uint8_t*) flags, sizeof (unsigned char) *tabSize);
    
    unsigned int crc2=CRC.GetCrc32();
    
    if (crc2 != crcCheck)
        return false;
    
    return true;
}
Exemplo n.º 12
0
int main (int argc, char *argv[]){

    // VERIFICAR SE O USUARIO
    // CONTINUA OU SAI DO PROGRAMA
    char op=NULL;
    do {

        PPMImageParams* imageParams;

        imageParams = (PPMImageParams *)malloc(sizeof(PPMImageParams));

        // CARREGA O MENU OU SETA AS OPCOES
        // CASO INSERIDAS NA LINHA DE COMANDO
        initialParams* ct = (initialParams *)calloc(1,sizeof(initialParams));

        ct->DIRIMGIN = "images_in/";
        ct->DIRIMGOUT = "images_out/";
        ct->DIRRES = "resultados/";
        ct->typeAlg = 'S'; // SEQUENCIAL
        menu(ct, argc, argv);

        sprintf((char*) &imageParams->fileOut, "%s%s", ct->DIRIMGOUT, ct->filePath);
        sprintf((char*) &imageParams->fileIn, "%s%s", ct->DIRIMGIN, ct->filePath);

        if (ct->filePath != NULL) {
            // RELOGIO
            tempo* relogio = (tempo* )malloc(sizeof(tempo)*2);

            //CARREGA O RELOGIO
            timer* tempoA = (timer *)malloc(sizeof(timer));
            timer* tempoR = (timer *)malloc(sizeof(timer));
            timer* tempoF = (timer *)malloc(sizeof(timer));
            timer* tempoW = (timer *)malloc(sizeof(timer));

            start_timer(tempoA);

            sequencial(imageParams, ct, tempoR, tempoF, tempoW);

            //PARA O RELOGIO
            stop_timer(tempoA);

            relogio[0].tempoA = total_timer(tempoA);
            relogio[1].tempoR = total_timer(tempoR);
            relogio[1].tempoF = total_timer(tempoF);
            relogio[1].tempoW = total_timer(tempoW);

            show_timer(relogio, 1);

            // ESCREVENDO OS RESULTADOS
            // NO ARQUIVO /resultados/
            writeFile(ct, imageParams, relogio);

            // LIMPANDO A MEMORIA
            cleanMemory(ct, imageParams, NULL, relogio, tempoA, tempoR, tempoF, tempoW);

        } else {
            printf("\nOpcao invalida!\n\n");
        }

        if (!argv[1]) {
            printf("\nPressione 's' para voltar ao menu ou 'n' para sair...\n");
            int ret = scanf(" %c", &op);
            if (ct->debug >= 1) printf("\nRet OP: %d", ret);
        } else {
            op = 'n';
        }

    } while (op != 'n');

    return 0;
}
Exemplo n.º 13
0
void lammps_eon::makeNewLAMMPS(long N, const double *R, const int *atomicNrs, const double *box){
    numberOfAtoms = N;
    for (int i=0;i<9;i++) oldBox[i] = box[i];

    if(LAMMPSObj != NULL){
        cleanMemory();
    }

    std::map<int,int> type_map;
    int ntypes=0;
    for (int i=0;i<N;i++) {
        if (type_map.count(atomicNrs[i]) == 0) {
            ntypes += 1;
            type_map.insert(std::pair<int,int>(atomicNrs[i],ntypes));
        }
    }

    char *lammps_argv[9];
    int nargs=7;
    lammps_argv[0] = "";
    lammps_argv[1] = "-log";
    if (parameters->LAMMPSLogging) {
        lammps_argv[2] = "log.lammps";
    }else{
        lammps_argv[2] = "none";
    }
    lammps_argv[3] = "-echo";
    lammps_argv[4] = "log";
    lammps_argv[5] = "-screen";
    lammps_argv[6] = "none";


    if (parameters->LAMMPSThreads > 0) {
        lammps_argv[7] = "-suffix";
        lammps_argv[8] = "omp";
        nargs += 2;
    }
    #ifdef EONMPI
        lammps_open(nargs, lammps_argv, parameters->MPIClientComm, &LAMMPSObj);
    #else
        lammps_open_no_mpi(nargs, lammps_argv, &LAMMPSObj);
    #endif
    void *ptr = LAMMPSObj;

    char cmd[200];

    if (parameters->LAMMPSThreads > 0) {
        snprintf(cmd, 200, "package omp %i force/neigh", parameters->LAMMPSThreads);
        lammps_command(ptr, cmd);
    }

    //Gives units in Angstoms and eV
    lammps_command(ptr, "units metal");
    lammps_command(ptr, "atom_style	charge");

    //Preserves atomic index ordering
    lammps_command(ptr, "atom_modify map array sort 0 0");

    //Always check to see if the neighbor list must be updated
    lammps_command(ptr, "neigh_modify delay 1");


    //Define periodic cell
    //    prism args = xlo xhi ylo yhi zlo zhi xy xz yz
    //        xlo,xhi,ylo,yhi,zlo,zhi = bounds of untilted prism
    //        xy = distance to tilt y in x direction
    //        xz = distance to tilt z in x direction
    //        yz = distance to tilt z in y direction
    snprintf(cmd, 200, "region cell prism 0 %f 0 %f 0 %f %f %f %f units box",
             box[0], box[4], box[8], box[3], box[6], box[7]);

    lammps_command(ptr, cmd);
    snprintf(cmd, 200, "create_box %i cell", ntypes);
    lammps_command(ptr, cmd);

    //Initialize the atoms and their types
    for (int i=0;i<N;i++) {
        snprintf(cmd, 200, "create_atoms %i single %f %f %f units box",
                 type_map[atomicNrs[i]], 0.0, 0.0, 0.0);
        lammps_command(ptr, cmd);
    }

    //We don't care about mass but have to set it
    lammps_command(ptr, "mass * 1.0");

    //Read in user commands from in.lammps files
    struct stat buffer;
    if (stat("in.lammps", &buffer) == -1) {
        fprintf(stderr, "couldn't open in.lammps: %s\n",strerror(errno));
        exit(1);
    }else{
        lammps_file(ptr, "in.lammps");
    }

    //Define variables for force and energy so they can be extracted
    lammps_command(ptr, "variable fx atom fx");
    lammps_command(ptr, "variable fy atom fy");
    lammps_command(ptr, "variable fz atom fz");
    lammps_command(ptr, "variable pe equal pe");
}
Exemplo n.º 14
0
Akuerdate::~Akuerdate() {
    
    cleanMemory();
    
}
Exemplo n.º 15
0
void main()
{
	FILE* f;
	Order com;
	DoubleList list;

	list.start = 0;
	list.end = 0;

	f = fopen("Orders.txt", "r");

	if (f)
	{
		char nameBuffer[64];
		char phoneBuffer[32];
		char adressBuffer[64];

		fscanf(f, "%d, %[^,], %[^,], %[^,], %d", &com.carId, nameBuffer, phoneBuffer, adressBuffer, &com.waitingTime);
		
		while (!feof(f))
		{
			com.clientName = (char*)malloc((strlen(nameBuffer) + 1) * sizeof(char));
			strcpy(com.clientName, nameBuffer);

			com.telNo = (char*)malloc((strlen(phoneBuffer) + 1) * sizeof(char));
			strcpy(com.telNo, phoneBuffer);

			com.adress = (char*)malloc((strlen(adressBuffer) + 1) * sizeof(char));
			strcpy(com.adress, adressBuffer);

			// insert the item into the double linked list
			list = rearInsertion(list, com);

			fscanf(f, "%d, %[^,], %[^,], %[^,], %d", &com.carId, nameBuffer, phoneBuffer, adressBuffer, &com.waitingTime);

		}
	}
	else
	{
		perror("[ERROR] Orders.txt");
	}

	printList(list);
	printListReverse(list);
	orderCount(list, 1);

	printf("\nAdjacent interchange: ");

	list = interchangeAdj(list, 4, 5);
	printList(list);

	printf("\nDelete node: ");
	list = deleteNode(list, 2);
	printList(list);

	printf("\nSorting the list by waiting time: ");
	list = sort(list);
	printList(list);

	printf("\nCleaning the list from memory");
	list = cleanMemory(list);

	printf("\n");
}
Exemplo n.º 16
0
void Akuerdate::onExitTransitionDidStart() {
    
    cleanMemory();
    
}
Exemplo n.º 17
0
lammps_eon::~lammps_eon(){
    cleanMemory();
}
Exemplo n.º 18
0
Ajustes::~Ajustes() {
    
    cleanMemory();
    
}
Exemplo n.º 19
0
void Ajustes::onExitTransitionDidStart() {
    
    cleanMemory();
    
}
Exemplo n.º 20
0
ReadsLayout::~ReadsLayout() {
    cleanMemory();
    //dtor
}