1. Matthew Turk
  2. enzo-timing-woc

Commits

James Bordner  committed ec1eda8

[lcaperf]: removing obsolete src/lcaperf directory

  • Participants
  • Parent commits 6fb8156
  • Branches lcaperf

Comments (0)

Files changed (19)

File src/lcaperf/Makefile

  • Ignore whitespace
-EXES = jb-attribute jb-columns jb-counter jb-delete jb-derive jb-global jb-header jb-merge jb-print jb-promote jb-region jb-rename
-
-all: $(EXES)
-
-jb-attribute: jb-attribute.o jb.o
-	$(CXX) -o jb-attribute jb-attribute.o jb.o
-jb-columns: jb-columns.o jb.o
-	$(CXX) -o jb-columns jb-columns.o jb.o
-jb-counter: jb-counter.o jb.o
-	$(CXX) -o jb-counter jb-counter.o jb.o
-jb-delete: jb-delete.o jb.o
-	$(CXX) -o jb-delete jb-delete.o jb.o
-jb-derive: jb-derive.o jb.o sort.o
-	$(CXX) -o jb-derive jb-derive.o jb.o sort.o
-jb-global: jb-global.o jb.o
-	$(CXX) -o jb-global jb-global.o jb.o
-jb-header: jb-header.o jb.o
-	$(CXX) -o jb-header jb-header.o jb.o
-jb-merge: jb-merge.o jb.o
-	$(CXX) -o jb-merge jb-merge.o jb.o
-jb-print: jb-print.o jb.o
-	$(CXX) -o jb-print jb-print.o jb.o
-jb-promote: jb-promote.o jb.o
-	$(CXX) -o jb-promote jb-promote.o jb.o
-jb-region: jb-region.o jb.o
-	$(CXX) -o jb-region jb-region.o jb.o
-jb-rename: jb-rename.o jb.o
-	$(CXX) -o jb-rename jb-rename.o jb.o
-
-install: $(EXES)
-	-@cp $(EXES) ../../bin
-clean:
-	-@rm -f $(EXES)
-	-@rm -f *.o

File src/lcaperf/README

  • Ignore whitespace
-This directory contains utilities for post-processing lcaperf output files.
-
-jb-attribute  Filters records according to attribute values
-jb-columns    Output data in columns; useful for plotting with gnuplot
-jb-counter    Filters counters from all regions
-jb-delete     Deletes the attribute, global, or counter
-jb-derive     Declares a new derived type.  Can reduce along attributes
-jb-global     Defines new global variables (e.g. plotting parameters)
-jb-header     Re-prints header
-jb-merge      Merges multiple data files into one
-jb-print      Display data in data files in a human-readable format
-jb-promote    Converts the listed global variables to attributes
-jb-region     Filters records according to region names
-jb-rename     Renames globals, attributes, and counters.
-
-See http://lca.ucsd.edu/workshops/enzo2010/slides/bordner-lcaperf.pdf for more
-information.

File src/lcaperf/jb-attribute.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// File: jb-attribute.C
-//
-// Usage: jb-attribute  attribute-name1 attribute-value1
-// Usage:              [attribute-name2 attribute-value2 ...]
-//
-// Description: Filters records according to attribute values
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2006 James Bordner
-// Copyright 2006 Laboratory for Computational Astrophysics
-// Copyright 2006 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-{
-  int i,j;
-  vector<int> filtered_counter_indices;
-  map<string,string> Globals;
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  vector<string> Counter_names_new;
-  vector<string> Counter_types_new;
-  string augregion;
-  vector<string> augregion_split;
-  vector<string> counters;
-  vector<string> counters_new;
-
-  // Log start
-
-  jb_log("start", argv[0]);
-
-  FILE *fp = stdin;
-
-  // Read and write globals
-
-  jb_read_globals(fp, Globals);
-  jb_print_globals (Globals);
-
-
-  // Read and write data header
-
-  jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-  jb_print_header (Attribute_names, Counter_names, Counter_types);
-
-  // First determine Attribute indices 
-
-  vector<int>    indices;
-  vector<string> values;
-
-  for (i=1; i<argc; i+=2) {
-
-    string argv_attribute = argv[i];
-    string argv_value     = argv[i+1];
-
-    bool any_found = false;
-    for (j=0; j<Attribute_names.size(); j++) {
-      if (argv_attribute == Attribute_names[j]) {
-	indices.push_back(j);
-	values.push_back(argv_value);
-	any_found = true;
-	break;
-      }
-    }
-    if (! any_found) {
-      fprintf (stderr,"Error: Attribute '%s' not in file!\n",argv_attribute.c_str());
-    }
-  }
-
-  // Now print only selected records based on attribute values
-
-  while (jb_read_next_record(fp,Attribute_names.size(),Counter_names.size(),
-			     augregion, counters)) {
-
-    jb_split (augregion, augregion_split);
-
-    bool print_record = true;
-
-    for (i=0; i<indices.size(); i++) {
-      if (augregion_split[indices[i]+1] != values[i]) print_record = false;
-    }
-
-    if (print_record) jb_print_record (augregion, counters);
-  }
-  jb_log("stop", argv[0]);
-}

File src/lcaperf/jb-columns.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// File: jb-columns.C
-//
-// Usage: jb-columns "x_1 [x_2 ... x_N]"
-//
-// Description: Prints the given attributes or counter values in columns
-// Description: that are easy for plotting programs to read (e.g. gnuplot)
-//
-// Caveats: The output is unsorted, so should be run through "sort -n"
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2005 James Bordner
-// Copyright 2005 Laboratory for Computational Astrophysics
-// Copyright 2005 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-
-{
-
-  int i;
-  map<string,string> Globals;
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  string augregion;
-  vector<string> augregion_split;
-  vector<string> counters;
-
-  vector<int> indices;
-  vector<bool> isAttribute;
-  vector<bool> isCounter;
-  
-  // Log start of jb-merge
-
-  jb_log("start", argv[0]);
-
-  FILE *fp = stdin;
-
-  // Read globals and data header
-
-  jb_read_globals(fp, Globals);
-  jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-
-  indices.clear();
-  isAttribute.clear();
-  isCounter.clear();
-
-  // Find indices of columns, and whether they're Attributes or Counters
-
-  for (i=0; i<argc-1; i++) {
-    bool found = false;
-    char * column = argv[i+1];
-    int j;
-    if (strcmp(column,"region")==0) {
-       isAttribute.push_back(1);
-       isCounter.push_back  (0);
-       indices.push_back    (-1);
-       found = true;
-    }
-    for (j=0; j<Attribute_names.size(); j++) {
-      if (Attribute_names[j] == column) {
-        isAttribute.push_back(1);
-        isCounter.push_back  (0);
-        indices.push_back    (j);
-        found = true;
-        break;
-      }
-    }
-    for (j=0; j<Counter_names.size(); j++) {
-      if (Counter_names[j] == column) {
-        isAttribute.push_back(0);
-        isCounter.push_back  (1);
-        indices.push_back    (j);
-        found = true;
-        break;
-      }
-    }
-    if (! found) {
-      fprintf (stderr, "%s Error: Attribute or Counter name '%s' not found!\n",
-               argv[0],column);
-      exit(1);
-    }
-  }
-        
-  while (jb_read_next_record(fp,Attribute_names.size(),Counter_names.size(),
-                             augregion, counters)) {
-
-    jb_split (augregion, augregion_split);
-
-    // Determine whether to print the record
-    
-    string line = "";
-
-    for (int i=0; i<argc-1; i++) {
-      string value;
-      if (isAttribute[i]) {
-        value = augregion_split[indices[i]+1];
-      } else if (isCounter[i]) {
-        value = counters[indices[i]];
-      } else {
-        fprintf (stderr, "%s Error: index is neither Attribute nor Counter name!\n",
-                argv[0]);
-        exit(1);
-      }
-
-      line = (i==0) ? value : line + " " + value;
-    }
-    printf ("%s\n",line.c_str());
-
-    // Get next record
-  }
-  jb_log("stop", argv[0]);
-}

