void MTGAllCards::init() { tempCard = NULL; tempPrimitive = NULL; total_cards = 0; initCounters(); }
const SimulationResults& Simulation::run() { //Stat* statistics = new Stat(); //statistics->setVerbose(true); // FIXME: remove! //statistics->setSchedulerId(scheduler->getId()); LOG(0) << "######## Running Simulation with scheduler " << scheduler->getId(); LOG(0) << "\tAim are " << steps << " iterations"; initCounters(); for (size_t taskNum = 0; taskNum< (*taskset).size(); taskNum++) { (*taskset)[taskNum]->start(0); } unsigned int time = 0; bool schedSuccess = true; for (time = 0; time < steps; time++) { LOG(1) << "\n\nT : " << time; doActivations(time, scheduler); schedSuccess = doExecutions(time, scheduler/*, statistics*/); if (!schedSuccess) { LOG(0) << "Executions failed in regular time step " << time; break; } } if (schedSuccess) { while (scheduler->hasPendingJobs()) { bool bdisp = doExecutions(time, scheduler/*, statistics*/); ++time; if (!bdisp) { LOG(0) << "Executions failed in during cleanup in step " << time; break; } } } LOG(0) << "Totally simulated time: " << time; printExecStats(scheduler->getId()); printDelayCounters(); // Save the statistics in a other object //storeStatistics(statistics); calculateStatistics(); stats.simulatedTime = time; stats.success = schedSuccess; return stats; }
void Downloader::useMirror(const QString& sdkArch, const QString& mirrorDomain) { _sdkArch = sdkArch; _rootUrl = mirrorMap[mirrorDomain]; QString subdir = "online/qtsdkrepository/" + sdkArch + "/root/qt/"; // Delete old files QDir place(subdir + "qt/"); place.removeRecursively(); place.mkpath("."); initCounters(); qDebug() << "Downloading raw metadata..."; getFilesFromIndex(_rootUrl, subdir, {".xml"}); getFilesFromIndex(_rootUrl, subdir + "qt/", {".7z", ".sha1"}); }
void initNtop(char *devices) { char value[32]; revertSlashIfWIN32(myGlobals.dbPath, 0); revertSlashIfWIN32(myGlobals.spoolPath, 0); initIPServices(); handleProtocols(); myGlobals.l7.numSupportedProtocols = IPOQUE_MAX_SUPPORTED_PROTOCOLS; if(myGlobals.numIpProtosToMonitor == 0) addDefaultProtocols(); /* * Initialize memory and data. */ initDevices(devices); init_events(); if(myGlobals.runningPref.enableSessionHandling) initPassiveSessions(); initL7Discovery(); /* ********************************** */ initGdbm(myGlobals.dbPath, myGlobals.spoolPath, 0); /* We just initialized gdbm: let's now dump serials */ dumpHostSerial(&myGlobals.broadcastEntry->hostSerial, myGlobals.broadcastEntry->serialHostIndex); dumpHostSerial(&myGlobals.otherHostEntry->hostSerial, myGlobals.otherHostEntry->serialHostIndex); if(myGlobals.runningPref.daemonMode) { /* Before bacoming a daemon we need o make sure that ntop has been installed properly and that all the html files are on the right place */ int idx, found = 0; for(idx=0; (!found) && (myGlobals.dataFileDirs[idx] != NULL); idx++) { char tmpStr[256]; struct stat statbuf; if(strcmp(myGlobals.dataFileDirs[idx], ".") /* ignore local paths */ ) { safe_snprintf(__FILE__, __LINE__, tmpStr, sizeof(tmpStr), "%s/html/%s", myGlobals.dataFileDirs[idx], "ntop.gif" /* This file must always exist */); if(stat(tmpStr, &statbuf) == 0) { found = 1; break; } } } if(!found) { traceEvent(CONST_TRACE_WARNING, "ntop will not become a daemon as it has not been"); traceEvent(CONST_TRACE_WARNING, "installed properly (did you do 'make install')"); } else daemonizeUnderUnix(); } /* Handle local addresses (if any) */ handleLocalAddresses(myGlobals.runningPref.localAddresses); /* Handle known subnetworks (if any) */ handleKnownAddresses(myGlobals.runningPref.knownSubnets); if((myGlobals.pcap_file_list != NULL) && (myGlobals.runningPref.localAddresses == NULL)) { char *any_net = "0.0.0.0/0"; traceEvent(CONST_TRACE_WARNING, "-m | local-subnets must be specified when the -f option is used" "Assuming %s", any_net); myGlobals.runningPref.localAddresses = strdup(any_net); } if(myGlobals.runningPref.currentFilterExpression != NULL) parseTrafficFilter(); else myGlobals.runningPref.currentFilterExpression = strdup(""); /* so that it isn't NULL! */ /* Handle flows (if any) */ handleFlowsSpecs(); createPortHash(); initCounters(); initApps(); initThreads(); #ifndef MAKE_MICRO_NTOP traceEvent(CONST_TRACE_NOISY, "Starting Plugins"); startPlugins(); traceEvent(CONST_TRACE_NOISY, "Plugins started... continuing with initialization"); #endif #if defined(MEMORY_DEBUG) && defined(MAKE_WITH_SAFER_ROUTINES) resetLeaks(); #endif addNewIpProtocolToHandle("IGMP", 2, 0 /* no proto */); addNewIpProtocolToHandle("OSPF", 89, 0 /* no proto */); addNewIpProtocolToHandle("IPsec", 50, 51); init_maps(); loadGeoIP(); /* Note that by default ntop will merge network interfaces */ if(myGlobals.runningPref.mergeInterfaces == 0) traceEvent(CONST_TRACE_ALWAYSDISPLAY, "NOTE: Interface merge disabled by default"); else traceEvent(CONST_TRACE_ALWAYSDISPLAY, "NOTE: Interface merge enabled by default"); if(fetchPrefsValue("globals.displayPolicy", value, sizeof(value)) == -1) { myGlobals.hostsDisplayPolicy = showAllHosts /* 0 */; storePrefsValue("globals.displayPolicy", "0"); } else { myGlobals.hostsDisplayPolicy = atoi(value); /* Out of range check */ if((myGlobals.hostsDisplayPolicy < showAllHosts) || (myGlobals.hostsDisplayPolicy > showOnlyRemoteHosts)) myGlobals.hostsDisplayPolicy = showAllHosts; } if(fetchPrefsValue("globals.localityPolicy", value, sizeof(value)) == -1) { myGlobals.localityDisplayPolicy = showSentReceived /* 0 */; storePrefsValue("globals.localityPolicy", "0"); } else { myGlobals.localityDisplayPolicy = atoi(value); /* Out of range check */ if((myGlobals.localityDisplayPolicy < showSentReceived) || (myGlobals.localityDisplayPolicy > showOnlyReceived)) myGlobals.localityDisplayPolicy = showSentReceived; } if(myGlobals.runningPref.skipVersionCheck != TRUE) { pthread_t myThreadId; createThread(&myThreadId, checkVersion, NULL); } }
int main(int argc, char * argv[]) { char* infile=0; char str[64]; int f ; int k; int p ; if (argc<7) { printf ("Enter Number of Meters: \n"); scanf ("%d",&M); printf ("Enter Number of Poles: \n"); scanf ("%d",&P); printf ("Enter Input File: \n"); scanf ("%s",str); infile =str; printf ("Enter Number for Heuristic Funtions ( 0: Greedy; 1: Score1 ; 2:Score2 ;3: Score_G \n"); scanf ("%d",&f); if(f==3) { printf ("Enter K number \n"); scanf ("%d",&k); } else { k=1; } printf ("Do you want Preprocessing? 0: No; 1: Yes\n"); scanf ("%d",&p); } else { M = atoi(argv[1]); P = atoi(argv[2]); infile = argv[3]; f = atoi(argv[4]); k = atoi(argv[5]); p = atoi(argv[6]); } initMatrix(M, P, &matrix, infile); initCounters(M,P); clock_t begin, end; begin = clock(); if( f==0) { greedyCover(p); } else { MGreedyCover(f,k,p); } end = clock(); printf("clocks %d second %f\n", end - begin, (float)(end - begin) / CLOCKS_PER_SEC); }
int main(void) { volatile int * (cam_start) = (int *)CAM_START; // Output volatile int * (sdram_data1) = (int *)SDRAM_DATA1; //Input volatile int * (sdram_read) = (int *)READ_OUT_ADDR; //Output volatile int * (read_good) = (int *)VGA_CLK_IN; //Input volatile int * (sdram_reset) = (int *)VGA_DATA1; //Output volatile int * (vga_reset) = (int *)VGA_DATA2; //Output volatile int *(clock_select) = (int *)SOURCE_SELECT; volatile int *(clock_gen) = (int *)CONTROLLING_CLK; volatile int *nn_write_data_1 = (int *)NN_WRITE_DATA_1; volatile int *nn_write_data_2 = (int *)NN_WRITE_DATA_2; volatile int *nn_write_enable = (int *)NN_WRITE_ENABLE; volatile int *nn_write_clock = (int *)NN_WRITE_CLOCK; volatile int *nn_read_enable = (int *)NN_READ_ENABLE; volatile int *nn_read_clock = (int *)NN_READ_CLOCK; volatile int *nn_bootup = (int *)NN_BOOTUP; volatile int *nn_access = (int *)NN_ACCESS; volatile int *nn_read_data_1 = (int *)NN_READ_DATA_1; volatile int *nn_read_data_2 = (int *)NN_READ_DATA_2; int16_t number1, number2; *cam_start = 0; *nn_write_clock = 0; *nn_read_clock = 0; *nn_bootup = 1; *sdram_reset = 1; // reset signals to set read address *sdram_reset = 0; *sdram_reset = 1; *nn_write_enable = 1; int i = 0; // WRITING // finalW1L1 /* for (int i = 0; i < 200; i++) { for (int j = 0; j < 784/4; j = j + 4) { number1 = (finalW1L1[i][j] << 8) | (finalW1L1[i][j+1] & 0xff); number2 = (finalW1L1[i][j+2] << 8) | (finalW1L1[i][j+3] & 0xff); *nn_write_data_1 = number1; *nn_write_data_2 = number2; *nn_write_clock = 1; *nn_write_clock = 0; } } // finalW1L1 // finalB1L1 for (int i = 0; i < 200/4; i = i + 4) { number1 = (finalB1L1[i] << 8) | (finalB1L1[i+1] & 0xff); number2 = (finalB1L1[i+2] << 8) | (finalB1L1[i+3] & 0xff); *nn_write_data_1 = number1; *nn_write_data_2 = number2; *nn_write_clock = 1; *nn_write_clock = 0; } // finalB1L1 // finalW1L2 for (int i = 0; i < 200; i++) { for (int j = 0; j < 200/4; j = j + 4) { number1 = (finalW1L2[i][j] << 8) | (finalW1L2[i][j+1] & 0xff); number2 = (finalW1L2[i][j+2] << 8) | (finalW1L2[i][j+3] & 0xff); *nn_write_data_1 = number1; *nn_write_data_2 = number2; *nn_write_clock = 1; *nn_write_clock = 0; } } // finalW1L2 // finalB1L2 for (int i = 0; i < 200/4; i = i + 4) { number1 = (finalW1L2[i] << 8) | (finalW1L2[i+1] & 0xff); number2 = (finalW1L2[i+2] << 8) | (finalW1L2[i+3] & 0xff); *nn_write_data_1 = number1; *nn_write_data_2 = number2; *nn_write_clock = 1; *nn_write_clock = 0; } // finalB1L2 // finalSoftmaxTheta for (int i = 0; i < 10; i++) { for (int j = 0; j < 200/4; j = j + 4) { number1 = (finalW1L2[i][j] << 8) | (finalW1L2[i][j+1] & 0xff); number2 = (finalW1L2[i][j+2] << 8) | (finalW1L2[i][j+3] & 0xff); *nn_write_data_1 = number1; *nn_write_data_2 = number2; *nn_write_clock = 1; *nn_write_clock = 0; } } // finalSoftmaxTheta */ for (i = 0; i < 20; i = i + 2) { number1 = 1; number2 = 2; *nn_write_data_1 = number1; *nn_write_data_2 = number2; *nn_write_clock = 1; *nn_write_clock = 0; } // READING *nn_access = 1; *nn_read_enable = 1; *sdram_reset = 0; // reset sdram *sdram_reset = 1; int8_t testRead1, testRead2; for (i = 0; i < 20; i = i + 2) { number1 = *nn_read_data_1; number2 = *nn_read_data_2; *nn_read_clock = 1; *nn_read_clock = 0; printf("%d\t", number1); printf("%d\n", number2); } *nn_write_enable = 0; *nn_bootup = 0; *nn_read_enable = 0; *nn_access = 0; int M; //int i = 0; int j = 0; int k = 0; int L = 0; int snapshot = 0; *nn_bootup = 0; *nn_access = 0; *sdram_reset = 0; *sdram_reset = 1; *vga_reset = 1; *clock_select = 0; int write_data = 0; int written = 0; int height = HEIGHT, width = WIDTH; int** black_white = (int**)malloc(HEIGHT*sizeof(int*)); for (i = 0; i < HEIGHT; i++) { black_white[i] = (int*)malloc(sizeof(int)*WIDTH); } while (1){ *cam_start = 1; totalCycles = 0; printf("Press enter to start\n"); fflush(stdin); getchar(); fflush(stdin); // delay before capture for (i = 0; i < 30000; i++) { } snapshot = 1; if (snapshot) { // // int cycleCounter = 0; // int cycleIndex = 0; initCounters(); main_1 = getCycles(); *cam_start = 0; // pause camera *clock_select = 1; // choose custom clock from hps *sdram_reset = 0; // reset sdram *sdram_reset = 1; *sdram_read = 1; // set read request to high // // main_2 = getCycles(); // clear out first horizontal row, it is all black for (k = 0; k < WIDTH + 3; k = k + 1) { *clock_gen = 1; // generate 4 clock cycles to move slower clock 1 cycle *clock_gen = 0; *clock_gen = 1; *clock_gen = 0; } // // main_3 = getCycles(); // begin reading in data for (j = 0; j < HEIGHT; j = j + 1) { for (k = 0; k < WIDTH; k = k + 1) { for (L = 0; L < 2; L = L + 1) { *clock_gen = 1; // generate 4 clock cycles, checking each cycle if (!written) { if (*read_good) // take in data from verilog to read block (not sure if needed) { black_white[j][k] = *(sdram_data1); written = 1; } } *clock_gen = 0; } written = 0; } *sdram_read = 0; *sdram_read = 1; /* // if (cycleCounter == 48) { cycleCounter = 0; cycle[cycleIndex] = getCycles(); cycleIndex++; } */ } // // main_3 = getCycles(); *sdram_read = 0; *sdram_reset = 0; *vga_reset = 0; *sdram_reset = 1; *vga_reset = 1; *cam_start = 1; *clock_select = 0; snapshot = 0; //printf("Done\n"); } // main_4 = getCycles(); height = HEIGHT; width = WIDTH; printf("Image = %d x %d\n", height, width); printf("\n\n"); for (i = 0; i < height; i++) { for (k = 0; k < width; k++) { printf("%d\t", black_white[i][k]); } printf("\n"); }/**/ //printf("Total Image = %d %d\n",height, width); region_1 = getCycles(); region2(&width, &height, black_white); region_end = getCycles(); /* printf("ROI = %d x %d\n",height, width); printf("\n\n"); for (i = 0; i < height; i++) { for (k = 0; k < width; k++) { printf("%d\t",black_white[i][k]); } printf("\n"); } /* */ //printf("Region Found\n\n"); digit_separate2(height, width, black_white); //separate_end = getCycles(); rec_2 = getCycles(); printf("Done\n"); /* for (i = 0; i < 10; i++) printf("%d:\t %u\n",i+1,cycle[i]); */ // printf("\n1: \t%d\n2: \t%d\n3: \t%d\n4: \n5: \n6: \t%d\n7: \t%d\n", main_1, main_2, main_3, main_6, main_7); final = (main_4 - main_1); // printf("\nTimes:\nMain: \t%d\n\n", final); totalCycles += final; final = (region_end - region_1);