<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to improve PCIe PIO Read Performance in Software Tuning, Performance Optimization &amp; Platform Monitoring</title>
    <link>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1242374#M7761</link>
    <description>&lt;P&gt;Thanks John for your explanation. I will try WC and&amp;nbsp;&lt;SPAN&gt;MOVNTDQA instruction to see the performance there.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;By the way let me to give more details on problem.&amp;nbsp;I'm trying to handle data stream from FPGA to CPU, since latency is more important than bandwidth, decided to use PIO for directly accessing data instead of spending time on writing DMA descriptors and handling interrupts. CPU polling specific addresses on MMAP BAR and trying to get next available data in sequential order to handle stream operation.&amp;nbsp;All cache related speculative reads will grab the data from (BAR) FIFO and CPU will needs to invalidate cache after consuming it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Till it is clear what to do but it seems risky for maintaining coherence for MMAPIO. Do you have any other suggestion to keep latency low?&lt;/P&gt;</description>
    <pubDate>Thu, 31 Dec 2020 11:07:55 GMT</pubDate>
    <dc:creator>ACL</dc:creator>
    <dc:date>2020-12-31T11:07:55Z</dc:date>
    <item>
      <title>How to improve PCIe PIO Read Performance</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1241204#M7758</link>
      <description>&lt;P&gt;Hİ All,&lt;/P&gt;
&lt;P&gt;I'm working on developing user space pcie driver for xilinx fpga ip core on linux.&lt;/P&gt;
&lt;P&gt;Mapping BAR0 register in kernel driver like below;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;mmio_start = pci_resource_start(pdev, 0);
mmio_len = pci_resource_len(pdev, 0);
iomemm = ioremap_nocache(mmio_start, mmio_len);&lt;/LI-CODE&gt;
&lt;P&gt;and accessing it via mmap through user space.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;fd = open(filename, O_RDWR | O_SYNC))
map_base = mmap(0, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target_base);

clock_gettime(CLOCK_REALTIME, &amp;amp;start);
read_result = *((uint64_t *) virt_addr);
clock_gettime(CLOCK_REALTIME, &amp;amp;end);
diff = 1000000000L * (end.tv_sec - start.tv_sec) + end.tv_nsec - start.tv_nsec;

&lt;/LI-CODE&gt;
&lt;P&gt;When I measure the 64 bit read latency it is always bigger than 2us,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;clock_gettime(CLOCK_REALTIME, &amp;amp;start);
memread = _mm_stream_load_si128((__m128i *) virt_addr);
clock_gettime(CLOCK_REALTIME, &amp;amp;end);
diff = 1000000000L * (end.tv_sec - start.tv_sec) + end.tv_nsec - start.tv_nsec;&lt;/LI-CODE&gt;
&lt;P&gt;When I used&amp;nbsp;Intrinsics (_mm_stream_load_si128) it is still like 2us.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to improve PIO read performance here, all suggestions are welcome.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 12:08:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1241204#M7758</guid>
      <dc:creator>ACL</dc:creator>
      <dc:date>2020-12-28T12:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve PCIe PIO Read Performance</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1241240#M7759</link>
      <description>&lt;P&gt;Additional System Info;&lt;/P&gt;