File src/lcaperf/jb-counter.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// File: jb-counter.C
-//
-// Usage: jb-counter counter-name1 [counter-name2 ...]
-//
-// Description: Filter counters from records, leaving only those named
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2005 James Bordner
-// Copyright 2005 Laboratory for Computational Astrophysics
-// Copyright 2005 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-{
-  int i,j;
-  vector<int> filtered_counter_indices;
-  map<string,string> Globals;
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  vector<string> Counter_names_new;
-  vector<string> Counter_types_new;
-  string augregion;
-  vector<string> counters;
-  vector<string> counters_new;
-
-  // Log start
-
-  jb_log("start", argv[0]);
-
-  FILE *fp = stdin;
-
-  // Read and write globals
-
-  jb_read_globals(fp, Globals);
-  jb_print_globals (Globals);
-
-
-  // Read and write data header
-
-  jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-
-  filtered_counter_indices.clear();
-  Counter_names_new.clear();
-  Counter_types_new.clear();
-  for (i=1; i<argc; i++) {
-    for (j=0; j<Counter_names.size(); j++) {
-      if (Counter_names[j] == argv[i]) {
-	filtered_counter_indices.push_back(j);
-	Counter_names_new.push_back(Counter_names[j]);
-	Counter_types_new.push_back(Counter_types[j]);
-      }
-    }
-  }
-  
-  jb_print_header (Attribute_names, Counter_names_new, Counter_types_new);
-
-  // Now print records with only given counters
-
-  while (jb_read_next_record(fp,Attribute_names.size(),Counter_names.size(),
-			     augregion, counters)) {
-    counters_new.clear();
-    for (i=0; i<filtered_counter_indices.size(); i++) {
-      counters_new.push_back(counters[filtered_counter_indices[i]]);
-    }
-    jb_print_record (augregion, counters_new);
-  }
-
-  jb_log("stop", argv[0]);
-}

File src/lcaperf/jb-delete.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// Usage: jb-delete <name1> [<name2> ...]
-//
-// Description: Deletes the attribute, global, or counter
-//
-// Bugs: 1. Attributes can be deleted such that augmented regions
-// Bugs:    are no longer unique, resulting in an ill-formed file
-// Bugs: 2. "region" cannot be deleted:  currently it's hard-coded in jb.C
-// Bugs:    for file type backwards compatibility. 
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2006 James Bordner
-// Copyright 2006 Laboratory for Computational Astrophysics
-// Copyright 2006 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-{
-  int i,j;
-  vector<int> filtered_counter_indices;
-  map<string,string> Globals;
-  map<string,string> Globals_new;
-  vector<string> Attribute_names;
-  vector<string> Attribute_names_new;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  vector<string> Counter_names_new;
-  vector<string> Counter_types_new;
-  string augregion;
-  string new_augregion;
-  vector<string> augregion_split;
-  vector<string> counters;
-  vector<string> new_counters;
-
-  map<string,int> delete_name;
-  vector<int> attribute_indices;
-  vector<int> counter_indices;
-
-  // Log start
-
-  jb_log("start", argv[0]);
-
-  // Read from stdin or named file
-  
-  FILE *fp = stdin;
-
-  // Check number of arguments: exit if 0
-
-  if ((argc-1) == 0) {
-    fprintf (stderr,"%s:%d ERROR: wrong number of arguments!\n",
-	     __FILE__,__LINE__);
-    exit(1);
-  }
-
-  for (i=1; i<argc; i++) {
-    delete_name[argv[i]] = 1;
-  }
-
-  //--------------------------------------------------------------------
-  // Globals
-  //--------------------------------------------------------------------
-
-  // Read Globals
-
-  jb_read_globals(fp, Globals);
-
-
-  // Delete Globals
-
-  map<string,string>::iterator global_var;
-
-  for (global_var = Globals.begin();
-       global_var != Globals.end();
-       ++global_var) {
-    if (delete_name[global_var->first] != 1) {
-      Globals_new[global_var->first] = global_var->second;
-    }
-  }
-
-  // Write Globals_new
-
-  jb_print_globals(Globals_new);
-
-  //--------------------------------------------------------------------
-  // Header
-  //--------------------------------------------------------------------
-
-  // Read Header
-
-  jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-  int num_attributes = Attribute_names.size();
-  int num_counters   = Counter_names.size();
-
-  // Remap Header: attributes
-
-  for (i=0; i<Attribute_names.size(); i++) {
-    if (delete_name[Attribute_names[i]] != 1) {
-      attribute_indices.push_back(i);
-      Attribute_names_new.push_back(Attribute_names[i]);
-    }
-  }
-
-  // Remap Header: counters
-
-  for (i=0; i<Counter_names.size(); i++) {
-    if (delete_name[Counter_names[i]] != 1) {
-      counter_indices.push_back(i);
-      Counter_names_new.push_back(Counter_names[i]);
-      Counter_types_new.push_back(Counter_types[i]);
-    }
-  }
-
-  // Write Header
-
-  jb_print_header (Attribute_names_new, Counter_names_new, Counter_types_new);
-
-  //--------------------------------------------------------------------
-  // Records
-  //--------------------------------------------------------------------
-
-  while (jb_read_next_record(fp,num_attributes,num_counters, augregion, counters)) {
-
-    // Split augregion --> augregion_split
-
-    jb_split (augregion, augregion_split);
-
-    // Remap augregion_split
-
-    new_augregion = augregion_split[0];
-
-    for (i=0; i<attribute_indices.size(); i++) {
-      new_augregion = new_augregion + " " + augregion_split[attribute_indices[i]+1];
-    }
-
-    new_counters.clear();
-    for (i=0; i<counter_indices.size(); i++) {
-      new_counters.push_back(counters[counter_indices[i]]);
-    }
-
-    // Write record
-
-    jb_print_record (new_augregion, new_counters);
-  }
-
-
-  jb_log("stop", argv[0]);
-}
-

File src/lcaperf/jb-derive.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// Usage: jb-derive <operation> <new-metric> <argument1> [<argument2> ...]
-//
-// Description: Derive a new metric in terms of existing counters or
-// Description: other previously-derived metrics
-//
-// Arguments:
-//
-//    Arguments depend on the operation; below we list the available operations
-//    and their arguments.  We use the following notation for argument names:
-//
-//    "x" is the new derived counter
-//    "y" and "z" are existing counters
-//    "z[]" is an attribute, indexed by i
-//    "a" is a (real) scalar
-//    "i" in the descriptions refers to the index of the independent metric
-//
-//
-// LOCAL UNARY OPERATORS
-// ---------------------
-// 
-// Arguments:
-//
-//    Counter x
-//    Real    a
-//    Counter y
-//
-// Operators: 
-//
-//    scale      x(i) <-- a * y(i)
-//    offset     x(i) <-- a + y(i)
-//    invscale   x(i) <-- a / y(i)
-//
-//
-// LOCAL BINARY OPERATORS
-// ----------------------
-//
-// Arguments:
-//
-//    Counter x
-//    Counter y
-//    Counter z
-//
-// Operators: 
-//
-//    [add | +]   x(i) <-- y(i) + z(i)
-//    [sub | -]   x(i) <-- y(i) - z(i)
-//    [div | /]   x(i) <-- y(i) / z(i)
-//    [mul | *]   x(i) <-- y(i) * z(i)
-//
-//
-// REDUCTION OPERATORS
-// -------------------
-//
-// Arguments:
-//
-//    Counter x
-//    Counter y
-//    Attribute z
-//
-// Operators: 
-//
-//    sum         x(i) <-- sum of y(i) over different z 
-//    min         x(i) <-- minimum of y(i) over different z
-//    max         x(i) <-- maximum of y(i) over different z 
-//    avg         x(i) <-- average of y(i) over different z 
-//   
-//
-// FINITE DIFFERENCE OPERATORS
-// ---------------------------
-//
-// (For I and D operators, x(i) are sorted such that x(i-1) < x(i))
-//
-// Arguments:
-//
-//    Counter x
-//    Counter y
-//    Attribute z
-//
-// Operators: 
-//
-//    I           x(n) <-- y(0) + (z(1)-z(0))*y(1) + ... + (z(n)-z(n-1))*y(n)
-//                
-//    D (i = 0)   x(i) <-- y(0)
-//    D (i > 0)   x(i) <-- (y(i) - y(i-1)) / (z(i) - z(i-1)) 
-//
-//
-// INTERPOLATION OPERATOR
-// ----------------------
-//
-// Arguments:
-//
-//    Counter x
-//    Counter y
-//    Attribute z
-//
-// Operators: 
-//
-//    interpolate (z(i) != "*") x(i) <-- z(i) 
-//    interpolate (z(i) != "*") x(i) <-- z(i1) + (z(i2)-z(i1)) / (y(i2)-y(i1))
-//             where i1 s.t. y(i1) < y(i) and z(k) < z(i1) ==> @@@@@
-//             and   i2 = minarg_k y(k) > y(i)
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2004 James Bordner
-// Copyright 2004 Laboratory for Computational Astrophysics
-// Copyright 2004 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-#include "sort.h"
-
-main(int argc, char **argv)
-{
-
-  string operation;
-  string new_metric;
-  vector<string> arguments;
-  map<string,string> Globals;
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  string augregion;
-  vector<string> counters;
-  vector<string> augregion_split;
-  map<string,vecstr> Records;
-
-  vector<struct reg_struct *> aug_regions;
-
-  char svalue[20];
-
-  // Log start
-
-  jb_log("start", argv[0]);
-
-  // Parse command-line arguments
-
-  operation  = argv[1];
-  new_metric = argv[2];
-  for (int i=3; i<argc; i++) {
-    arguments.push_back (argv[i]);
-  }
-
-  bool valid_operation = false;
-
-  FILE *fp = stdin;
-
-  // -----------------------------------------------------------------------
-  // Read and write globals
-  // -----------------------------------------------------------------------
-
-  jb_read_globals(fp, Globals);
-  jb_print_globals (Globals);
-
-  // -----------------------------------------------------------------------
-  // Read, modify, and write data header
-  // -----------------------------------------------------------------------
-
-  jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-
-  Counter_names.push_back (new_metric);
-  Counter_types.push_back ("derived");
-  
-  jb_print_header (Attribute_names, Counter_names, Counter_types);
-
-  // -----------------------------------------------------------------------
-  // Local unary operators
-  // -----------------------------------------------------------------------
-  
-  if (operation == "scale" ||
-      operation == "offset" ||
-      operation == "invscale") {
-
-    valid_operation = true;
-
-    // Get arguments
-
-    double a;
-    int iy;
-
-    a = atof (arguments[0].c_str());
-    for (iy=0; iy < Counter_names.size() && arguments[1] != Counter_names[iy]; iy++)
-      ;
-  
-    // Check arguments
-
-    if (iy >= Counter_names.size()) {
-      fprintf (stderr, "%s Error: no Counter named %s!\n",
-	       argv[0],arguments[1].c_str());
-    }
-
-    // Perform operation
-
-    while (jb_read_next_record(fp,Attribute_names.size(),Counter_names.size()-1,
-			       augregion, counters)) {
-
-      char value[20];
-      if (counters[iy] == "*") {
-	sprintf (value,"*");
-      } else {
-	double y = atof(counters[iy].c_str());
-	if (operation == "scale")    sprintf (value,"%g",a*y);
-	if (operation == "offset")   sprintf (value,"%g",a+y);
-	if (operation == "invscale") sprintf (value,"%g",a/y);
-      }
-
-      counters.push_back (value);
-
-      jb_print_record (augregion, counters);
-      
-    }
-  }
-
-  // -----------------------------------------------------------------------
-  // Local binary operators
-  // -----------------------------------------------------------------------
-  
-  if (operation == "add" ||
-      operation == "sub" ||
-      operation == "div" ||
-      operation == "mul" ||
-      operation == "+" ||
-      operation == "-" ||
-      operation == "/" ||
-      operation == "*") {
-
-    valid_operation = true;
-
-    // Get arguments
-
-    int ix,iy;
-
-    for (iy=0; 
-	 iy < Counter_names.size() && arguments[0] != Counter_names[iy]; 
-	 iy++)
-      ;
-    for (ix=0; 
-	 ix < Counter_names.size() && arguments[1] != Counter_names[ix]; 
-	 ix++)
-      ;
-  
-    // Check arguments
-
-    if (iy >= Counter_names.size()) {
-      fprintf (stderr, "%s Error: no Counter named %s!\n",
-	       argv[0],arguments[0].c_str());
-    }
-    if (ix >= Counter_names.size()) {
-      fprintf (stderr, "%s Error: no Counter named %s!\n",
-	       argv[0],arguments[1].c_str());
-    }
-
-    // Perform operation
-
-    while (jb_read_next_record(fp,Attribute_names.size(),Counter_names.size()-1,
-			       augregion, counters)) {
-
-      if (counters[ix] == "*" || counters[iy] == "*") {
-	sprintf (svalue,"*");
-      } else {
-	double x = atof(counters[ix].c_str());
-	double y = atof(counters[iy].c_str());
-	if (operation == "add" || operation == "+") sprintf (svalue,"%g",y+x);
-	if (operation == "sub" || operation == "-") sprintf (svalue,"%g",y-x);
-	if (operation == "mul" || operation == "*") sprintf (svalue,"%g",y*x);
-	if (operation == "div" || operation == "/") sprintf (svalue,"%g",y/x);
-      }
-
-      counters.push_back (svalue);
-
-      jb_print_record (augregion, counters);
-      
-    }
-  }
-
-// =======================================================================
-// OPERATIONS THAT REQUIRE SORTING
-// =======================================================================
-
-  if (operation == "sum" ||
-      operation == "min" ||
-      operation == "max" ||
-      operation == "avg" ||
-      operation == "I" ||
-      operation == "D" ||
-      operation == "interpolate") {
-
-    int ix,iy;
-
-    for (iy=0; 
-	 iy < Counter_names.size() && arguments[0] != Counter_names[iy]; 
-	 iy++)
-      ;
-    for (ix=0; 
-	 ix < Attribute_names.size() && arguments[1] != Attribute_names[ix]; 
-	 ix++)
-      ;
-  
-    // Check arguments
-
-    if (iy >= Counter_names.size()) {
-      fprintf (stderr, "%s Error: no Counter named %s!\n",
-	       argv[0],arguments[0].c_str());
-    }
-    if (ix >= Attribute_names.size()) {
-      fprintf (stderr, "%s Error: no Attribute named %s!\n",
-	       argv[0],arguments[1].c_str());
-    }
-
-    // Adjust attribute index
-    
-    ++ix;
-
-    // Generate list aug_regions of
-    // [sorted-aug-regions, original aug-regions, indices, values-to-reduce]
-
-    int index = 0;
-    
-    jb_read_records(fp,Attribute_names.size(),Counter_names.size()-1,Records);
-
-    map<string,vecstr>::iterator it_augregion;
-    for (it_augregion = Records.begin();
-	 it_augregion != Records.end();
-	 ++it_augregion) {
-
-      double x,y;
-
-      string augregion = it_augregion->first;
-
-      if (Records[augregion][iy] == "*") {
-	y = STAR_FLOAT;
-      } else {
-	y = atof (Records[augregion][iy].c_str());
-      }
-
-      string augregion_r;
-      jb_augregion_rotate_(augregion,ix,augregion_r);
-      
-      jb_split (augregion,augregion_split);
-
-      if (augregion_split[ix] == "*") {
-	x = STAR_FLOAT;
-      } else {
-	x = atof (augregion_split[ix].c_str());
-      }
-
-      struct reg_struct *pregyx = new reg_struct;
-      pregyx->sorted   = augregion_r;
-      pregyx->original = augregion;
-      pregyx->y = y;
-      pregyx->x = x;
-
-      aug_regions.push_back (pregyx);
-      
-      ++ index;
-    }
-
-    // Sort depending on operation type
-
-    if (operation == "sum" ||
-	operation == "min" ||
-	operation == "max" ||
-	operation == "avg") {
-      jb_sort_sorted(aug_regions,0,aug_regions.size()-1);
-    } else if (operation == "D" ||
-	       operation == "I" ||
-	       operation == "interpolate") {
-      jb_sort_x(aug_regions,0,aug_regions.size()-1);
-    }
-
-    int istart, iend;
-    string root_start,root_end;
-    double value;
-    istart = 0;
-
-    // Get aug_region's root
-
-    bool isFinished = false;
-    
-    while (! isFinished) {
-
-        // Find ending index for reduction
-
-      iend = istart;
-      root_start = jb_augregion_root_(aug_regions[istart]->sorted);
-      root_end   = root_start;
-      while (! isFinished  && root_start == root_end) {
-	++ iend;
-	if (iend >= aug_regions.size()) {
-	  isFinished = true;
-	} else {
-	  root_end = jb_augregion_root_(aug_regions[iend]->sorted);
-	}
-      }
-
-
-      // ----------------------------------------------------------------------
-      // Reduction operations
-      // ----------------------------------------------------------------------
-
-      if (operation == "sum" ||
-	  operation == "min" ||
-	  operation == "max" ||
-	  operation == "avg") {
-    
-	value = aug_regions[istart]->y;
-
-	double x,y;
-
-	for (int i=istart+1; i<iend; i++) {
-	  
-	  y = aug_regions[i]->y;
-	  if (value == STAR_FLOAT or y == STAR_FLOAT) {
-            value = STAR_FLOAT;
-	  } else if (operation == "sum") {                
-	    value = value + y;
-	  } else if (operation == "min" and value > y) {  
-	    value = y;
-	  } else if (operation == "max" and value < y) {  
-	    value = y;
-	  } else if (operation == "avg") {
-	    value = value + y;
-	  }
-	}
-                            
-	if (operation == "avg" and value != STAR_FLOAT) {
-	  value = value / (iend - istart);
-	}
-
-	// Store the values
-
-	sprintf (svalue,"%g",value);
-	for (int i=istart; i<iend; i++) {
-	  augregion = aug_regions[i]->original;
-	  Records[augregion].push_back(svalue);
-	}
-      }
-
-// ----------------------------------------------------------------------
-// Difference/quadrature operations
-// ----------------------------------------------------------------------
-
-      if (operation == "D" ||
-	  operation == "I") {
-
-	double x,y,xprev,yprev;
-
-	y = aug_regions[istart]->y;
-	x = aug_regions[istart]->x;
-	yprev = y;
-	xprev = x;
-	value = y;
-
-	// First value z(0) is y(0)
-
-	augregion = aug_regions[istart]->original;
-	sprintf (svalue,"%g",value);
-	Records[augregion].push_back(svalue);
-	for (int i=istart+1; i<iend; i++) {
-	  y = aug_regions[i]->y;
-	  x = aug_regions[i]->x;
-	  // compute value
-	  if (value == STAR_FLOAT || y == STAR_FLOAT || x == STAR_FLOAT) {
-	    value = STAR_FLOAT;
-	  } else {
-	    double xv = x;
-	    double xvprev = xprev;
-	    if (operation == "I") { 
-	      value = value + (xv - xvprev) * y;
-	    } else if (operation == "D") { 
-	      value = (y - yprev) / (xv - xvprev);
-	    }
-	  }
-
-	  // store value
-	  augregion = aug_regions[i]->original;
-	  sprintf (svalue,"%g",value);
-	  Records[augregion].push_back(svalue);
-	  yprev = y;
-	  xprev = x;
-	}
-      }
-
-// ----------------------------------------------------------------------
-// Interpolation operation
-// ----------------------------------------------------------------------
-
-      if (operation == "interpolate") {
-
-	double x,y,x_first,y_first,x_second,y_second;
-	int i_first,i_second,i_last;
-
-	x = aug_regions[istart]->x;
-	y = aug_regions[istart]->y;
-
-	// Find i_first
-	i_first = istart;
-	while (i_first < iend) {
-	  if (aug_regions[i_first]->y != STAR_FLOAT) break;
-	  ++i_first;
-	}
-
-	x_first = aug_regions[i_first]->x;
-	y_first = aug_regions[i_first]->y;
-
-	// Find i_last
-	i_last = iend - 1;
-	while (i_last >= i_first) {
-	  if (aug_regions[i_last]->y != STAR_FLOAT) break;
-	  --i_last;
-	}
-
-	// If at most one y is not "*"...
-
-	if (i_first == iend || i_first == i_last) {
-	  // nothing to interpolate
-	  if (i_first == iend) value = STAR_FLOAT;
-	  // one value to "interpolate"--assume constant
-	  if (i_first == i_last) value = aug_regions[i_first]->y;
-	  for (int i=istart; i<iend; i++) {
-	    augregion = aug_regions[i]->original;
-	    sprintf (svalue,"%g",value);
-	    Records[augregion].push_back(svalue);
-	  }
-	} else {
-
-	  // If at least two y's are not "*"...
-
-	  // Find i_second
-	  i_second = i_first + 1;
-	  while (i_second < iend) {
-	    if (aug_regions[i_second]->y != STAR_FLOAT) break;
-	    ++ i_second;
-	  }
-
-	  x_second = aug_regions[i_second]->x;
-	  y_second = aug_regions[i_second]->y;
-
-	  for (int i=istart; i<iend; i++) {
-	    x = aug_regions[i]->x;
-	    y = aug_regions[i]->y;
-	    if (i < i_second && y == STAR_FLOAT) {
-	      value = y_first + (x - x_first) 
-		/     (x_second - x_first) * (y_second - y_first);
-	    }	else if (i < i_second && y != STAR_FLOAT) {
-	      value = y;
-	    }	else {
-	      // assert (i == i_second), so we know y != "*"
-	      value = aug_regions[i]->y;
-	      // also move to next (i_first, i_second) if needed
-	      if (i_second != i_last) {
-		i_first = i_second;
-		x_first = aug_regions[i_first]->x;
-		y_first = aug_regions[i_first]->y;
-		  
-		// Find i_second
-		i_second = i_first+1;
-		while (i_second < iend) {
-		  if (aug_regions[i_second]->y != STAR_FLOAT) break;
-		  ++i_second;
-		}
-		x_second = aug_regions[i_second]->x;
-		y_second = aug_regions[i_second]->y;
-
-	      }
-	    }
-	    augregion = aug_regions[i]->original;
-	    sprintf (svalue,"%g",value);
-	    Records[augregion].push_back(svalue);
-	  }
-	}
-      }                 
-      // Prepare for next reduction
-
-      istart = iend;
-
-    }
-    jb_print_records (Records);
-    
-  }
-  jb_log("stop", argv[0]);
-}

