<!-- ******************************************************************** -->
<!-- HPCToolkit Experiment DTD						  -->
<!-- Version 2.2							  -->
<!-- ******************************************************************** -->
<!ELEMENT HPCToolkitExperiment (Header, (SecCallPathProfile|SecFlatProfile)*)>
<!ATTLIST HPCToolkitExperiment
	  version CDATA #REQUIRED>

  <!-- ****************************************************************** -->

  <!-- Info/NV: flexible name-value pairs: (n)ame; (t)ype; (v)alue -->
  <!ELEMENT Info (NV*)>
  <!ATTLIST Info
	    n CDATA #IMPLIED>
  <!ELEMENT NV EMPTY>
  <!ATTLIST NV
	    n CDATA #REQUIRED
	    t CDATA #IMPLIED
	    v CDATA #REQUIRED>

  <!-- ****************************************************************** -->
  <!-- Header								  -->
  <!-- ****************************************************************** -->
  <!ELEMENT Header (Info*)>
  <!ATTLIST Header
	    n CDATA #REQUIRED>

  <!-- ****************************************************************** -->
  <!-- Section Header							  -->
  <!-- ****************************************************************** -->
  <!ELEMENT SecHeader (MetricTable?, MetricDBTable?, TraceDBTable?, LoadModuleTable?, FileTable?, ProcedureTable?, Info*)>

    <!-- MetricTable: -->
    <!ELEMENT MetricTable (Metric)*>

    <!-- Metric: (i)d; (n)ame -->
    <!--   o: metric sequence order (hpcrun metric order) -->
    <!--   md: metric description -->
    <!--   mp: metric parent ID   -->
    <!--   es: number of samples    (perf_events only) -->
    <!--   em: event multiplexed    (perf_events only) -->
    <!--   ep: average event period (perf_events only) -->
    <!--   (v)alue-type: transient type of values -->
    <!--   (t)ype: persistent type of metric      -->
    <!--   show: metric visibility type. Possible values: -->
    <!--        0: hidden -->
    <!--        1: shown  -->
    <!--        2: show inclusive metric only -->
    <!--        3: show exclusive metric only -->
    <!--        4: invisible, do not show at all -->
    <!--   show-percent: whether to show the percent (1) or not (0)  -->
    <!--   partner: the exclusive or inclusive partner ID of this metric -->
    <!--   fmt: format; show; -->
    <!ELEMENT Metric (MetricFormula*, Info?)>
    <!ATTLIST Metric
	      i            CDATA #REQUIRED
	      o	           CDATA #IMPLIED
	      n            CDATA #REQUIRED
	      md           CDATA #IMPLIED
	      mp           CDATA #IMPLIED
	      es           CDATA #IMPLIED
	      em           CDATA #IMPLIED
	      ep           CDATA #IMPLIED
	      v            (raw|final|derived-incr|derived) "raw"
	      t            (inclusive|exclusive|nil) "nil"
	      partner      CDATA #IMPLIED
	      fmt          CDATA #IMPLIED
	      show         (1|0|2|3|4) "1"
	      show-percent (1|0) "1">

    <!-- MetricFormula represents derived metrics: (t)ype; (frm): formula -->
    <!ELEMENT MetricFormula (Info?)>
    <!ATTLIST MetricFormula
	      t   (combine|finalize|view) "finalize"
	      i   CDATA #IMPLIED
	      frm CDATA #REQUIRED>

    <!-- Metric data, used in sections: (n)ame [from Metric]; (v)alue -->
    <!ELEMENT M EMPTY>
    <!ATTLIST M
	      n CDATA #REQUIRED
	      v CDATA #REQUIRED>

    <!-- MetricDBTable: -->
    <!ELEMENT MetricDBTable (MetricDB)*>

    <!-- MetricDB: (i)d; (n)ame -->
    <!--   (t)ype: persistent type of metric -->
    <!--   db-glob:        file glob describing files in metric db -->
    <!--   db-id:          id within metric db -->
    <!--   db-num-metrics: number of metrics in db -->
    <!--   db-header-sz:   size (in bytes) of a db file header -->
    <!ELEMENT MetricDB EMPTY>
    <!ATTLIST MetricDB
	      i              CDATA #REQUIRED
	      n              CDATA #REQUIRED
	      t              (inclusive|exclusive|nil) "nil"
	      partner        CDATA #IMPLIED
	      db-glob        CDATA #IMPLIED
	      db-id          CDATA #IMPLIED
	      db-num-metrics CDATA #IMPLIED
	      db-header-sz   CDATA #IMPLIED>

    <!-- TraceDBTable: -->
    <!ELEMENT TraceDBTable (TraceDB)>

    <!-- TraceDB: (i)d -->
    <!--   u: unit time of the trace (ms, ns, ..) -->
    <!--   db-min-time: min beginning time stamp (global) -->
    <!--   db-max-time: max ending time stamp (global) -->
    <!ELEMENT TraceDB EMPTY>
    <!ATTLIST TraceDB
	      i            CDATA #REQUIRED
	      u            CDATA #IMPLIED
	      db-glob      CDATA #IMPLIED
	      db-min-time  CDATA #IMPLIED
	      db-max-time  CDATA #IMPLIED
	      db-header-sz CDATA #IMPLIED>

    <!-- LoadModuleTable assigns a short name to a load module -->
    <!ELEMENT LoadModuleTable (LoadModule)*>

    <!ELEMENT LoadModule (Info?)>
    <!ATTLIST LoadModule
	      i CDATA #REQUIRED
	      n CDATA #REQUIRED>

    <!-- FileTable assigns a short name to a file -->
    <!ELEMENT FileTable (File)*>

    <!ELEMENT File (Info?)>
    <!ATTLIST File
	      i CDATA #REQUIRED
	      n CDATA #REQUIRED>

    <!-- ProcedureTable assigns a short name to a procedure -->
    <!ELEMENT ProcedureTable (Procedure)*>

    <!-- Dictionary for procedure: (i)d, (n)ame, (f)eature and (v)alue of the address -->
    <!-- Possible value of f: -->
    <!-- 0: normal procedure -->
    <!-- 1: place holder, do not add anything -->
    <!-- 2: root-type, has to be shown in a separate view -->
    <!-- 3: invisible in hpcviewer, but visible in hpctraceviewer  -->
    <!ELEMENT Procedure (Info?)>
    <!ATTLIST Procedure
	      i CDATA #REQUIRED
	      n CDATA #REQUIRED
	      f CDATA #IMPLIED
	      v CDATA #IMPLIED>

  <!-- ****************************************************************** -->
  <!-- Section: Call path profile					  -->
  <!-- ****************************************************************** -->
  <!ELEMENT SecCallPathProfile (SecHeader, SecCallPathProfileData)>
  <!ATTLIST SecCallPathProfile
	    i CDATA #REQUIRED
	    n CDATA #REQUIRED>

    <!ELEMENT SecCallPathProfileData (PF|M)*>
      <!-- Procedure frame -->
      <!--   (i)d: unique identifier for cross referencing -->
      <!--   (s)tatic scope id -->
      <!--   (n)ame: a string or an id in ProcedureTable -->
      <!--   (lm) load module: a string or an id in LoadModuleTable -->
      <!--   (f)ile name: a string or an id in LoadModuleTable -->
      <!--   (l)ine range: "beg-end" (inclusive range) -->
      <!--   (a)lien: whether frame is alien to enclosing P -->
      <!--   (str)uct: hpcstruct node id -->
      <!--   (v)ma-range-set: "{[beg-end), [beg-end)...}" -->
      <!ELEMENT PF (PF|Pr|L|C|S|M)*>
      <!ATTLIST PF
		i  CDATA #IMPLIED
		s  CDATA #IMPLIED
		n  CDATA #REQUIRED
		lm CDATA #IMPLIED
		f  CDATA #IMPLIED
		l  CDATA #IMPLIED
		str  CDATA #IMPLIED
		v  CDATA #IMPLIED>
      <!-- Procedure (static): GOAL: replace with 'P' -->
      <!ELEMENT Pr (Pr|L|C|S|M)*>
      <!ATTLIST Pr
                i  CDATA #IMPLIED
		s  CDATA #IMPLIED
                n  CDATA #REQUIRED
		lm CDATA #IMPLIED
		f  CDATA #IMPLIED
                l  CDATA #IMPLIED
		a  (1|0) "0"
		str  CDATA #IMPLIED
		v  CDATA #IMPLIED>
      <!-- Callsite (a special StatementRange) -->
      <!ELEMENT C (PF|M)*>
      <!ATTLIST C
		i CDATA #IMPLIED
		s CDATA #IMPLIED
		l CDATA #IMPLIED
		str CDATA #IMPLIED
		v CDATA #IMPLIED>

  <!-- ****************************************************************** -->
  <!-- Section: Flat profile						  -->
  <!-- ****************************************************************** -->
  <!ELEMENT SecFlatProfile (SecHeader, SecFlatProfileData)>
  <!ATTLIST SecFlatProfile
	    i CDATA #REQUIRED
	    n CDATA #REQUIRED>

    <!ELEMENT SecFlatProfileData (LM|M)*>
      <!-- Load module: (i)d; (n)ame; (v)ma-range-set -->
      <!ELEMENT LM (F|P|M)*>
      <!ATTLIST LM
                i CDATA #IMPLIED
                n CDATA #REQUIRED
		v CDATA #IMPLIED>
      <!-- File -->
      <!ELEMENT F (P|L|S|M)*>
      <!ATTLIST F
                i CDATA #IMPLIED
                n CDATA #REQUIRED>
      <!-- Procedure (Note 1) -->
      <!ELEMENT P (P|A|L|S|C|M)*>
      <!ATTLIST P
                i CDATA #IMPLIED
                n CDATA #REQUIRED
                l CDATA #IMPLIED
		str CDATA #IMPLIED
		v CDATA #IMPLIED>
      <!-- Alien (Note 1) -->
      <!ELEMENT A (A|L|S|C|M)*>
      <!ATTLIST A
                i CDATA #IMPLIED
                f CDATA #IMPLIED
                n CDATA #IMPLIED
                l CDATA #IMPLIED
		str CDATA #IMPLIED
		v CDATA #IMPLIED>
      <!-- Loop (Note 1,2) -->
      <!ELEMENT L (A|Pr|L|S|C|M)*>
      <!ATTLIST L
		i CDATA #IMPLIED
		s CDATA #IMPLIED
		l CDATA #IMPLIED
	        f CDATA #IMPLIED
		str CDATA #IMPLIED
		v CDATA #IMPLIED>
      <!-- Statement (Note 2) -->
      <!--   (it): trace record identifier -->
      <!ELEMENT S (S|M)*>
      <!ATTLIST S
		i  CDATA #IMPLIED
		it CDATA #IMPLIED
		s  CDATA #IMPLIED
		l  CDATA #IMPLIED
		str  CDATA #IMPLIED
		v  CDATA #IMPLIED>
      <!-- Note 1: Contained Cs may not contain PFs -->
      <!-- Note 2: The 's' attribute is not used for flat profiles -->
