<?xml version="1.0" encoding="UTF-8"?>
<bag xmlns:boolean="http://www.w3.org/2001/XMLSchema#boolean" xmlns:exsl="http://exslt.org/common" xmlns:int="http://www.w3.org/2001/XMLSchema#int" xmlns:str="http://exslt.org/strings" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <internal>
  <name>%MemoryAccessAtypeName</name>
  <shortName>%MemoryAccesAtypeShortName</shortName>
  <description>%MemoryAccesAtypeDescription</description>
  <shortDescription>%MemoryAccessAtypeShortDescription</shortDescription>
  <abbreviation>macc</abbreviation>
  <alias>memory-access</alias>
  <int:schemaVersion>1</int:schemaVersion>
  <int:contentVersion>1</int:contentVersion>
  <iconClass>analysis-memory-access solid</iconClass>
  <property name="helpId">configs.memory_access_f1208</property>
 </internal>
 <prerequisites xsl:version="1.0" str:keep_str_namespace="" exsl:keep_exsl_namespace="" syntax="norules">
  <xsl:if test="contains(exsl:ctx('androidBoardPlatform', ''), 'sofia')">
   <xsl:value-of select="exsl:error('%ThisAnalysisTypeIsNotApplicable')"/>
  </xsl:if>
  <xsl:copy-of select="document('config://analysis_type/include/require_connection.xsl?connections=group_generic')"/>
 </prerequisites>
 <knobs xsl:version="1.0" exsl:keep_exsl_namespace="" syntax="norules">
  <xsl:choose>
   <xsl:when test="(exsl:ctx('PMU') = 'core2') or (exsl:ctx('PMU') = 'core2p')">
    <stringKnob id="initialViewpoint" displayName="%InitialViewpoint" boolean:visible="false">
     <defaultValue>%PMUEventsViewpointName</defaultValue>
    </stringKnob>
   </xsl:when>
   <xsl:when test="(exsl:ctx('PMU') = 'corei7b')">
    <stringKnob id="initialViewpoint" displayName="%InitialViewpoint" boolean:visible="false">
     <defaultValue>%WSMEXBandwidthViewpointName</defaultValue>
    </stringKnob>
   </xsl:when>
   <xsl:otherwise>
    <stringKnob id="initialViewpoint" displayName="%InitialViewpoint" boolean:visible="false">
     <defaultValue>%SNBBandwidthViewpointName</defaultValue>
    </stringKnob>
   </xsl:otherwise>
  </xsl:choose>
  <xsl:variable name="knobsParams">
   <params collectMemoryBandwidthSwitchCheck="false"/>
  </xsl:variable>
  <xsl:variable name="knobsParamsName">
   <xsl:text>config://analysis_type/include/knobs.xsl?</xsl:text>
   <xsl:for-each select="exsl:node-set($knobsParams)//@*">
    <xsl:value-of select="concat(name(), '=', .)"/>
    <xsl:text>&amp;</xsl:text>
   </xsl:for-each>
  </xsl:variable>
  <xsl:variable name="commonKnobs" select="document($knobsParamsName)"/>
  <xsl:copy-of select="$commonKnobs//knobs/doubleKnob[@id='samplingInterval']"/>
  <booleanKnob id="analyzeMemoryObjects" displayName="%AnalyzeMemoryObjects" boolean:visible="false" cliName="analyze-mem-objects">
   <xsl:if test="exsl:ctx('targetOS')='Linux' and exsl:ctx('PMU') != 'knc' and exsl:ctx('PMU') != 'core2' and                     exsl:ctx('PMU') != 'core2p' and exsl:ctx('PMU') != 'corei7b' and exsl:ctx('PMU') != 'silvermont' and                     exsl:ctx('PMU') != 'tangier' and exsl:ctx('PMU') != 'avoton' and exsl:ctx('PMU') != 'airmont'">
    <xsl:attribute name="boolean:visible">true</xsl:attribute>
   </xsl:if>
   <boolean:defaultValue>false</boolean:defaultValue>
   <description>%AnalyzeMemoryObjectsDescription</description>
  </booleanKnob>
  <intKnob id="memoryObjectMinSize" displayName="%MemoryObjectMinSize" boolean:visible="false" cliName="mem-object-size-min-thres">
   <xsl:if test="exsl:ctx('targetOS')='Linux' and exsl:ctx('PMU') != 'knc' and exsl:ctx('PMU') != 'core2' and exsl:ctx('PMU') != 'core2p' and                     exsl:ctx('PMU') != 'corei7b' and exsl:ctx('PMU') != 'silvermont' and exsl:ctx('PMU') != 'tangier' and                     exsl:ctx('PMU') != 'avoton' and exsl:ctx('PMU') != 'airmont'">
    <xsl:attribute name="boolean:visible">true</xsl:attribute>
   </xsl:if>
   <description>%MemoryObjectMinSizeDescription</description>
   <int:minValue>1</int:minValue>
   <int:defaultValue>1024</int:defaultValue>
  </intKnob>
  <xsl:copy-of select="$commonKnobs//knobs/booleanKnob[@id='dramBandwidthLimitsAT']"/>
  <booleanKnob id="enableMemoryObjectGrouper" displayName="%EnableMemoryObjectGrouper" boolean:visible="false" cliName="enable-mem-object-grouper">
   <boolean:defaultValue>false</boolean:defaultValue>
  </booleanKnob>
  <xsl:copy-of select="$commonKnobs//knobs/booleanKnob[@id='analyzeCAT']"/>
  <xsl:copy-of select="$commonKnobs//knobs/booleanKnob[@id='analyzeCacheOccupancy']"/>
  <xsl:copy-of select="$commonKnobs//knobs/booleanKnob[@id='analyzeL3ExternalBW']"/>
  <xsl:copy-of select="$commonKnobs//knobs/booleanKnob[@id='analyzeOpenMPRegions']"/>
 </knobs>
 <analysis xsl:version="1.0" exsl:keep_exsl_namespace="" str:keep_str_namespace="" syntax="norules">
  <xsl:copy-of select="document('config://analysis_type/include/prerequisites.xsl')/pmu_prerequisites/*"/>
  <xsl:if test="       exsl:ctx('PMU') = 'core2'         or exsl:ctx('PMU') = 'core2p'         or exsl:ctx('PMU') = 'corei7'         or exsl:ctx('PMU') = 'corei7wsp'         or exsl:ctx('PMU') = 'corei7wdp'         or exsl:ctx('PMU') = 'corei7b'         or exsl:ctx('PMU') = 'atom'         or exsl:ctx('PMU') = 'lakemont'       ">
   <xsl:value-of select="exsl:error('%ThisAnalysisTypeIsNotApplicable')"/>
  </xsl:if>
  <xsl:if test="not(exsl:ctx('Hypervisor', 'None') = 'None' or (exsl:ctx('Hypervisor', 'None') = 'Microsoft Hv' and exsl:ctx('HypervisorType', 'None') = 'Hyper-V'))">
   <xsl:value-of select="exsl:error('%MemoryAccessNotSupportedOnVM')"/>
  </xsl:if>
  <xsl:if test="exsl:ctx('PerfmonVersion', '4') = '0'">
   <xsl:value-of select="exsl:error('%PerfMonVersionWarning')"/>
  </xsl:if>
  <xsl:variable name="events" select="document('config://analysis_type/include/common_events.xsl')"/>
  <xsl:variable name="MainEvents" select="$events//events/cpi"/>
  <xsl:variable name="MemAccessEvents" select="$events//events/memAccess"/>
  <xsl:variable name="pmuCommon" select="document('config://include/pmu_common.xsl')"/>
  <xsl:variable name="tmamEventsFile" select="$pmuCommon//variables/tmamEventsFile"/>
  <xsl:variable name="isBandwidthAvailable" select="$pmuCommon//variables/isDRAMBWAvailable"/>
  <xsl:variable name="isInterSocketBandwidthAvailable" select="$pmuCommon//variables/isInterSocketBWAvailable"/>
  <xsl:variable name="memBandwidthEvents" select="$pmuCommon//variables/memBandwidthEvents"/>
  <xsl:variable name="qpiBandwidthEvents" select="$pmuCommon//variables/qpiBandwidthEvents"/>
  <xsl:variable name="MetricsEvents">
   <xsl:choose>
    <xsl:when test="exsl:ctx('PMU') = 'ivybridge' or exsl:ctx('PMU') = 'ivytown' or exsl:ctx('PMU') = 'haswell' or exsl:ctx('PMU') = 'haswell_server' or exsl:ctx('PMU') = 'crystalwell' or exsl:ctx('PMU') = 'broadwell' or exsl:ctx('PMU') = 'broadwell_server' or exsl:ctx('PMU') = 'broadwell_de' or exsl:ctx('PMU') = 'skylake' or exsl:ctx('PMU') = 'skylake_server' or exsl:ctx('PMU') = 'cascadelake_server' or exsl:ctx('PMU') = 'kabylake' or exsl:ctx('PMU') = 'cannonlake' or exsl:ctx('PMU') = 'icelake' or exsl:ctx('PMU') = 'icelake_server' or exsl:ctx('PMU') = 'sapphirerapids_server' or exsl:ctx('PMU') = 'snowridge' or exsl:ctx('PMU') = 'tigerlake'">
     <xsl:variable name="baseEvents">
      <xsl:value-of select="document($tmamEventsFile)/main/Memory_Bound_Tree/BaseEvents"/>
     </xsl:variable>
     <xsl:variable name="HypervisorEvents">
      <xsl:value-of select="document($tmamEventsFile)/main/Memory_Bound_Tree/HypervisorEvents"/>
     </xsl:variable>
     <xsl:choose>
      <xsl:when test="exsl:ctx('Hypervisor', 'None') = 'None' or (exsl:ctx('Hypervisor', 'None') = 'Microsoft Hv' and exsl:ctx('HypervisorType', 'None') = 'Hyper-V')">
       <xsl:value-of select="concat($baseEvents,$HypervisorEvents)"/>
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="$baseEvents"/>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="exsl:ctx('PMU') = 'silvermont' or exsl:ctx('PMU') = 'airmont' or exsl:ctx('PMU') = 'goldmont' or exsl:ctx('PMU') = 'goldmont_plus' or exsl:ctx('PMU') = 'knl'">
     <xsl:variable name="baseEvents">
      <xsl:value-of select="document($tmamEventsFile)/main/Back_End_Bound_Tree/BaseEvents"/>
     </xsl:variable>
     <xsl:variable name="HypervisorEvents">
      <xsl:value-of select="document($tmamEventsFile)/main/Back_End_Bound_Tree/HypervisorEvents"/>
     </xsl:variable>
     <xsl:choose>
      <xsl:when test="exsl:ctx('Hypervisor', 'None') = 'None' or (exsl:ctx('Hypervisor', 'None') = 'Microsoft Hv' and exsl:ctx('HypervisorType', 'None') = 'Hyper-V')">
       <xsl:value-of select="concat($baseEvents,$HypervisorEvents)"/>
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="$baseEvents"/>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:when>
   </xsl:choose>
  </xsl:variable>
  <collector id="runsa">
   <boolean:collectorKnob knob="cpuGpuUsageData">true</boolean:collectorKnob>
   <xsl:if test="exsl:ctx('platformType', '0') = '146'">
    <xsl:value-of select="exsl:error('%UnknownPMUForAT')"/>
   </xsl:if>
   <xsl:choose>
    <xsl:when test="not($isBandwidthAvailable = 'true' and $memBandwidthEvents != '')">
     <boolean:collectorKnob knob="collectMemBandwidth">false</boolean:collectorKnob>
     <boolean:collectorKnob knob="perfForceSystemWide">true</boolean:collectorKnob>
    </xsl:when>
    <xsl:otherwise>
     <boolean:collectorKnob knob="collectMemBandwidth">true</boolean:collectorKnob>
     <boolean:collectorKnob knob="enableDramBandwidthLimitsWarning">true</boolean:collectorKnob>
     <boolean:collectorKnob knob="memoryAccessBandwidthMeasuring">true</boolean:collectorKnob>
    </xsl:otherwise>
   </xsl:choose>
   <xsl:if test="(exsl:ctx('PMU') = 'haswell' or exsl:ctx('PMU') = 'haswell_server' or exsl:ctx('PMU') = 'crystalwell') and                      (exsl:ctx('isHTEnabled', 0) or (exsl:ctx('logicalCPUCount', 1) &gt; exsl:ctx('physicalCoreCount', 1)))">
    <xsl:value-of select="exsl:warning('%HTisONAT')"/>
   </xsl:if>
   <xsl:if test="exsl:ctx('targetOS')='Linux'">
    <collectorKnob knob="collectMemObjects">
     <xsl:copy-of select="exsl:ctx('analyzeMemoryObjects', 0)"/>
    </collectorKnob>
   </xsl:if>
   <collectorKnob knob="memoryObjectMinSize">
    <xsl:copy-of select="exsl:ctx('memoryObjectMinSize', 1024)"/>
   </collectorKnob>
   <xsl:if test="exsl:ctx('PMU') != 'knl' and exsl:ctx('dramBandwidthLimitsAT', 0)">
    <collectorKnob knob="dramBandwidthLimits">true</collectorKnob>
   </xsl:if>
   <collectorKnob knob="collectCAT">
    <xsl:copy-of select="exsl:ctx('analyzeCAT', 0)"/>
   </collectorKnob>
   <collectorKnob knob="collectCacheOccupancy">
    <xsl:copy-of select="exsl:ctx('analyzeCacheOccupancy', 0)"/>
   </collectorKnob>
   <collectorKnob knob="collectL3ExternalBW">
    <xsl:copy-of select="exsl:ctx('analyzeL3ExternalBW', 0)"/>
   </collectorKnob>
   <xsl:variable name="allEvents">
    <xsl:value-of select="$MainEvents"/>
    <xsl:if test="$MemAccessEvents != ''">
     <xsl:text>,</xsl:text>
     <xsl:value-of select="$MemAccessEvents"/>
    </xsl:if>
    <xsl:if test="$MetricsEvents != ''">
     <xsl:value-of select="$MetricsEvents"/>
    </xsl:if>
    <xsl:if test="$isBandwidthAvailable = 'true' and $memBandwidthEvents != ''">
     <xsl:text>,</xsl:text>
     <xsl:value-of select="$memBandwidthEvents"/>
     <xsl:if test="$isInterSocketBandwidthAvailable = 'true' and $qpiBandwidthEvents != ''">
      <xsl:text>,</xsl:text>
      <xsl:value-of select="$qpiBandwidthEvents"/>
     </xsl:if>
    </xsl:if>
   </xsl:variable>
   <collectorKnob knob="pmuEventConfig">
    <xsl:value-of select="exsl:merge_pmu_events($allEvents)"/>
   </collectorKnob>
   <collectorKnob knob="collectOpenMPRegions">
    <xsl:value-of select="exsl:ctx('analyzeOpenMPRegions', 0)"/>
   </collectorKnob>
   <collectorKnob knob="pmuSamplingInterval">
    <xsl:value-of select="format-number(exsl:ctx('samplingInterval', 1), '#.####')"/>
   </collectorKnob>
   <boolean:collectorKnob knob="collectUserTasksEventsCountersMode">true</boolean:collectorKnob>
   <boolean:collectorKnob knob="enableMemoryObjectCorrelation">true</boolean:collectorKnob>
   <boolean:collectorKnob knob="explicitUncoreEventsConfig">true</boolean:collectorKnob>
  </collector>
 </analysis>
</bag>