File src/lcaperf/jb-global.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// File: jb-global.C
-//
-// Usage: jb-global <global1> <value1> [<global2> <value2> ... ]
-//
-// Description: (Re)defines the listed global variables.  Defining a global to be "*"
-// Description: serves to undefine it (remember the quotes!)
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2005 James Bordner
-// Copyright 2005 Laboratory for Computational Astrophysics
-// Copyright 2005 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-
-{
-
-  map<string,string> Globals;
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  string augregion;
-  vector<string> augregion_split;
-  vector<string> counters;
-
-  // Log start of jb-merge
-
-  jb_log("start", argv[0]);
-
-  FILE *fp = stdin;
-
-  // Read and write globals
-
-  jb_read_globals(fp, Globals);
-
-  if (argc == 2) {
-
-    // Print existing global value
-
-    if (Globals.find(argv[1]) != Globals.end()) {
-      printf ("%s\n",Globals[argv[1]].c_str());
-    }
-      
-  } else {
-    for (int i=1; i<argc; i+=2) {
-      const char * new_global = argv[i];
-      const char * new_value = argv[i+1];
-      if (strcmp(new_value,"*") != 0) {
-	Globals[new_global] = new_value;
-      } else {
-	if (Globals.find(new_global) != Globals.end()) {
-	  Globals.erase(new_global);
-	}
-      }
-    }
-    jb_print_globals (Globals);
-
-    // Read and write data header
-
-    jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-    jb_print_header (Attribute_names, Counter_names, Counter_types);
-
-    // Print records
-
-    while (jb_read_next_record(fp,Attribute_names.size(),Counter_names.size(),
-			       augregion, counters)) {
-      jb_split (augregion, augregion_split);
-      jb_print_record (augregion, counters);
-    }
-  }
-  jb_log("stop", argv[0]);
-}

