Forum Discussion
Altera_Forum
Honored Contributor
15 years agoWhen you create a global variable used by the accelerated function C2H will create a master to access that value. Just like any other multi-core design, sharing data via global variables can be tricky. There are some corner cases of global variables that are documented that you should refer to in the C2H documentation.
If you are passing in a 2D set of data I recommend just passing in a pointer to the base address of this data and the row and column dimensions of this data as function parameters. I have a hunch that the issues you are running into are due to the fact that this accelerator is essentially it's own stand alone core, which has it's own view of the memory, without knowing what is cached by the Nios II processor, etc.... Basically treat the accelerator like it's a separate DMA engine and all the precautions that you would take with a DMA engine apply to a C2H accelerator as well. By the sounds of what you are doing, if your algorithm can handle multiple packets in flight you should take a look at the user guide in the section where it talks about adding interrupts. There are pragmas that you can add to make the accelerator non-blocking so if you can devise a scheme that you keep shoveling data at the accelerator you can eliminate any overhead of calling it multiple times. By doing this change you can make the accelerator behave even more like a dedicate hand coded accelerator and hide any overhead associated to offloading software into hardware.