&lt;P&gt;CPU -&amp;gt; Intel(R) Xeon(R) CPU E3-1240 v3 @ 3.40GHz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt; $ lspci -vvv&lt;/P&gt;
&lt;P&gt;05:00.0 Ethernet controller: Silicom Denmark Device 0001&lt;BR /&gt;Subsystem: Silicom Denmark Device 0001&lt;BR /&gt;Physical Slot: 4&lt;BR /&gt;Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-&lt;BR /&gt;Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast &amp;gt;TAbort- &amp;lt;TAbort- &amp;lt;MAbort- &amp;gt;SERR+ &amp;lt;PERR- INTx-&lt;BR /&gt;Latency: 0, Cache Line Size: 64 bytes&lt;BR /&gt;Interrupt: pin A routed to IRQ 16&lt;BR /&gt;Region 0: Memory at f7100000 (64-bit, non-prefetchable) [size=128K]&lt;BR /&gt;Capabilities: [40] Power Management version 3&lt;BR /&gt;Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold-)&lt;BR /&gt;Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-&lt;BR /&gt;Capabilities: [48] MSI: Enable- Count=1/1 Maskable- 64bit+&lt;BR /&gt;Address: 0000000000000000 Data: 0000&lt;BR /&gt;Capabilities: [70] Express (v2) Endpoint, MSI 00&lt;BR /&gt;DevCap: MaxPayload 1024 bytes, PhantFunc 0, Latency L0s &amp;lt;64ns, L1 &amp;lt;1us&lt;BR /&gt;ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 25.000W&lt;BR /&gt;DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-&lt;BR /&gt;RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+&lt;BR /&gt;MaxPayload 128 bytes, MaxReadReq 512 bytes&lt;BR /&gt;DevSta: CorrErr+ UncorrErr+ FatalErr- UnsuppReq+ AuxPwr- TransPend-&lt;BR /&gt;LnkCap: Port #0, Speed 8GT/s, Width x16, ASPM not supported, Exit Latency L0s unlimited, L1 unlimited&lt;BR /&gt;ClockPM- Surprise- LLActRep- BwNot- ASPMOptComp+&lt;BR /&gt;LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- CommClk+&lt;BR /&gt;ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-&lt;BR /&gt;LnkSta: Speed 5GT/s, Width x4, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-&lt;BR /&gt;DevCap2: Completion Timeout: Range BC, TimeoutDis+, LTR-, OBFF Not Supported&lt;BR /&gt;DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled&lt;BR /&gt;LnkCtl2: Target Link Speed: 8GT/s, EnterCompliance- SpeedDis-&lt;BR /&gt;Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-&lt;BR /&gt;Compliance De-emphasis: -6dB&lt;BR /&gt;LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete-, EqualizationPhase1-&lt;BR /&gt;EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-&lt;BR /&gt;Capabilities: [100 v1] Advanced Error Reporting&lt;BR /&gt;UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-&lt;BR /&gt;UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-&lt;BR /&gt;UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-&lt;BR /&gt;CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+&lt;BR /&gt;CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+&lt;BR /&gt;AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-&lt;BR /&gt;Capabilities: [1a0 v1] Device Serial Number a3-c5-00-b8-84-49-94-80&lt;BR /&gt;Capabilities: [1c0 v1] #19&lt;BR /&gt;Kernel driver in use: fiberblaze&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 16:08:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1241240#M7759</guid>
      <dc:creator>ACL</dc:creator>
      <dc:date>2020-12-28T16:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve PCIe PIO Read Performance</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1241707#M7760</link>
      <description>&lt;P&gt;If the space has to be mapped as UC, then I don't think that there is any way to improve read performance. &amp;nbsp;The processor operates in an extremely serialized fashion in this mode in order to guarantee that no accesses are speculative and that all transactions are executed exactly once and in program order (and typically with no overlap between transactions). &amp;nbsp;There is also very likely a limit on the payload size for each transaction -- probably 32 bits or 64 bits.&lt;/P&gt;