File src/lcaperf/jb-header.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// File: jb-header.C
-//
-// Usage: jb-header
-//
-// Description: Displays the header information (header record)
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2005 James Bordner
-// Copyright 2005 Laboratory for Computational Astrophysics
-// Copyright 2005 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-
-{
-
-  map<string,string> Globals;
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  string augregion;
-  vector<string> augregion_split;
-  vector<string> counters;
-
-  // Log start of jb-merge
-
-  jb_log("start", argv[0]);
-
-  FILE *fp = stdin;
-
-  // Read and write globals
-
-  jb_read_globals(fp, Globals);
-
-  // Read and write data header
-
-  jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-  jb_print_header (Attribute_names, Counter_names, Counter_types);
-
-  jb_log("stop", argv[0]);
-}

File src/lcaperf/jb-merge.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// File: jb-merge.C
-//
-// Usage: jb-merge <file1> [ <file2> ... ] 
-//
-// Description: Merges the listed jbPerf files into a single file.
-// Description: Promotes globals to attributes as needed.
-
-// Assumptions: Merged files that promote globals must have different
-// Assumptions: global values for each file, e.g. processor-rank.  If no globals
-// Assumptions: are promoted, then a "slow" version is used that accumulates
-// Assumptions: records before writing them.
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2005 James Bordner
-// Copyright 2005 Laboratory for Computational Astrophysics
-// Copyright 2005 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-{
-  int i;
-
-  // Exit if there is nothing to do
-
-  if (argc == 1) exit(1);
-
-  // Log start of jb-merge
-
-  jb_log("start", argv[0]);
-
-  // Get command-line arguments
-  
-  vector<string> infiles;
-  infiles.resize(argc-1);
-  for (i=1; i<argc; i++) infiles[i-1] = argv[i];
-
-  // (DEBUG: print out command-line arguments)
-  
-  map<string,string> old_globals;
-  map<string,string> new_globals;
-  map<string,string> curr_globals;
-  map<string,string> Globals; // @@@ Might not need--can re-use curr_globals?
-  map<string,string> new_promoted_attributes;
-  map<string,int> new_attribute_index;
-  map<string,int> new_counter_index;
-  vector<string> new_counter_names;
-  vector<string> new_counter_types;
-
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  map<int,int> attribute_remap;
-  map<int,int> counter_remap;
-  map<string,vecstr> new_records;
-  string old_augregion;
-  vector<string> old_record_counters;
-  vector<string> augregion_split;
-  vector<string> new_augregion_split;
-  string new_augregion;
-  string attribute_value;
-  string counter_value;
-  vector<string> new_counter_values;
-
-  bool are_disjoint = false;
-
-  //------------------------------------------------------------------------
-  // READ GLOBALS AND HEADER RECORD
-  //------------------------------------------------------------------------
-
-  int ifile=0;
-  for (ifile=0; ifile<infiles.size(); ifile++) {
-
-    string infile = infiles[ifile];
-
-    // First figure out which globals to promote to locals
-    
-    FILE *fp = jb_file_open (infile);
-
-    // Read globals
-
-    jb_read_globals(fp, curr_globals);
-
-    // if first file, set new and old globals to its globals...
-    
-    if (infile==infiles[0]) {
-
-      old_globals = curr_globals;
-      new_globals = curr_globals;
-
-    // ...otherwise update old and new globals accordingly
-
-    } else {
-
-      if (old_globals.size() != curr_globals.size()) {
-	printf ("ERROR: '%s' and '%s' have different numbers of globals--exiting!",
-		infiles[0].c_str(), infile.c_str());
-      } else {
-	map<string,string>::iterator global_var;
-	for (global_var = curr_globals.begin();
-	     global_var != curr_globals.end();
-	     ++global_var) {
-	  if (strcmp(curr_globals[global_var->first].c_str(),
-		     old_globals[global_var->first].c_str()) != 0 &&
-	      new_globals.find(global_var->first) != new_globals.end()) {
-	    new_globals.erase(global_var->first);
-	    new_promoted_attributes[global_var->first] = curr_globals[global_var->first];
-	  }
-	}
-      }
-    }
-
-    // Which attributes...
-
-    jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-
-    int i;
-
-    for (i=0; i<Attribute_names.size(); i++) {
-      if (new_attribute_index.find(Attribute_names[i]) 
-	  == new_attribute_index.end()) {
-	new_attribute_index[Attribute_names[i]] = new_attribute_index.size();
-      }
-    }
-
-    // And which counter names and types ...
-
-    for (i=0; i<Counter_names.size(); i++) {
-      if (new_counter_index.find(Counter_names[i]) 
-	  == new_counter_index.end()) {
-	new_counter_index[Counter_names[i]] = new_counter_index.size() - 1;
-	new_counter_types.push_back(Counter_types[i]);
-	new_counter_names.push_back(Counter_names[i]);
-      }
-    }
-
-    jb_file_close(fp);
-
-  }
-
-  
-  //------------------------------------------------------------------------
-  // DETERMINE WHETHER RECORDS ARE DISJOINT OR NOT (SEE ASSUMPTIONS IN HEADER COMMENT!)
-  //------------------------------------------------------------------------
-
-  are_disjoint = (new_promoted_attributes.size() != 0);
-
-  //------------------------------------------------------------------------
-  // WRITE GLOBAL RECORD
-  //------------------------------------------------------------------------
-
-  jb_print_globals (new_globals);
-
-  //------------------------------------------------------------------------
-  // WRITE HEADER RECORD
-  //------------------------------------------------------------------------
-
-  Attribute_names.clear();
-
-  //    region and existing attributes
-
-  for (map<string,int>::iterator pattribute = new_attribute_index.begin();
-       pattribute != new_attribute_index.end();
-       ++pattribute) {
-    Attribute_names.push_back (pattribute->first);
-  }
-  //   new attributes promoted from globals
-  for (map<string,string>::iterator pattribute = new_promoted_attributes.begin();
-       pattribute != new_promoted_attributes.end();
-       ++pattribute) {
-    Attribute_names.push_back (pattribute->first);
-  }
-  //    counters
-  Counter_names.clear();
-  Counter_types.clear();
-  for (map<string,int>::iterator pcounter = new_counter_index.begin();
-       pcounter != new_counter_index.end();
-       ++pcounter) {
-    Counter_types.push_back (new_counter_types[pcounter->second]);
-    Counter_names.push_back (pcounter->first);
-  }
-
-  jb_print_header (Attribute_names, Counter_names, Counter_types);
-
-  //------------------------------------------------------------------------
-  // READ DATA RECORDS
-  //------------------------------------------------------------------------
-
-  new_records.clear();
-
-  for (ifile=0; ifile<infiles.size(); ifile++) {
-
-    string infile = infiles[ifile];
-
-    FILE *fp = jb_file_open (infile);
-
-    // Read globals
-
-    jb_read_globals(fp, Globals);
-
-    // Read header
-
-    jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-
-    // map attributes from new-order to file-order
-
-    
-    attribute_remap.clear();
-    int num_attributes = Attribute_names.size();
-    for (i=0; i<num_attributes; i++) {
-      attribute_remap [new_attribute_index[Attribute_names[i]]] = i + 1;
-    }
-
-    // map counters from new-order to file-order
-
-    counter_remap.clear();
-    int num_counters = Counter_names.size();
-    for (i=0; i<num_counters; i++) {
-      counter_remap [new_counter_index[Counter_names[i]]] = i;
-    }
-
-    // Read data records
-
-    while (jb_read_next_record(fp,num_attributes,num_counters,
-			       old_augregion, old_record_counters)) {
-    
-      // Generate new augmented region for current record
-
-      jb_split (old_augregion, augregion_split);
-
-      new_augregion_split.clear();
-      new_augregion_split.push_back(augregion_split[0]);
-      
-      for (map<string,int>::iterator pattribute = new_attribute_index.begin();
-	   pattribute != new_attribute_index.end();
-	   ++ pattribute) {
-	int index = pattribute->second;
-	if (attribute_remap.find(index) != attribute_remap.end()) {
-	  attribute_value = augregion_split[attribute_remap[index]];
-	} else {
-	  attribute_value = "*";
-	}
-	new_augregion_split.push_back(attribute_value);
-      }
-
-      for (map<string,string>::iterator pattribute = new_promoted_attributes.begin();
-	   pattribute != new_promoted_attributes.end();
-	   ++pattribute) {
-	new_augregion_split.push_back(Globals[pattribute->first]);
-      }
-
-      // (un-split new_augregion_split)
-
-      new_augregion = new_augregion_split[0];
-
-      for (i=1; i<new_augregion_split.size(); i++) {
-	new_augregion = new_augregion + " " + new_augregion_split[i];
-      }
-
-      // Generate new counters for current record
-
-      new_counter_values.clear();
-      for (map<string,int>::iterator pcounter = new_counter_index.begin();
-	   pcounter != new_counter_index.end();
-	   ++ pcounter) {
-	int index = pcounter->second;
-	if (counter_remap.find(index) != counter_remap.end()) {
-	  counter_value = old_record_counters[counter_remap[index]];
-	} else {
-	  counter_value = "*";
-	}
-	new_counter_values.push_back(counter_value);
-      }
-
-      // merge new augmented region and counter values those accumulated
-      // so far
-
-      if (are_disjoint) {
-
-	jb_print_record (new_augregion, new_counter_values);
-
-      } else {
-
-	if (new_records.find(new_augregion) != new_records.end()) {
-	  jb_counters_merge 
-	    (new_records[new_augregion], new_counter_values,new_counter_values);
-	}
-      }
-      
-      // @@@ new_augregion too long
-      new_records[new_augregion] = new_counter_values;
-
-    } // while record
-
-    jb_file_close(fp);
-
-  } // for files
-
-  //------------------------------------------------------------------------
-  // WRITE DATA RECORDS
-  //------------------------------------------------------------------------
-
-  if (! are_disjoint) {
-
-    for (map<string,vecstr>::iterator augregion = new_records.begin();
-	 augregion != new_records.end();
-	 ++augregion) {
-
-      jb_split (augregion->first, augregion_split);
-      for (i=0; i<augregion_split.size(); i++) {
-	printf ("%s\n",augregion_split[i].c_str());
-      }
-
-      for (i=0; i<(new_records[augregion->first]).size(); i++) {
-	printf ("%s\n",((new_records[augregion->first])[i]).c_str());
-      }
-
-      printf ("\n");
-    }
-
-  }
-
-  jb_log("stop", argv[0]);
-
-}

