Imported Upstream version 3.2.2
[debian/gnuradio] / gcell / apps / spu / benchmark_procs.c
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #include <gcell/gc_declare_proc.h>
23 #include <gcell/spu/gc_delay.h>
24 #include <string.h>
25
26 static void
27 benchmark_udelay(const gc_job_direct_args_t *input,
28                  gc_job_direct_args_t *output _UNUSED,
29                  const gc_job_ea_args_t *eaa _UNUSED)
30 {
31   gc_udelay(input->arg[0].u32);
32 }
33
34 GC_DECLARE_PROC(benchmark_udelay, "benchmark_udelay");
35
36
37
38 static void
39 benchmark_put_zeros(const gc_job_direct_args_t *input _UNUSED,
40                     gc_job_direct_args_t *output _UNUSED,
41                     const gc_job_ea_args_t *eaa)
42 {
43   for (unsigned int i = 0; i < eaa->nargs; i++){
44     if (eaa->arg[i].direction == GCJD_DMA_PUT)
45       memset(eaa->arg[i].ls_addr, 0, eaa->arg[i].put_size);
46   }
47 }
48
49 GC_DECLARE_PROC(benchmark_put_zeros, "benchmark_put_zeros");
50
51
52 static void
53 benchmark_copy(const gc_job_direct_args_t *input _UNUSED,
54                gc_job_direct_args_t *output,
55                const gc_job_ea_args_t *eaa)
56 {
57   if (eaa->nargs != 2
58       || eaa->arg[0].direction != GCJD_DMA_PUT
59       || eaa->arg[1].direction != GCJD_DMA_GET){
60     output->arg[0].s32 = -1;
61     return;
62   }
63
64   output->arg[0].s32 = 0;
65   unsigned n = eaa->arg[0].put_size;
66   if (eaa->arg[1].get_size < n)
67     n = eaa->arg[1].get_size;
68   
69   memcpy(eaa->arg[0].ls_addr, eaa->arg[1].ls_addr, n);
70 }
71
72 GC_DECLARE_PROC(benchmark_copy, "benchmark_copy");