&lt;P&gt;If you can relax the ordering to WC, this allows speculative reads, which allows concurrency and/or larger payloads. &amp;nbsp;Sometimes it is possible to get a speedup via speculation alone (though I have had trouble reproducing the benefits), but it is better to use the MOVNTDQA instruction(which was designed precisely for this case of "streaming reads" from WC-mapped space). &amp;nbsp; The best description of the details is in the MOVNTDQA instruction description in Volume 2 of the Intel Architectures Software Developers Manual.&lt;/P&gt;
&lt;P&gt;I wrote up some notes on related topics at&amp;nbsp;&lt;A href="https://sites.utexas.edu/jdm4372/2013/05/" target="_blank"&gt;https://sites.utexas.edu/jdm4372/2013/05/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 18:06:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1241707#M7760</guid>
      <dc:creator>McCalpinJohn</dc:creator>
      <dc:date>2020-12-29T18:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve PCIe PIO Read Performance</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1242374#M7761</link>
      <description>&lt;P&gt;Thanks John for your explanation. I will try WC and&amp;nbsp;&lt;SPAN&gt;MOVNTDQA instruction to see the performance there.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;By the way let me to give more details on problem.&amp;nbsp;I'm trying to handle data stream from FPGA to CPU, since latency is more important than bandwidth, decided to use PIO for directly accessing data instead of spending time on writing DMA descriptors and handling interrupts. CPU polling specific addresses on MMAP BAR and trying to get next available data in sequential order to handle stream operation.&amp;nbsp;All cache related speculative reads will grab the data from (BAR) FIFO and CPU will needs to invalidate cache after consuming it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Till it is clear what to do but it seems risky for maintaining coherence for MMAPIO. Do you have any other suggestion to keep latency low?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 11:07:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1242374#M7761</guid>
      <dc:creator>ACL</dc:creator>
      <dc:date>2020-12-31T11:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve PCIe PIO Read Performance</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1242424#M7763</link>
      <description>&lt;P&gt;This is pretty much the same approach that I put together for AMD's tightly-coupled accelerator program back in 2006-2008 (with some extensions discussed in my blog entries referenced above). &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Latency is certainly problematic if you don't have a commitment from all of the engineering teams to support a particular architecture for core-to-device communication and synchronization. &amp;nbsp;At AMD I typically worked with HyperTransport, rather than PCIe, mostly because I only had one layer of translation (from core instructions to HyperTransport interface transactions) to deal with. &amp;nbsp;Going to PCIe would require a second translation layer designed and implemented by another design team (and in a different chip at the time). &amp;nbsp; With Intel processors, transactions leaving the core+L1+L2 block generate IDI transactions on the mesh or ring interface targeting an IO block. &amp;nbsp;The IDI protocol (which stands for "Intra-Die Interconnect" or "In-Die Interface" depending on the reference) is not well documented in public, though there is enough information in the uncore performance monitoring manuals to reverse-engineer many of the features. &amp;nbsp;Unfortunately, understanding the protocol is only part of the problem -- it is often necessary to get into the guts of the &lt;EM&gt;implementation&lt;/EM&gt; to understand how to best address performance issues.&lt;/P&gt;
&lt;P&gt;When attempting to control communication on the interface between a core and an attached "device", there are lots of combinations of transaction [size, speculation, ordering] to consider, and processors typically only directly support a few of the combinations. &amp;nbsp; &amp;nbsp;The "loose" end is optimized for cache-line blocks, full speculation, limited ordering. &amp;nbsp;The "tight" end is pessimized for correctness in all of the remaining cases -- 8-32-bit accesses, no speculation, full (serialized) ordering. &amp;nbsp; In between you have WC, WT, WP memory modes which can sometimes provide a modest benefit. &amp;nbsp;Of these, only WC is widely used, and almost exclusively in device drivers. &amp;nbsp;None of them do what is really required for a tightly-coupled accelerator interface....&lt;/P&gt;
&lt;P&gt;The problem is fundamentally an architectural one. &amp;nbsp;The architecture of almost all current processors is the result of decades of "hacks" on the single-core, flat-memory architecture of the first microprocessors. &amp;nbsp;Despite the many cores on a die, there is no explicit architectural support for communication. &amp;nbsp;Instead, the architecture specifies a set of "ordering rules" that allow communication to occur as a side-effect of ordered memory writes. &amp;nbsp;If we want communication and synchronization to be fast (for both cores and devices), the architecture must contain specific communication functions that are distinct from cache-coherent memory functions, so that the hardware can provide optimized implementations for these very different use cases.&lt;/P&gt;
&lt;P&gt;Manually-maintained cache coherence can be tricky. &amp;nbsp; Accesses to anything other than UC space are allowed to be speculative (past a predicted branch or prefetched based on access pattern or just randomly selected to be loaded), so side effects cannot be allowed on reads. &amp;nbsp;Speculation allows concurrency, but also allows the core to drop the data and request it again. &amp;nbsp; There is no architectural support for the kind of metadata that would allow a core to "tag" a read as being a repeat of a previous read (to suppress or undo a speculative side effect), or to allow a read response to contain a valid/invalid bit (to allow immediate response of invalid data, e.g., reading from an empty queue), or any of the myriad architectures used by hardware designers (but not accessible from the ISA). &amp;nbsp;For cached MMIO (using the WT or WP memory types), the core can always perform a "flush after use" on cache line. &amp;nbsp;For streaming loads from WC space, it may take some experimentation to find a way to ensure that stale data does not stay in the core's read buffer after the device has modified the target line. &amp;nbsp;The description of the MOVNTDQA instruction gives some clues, but these are typically not definitive. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck with your project. &amp;nbsp;It seems like you are on the right track, but don't be surprised if something occasionally does not work for inexplicable reasons. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 17:28:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1242424#M7763</guid>
      <dc:creator>McCalpinJohn</dc:creator>
      <dc:date>2020-12-31T17:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve PCIe PIO Read Performance</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1242428#M7764</link>
      <description>&lt;P&gt;Thanks a lot for your guidance John. I will try to keep you updated with the progress.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 17:44:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1242428#M7764</guid>
      <dc:creator>ACL</dc:creator>
      <dc:date>2020-12-31T17:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve PCIe PIO Read Performance</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1251267#M7791</link>
      <description>&lt;P&gt;Hi John,&lt;/P&gt;
