// ========== Copyright Header Begin ========================================== // // OpenSPARC T2 Processor File: rstexample.C // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public // License version 2 as published by the Free Software Foundation. // // The above named program is distributed in the hope that it will be // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public // License along with this work; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. // // ========== Copyright Header End ============================================ #include #include #include #include #include "rstf/rstf.h" #include "rstzip/Rstzip.H" const char usage[] = "rstexample "; int main(int argc, char **argv) { // argv[1] must be input file const char * ifname = NULL; int i=1; while(iopen(ifname, "r", "verbose=0"); if (rv != RSTZIP_OK) { fprintf(stderr, "ERROR: rstexample: Rstzip error opening input file %s\n", ifname); exit(1); } const int max_ncpu=1<<10; // RST supports 10-bit cpuids int64_t icounts[max_ncpu]; memset(icounts, 0, max_ncpu*sizeof(int64_t)); int64_t total_icount = 0; int nrecs; rstf_unionT buf[rstzip_opt_buffersize]; while((nrecs = rz->decompress(buf, rstzip_opt_buffersize)) != 0) { int i; for (i=0; iproto.rtype == INSTR_T) { total_icount++; int cpuid = rstf_instrT_get_cpuid(&(rp->instr)); icounts[cpuid]++; } } } rz->close(); delete rz; rz=NULL; printf("Total icount=%lld\n", total_icount); for (i=0; i 0) { printf("cpu%d: icount=%lld\n", i, icounts[i]); } } } // main()