int Xmain() { ifstream infile; // Get lines from file cout << "Let's process a file of random text and count characters!" << endl; PromptUserToOpenFile(infile); linesV lines = GetLinesFromFile(infile); //for (int i = 0; i < lines.size(); i++) //cout << "score " << i << " is " << lines.getAt(i) << endl; // Prepare an array to hold the data. int lCount[alpha_size]; for (int i = 0; i < alpha_size; i++) lCount[i] = 0; // Examine each line for its characters, increment the proper indexes. for (int i = 0; i < lines.size(); i++) { BumpCountForEachChar(lines[i], lCount); } PrintCounts(lCount); return 0; }
void multiplex(period,normalize) { // initialize sw thread to use BGPM in sw thread distributed mode // Allows up to 12 simultaineous punit counter per thread when using only // 2 threads/core Bgpm_Init(BGPM_MODE_SWDISTRIB); // Create event set and add events needed to calculate CPI, int hEvtSet = Bgpm_CreateEventSet(); // Multiplexing must be enabled prior to adding events to a Punit event set. // With Multiplexing active on Punit event set, we can have as many Punit events as we like, // regardless of Max Events. Muxing will create as many groups as needed to hold all the events, // but by default only assigns up to 5 events per group (And reserves the 6th counter to track the number of // cycles a group has been active). // However, a few of the core-wide attributes used by events must still remain consistent // (like the l1p mode associated with the l1p events) // // Parameters: // period-> number of cycles between multiplex switches. A value of 0 disables multiplexing for this thread, // which means you must explicitly call Bgpm_SwitchMux to switch between groups. // normalize->Pass in BGPM_NORMAL or BGPM_NOTNORMAL to choose whether event counts // reported by Bgpm_ReadEvent() or Bgpm_ReadEventList() will be scaled to the to the maximum number of cycles spent // by any mux group. // With BGPM_NOTNORMAL, Bgpm_ReadEvent() and Bgpm_ReadEventList() report the raw numbers and you may use // Bgpm_GetMultiplex() and Bgpm_GetMuxEventElapsedCycles() to do your own normalization as desired. Bgpm_SetMultiplex2(hEvtSet, period, normalize, BGPMMuxMinEvts); Bgpm_AddEventList(hEvtSet, evtList, sizeof(evtList)/sizeof(unsigned) ); Bgpm_Apply(hEvtSet); Bgpm_Start(hEvtSet); const int loops = 100; int i; for (i=0; i<loops; i++) { CreateEvents(); if(!period){Bgpm_SwitchMux(hEvtSet);} // Switching mutiplex is needed only in case of period=0. } Bgpm_Stop(hEvtSet); PrintCounts(hEvtSet); Bgpm_Disable(); }