&lt;P&gt;With PCIe Gen 2 and 4X Lane configuration with link speed 5GTs. I used movntdqa from sse2 intruction set with WC memory type. It allows me to read in 64B chunks.&amp;nbsp;Single 64B read still took 1us. It improves&amp;nbsp; performance by factor 8 when you compare with UC. But still the read TLPs goes in serialized fashion way like UC memory. Not able to create speculative read to initiate concurrency on WC.&lt;/P&gt;
&lt;P&gt;I tried to crate multiple reader threads on different cores but still no concurrency on pcie read TLP. When listen read operations from the CPU, I saw that cores not able to initiate multiple read request to the bus. Only one read TLP at a time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm curious about if I'm doing smth wrong since WC memory type says allowing speculative reads. Do you have any idea regarding this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2021 10:45:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1251267#M7791</guid>
      <dc:creator>ACL</dc:creator>
      <dc:date>2021-01-29T10:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to improve PCIe PIO Read Performance</title>
      <link>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1251372#M7792</link>
      <description>&lt;P&gt;This is not really surprising -- "allowing" speculation does not mean that an implementation will actually &lt;EM&gt;perform&amp;nbsp;&lt;/EM&gt;the speculation. &amp;nbsp; Some implementations might speculate and other implementations might not. &amp;nbsp;Similarly, Intel's description of MOVNTDQA "allows" multiple 64-Byte buffers but does not mandate them.&lt;/P&gt;
&lt;P&gt;(I recall a case in which a processor was &lt;EM&gt;intended&lt;/EM&gt; to support concurrent cache line transfers from MMIO space, but for which bug-fix microcode updates reduced the maximum concurrency to a single transfer. &amp;nbsp;In another case, the processor supported a maximum of two concurrent cache line transfers from MMIO space (mapped WT or WP), with no documentation on the reason for the limit.)&lt;/P&gt;
&lt;P&gt;The limitation of read concurrency with the WC memory type is the reason I developed a double-mapped approach. &amp;nbsp;Device memory is mapped into system space twice -- once for read accesses (mapped WP or WT) and once for write accesses (mapped WC). &amp;nbsp;Coherence has to be handled explicitly. &amp;nbsp;This is discussed in two blog posts:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://sites.utexas.edu/jdm4372/2013/05/29/notes-on-cached-access-to-memory-mapped-io-regions/" target="_blank"&gt;Notes on Cached Access to Memory-Mapped IO Regions&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://sites.utexas.edu/jdm4372/2013/05/30/coherence-with-cached-memory-mapped-io/" target="_blank"&gt;Coherence with Cached Memory-Mapped IO&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 29 Jan 2021 17:48:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Tuning-Performance/How-to-improve-PCIe-PIO-Read-Performance/m-p/1251372#M7792</guid>
      <dc:creator>McCalpinJohn</dc:creator>
      <dc:date>2021-01-29T17:48:14Z</dc:date>
    </item>
  </channel>
</rss>

