cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
e_ensafi
Explorer
Explorer
176 Views
Registered: ‎08-13-2020

Polling vs. Interrupts With PL GMIO

Jump to solution

I would like to tell a PL data moving HLS kernel connected to an AIE graph via PL GMIO that new data is available from the PS.  We can either use interrupts between the HLS kernel and the PS, or the HLS kernel can poll a memory location for a change as follows:

extern "C" void mm2s(const ap_int<128>* mem, hls::stream<ap_axis<128, 0, 0, 0>>& s)
{
  static ap_int<128> last_value = 0;
  // Caveat: we only enter this kernel at the start of a new iteration,
  // and the PS will not overwrite *mem until it has received the output
  // of the previous iteration, so we can rest assured that any previous
  // data has been consumed.
  while (mem[0] != last_value); // Treating mem[0] as a frame counter.
  // For the above to work, *mem must be volatile. Is it?
  last_value = mem[0];
  // Process new PS data in DDR memory...
}

 Is polling a bad idea in terms of power consumption?

Tags (3)
0 Kudos
Reply
1 Solution

Accepted Solutions
florentw
Moderator
Moderator
106 Views
Registered: ‎11-09-2015

HI @e_ensafi 

So accessing ap_int<N>* mem in mm2s is performing an AXI request?  I thought this would only be the case with hls::stream<ap_axis<...>>> but not with the mem pointer (you're just accusing an array of data, which should be in memory already).  

Yes you will have an AXI transaction each time you want to read new data in memory (this is the only way the HLS kernel can access the memory).

Am I wrong about this, and if so, does that mean I'm better off copying the contents of ap_int<N>* mem to a local BRAM buffer if I plan on accessing it repeatedly, not just for polling, but for any other purpose?

Well... this is a system consideration so it depends on your system. If you think you need to limit the access to the memory to the maximum then yes using a local buffer can help. But of course this will increase your resources utilisation.

But you might also have enough DDR BW to not need this.

One other consideration to take in account: this is more efficient to read burst of memory. So you might want to read multiple samples each time.

So polling one data is not efficient in 2 ways: both because you creating transaction which will take the BW and the transactions are inefficient because reading only one data


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**

View solution in original post

3 Replies
florentw
Moderator
Moderator
137 Views
Registered: ‎11-09-2015

HI @e_ensafi 

I would say that polling is a bad idea in terms of consumption and memory usage.

Because the polling means that you are constantly sending AXI request to the memory. So no only this will increase power consumption but more importantly you will use the memory bandwidth that the rest of your system might need


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Reply
e_ensafi
Explorer
Explorer
111 Views
Registered: ‎08-13-2020

@florentw So accessing ap_int<N>* mem in mm2s is performing an AXI request?  I thought this would only be the case with hls::stream<ap_axis<...>>> but not with the mem pointer (you're just accusing an array of data, which should be in memory already).  Am I wrong about this, and if so, does that mean I'm better off copying the contents of ap_int<N>* mem to a local BRAM buffer if I plan on accessing it repeatedly, not just for polling, but for any other purpose?

0 Kudos
Reply
florentw
Moderator
Moderator
107 Views
Registered: ‎11-09-2015

HI @e_ensafi 

So accessing ap_int<N>* mem in mm2s is performing an AXI request?  I thought this would only be the case with hls::stream<ap_axis<...>>> but not with the mem pointer (you're just accusing an array of data, which should be in memory already).  

Yes you will have an AXI transaction each time you want to read new data in memory (this is the only way the HLS kernel can access the memory).

Am I wrong about this, and if so, does that mean I'm better off copying the contents of ap_int<N>* mem to a local BRAM buffer if I plan on accessing it repeatedly, not just for polling, but for any other purpose?

Well... this is a system consideration so it depends on your system. If you think you need to limit the access to the memory to the maximum then yes using a local buffer can help. But of course this will increase your resources utilisation.

But you might also have enough DDR BW to not need this.

One other consideration to take in account: this is more efficient to read burst of memory. So you might want to read multiple samples each time.

So polling one data is not efficient in 2 ways: both because you creating transaction which will take the BW and the transactions are inefficient because reading only one data


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**

View solution in original post