File src/lcaperf/jb-print.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// Usage: jb-print < <file>
-// Usage: jb-print <file>
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2004 James Bordner
-// Copyright 2004 Laboratory for Computational Astrophysics
-// Copyright 2004 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-{
-  int i,j;
-  vector<int> filtered_counter_indices;
-  map<string,string> Globals;
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  vector<string> Counter_names_new;
-  vector<string> Counter_types_new;
-  string augregion;
-  vector<string> augregion_split;
-  vector<string> counters;
-
-  // Log start
-
-  jb_log("start", argv[0]);
-
-  // Read from stdin or named file
-  
-  FILE *fp = (argc == 1) ? stdin : jb_file_open(argv[1]);
-
-  // Read globals and header
-
-  jb_read_globals(fp, Globals);
-  jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-
-  int num_attributes = Attribute_names.size();
-  int num_counters   = Counter_names.size();
-
-  while (jb_read_next_record(fp,num_attributes,num_counters, augregion, counters)) {
-
-    printf ("\n");
-
-    jb_split (augregion, augregion_split);
-
-    printf ("Region %s\n", augregion_split[0].c_str());
-    for (i=0; i<num_attributes; i++) {
-      printf ("Attribute %s %s\n", Attribute_names[i].c_str(), augregion_split[i+1].c_str());
-    }
-    for (i=0; i<num_counters; i++) {
-      printf ("Counter %s %s\n", Counter_names[i].c_str(), counters[i].c_str());
-    }
-  }
-
-
-  jb_log("stop", argv[0]);
-}
-

