cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bangbang0344
Visitor
Visitor
1,107 Views
Registered: ‎09-18-2017

the hardware function hangs when using data copy

Jump to solution

My simple hardware function hangs when using data copy. 

 

Here is my code

/**************  hardware function  *************************/

#pragma SDS data mem_attribute(m_iimgBufOffset:NON_CACHEABLE | PHYSICAL_CONTIGUOUS)
#pragma SDS data access_pattern(m_iimgBufOffset:SEQUENTIAL)
#pragma SDS data copy(m_iimgBufOffset[0:152 * 4*4])
#pragma SDS data data_mover(m_iimgBufOffset:AXIDMA_SIMPLE)
int my_function(int* dst)
{
    int i = 0;
    int sum = dst[30]+dst[40]+dst[0] + dst[20];
    if(sum >1000)
    i = 1;
    return i;
}

 

 

 

/********************** call  function  *************************/
int* val = (int*)sds_alloc_non_cacheable(sizeof(int)*152*4 * 4);
for(int i = 0; i< 152*4 * 4; i++){
      val[i] = i;
}
std::cout<<"start my_function"<<std::endl;
my_function(val);
std::cout<<"finish my_function"<<std::endl;
sds_free(val);

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
skalicky
Explorer
Explorer
1,350 Views
Registered: ‎09-19-2017
Hi bangbang,

You have a couple of problems here.

1. Your function is called "my_function" and has an argument called "dst" but your data copy pragma refers to an argument named "m_iimgBufOffset". So that pragma will not get applied when you do a build. There should be a warning about that argument not existing.

2. Please realize that in your data copy pragma you're asking SDSoC to transfer 152 * 4*4 = 2432 elements from the PS (software) to the PL (hardware). SDSoC does this by creating a data mover (DMA) which has an AXI Stream output to your accelerator. Then in your function you only consume elements dst[30]+dst[40]+dst[0] + dst[20]. You must consume all elements in your accelerator that you asked SDSoC to transfer when you use the access_pattern(m_iimgBufOffset:SEQUENTIAL) pragma. If you want a BRAM (which will use more resources), the use RANDOM instead of SEQUENTIAL.

View solution in original post

0 Kudos
1 Reply
skalicky
Explorer
Explorer
1,351 Views
Registered: ‎09-19-2017
Hi bangbang,

You have a couple of problems here.

1. Your function is called "my_function" and has an argument called "dst" but your data copy pragma refers to an argument named "m_iimgBufOffset". So that pragma will not get applied when you do a build. There should be a warning about that argument not existing.

2. Please realize that in your data copy pragma you're asking SDSoC to transfer 152 * 4*4 = 2432 elements from the PS (software) to the PL (hardware). SDSoC does this by creating a data mover (DMA) which has an AXI Stream output to your accelerator. Then in your function you only consume elements dst[30]+dst[40]+dst[0] + dst[20]. You must consume all elements in your accelerator that you asked SDSoC to transfer when you use the access_pattern(m_iimgBufOffset:SEQUENTIAL) pragma. If you want a BRAM (which will use more resources), the use RANDOM instead of SEQUENTIAL.

View solution in original post

0 Kudos