简体   繁体   English

使用C ++中的线程的FPGA使FAST DMA受益

[英]FAST DMA benefit from FPGA using threads in C++

I am transferring data from FPGA PCIe thru DMA, which is very fast. 我正在通过DMA从FPGA PCIe传输数据,速度非常快。 I have 500 data with each data comprise of 80000 BYTES. 我有500个数据,每个数据包含80000个字节。 Hence the time for all 500 data receiving and saving in .bin file is 0.5 seconds. 因此,所有500个数据在.bin文件中的接收和保存时间为0.5秒。 If I do the same in .txt file (which is my final goal) it takes 15 seconds. 如果我在.txt文件中做同样的事情(这是我的最终目标),则需要15秒。

Hence Now what I want is to use threads in c++, where 1 thread (I call it as master thread) take DMA data(single data at a time) and simultaneously open the 500 other threads (one for each file) each file saving thread wait for some trigger event etc. (not much idea, since CPU inherently runs in sequential manner, causing problem for an FPGA designer who deals in parallel domain) 因此,现在我想要的是在c ++中使用线程,其中1个线程(我称其为主线程)获取DMA数据(一次为单个数据),并同时打开500个其他线程(每个文件一个),每个文件保存线程等待一些触发事件等。(没什么主意,因为CPU本质上是按顺序运行的,这给处理并行域的FPGA设计人员带来了麻烦)

Please see the case I have explained could be the solution, but I need to know how to implement it if it is correct in++ ???? 请查看我所解释的情况可能是解决方案,但如果在++中正确,我需要知道如何实现它?

case 案件

1st data(thru DMA) comes in master thread (where global memory is assigned using malloc() ) -> thread for file 1 is waiting for any TRIGGER etc. and as soon as it gets this trigger, copy the memory contents to its own allocated memory and then starts saving in the file, meanwhile it also triggers the 'master thread' to increment its counter and receive the next data and the process continues for the whole 500 data. 第一个数据(通过DMA)进入主线程(使用malloc()分配了全局内存)->文件1的线程正在等待任何TRIGGER等,并且一旦获得此触发器,就将内存内容复制到自己的内存中分配的内存,然后开始保存在文件中,与此同时,它还触发“主线程”增加其计数器并接收下一个数据,并且该过程将继续处理全部500个数据。

I am mostly and FPGA guy and c++ at this high level is first time, I am determined but am stuck. 我主要是和FPGA专家和c ++在这个高水平上的第一次,我决心但是被卡住。 really messed up for two days reading loads of material over threads (in c++) mainly starting from createthreads() and going on and on, I thought the WaitForSingleObject might be solution but I cannot understand how to implement this... 真的搞乱了两天,主要是从createthreads()开始,并且不断地读取线程上的材料负载(在c ++中),我认为WaitForSingleObject可能是解决方案,但我不知道如何实现此目的...

any idea would be appreciable. 任何想法都是可取的。 I do not seek any code, I just seek the way to implement. 我不寻求任何代码,我只是寻求实现方式。 For example those familiar with VHDL, they might know in VHDL we can use 例如,那些熟悉VHDL的人可能会知道在VHDL中我们可以使用

Code: wait until abc'event and abc = '1'; 代码: wait until abc'event and abc = '1';

but what to do here? 但是在这里做什么?

Thanks sraza 谢谢sraza

The performance measurement you give show that the problem has nothing to do with DMA or threads. 您提供的性能评估表明该问题与DMA或线程无关。 What's slow is converting from binary to string data. 缓慢的是从二进制数据转换为字符串数据。

Not surprising, since C++ iostreams are miserably slow and even the C stdio functions are significantly suboptimal 不足为奇,因为C ++ iostream的运行速度非常慢甚至C stdio函数的运行效果也不理想

Use an optimized function for number->string conversion, and your 15 second time for writing a text file will get a lot closer to that 0.5 second time you have for binary. 使用优化的函数进行数字->字符串转换,您编写文本文件的15秒时间与二进制文件的0.5秒时间相差很远。 I'd expect 1.0 seconds or less, from this single change. 我希望此更改不会超过1.0秒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM