Re: [hatari-devel] view the DSP stack? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
On sunnuntai 17 helmikuu 2013, Laurent Sallafranque wrote:
> /* Add the waitstate due to external memory access */
> + /* (2 extra cycles per extra access to the external memory after the
> first one */ + if (access_to_ext_memory != 0) {
> + value = access_to_ext_memory & 1;
> + value += (access_to_ext_memory & 2) >> 1;
> + value += (access_to_ext_memory & 4) >> 2;
> +
> + if (value > 1)
> + dsp_core.instr_cycle += (value - 1) * 2;
> + }
>
> If you think there's a more optimized way to do it, just don't hesitate
> to change it.
If it's performance critical, you could just use lookup table:
static const int ext_access_cost[8] = { ... };
...
dsp_core.instr_cycle += ext_access_cost[access_to_ext_memory];
Whether lookup table is faster depends on how tight loop you call it
and how many times, your host architecture cache size and prefetch etc.
Or you might consider using bitfields. I think GCC has also special
intrinsic for counting bits.
- Eero