[vsipl++] CFAR Benchmark cleanup

Jules Bergmann jules at codesourcery.com
Fri Jun 16 03:12:46 UTC 2006


Don McCoy wrote:
> The attached patch reorganizes the CFAR benchmark.  It now resembles the 
> FIR Bank benchmark in that it has more than one algorithm for processing 
> the data sets.  They now both use a similar structure.
> 
> There are enough changes to make a fairly complex diff, so I'm also 
> including the source file which should be somewhat easier to read and 
> review.
> 

Don,

This looks good.  I have one comment below, the temporary 'strip' in 
ImplHybrid should be created outside of cfar_detect.  Once that is 
fixed, please check it in.

				thanks,
				-- Jules

> 
> template <typename T>
> struct t_cfar_base<T, ImplHybrid>
> {
>   char* what() { return "t_cfar_sweep_range<T, ImplHybrid>"; }
> 
>   template <typename Block>
>   void
>   cfar_detect(
>     Tensor<T, Block>    cube,
>     Tensor<T, Block> /* cpow */,
>     Matrix<Index<2> >   located,
>     Vector<length_type> count)
>   {
>     length_type const c = cfar_gates_;
>     length_type const g = guard_cells_;
>     length_type const beams = cube.size(0);
>     length_type const dbins = cube.size(1);
>     length_type const gates = cube.size(2);
> 
>     // Clear counts for targets found per gate.
>     count = 0;
> 
>     Vector<v4sf> strip(gates);

Oops, I left a surprise for you here!

'strip' should be allocated outside of cfar_detect, similar to cpow.

Unfortunately, passing an additional parameter breaks the interface 
consistency with ImplSlice and ImplVector.


Here's an idea:

In t_cfar_base, create a typedef for the temporary view (cpow for 
ImplSlice and ImplVector, slice for ImplHybrid), and a function to 
initialize it.  operator() can use these to create the right temporary.

I.e. for t_cfar_base<T, ImplHybrid> you might have:

   typedef Vector<v4sf> temp_view;

   temp_view create_temp_view(length_type /*beams*/,
                              length_type /*dbins*/,
                              length_type gates)
   {
     return temp_view(gates);
   }





> 
>   void operator()(length_type size, length_type loop, float& time)
>   {
>     length_type beams = this->beams_;
>     length_type dbins = this->dbins_;
>     length_type gates = size;
> 
>     // The number of range gates must be sufficiently greater than the sum
>     // of CFAR gates and guard cells.  If not, the radar signal processing 
>     // parameters are flawed!
>     test_assert( 2 * (this->cfar_gates_ + this->guard_cells_) < gates );
>     
>     // Create a "root" view for initialization.  Only the first processor
>     // will access the data.
>     root_view_type root(beams, dbins, gates);
>     initialize_cube(root);
> 
>     // Create a (possibly distributed) view for computation.  Also create a 
>     // temporary cube with an identical map to hold squared values.
> #if PARALLEL_CFAR
>     typedef Map<Block_dist, Block_dist, Whole_dist>  map_type;
>     typedef Dense<3, T, OrderT, map_type>            block_type;
>     typedef Tensor<T, block_type>                    view_type;
>     typedef typename view_type::local_type           local_type;
> 
>     processor_type np = num_processors();
>     map_type map = map_type(Block_dist(np), Block_dist(1), Whole_dist());
> 
>     view_type dist_cube(beams, dbins, gates, map);
>     view_type dist_cpow(beams, dbins, gates, map);

'temp' replaces cpow:

	t_cfar_base<...>::temp_view temp(
	   t_cfar_base<...>::create_temp_view(beams, dbins, gates));
> 
>     dist_cube = root;
> 
>     local_type cube = dist_cube.local();
>     local_type cpow = dist_cpow.local();
> #else
>     typedef Dense<3, T, OrderT>     block_type;
>     typedef Tensor<T, block_type>   view_type;
>     typedef view_type local_type;
> 
>     view_type& cube = root;
>     view_type cpow(beams, dbins, gates);
> #endif
> 
> 
>     // Create a place to store the locations of targets that are found
>     Matrix<Index<2> > located(gates, this->ntargets_, Index<2>());
>     Vector<length_type> count(gates);
>     
>     // Process the data cube and time it
>     vsip::impl::profile::Timer t1;
>     t1.start();
>     for (index_type l=0; l<loop; ++l)
>     {
>       cfar_detect(cube, cpow, located, count);

	cfar_detect(cube, temp, located, count);

>     }
>     t1.stop();
>     time = t1.delta();
> 
>     // Verify targets detected
>     cfar_verify(cube, located, count);
>   }
> 
> 
>   t_cfar_sweep_range(length_type beams, length_type bins,
>                  length_type cfar_gates, length_type guard_cells)
>    : t_cfar_base<T, ImplTag>(beams, bins, cfar_gates, guard_cells)
>   {}
> };
> 
> 


-- 
Jules Bergmann
CodeSourcery
jules at codesourcery.com
(650) 331-3385 x705



More information about the vsipl++ mailing list