File src/lcaperf/jb-promote.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// File: jb-promote.C
-//
-// Usage: jb-promote <global1> [ <global2> ... ] 
-//
-// Description: Converts the listed global variables to attributes in all
-// Description: records
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2005 James Bordner
-// Copyright 2005 Laboratory for Computational Astrophysics
-// Copyright 2005 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-
-{
-  int i;
-
-  map<string,string> Globals;
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  string augregion;
-  vector<string> augregion_split;
-  vector<string> counters;
-
-  vector<string> new_attributes;
-  string attribute_string;
-  // Log start of jb-merge
-
-  jb_log("start", argv[0]);
-
-  FILE *fp = stdin;
-
-  // Read and write globals
-
-  jb_read_globals(fp, Globals);
-
-  new_attributes.clear();
-  attribute_string = "";
-  for (i=1; i<argc; i++) {
-    if (Globals.find(argv[i]) != Globals.end()) {
-      new_attributes.push_back(argv[i]);
-      attribute_string = attribute_string + " " + Globals[argv[i]];
-      Globals.erase(argv[i]);
-    }
-  }
-
-  jb_print_globals (Globals);
-
-  // Read and write data header
-
-  jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-
-  int num_attributes = Attribute_names.size();
-  for (i=0; i<new_attributes.size(); i++) {
-    Attribute_names.push_back(new_attributes[i]);
-  }
-
-  jb_print_header (Attribute_names, Counter_names, Counter_types);
-
-  // Now print only selected records based on region names:
-
-  while (jb_read_next_record(fp,num_attributes,Counter_names.size(),augregion,counters)) {
-
-    jb_split (augregion, augregion_split);
-
-    // Determine whether to print the record
-    
-    augregion = augregion + attribute_string;
-
-    jb_print_record (augregion, counters);
-
-    // Get next record
-  }
-  jb_log("stop", argv[0]);
-}

File src/lcaperf/jb-region.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// File: jb-region.C
-//
-// Usage: jb-region region1 [region2 ...]
-//
-// Description: Filters records, leaving only those with the specified region
-// Description: names.
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2005 James Bordner
-// Copyright 2005 Laboratory for Computational Astrophysics
-// Copyright 2005 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-
-{
-
-  map<string,string> Globals;
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  string augregion;
-  vector<string> augregion_split;
-  vector<string> counters;
-
-  // Log start of jb-merge
-
-  jb_log("start", argv[0]);
-
-  FILE *fp = stdin;
-
-  // Read and write globals
-
-  jb_read_globals(fp, Globals);
-  jb_print_globals (Globals);
-
-  // Read and write data header
-
-  jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-  jb_print_header (Attribute_names, Counter_names, Counter_types);
-
-  // Now print only selected records based on region names:
-
-  while (jb_read_next_record(fp,Attribute_names.size(),Counter_names.size(),
-			     augregion, counters)) {
-
-    jb_split (augregion, augregion_split);
-
-    // Determine whether to print the record
-    
-    for (int i=1; i<argc; i++) {
-      if (strcmp(argv[i],augregion_split[0].c_str())==0) {
-	jb_print_record (augregion, counters);
-	break;
-      }
-    }
-
-    // Get next record
-  }
-  jb_log("stop", argv[0]);
-}

File src/lcaperf/jb-rename.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// Usage: jb-rename <name1-from> <name1-to> [<name*-from> <name*-to>] < <file>
-//
-// Description: Renames globals, attributes, and counters.
-//
-// Bugs: 1. Does not do error-checking--it doesn't check whether 
-// Bugs:    an attribute etc. already exists with the new name.
-// Bugs: 2. "region" does not get remapped: currently it's hard-coded in jb.C
-// Bugs:    for file type backwards compatibility. 
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2006 James Bordner
-// Copyright 2006 Laboratory for Computational Astrophysics
-// Copyright 2006 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-main(int argc, char **argv)
-{
-  int i,j;
-  vector<int> filtered_counter_indices;
-  map<string,string> Globals;
-  map<string,string> Globals_new;
-  vector<string> Attribute_names;
-  vector<string> Counter_names;
-  vector<string> Counter_types;
-  vector<string> Counter_names_new;
-  vector<string> Counter_types_new;
-  string augregion;
-  string new_augregion;
-  vector<string> augregion_split;
-  vector<string> counters;
-
-  map<string,string> map_name;
-
-  // Log start
-
-  jb_log("start", argv[0]);
-
-  // Read from stdin or named file
-  
-  FILE *fp = stdin;
-
-  // Check number of arguments: exit if 0 or odd number
-
-  if ((argc-1) == 0 || (argc-1) % 2 != 0) {
-    fprintf (stderr,"%s:%d ERROR: wrong number of arguments!\n",
-	     __FILE__,__LINE__);
-    exit(1);
-  }
-
-  for (i=1; i<argc-1; i+=2) {
-    map_name[argv[i]] = argv[i+1];
-  }
-
-  //--------------------------------------------------------------------
-  // Globals
-  //--------------------------------------------------------------------
-
-  // Read Globals
-
-  jb_read_globals(fp, Globals);
-
-  // Remap Globals --> Globals_new
-
-  map<string,string>::iterator global_var;
-
-  for (global_var = Globals.begin();
-       global_var != Globals.end();
-       ++global_var) {
-    if (map_name[global_var->first] != "") {
-      Globals_new[map_name[global_var->first]] = global_var->second;
-    } else {
-      Globals_new[global_var->first] = global_var->second;
-    }
-  }
-
-  // Write Globals_new
-
-  jb_print_globals(Globals_new);
-
-  //--------------------------------------------------------------------
-  // Header
-  //--------------------------------------------------------------------
-
-  // Read Header
-
-  jb_read_header(fp, Attribute_names, Counter_names, Counter_types);
-  int num_attributes = Attribute_names.size();
-  int num_counters   = Counter_names.size();
-
-  // Remap Header: attributes
-
-  for (i=0; i<Attribute_names.size(); i++) {
-    if (map_name[Attribute_names[i]] != "") {
-      Attribute_names[i] = map_name[Attribute_names[i]];
-    }
-  }
-
-  // Remap Header: counters
-
-  for (i=0; i<Counter_names.size(); i++) {
-    if (map_name[Counter_names[i]] != "") {
-      Counter_names[i] = map_name[Counter_names[i]];
-    }
-  }
-
-  // Write Header
-
-  jb_print_header (Attribute_names, Counter_names, Counter_types);
-
-  //--------------------------------------------------------------------
-  // Records
-  //--------------------------------------------------------------------
-
-  while (jb_read_next_record(fp,num_attributes,num_counters, augregion, counters)) {
-
-    // Split augregion --> augregion_split
-
-    jb_split (augregion, augregion_split);
-
-    // Remap augregion_split
-
-    for (i=0; i<augregion_split.size(); i++) {
-      if (map_name[augregion_split[i]] != "") {
-	augregion_split[i] = map_name[augregion_split[i]];
-      }
-    }
-
-    new_augregion = augregion_split[0];
-
-    for (i=1; i<augregion_split.size(); i++) {
-      new_augregion = new_augregion + " " + augregion_split[i];
-    }
-
-    // Write record
-
-    jb_print_record (new_augregion, counters);
-  }
-
-
-  jb_log("stop", argv[0]);
-}
-

