View Single Post
Old 16 August 2018, 10:47   #57
zero
Registered User

 
Join Date: Jun 2016
Location: UK
Posts: 254
Quote:
Originally Posted by roondar View Post
In short, I'm not seeing it - if C compilers back in the day truly made code that was that much slower, we'd never see anything of any serious complexity made in C - it would be far to slow.
While C compilers do a reasonable job overall, for certain specific tasks like matrix multiplication they don't.

The fastest way to do it on 68000 is to use all the registers and create a highly optimized unrolled loop. Avoid unnecessary memory access by keeping everything in registers for as long as possible. Also align everything in memory to make lookups as fast as possible.

C compilers will struggle to do that. You have to remember that the compiler can't tell that the matrix math code is timing critical and so it will use the same strategy for register management as the rest of the code.

You can sometimes manually tune the C code to get better performance. I've seen an order of magnitude improvement just from doing that before. I have a polyphonic music player that I managed to get down from 80% CPU consumption to 16% just by adjusting the C code, and that was with GCC which has a relatively good optimizer for AVR.
zero is offline  
 
Page generated in 0.07461 seconds with 11 queries