Esempio n. 1
0
int main(int argc, char *argv[])
{
	int n, i;
	double *a, *b, *c0, *c1, *c2, *c3;
	double t0, t1, t2, t3;
	double diff1, diff2, diff3;
	struct timespec start, end;

	n = atoi(argv[1]);
	a = (double *) malloc(n*n*sizeof(double));
	b = (double *) malloc(n*n*sizeof(double));
	c0 = (double *)malloc(n*n*sizeof(double));
	c1 = (double *)malloc(n*n*sizeof(double));
	c2 = (double *)malloc(n*n*sizeof(double));
	c3 = (double *)malloc(n*n*sizeof(double));

	RandMatrixGen(a, n);
	RandMatrixGen(b, n);

	clock_gettime(CLOCK_MONOTONIC, &start);
	dgemm0(a, b, c0, n);
	clock_gettime(CLOCK_MONOTONIC, &end);
	t0 = (end.tv_sec - start.tv_sec)*BILLION + end.tv_nsec - start.tv_nsec;


	clock_gettime(CLOCK_MONOTONIC, &start);
	dgemm1(a, b, c1, n);
	clock_gettime(CLOCK_MONOTONIC, &end);
	t1 = (end.tv_sec - start.tv_sec)*BILLION + end.tv_nsec - start.tv_nsec;

	clock_gettime(CLOCK_MONOTONIC, &start);
	dgemm2(a, b, c2, n);
	clock_gettime(CLOCK_MONOTONIC, &end);
	t2 = (end.tv_sec - start.tv_sec)*BILLION + end.tv_nsec - start.tv_nsec;

	clock_gettime(CLOCK_MONOTONIC, &start);
	dgemm3(a, b, c3, n);
	clock_gettime(CLOCK_MONOTONIC, &end);
	t3 = (end.tv_sec - start.tv_sec)*BILLION + end.tv_nsec - start.tv_nsec;

	diff1 = verification(c0, c1, n);
	diff2 = verification(c0, c2, n);
	diff3 = verification(c0, c3, n);

	printf ("matrix size: %d\n", n);
	printf ("dgemm0 runtime: %llu nanoseconds\n", (long long unsigned int) t0);
	printf ("dgemm1 runtime: %llu nanoseconds\n", (long long unsigned int) t1);
	printf ("dgemm2 runtime: %llu nanoseconds\n", (long long unsigned int) t2);
	printf ("dgemm3 runtime: %llu nanoseconds\n", (long long unsigned int) t3);
	printf ("maximum difference between dgemm0 and dgemm1: %f\n", diff1);
	printf ("maximum difference between dgemm0 and dgemm2: %f\n", diff2);
	printf ("maximum difference between dgemm0 and dgemm3: %f\n", diff3);

	return 0;

}
Esempio n. 2
0
int main(int argc, char* argv[]){
	int n = atoi(argv[1]);
	uint64_t t0;
	float t;
	struct timespec begin, end;
	double *a, *b;
	double *c0, *c1, *c2;
	double diff;
	int i;

	srand(time(NULL));
	a = (double *) calloc(sizeof(double), n * n);
	for(i = 0; i < n * n; i++){
		a[i] = rand() / 1000000.0;
	}
        b = (double *) calloc(sizeof(double), n * n);
        for(i = 0; i < n * n; i++){
                b[i] = rand() / 1000000.0;
        }
        c0 = (double *) calloc(sizeof(double), n * n);
        c1 = (double *) calloc(sizeof(double), n * n);
        c2 = (double *) calloc(sizeof(double), n * n);

	clock_gettime(CLOCK_MONOTONIC, &begin);
	dgemm0(a, b, c0, n);
	clock_gettime(CLOCK_MONOTONIC, &end);
	t0 = 1000000000L * (end.tv_sec - begin.tv_sec) + end.tv_nsec - begin.tv_nsec;
	t = t0 / 1000000000.0;
	printf("%f\t", t);

        clock_gettime(CLOCK_MONOTONIC, &begin);
        dgemm1(a, b, c1, n);
        clock_gettime(CLOCK_MONOTONIC, &end);
        t0 = 1000000000L * (end.tv_sec - begin.tv_sec) + end.tv_nsec - begin.tv_nsec;
        t = t0 / 1000000000.0;
		printf("%f\t", t);
        
	clock_gettime(CLOCK_MONOTONIC, &begin);
	dgemm2(a, b, c2, n);
	clock_gettime(CLOCK_MONOTONIC, &end);
	t0 = 1000000000L * (end.tv_sec - begin.tv_sec) + end.tv_nsec - begin.tv_nsec;
	t = t0 / 1000000000.0;
	printf("%f\t", t);

	diff = verification(a, b, c0, c1, n);
	printf("%f\t", diff);
	diff = verification(a, b, c0, c2, n);
	printf("%f\n", diff);

	return 0;
}
Esempio n. 3
0
void start()
	{
		char choice;
		printf("\n\t\t\t\t***WELCOME TO THE HOSPITAL MANAGEMENT SYSTEM***\t\t\t\t\n");
		printf("1.Patient\n");
		printf("2.Staff\n");
		printf("3.Expense\n");
		printf("4.Change the user mode\n");
		printf("0.Exit");
		printf("\n\nEnter your choice:");
		scanf("%c", &choice);
		
		switch(choice)
			{
				case 1:
					patient();
					break;
				case 2:
					
					staff();
					break;
				case 3:
					exp();
					break;
				case 4:
					verification();
					break;
				case 0:
					exit(1);
		}

}
void DialogProgTache::accept()
{
    Agenda* ag = &Agenda::getInstance();
    try
    {
        verification();
        //ajout des parties de la tache dans l'agenda
        if(ui->parties->isChecked())
        {
            verificationParties();
            ag->ajouterProgrammationPartieTache(vec_date, vec_titre, vec_debut, vec_duree, tache, projet);
        }
        //sinon ajout de la tache unitaire dans l'agenda
        else
        {
            ag->ajouterProgrammation(2, ui->date->date(), tache->getTitre(), tache->getDescription(),ui->horaire->time(),
                                     tache->getDuree(),"", "", tache, projet);
        }
        close();
    }
    catch(CalendarException e)
    {
        QMessageBox::critical(this, "Erreur", e.getInfo());
    }

}
int main()
{
    verification();
    grading_book();
    logg_out();
    return 0;
}
Esempio n. 6
0
void verification(){

	char userp[] = {"passuser"};
	char adminp[] = {"passadmin"};
	char u[20];
	char a[20];
	int uchoice;
	int ucheck;
	printf("\nEnter choice\n 1 - Administrator\n 2 - User\n");
	scanf("%d" , &uchoice);
	if(uchoice == 1)		
		{
			printf("\nPlease enter the password\n");
			scanf("%s" , a);
			ucheck = strcmp(a , adminp);
			if(ucheck == 0)
				{
					printf("Welcome administrator\n");
					start();
				}
			else
				{
					printf("\nEntered password is wrong.Try again\n");
					printf("\nPlease ensure that selected mode is correct\n");
					verification();
				}
		}
	if(uchoice == 2)
		{
			printf("\nPlease enter the password\n");
			scanf("%s" , u);
			ucheck = strcmp(u , userp);
			if(ucheck == 0)
				{
					printf("Welcome user\n");
					start();
				}
			else
				{
					printf("\nEntered password is wrong.Try again\n");
					printf("\nPlease ensure that selected mode is correct\n");
					verification();
				}
		}
}
Esempio n. 7
0
/*
** Get a string entry in a string table
*/
int			elf_strtab_get(t_elf *elf, t_elf_section *strtab,
				       size_t index, const char **str_ptr)
{
  *str_ptr = NULL;
  if (verification(elf, strtab, index) == -1)
    return (-1);
  *str_ptr = (const char *)&strtab->content[index];
  return (0);
}
Esempio n. 8
0
bool NutshSqlSaver::connect() {
    //connexion à la base de donnée (ne doit être exécuté qu'une seule fois dans le code.

    QString MusicDir = QDesktopServices::storageLocation(QDesktopServices::MusicLocation);

    //creation du dossier NutshConfig qui contient la base de donnee
    QDir verification(MusicDir);
    bool wizard = false;

    if(!verification.exists("NutshConfig")|| !QFile::exists(MusicDir+"/NutshConfig/NutshDB")) {

        verification.mkdir("NutshConfig");
        wizard = true;

    }

    QSqlDatabase NutshDB = QSqlDatabase::addDatabase("QSQLITE");

    NutshDB.setHostName("localhost");
    NutshDB.setDatabaseName(QDir::toNativeSeparators(MusicDir+"/NutshConfig/NutshDB"));
    NutshDB.setUserName("root");
    NutshDB.setPassword("");

    NutshDB.open();

    if(!NutshDB.open()) { // si il n'arrive pas à ouvrir la base de donnée

        qDebug() << "NutshSqlSaver : " << NutshDB.lastError();

    }


    //crée les tables obligatoires si elles n'existent pas

    QSqlQuery requete;

    requete.exec("create table bibliotheque ( id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, artiste text, album text, titre text, date date, genre text, description text, track integer, chemin text, playlists text, duree text, enregistrement datetime, derniereLecture datetime, compteur integer)");
    requete.exec("CREATE TABLE listeDeLecture (id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, name text, ordre text)");
    requete.exec("CREATE TABLE path_list (id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, path text)");
    requete.exec("CREATE TABLE relationships (playlist_id text, music_id INTEGER)");

    requete.exec("SELECT * FROM bibliotheque");

    while(requete.next()) { //création de la liste des verifications.

        metadatas.append(requete.value(1).toString()+requete.value(2).toString()+requete.value(3).toString());
    }


    if(wizard == true) { // affichage de l'assistant d'installation si le dossier n'était pas créé

        NutshInstallationWizard Wizard;
        Wizard.exec();
    }

    return NutshDB.open();
}
Esempio n. 9
0
int main() {
	
	char user_name[64];
	char password[8];
	printf("\t\t-----------------------------------\n");
	printf("\t\t***********************************\n");	
	printf("\t\tWelcome to College Of Engg Pune\n");
	printf("\t\t***********************************\n");
	printf("\t\t-----------------------------------\n");	
	verification();
	return 0;
}
Esempio n. 10
0
char *exec(ListeString *listeArg, Commande *commande, Niveau *niveau){
	int nbArgument = nbArg(commande);
	int fd[2];
	pipe(fd);
	int status;
	pid_t pid = fork();
	commande->pid = pid;
	child_pid = commande->pid;
    if (pid == -1)
    {
        wprintw(stdscr, "Erreur fork\n");
        exit(EXIT_FAILURE);
    }
    if(pid == 0)
    {
    	if (nbArgument == 0)
		{
			close(fd[0]);
		   	dup2(fd[1], 1);
		   	close(fd[1]);
		   	strcpy(commande->commande, deleteSpaces(commande->commande));
			execlp(commande->commande, commande->commande, NULL);
		}else{
	    	char **tab = malloc(sizeof(char)*TAILLE_MAX_COMMANDE*nbArgument);
	    	creeTabArgs(tab, listeArg, nbArgument);
	    	close(fd[0]);
		   	dup2(fd[1], 1);
		   	close(fd[1]);
		   	strcpy(tab[0], deleteSpaces(tab[0]));
	        execvp(tab[0], tab);
	        free(tab);
	    }
	    exit(0);
    }else
    {
        waitpid(pid, &status, WCONTINUED);
        if (WIFEXITED(status))
        {
        	commande->pid = getpid();
        	char *sortie = malloc(sizeof(char)*TAILLE_MAX_COMMANDE*200);
        	read(fd[0], sortie, TAILLE_MAX_COMMANDE*200);
        	// fprintf(stderr, "verification : %s\n", niveau->nom);
        	verification(sortie, &(*niveau), commande);
        	return sortie;
        }
        else
        	return NULL;
    }
}
Esempio n. 11
0
int MSudoku::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: generer(); break;
        case 1: initialiser(); break;
        case 2: sauvegarder(); break;
        case 3: charger(); break;
        case 4: changerTheme(); break;
        case 5: apropos(); break;
        case 6: resoudre(); break;
        case 7: verification(); break;
        case 8: possibilites(); break;
        case 9: gagner(); break;
        }
        _id -= 10;
    }
    return _id;
}
Esempio n. 12
0
int main()
{
	srand(time(0));

	uint8 c[SIGNATURE_BYTES];
	uint8 m[SHORTHASH_BYTES];
	uint8 pk[PUBLICKEY_BYTES];
	uint8 sk[SECRETKEY_BYTES];

	uint64 lc,lm = SHORTHASH_BYTES,lpk,lsk;

	keypair( sk , &lsk , pk , &lpk );

	for( int i=0;i<SHORTHASH_BYTES;i++) m[i] = rand() % 256;

	for( int i=0;i<SHORTHASH_BYTES;i++) printf("%x " , (unsigned) m[i]); printf("\n");

	signatureofshorthash( c , &lc , m , lm , sk , lsk );
	for( int i=0;i<SIGNATURE_BYTES;i++) printf("%x " , (unsigned) c[i]); printf("\n");

	int i = verification( m , lm , c , lc , pk , lpk );
	printf("verify: %d\n" , i );

}
Esempio n. 13
0
int main(int argc, char *argv[])
{
    int chance = 10 , chan = 10 ,  menu , *lettreTrouvee = NULL , l , i , a , donnees[2] = {0};
    char mot[100] , caract;
    do
    {
        do
        {
            printf("\n\n              ----------PENDU----------\n\n\n");
            printf("\t\t1 : Jouer\n\t\t2 : Nombre de chance\n\t\t3 : Quitter\n");
            printf("\n\t\t? ");
            scanf("%ld", &menu);
            printf("\n\n");
        } while (menu < 1 || menu > 3);

        if (menu == 1)
        {         
            a = 0;
            mot[100] = motAleatoire(mot);
            l = strlen(mot);
            lettreTrouvee = malloc(l*sizeof(int));
            for(i = 0 ; i < l ; i++)
            {
                lettreTrouvee[i] = 0;
            }
            chance = chan;
            while (a < l && chance > 0)
            {
                printf("Mot secret : ");
                for(i = 0 ; i < l ; i++)
                {
                    if (lettreTrouvee[i] == 1)
                        printf("%c" , mot[i]);
                    else
                        printf("=");
                }
                printf("\nChance(s) : %ld" , chance);
                printf("\nLettre : ");
                do
                {
                    caract = getchar();
                    caract = maj(caract);
                } while (caract == '\n');
                printf("\n");
                donnees[1] = a;
                donnees[2] = chance;
                verification(caract , mot , lettreTrouvee , donnees);
                a = donnees[1];
                chance = donnees[2];
            }
            if (a == l)
            {
                printf("\nVous avez GAGNE :D !!!!!\nLe mot etait bien : %s\n\n", mot);
                chance = chan;
            }
            if (chance == 0 && a != l)
            {
                printf("\nVous avez PERDU  :(\nLe mot etait : %s\n\n", mot);
                chance = chan;
            }
        }

        if (menu == 2)
        {
            do
            {
                printf("\nNombre de chance (defaut : 10 ) ?  ");
                scanf("%ld", &chance);
            } while (chance <= 0);
            chan = chance;
        }
    } while (menu != 3);

    return 0;
}
Esempio n. 14
0
void server_mastersHtml(socket_t * client, http_request_t * req, db_t * db)
{
    char buffer[10240] = "";

    if (strcmp(req->method, "GET") == 0)
    {
        char pageText[10240] = "";

        for(int i = 0; i < db_count(db); i++)
        {
            master_t * master = db_getDataById(db, i);

            char text[100] = "";
            sprintf(text, "<a href=\"http://127.0.0.1:5000/ScrumMasters/%i\">%s %s<br></a>\n", i + 1, master_getSurname(master), master_getName(master));
            strcat(pageText, text);

            master_free(master);
        }

        char * text = "<a href=\"http://127.0.0.1:5000/new-ScrumMaster\"><br>New Scrum Master</a>";
        strcat(pageText, text);

        char * textHTML = textToHTML(pageText);
        strcat(buffer, textHTML);
        free(textHTML);
    }
    else if (strcmp(req->method, "POST") == 0)
    {
        char * name = (char *)http_request_getArg(req, "name");
        char * surname = (char *)http_request_getArg(req, "surname");
        char * countK = (char *)http_request_getArg(req, "countK");
        char * countP = (char *)http_request_getArg(req, "countP");

        if(verification(name, surname, countK, countP) == 1)
        {
            db_insertData(db, name, surname, atoi(countK), atoi(countP));

            char pageText[1024] = "";
            sprintf(pageText,
                    "<p>"
                    "Name: %s<br>"
                    "Surname: %s<br>"
                    "CountK: %i<br>"
                    "CountP: %i<br>"
                    "</p>",
                    name, surname,
                    atoi(countK),
                    atoi(countP));

            char * textHTML = textToHTML(pageText);
            strcat(buffer, textHTML);
            free(textHTML);
        }
        else
        {
            char * pageText = "<h3>Wrong input</h3>";
            char * textHTML = textToHTML(pageText);
            strcat(buffer, textHTML);
            free(textHTML);
        }
    }

    socket_write_string(client, buffer);
    socket_close(client);
}
Esempio n. 15
0
void server_masters(socket_t * client, http_request_t * req, db_t * db)
{
    char buffer[10240] = "";

    if (strcmp(req->method, "GET") == 0)
    {
        list_t * masters = list_new();

        char * countK = (char *)http_request_getArg(req, "countK");
        char * countP = (char *)http_request_getArg(req, "countP");

        if(countK != NULL && countP != NULL)
        {
            db_filtration(db, masters, atoi(countK), atoi(countP));
        }
        else
        {
            db_parse(db, masters);
        }

        cJSON * jPageText = cJSON_CreateArray();

        for(int i = 0; i < list_size(masters); i++)
        {
            master_t * sm = list_get(masters, i);

            cJSON * jText = cJSON_CreateObject();
            cJSON_AddItemToObject(jText, "Name", cJSON_CreateString(master_getName(sm)));
            cJSON_AddItemToObject(jText, "Surname", cJSON_CreateString(master_getSurname(sm)));
            cJSON_AddItemToObject(jText, "CountK", cJSON_CreateNumber(master_getCountK(sm)));
            cJSON_AddItemToObject(jText, "CountP", cJSON_CreateNumber(master_getCountP(sm)));
            cJSON_AddItemToArray(jPageText, jText);
        }

        char * pageText = cJSON_Print(jPageText);

        list_free(masters);

        char * textJSON = textToJSON(pageText);
        strcat(buffer, textJSON);
        free(textJSON);
    }
    else if (strcmp(req->method, "POST") == 0)
    {
        char * name = (char *)http_request_getArg(req, "name");
        char * surname = (char *)http_request_getArg(req, "surname");
        char * countK = (char *)http_request_getArg(req, "countK");
        char * countP = (char *)http_request_getArg(req, "countP");

        if(verification(name, surname, countK, countP) == 1)
        {
            db_insertData(db, name, surname, atoi(countK), atoi(countP));

            cJSON * jText = cJSON_CreateObject();
            cJSON_AddItemToObject(jText, "Name", cJSON_CreateString(name));
            cJSON_AddItemToObject(jText, "Surname", cJSON_CreateString(surname));
            cJSON_AddItemToObject(jText, "CountK", cJSON_CreateNumber(atoi(countK)));
            cJSON_AddItemToObject(jText, "CountP", cJSON_CreateNumber(atoi(countP)));
            char * pageText = cJSON_Print(jText);

            char * textJSON = textToJSON(pageText);
            strcat(buffer, textJSON);
            free(textJSON);
        }
        else
        {
            cJSON * jText = cJSON_CreateObject();
            cJSON_AddItemToObject(jText, "Error", cJSON_CreateString("Wrong input"));
            char * pageText = cJSON_Print(jText);

            char * textJSON = textToJSON(pageText);
            strcat(buffer, textJSON);
            free(textJSON);
        }
    }

    socket_write_string(client, buffer);
    socket_close(client);
}
Esempio n. 16
0
int ClientApp::run(int argc, char* argv[])
{
  cvac::localAndClientMsg(VLogger::DEBUG_2, NULL, "App 2nd arg (testFileFolder): %s\n", argv[2]);
  std::string testFileFolder = std::string(argv[2]);

  if(argc < 3 || argc > 5)  // Warn wrong args
  {
	cvac::localAndClientMsg(VLogger::ERROR_V, NULL,
	"not enough or too many command line arguments\n", appName());
	cvac::localAndClientMsg(VLogger::ERROR_V, NULL,
	"<exe filename> <detector xml or zipFile from config> <name of the detector> [path to directory of images to process] [flag: 'verifyresults']\n");
	return EXIT_FAILURE;
  }

  // Connect to detector
  DetectorPrx detector = initIceConnection(m_detectorName);
  if(NULL == detector.get()) {
    cvac::localAndClientMsg(VLogger::ERROR_V, NULL, "Could not connect to CVAC Ice Services\n");
    return EXIT_FAILURE;
  }

  int resultInit = initializeDetector(detector);
  if((EXIT_SUCCESS != resultInit) || (false == detector->isInitialized())) {
      
    cvac::localAndClientMsg(VLogger::ERROR_V, NULL, "Detector->isInitialized() failed.  Aborting IceTestClient.\n");
    return(EXIT_FAILURE);
  }
  else {
    cvac::localAndClientMsg(VLogger::DEBUG, NULL, "IceBoxTestClient detector: initialization OK. \n");
  }

  //CTest requested?
  if(5 == argc) 
  {
	  std::string lastArgStr = std::string(argv[4]);
	  if(-1 == lastArgStr.find("verifyresults")) 
	  {
		  cvac::localAndClientMsg(VLogger::ERROR_V, NULL, "Invalid value for argument #5: %s.  CMakeLists.txt must specify token: 'verifyresults'\n", argv[4]);
		  return(EXIT_FAILURE);
	  }
		
	  int verResult = verification(testFileFolder, detector);
	  if(EXIT_SUCCESS != verResult)
	  {
		  return(EXIT_FAILURE);
	  }
  }
  else
	{
	  // Main Loop: build RunSet from 'testFileFolder'
	  cvac::RunSet runSet;
	  Ice::PropertiesPtr props = communicator()->getProperties();
	  std::string dataDir = props->getProperty("CVAC.DataDir");
		
	  cvac::PurposedDirectoryPtr dir = new cvac::PurposedDirectory();

    cvac::localAndClientMsg(VLogger::DEBUG, NULL, "IceBoxTestClient-mainLoop setting RunSet dir: %s\n", testFileFolder.c_str());
	  dir->directory.relativePath = std::string(testFileFolder.c_str());
	  runSet.purposedLists.push_back(dir);

	  std::string _detectorName = argv[1];
    if(appData->videoInputType) {
		  dir->fileSuffixes.push_back("mpg");
      cvac::localAndClientMsg(VLogger::DEBUG_2, NULL, "Using (.mpg) extension.\n");
    }
    else {
		  dir->fileSuffixes.push_back("jpg");
    }

	  dir->recursive = true;
		
	  try
	  {	// Create our callback class so that we can be informed when process completes
		  FinishedCallbackPtr finishCallback = new FinishedCallback();
		  Ice::CallbackPtr finishedAsync = Ice::newCallback(finishCallback, &FinishedCallback::finished);
			
		  Ice::AsyncResultPtr asyncResult = detector->begin_process(ident, runSet, finishedAsync);
		  cvac::localAndClientMsg(VLogger::DEBUG, NULL, "IceBox test client: initiated processing\n");
			
		  // end_myFunction should be call from the "finished" callback
		  //detector->end_process(asyncResult);
			
		  // Wait for the processing to complete before exiting the app
		  while (!finishCallback->hasFinished())
		  {
			  cvac::sleep(100);
		  }
		  cvac::localAndClientMsg(VLogger::DEBUG_2, NULL, "IceBox test client: finished processing\n");
	  }
	  catch (const Ice::Exception& ex)
	  {
		  cvac::localAndClientMsg(VLogger::WARN, NULL, "Ice- name():  %s\n", ex.ice_name().c_str());
		  cvac::localAndClientMsg(VLogger::WARN, NULL, "Ice- stackTrace(): \n%s\n", ex.ice_stackTrace().c_str());
		  cvac::localAndClientMsg(VLogger::WARN, NULL, "%s\n", ex.what());
		  return EXIT_FAILURE;
	  }
  }

  communicator()->shutdown();  // Shut down at the end of either branch
  return EXIT_SUCCESS;
}