Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Simplest compiler for C |
| Date | 2016-11-15 10:05 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <o0ej3s$5np$1@dont-email.me> (permalink) |
| References | (1 earlier) <4232d4c1-5461-40b8-8eac-94d0e9e055b6@googlegroups.com> <o0cs8t$58a$2@dont-email.me> <o0cvdo$ij4$1@dont-email.me> <o0d24h$tbb$1@dont-email.me> <o0d42c$53u$1@dont-email.me> |
On 14/11/16 20:42, BartC wrote: > On 14/11/2016 19:09, jacobnavia wrote: >> >> So, you are running a simulation of linux under windows. In that >> emulation you run the windows emulator, that eventually runs your >> program. >> >> No wonder! > > AFAIK native code code ought to run at full speed, as it is not > emulating the x86 processor. And some programs do. Yes. > > But others (like some of mine!) run slower than they ought, even leaving > wine out of it, but perhaps 30-50% slower. And one seemed to be > sensitive to some cache issues. So something about it (Virtualbox) is > causing problems. Make sure you isolate any startup delays from the timing - Wine has to create a bit of Windows-like environment at startup. Cache issues /can/ have an effect, though usually the speed difference of the main x86 code between native and VirtualBox is very minor. One thing to note is that when an OS is running natively, it has more information about the processors and can make more intelligent scheduling decisions. For example, if you have 4 cores with SMT, then the Linux kernel knows which cores are shared between two threads, and takes that into account when scheduling up to 8 running processes. But if you create a virtual machine and tell it to use up to 8 processors, the kernel in the virtual machine only sees 8 cpus but knows nothing about the SMT pairs, or cache sizes, etc. It also loses (almost) all information about processor affinity and cache contents - normally the Linux kernel will try to re-schedule processes on the same core in order to minimise cache misses. It can't do that when a Windows host OS has played with the cpus and caches behind its back. (I have no idea how smart the cpu scheduler is on Windows these days, I only know about the Linux one.) > > At the moment however I can only generate executable code to run > natively on Linux via gcc, which is yet another factor. (And I didn't > forget the -O3!) > Often -O2 is faster than -O3, as -O3 does a lot more loop unrolling and other code transformations that increase the size of code. L1 caches, prefetches, BTBs, etc., usually mean that the smaller code in -O2 is faster than the expanded -O3 code. But it can depend on details of the code - picking the best switches for the very fastest code generation is more of an art than a science. Unless you are interested in reading the documentation and doing a lot of trial and error, then stick to these: -O2 // Basic solid optimisation -march=native // Tell gcc to take full advantage of /your/ cpu -ffast-math // Makes floating point much faster, but not IEEE And try with something a little more demanding than "Hello, world!", even if it is little more than a big summation loop, to isolate the actual code performance.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Simplest compiler for C "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-14 18:57 +0800
Re: Simplest compiler for C Mark Storkamp <mstorkamp@yahoo.com> - 2016-11-14 08:44 -0600
Re: Simplest compiler for C "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-14 22:46 +0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-14 08:15 -0800
Re: Simplest compiler for C "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-15 01:29 +0800
Re: Simplest compiler for C Dutch Ingraham <spikeheron@att.net> - 2016-11-14 11:43 -0600
Re: Simplest compiler for C "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-15 19:18 +0800
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-14 18:23 +0000
Re: Simplest compiler for C jacobnavia <jacob@jacob.remcomp.fr> - 2016-11-14 20:09 +0100
Re: Simplest compiler for C Gareth Owen <gwowen@gmail.com> - 2016-11-14 19:11 +0000
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-14 19:42 +0000
Re: Simplest compiler for C fir <profesor.fir@gmail.com> - 2016-11-14 12:00 -0800
Re: Simplest compiler for C fir <profesor.fir@gmail.com> - 2016-11-14 12:17 -0800
Re: Simplest compiler for C fir <profesor.fir@gmail.com> - 2016-11-14 12:19 -0800
Re: Simplest compiler for C supercat@casperkitty.com - 2016-11-14 12:40 -0800
Re: Simplest compiler for C fir <profesor.fir@gmail.com> - 2016-11-14 13:08 -0800
Re: Simplest compiler for C fir <profesor.fir@gmail.com> - 2016-11-14 13:12 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-14 12:10 -0800
Re: Simplest compiler for C David Brown <david.brown@hesbynett.no> - 2016-11-15 10:05 +0100
Re: Simplest compiler for C David Brown <david.brown@hesbynett.no> - 2016-11-15 09:50 +0100
Re: Simplest compiler for C luser droog <luser.droog@gmail.com> - 2016-11-14 09:39 -0800
Re: Simplest compiler for C supercat@casperkitty.com - 2016-11-14 09:53 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-14 10:31 -0800
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-14 18:57 +0000
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-14 11:07 -0800
Re: optimization "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-15 19:20 +0800
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-15 12:56 +0000
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-15 05:34 -0800
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-15 16:07 +0000
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-15 08:59 -0800
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-15 21:35 +0000
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-15 15:33 -0800
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-16 14:58 +0000
Re: Simplest compiler for C supercat@casperkitty.com - 2016-11-16 08:44 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-16 08:54 -0800
Re: Simplest compiler for C supercat@casperkitty.com - 2016-11-16 09:11 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-16 09:36 -0800
Re: Simplest compiler for C supercat@casperkitty.com - 2016-11-16 11:41 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-16 11:45 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-16 18:54 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-17 04:44 -0800
Re: Simplest compiler for C supercat@casperkitty.com - 2016-11-17 08:42 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-17 09:17 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-17 09:42 -0800
Re: Simplest compiler for C supercat@casperkitty.com - 2016-11-17 09:57 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-17 10:07 -0800
Re: Simplest compiler for C supercat@casperkitty.com - 2016-11-17 11:35 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-17 12:02 -0800
Re: Simplest compiler for C supercat@casperkitty.com - 2016-11-17 13:23 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-17 13:55 -0800
Re: Simplest compiler for C supercat@casperkitty.com - 2016-11-17 15:15 -0800
Re: Simplest compiler for C David Brown <david.brown@hesbynett.no> - 2016-11-18 10:41 +0100
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-18 12:12 +0000
Re: Simplest compiler for C David Brown <david.brown@hesbynett.no> - 2016-11-18 13:24 +0100
Re: Simplest compiler for C Jerry Stuckle <jstucklex@attglobal.net> - 2016-11-18 09:45 -0500
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-17 20:08 +0000
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-17 12:21 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-18 03:22 -0800
Re: Simplest compiler for C "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-18 19:23 +0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-18 03:36 -0800
Re: Simplest compiler for C "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-18 19:52 +0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-19 17:55 -0800
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-16 17:19 +0000
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-16 19:09 +0000
Re: Simplest compiler for C David Brown <david.brown@hesbynett.no> - 2016-11-16 23:12 +0100
Re: Simplest compiler for C "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-11-16 14:21 -0800
Re: Simplest compiler for C "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-16 18:02 -0500
Re: Simplest compiler for C "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-11-17 17:01 -0800
Re: Simplest compiler for C "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-11-18 01:05 -0800
Re: Simplest compiler for C jameskuyper@verizon.net - 2016-11-18 10:38 -0800
Re: Simplest compiler for C "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-11-20 15:38 -0800
Re: Simplest compiler for C David Brown <david.brown@hesbynett.no> - 2016-11-17 09:57 +0100
Re: Simplest compiler for C BartC <bc@freeuk.com> - 2016-11-17 11:25 +0000
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-16 08:56 -0800
Re: Simplest compiler for C fir <profesor.fir@gmail.com> - 2016-11-16 09:10 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-16 09:34 -0800
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-15 06:32 -0800
[OT] Output of C compilers and CPU architectures "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-15 22:50 +0800
Re: [OT] Output of C compilers and CPU architectures "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-15 07:46 -0800
Re: [OT] Output of C compilers and CPU architectures "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-16 00:12 +0800
Re: [OT] Output of C compilers and CPU architectures "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-15 09:02 -0800
Re: [OT] Output of C compilers and CPU architectures "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-16 01:14 +0800
Re: [OT] Output of C compilers and CPU architectures "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-15 09:24 -0800
Re: [OT] Output of C compilers and CPU architectures "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-16 01:27 +0800
Re: Simplest compiler for C Anton Shepelev <anton.txt@gmail.com> - 2016-11-14 21:49 +0300
Re: Simplest compiler for C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-14 11:02 -0800
Re: Simplest compiler for C Anton Shepelev <anton.txt@gmail.com> - 2016-11-14 21:37 +0300
Re: Simplest compiler for C "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-15 18:07 +0800
Re: Simplest compiler for C "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-11-15 20:15 +0800
csiph-web