File src/lcaperf/jb.C

  • Ignore whitespace
-//----------------------------------------------------------------------
-//
-// File: jb.C
-//
-// Description: Functions used by jb-*.C utilities.  See jb.h for the list
-// Description: of functions
-//
-//----------------------------------------------------------------------
-//
-// Copyright 2005 James Bordner
-// Copyright 2005 Laboratory for Computational Astrophysics
-// Copyright 2005 Regents of the University of California
-//
-//----------------------------------------------------------------------
-
-#include "jb.h"
-
-static map<FILE *,string> global_version;
-#define global_version_write "1.0"
-
-//========================================================================
-void jb_log(const char * action, const char * name)
-//------------------------------------------------------------------------
-// Log a message (e.g. "start jb-merge") with the date in the 
-// file "JBPERF.log"
-//------------------------------------------------------------------------
-{
-#ifdef LOG_PROGRESS
-  time_t timer;
-  struct tm *tp;
-  time (&timer);
-  tp = localtime (&timer);
-
-//   FILE *fp = fopen ("JBPERF.log","a");
-//   fprintf (fp,"%-6s %-16s %04d %02d %02d %02d %02d %02d\n", action, name,
-// 	   1900+tp->tm_year,
-// 	   1+tp->tm_mon,
-// 	   tp->tm_mday,
-// 	   tp->tm_hour,
-// 	   tp->tm_min,
-// 	   tp->tm_sec);
-//   fclose (fp);
-
-  FILE *fp = fopen ("JBPERF.log","a");
-  fprintf (fp,"%02d %02d %02d %-5s        %s\n",tp->tm_hour,tp->tm_min,tp->tm_sec,action,name);
-  fclose (fp);
-#endif
-}
-//========================================================================
-FILE * jb_file_open (string filename)
-{
-  return fopen (filename.c_str(),"r");
-}
-//========================================================================
-FILE * jb_file_open_stdin ()
-{
-  return stdin;
-}
-//========================================================================
-void jb_file_close (FILE *fp)
-{
-  fclose (fp);
-}
-//========================================================================
-int jb_read_line (FILE * fp, string & line, char words[][MAX_WORD_LENGTH])
-{
-  int c;
-  char cline[MAX_LINE_LENGTH];
-  int i=0;  // Index into line string
-  int j=0;  // Index into word string
-  int c0 = c = getc(fp);
-
-  // Read line
-
-  while ((i < MAX_LINE_LENGTH) && c != EOF && c != '\n') {
-    cline[i++] = c;
-    c = getc(fp);
-  }
-  cline[i]='\0';
-  int n = i;
-
-  if (i==MAX_LINE_LENGTH) {
-    fprintf (stderr,"Line too long!");
-    exit(1);
-  }
-
-  // Read words
-
-  int iword=0;
-
-  for (i=0; i<n; i++) {
-    if (cline[i] == ' ') {
-      words[iword][j] = '\0';
-      ++iword;
-      j=0;
-    } else {
-      if (j < MAX_WORD_LENGTH) {
-	words[iword][j++] = cline[i];
-      } else {
-	fprintf (stderr,"Word too long!\n");
-	words[iword][MAX_WORD_LENGTH-1] = '\0';
-	fprintf (stderr,"%s\n",words[iword]);
-	exit(1);
-      }
-    }
-  }
-  words[iword][j] = '\0';
-
-  for (j=iword+1; j<MAX_NUM_WORDS; j++) words[j][0] = '\0';
-
-  line = cline;
-  return c0;
-}
-
-//========================================================================
-void jb_read_globals(FILE *fp, map<string,string> & Globals)
-// Reads the global definitions from the jbPerf data file fp
-{
-  string line;
-  char words[MAX_NUM_WORDS][MAX_WORD_LENGTH];
-  int c = jb_read_line (fp,line,words);
-
-  while (c != '\n') {
-    // Check that we're really in a valid Globals section
-    if (strcmp(words[0],"global")!=0) {
-      fprintf (stderr, "Error: Missing 'global' in global record!\n");
-      exit(1);
-    } else  {
-      Globals[words[1]] = words[2];
-      for (int i=3; strlen(words[i]) > 0; i++) {
-	Globals[words[1]] = Globals[words[1]] + string (" ") + string (words[i]);
-      }
-    }
-    c = jb_read_line (fp,line,words);
-  }
-  if (Globals.find("lcaperf-version") != Globals.end()) {
-    global_version[fp] = Globals["lcaperf-version"];
-  } else {
-    global_version[fp] = "0.0";
-  }
-}
-//========================================================================
-void jb_read_header(FILE * fp, 
-		    vector<string> & Attribute_name, 
-		    vector<string> & Counter_name, 
-		    vector<string> & Counter_type)
-{
-  if (global_version[fp] == "0.0") {
-    jb_read_header0 (fp,Attribute_name, Counter_name, Counter_type);
-  } else if (global_version[fp] == "1.0") {
-    jb_read_header1 (fp,Attribute_name, Counter_name, Counter_type);
-  } else {
-    fprintf (stderr, "Error: Unknown version %s in jb_read_header!\n",
-	     global_version[fp].c_str());
-      exit(1);
-  }
-}
-
-//========================================================================
-
-void jb_read_header0(FILE * fp, 
-		    vector<string> & Attribute_name, 
-		    vector<string> & Counter_name, 
-		    vector<string> & Counter_type)
-{
-  string line;
-  char words[MAX_NUM_WORDS][MAX_WORD_LENGTH];
-
-  int c = jb_read_line (fp,line,words);
-
-  if (c != '\n') {
-    if (strcmp(words[0],"region") != 0) {
-      fprintf (stderr, "jb_read_header0: Error in Header section: missing 'region'!\n");
-      fprintf (stderr, "%s\n",line.c_str());
-      exit(1);
-    }
-  }
-      
-  c = jb_read_line (fp,line,words);
-
-  Attribute_name.clear();
-  Counter_name.clear();
-  Counter_type.clear();
-
-  while (c != '\n') {
-    if (words[1][0] == '\0' || words[2][0] != '\0') {
-      // not two words in line 
-      fprintf (stderr, "jb_read_header0: Error in Header section: wrong line length!\n");
-      fprintf (stderr, "%s\n",line.c_str());
-      exit(1);
-    } else {
-      if (strcmp(words[0],"attribute") == 0) {
-	Attribute_name.push_back(words[1]); 
-      } else if (strcmp(words[0],"basic") == 0 ||
-		 strcmp(words[0],"papi") == 0 ||
-		 strcmp(words[0],"user") == 0 ||
-		 strcmp(words[0],"derived") == 0) {
-	Counter_type.push_back(words[0]);
-	Counter_name.push_back(words[1]);
-      } else {
-	fprintf (stderr,"jb_read_header0: Error in Header section: unknown keyword \n%s\n",
-		 line.c_str());